Библа для отрисовки всякого на диод

есть 2 экзампла для i2c oled 128x32
- плеер с иконками
- вывод графиками синус и ЭКГ (не встроена пока в gfx библиотеку)
This commit is contained in:
2025-02-20 18:17:53 +03:00
parent d3b5b834c9
commit 6746b8355e
1209 changed files with 606687 additions and 0 deletions

85
Core/OLED_Driver/oled.c Normal file
View File

@@ -0,0 +1,85 @@
/*
* oled.c
*
* Created on: Nov 17, 2021
* Author: wvv
*/
#include "oled.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <main.h>
extern I2C_HandleTypeDef hi2c1;
void oled_write_cmd(uint8_t cmd)
{
HAL_I2C_Mem_Write(&hi2c1, 0x78, 0x00, I2C_MEMADD_SIZE_8BIT, &cmd, 1, 0x100);
}
uint8_t oled_buf[OLED_HEIGHT * OLED_WIDTH] = { 0 };
void oled_clear(void)
{
memset(oled_buf, 0x00, sizeof(oled_buf));
}
void oled_refresh(void)
{
for (uint8_t i = 0; i < OLED_HEIGHT; i++)
{
oled_write_cmd(0xb0 + i);
oled_write_cmd(0x00);
oled_write_cmd(0x10);
HAL_StatusTypeDef ret = HAL_I2C_Mem_Write(&hi2c1, 0x78, 0x40, 1,
(uint8_t*) &oled_buf[i * OLED_WIDTH], OLED_WIDTH, 100);
if (ret != HAL_OK)
{
HAL_I2C_DeInit(&hi2c1);
HAL_I2C_Init(&hi2c1);
}
}
}
void oled_init(void)
{
oled_write_cmd(0xAE);
oled_write_cmd(0x20);
oled_write_cmd(0x10);
oled_write_cmd(0xB0);
oled_write_cmd(0xC8);
oled_write_cmd(0x00);
oled_write_cmd(0x10);
oled_write_cmd(0x40);
oled_write_cmd(0x81);
oled_write_cmd(0xff);
oled_write_cmd(0xa1);
oled_write_cmd(0xa6);
oled_write_cmd(0xa8);
oled_write_cmd(0x1f);
oled_write_cmd(0xd3);
oled_write_cmd(0x00);
oled_write_cmd(0xd5);
oled_write_cmd(0xf0);
oled_write_cmd(0xd9);
oled_write_cmd(0x22);
oled_write_cmd(0xda);
oled_write_cmd(0x02);
oled_write_cmd(0xdb);
oled_write_cmd(0x20);
oled_write_cmd(0x8d);
oled_write_cmd(0x14);
oled_write_cmd(0xaf);
HAL_Delay(100);
oled_clear();
oled_refresh();
}

20
Core/OLED_Driver/oled.h Normal file
View File

@@ -0,0 +1,20 @@
/*
* oled.h
*
* Created on: Nov 17, 2021
* Author: wvv
*/
#ifndef OLED_H
#define OLED_H
#include "stm32f1xx_hal.h"
#define OLED_WIDTH 128
#define OLED_HEIGHT 4
#define PIXEL_MODE_PAINT 0
#define PIXEL_MODE_CLEAR 1
extern uint8_t oled_buf[OLED_HEIGHT * OLED_WIDTH];
void oled_refresh(void);
void oled_init(void);
#endif //OLED_H

125
Core/OLED_Driver/syscalls.c Normal file
View File

@@ -0,0 +1,125 @@
/**
******************************************************************************
* @file syscalls.c
* @author Auto-generated by STM32CubeIDE
* @brief STM32CubeIDE Minimal System calls file
*
* For more information about which c-functions
* need which of these lowlevel functions
* please consult the Newlib libc-manual
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes */
#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
#include <signal.h>
#include <time.h>
#include <time.h>
/* Variables */
extern int __io_putchar(int ch) __attribute__((weak));
extern int __io_getchar(void) __attribute__((weak));
char *__env[1] = { 0 };
char **environ = __env;
/* Functions */
void initialise_monitor_handles()
{
}
int _getpid(void)
{
return 1;
}
int _kill(int pid, int sig)
{
errno = EINVAL;
return -1;
}
void _exit (int status)
{
_kill(status, -1);
while (1) {} /* Make sure we hang here */
}
__attribute__((weak)) int _read(int file, char *ptr, int len)
{
int DataIdx;
for (DataIdx = 0; DataIdx < len; DataIdx++)
{
*ptr++ = __io_getchar();
}
return len;
}
__attribute__((weak)) int _write(int file, char *ptr, int len)
{
int DataIdx;
for (DataIdx = 0; DataIdx < len; DataIdx++)
{
__io_putchar(*ptr++);
}
return len;
}
int _close(int file)
{
return -1;
}
int _isatty(int file)
{
return 1;
}
int _lseek(int file, int ptr, int dir)
{
return 0;
}
int _open(char *path, int flags, ...)
{
/* Pretend like we always fail */
return -1;
}
int _wait(int *status)
{
errno = 0;
return -1;
}
int _unlink(char *name)
{
errno = 0;
return -1;
}
int _execve(char *name, char **argv, char **env)
{
errno = ENOMEM;
return -1;
}