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

есть 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

269
Core/Example/general_gpio.c Normal file
View File

@@ -0,0 +1,269 @@
/**
**************************************************************************
* @file general_gpio.c
* @brief Модуль для инициализации портов.
**************************************************************************
@verbatim
//-------------------Функции-------------------//
Functions: users
- GPIO_Clock_Enable Инициализация тактирования порта
@endverbatim
***************************************************************************/
#include "general_gpio.h"
//-------------------------------------------------------------------
//------------------------GPIO INIT FUNCTIONS------------------------
HAL_StatusTypeDef GPIO_Clock_Enable(GPIO_TypeDef *GPIOx)
{
HAL_StatusTypeDef status = HAL_OK;
// choose port for enable clock
if (GPIOx==GPIOA)
__HAL_RCC_GPIOA_CLK_ENABLE();
else if (GPIOx==GPIOB)
__HAL_RCC_GPIOB_CLK_ENABLE();
else if (GPIOx==GPIOC)
__HAL_RCC_GPIOC_CLK_ENABLE();
else if (GPIOx==GPIOD)
__HAL_RCC_GPIOD_CLK_ENABLE();
else if (GPIOx==GPIOE)
__HAL_RCC_GPIOE_CLK_ENABLE();
else
status = HAL_ERROR;
return status;
}
//------------------------GPIO INIT FUNCTIONS------------------------
//-------------------------------------------------------------------
//-------------------------------------------------------------------
//------------------------GPIO LED FUNCTIONS-------------------------
/**
* @brief Инициализировать светодиод (структуру светодиода)
* @param led - указатель на структуру светодиода
* @param GPIOx - указатель на структуру порта для светодиода
* @param GPIO_PIN_X - пин для светодиода
* @param LED_On_State - состояния пина, при котором светодиод будет включен
*/
HAL_StatusTypeDef GPIO_LED_Init(GPIO_LEDTypeDef *led, GPIO_TypeDef *GPIOx, uint32_t GPIO_PIN_X, uint8_t LED_ActiveLevel)
{
if(check_null_ptr_2(led, GPIOx))
return HAL_ERROR;
led->LED_Port = GPIOx;
led->LED_Pin = GPIO_PIN_X;
led->LED_ActiveLvl = LED_ActiveLevel;
GPIO_LED_Off(led);
return HAL_OK;
}
/**
* @brief Включить светодиод
* @param led - указатель на структуру светодиода
*/
HAL_StatusTypeDef GPIO_LED_On(GPIO_LEDTypeDef *led)
{
if(check_null_ptr_1(led))
return HAL_ERROR;
led->state = LED_IS_ON;
if(led->LED_Port != NULL)
HAL_GPIO_WritePin(led->LED_Port, led->LED_Pin, led->LED_ActiveLvl);
else
return HAL_ERROR;
return HAL_OK;
}
/**
* @brief Выключить светодиод
* @param led - указатель на структуру светодиода
*/
HAL_StatusTypeDef GPIO_LED_Off(GPIO_LEDTypeDef *led)
{
if(check_null_ptr_1(led))
return HAL_ERROR;
led->state = LED_IS_OFF;
if(led->LED_Port != NULL)
HAL_GPIO_WritePin(led->LED_Port, led->LED_Pin, !led->LED_ActiveLvl);
else
return HAL_ERROR;
return HAL_OK;
}
/**
* @brief Активировать моргание светодиодом
* @param led - указатель на структуру светодиода
* @details Функция ставит режим моргания, который после управляется в @ref GPIO_LED_Dynamic_Handle
*/
HAL_StatusTypeDef GPIO_LED_Blink_Start(GPIO_LEDTypeDef *led, uint32_t period)
{
if(check_null_ptr_2(led, led->LED_Port))
return HAL_ERROR;
led->state = LED_IS_BLINKING;
led->LED_Period = period;
return HAL_OK;
}
/**
* @brief Активировать моргание светодиодом
* @param led - указатель на структуру светодиода
* @details Функция ставит режим моргания, который после управляется в @ref GPIO_LED_Dynamic_Handle
*/
HAL_StatusTypeDef GPIO_LED_Fading_Start(GPIO_LEDTypeDef *led, uint32_t period)
{
if(check_null_ptr_2(led, led->LED_Port))
return HAL_ERROR;
led->state = LED_IS_FADING;
led->LED_Period = period;
return HAL_OK;
}
//uint8_t LED_PWM_FADING_DUTYS[LED_PWM_TICKS] = {0 1 2 3 4 5 6 7 8 9 10 11 12 }
/**
* @brief Управление динамическими режимами свечения светодиода
* @param led - указатель на структуру светодиода
* @details Функция моргает/плавно моргает светодиодом в неблокирующем режиме
* Т.е. функцию надо вызывать постоянно, чтобы она мониторила тики
* и в нужный момент переключала светодиод
*/
void GPIO_LED_Dynamic_Handle(GPIO_LEDTypeDef *led)
{
if(check_null_ptr_2(led, led->LED_Port))
return;
/* Режим моргания светодиода */
if(led->state == LED_IS_BLINKING)
{
uint32_t tickcurrent = HAL_GetTick();
/* Ожидание истечения периода моргания */
if((tickcurrent - led->tickprev) > led->LED_Period)
{
/* Моргание */
HAL_GPIO_TogglePin(led->LED_Port, led->LED_Pin);
led->tickprev = tickcurrent;
}
}
/* Режим плавного моргания светодиода */
else if(led->state == LED_IS_FADING)
{
static unsigned direction = 0;
static int duty = 0;
uint32_t tickcurrent = HAL_GetTick();
/* Ожидание момента изменения яркости */
/* Период ШИМ 20 мс, поэтому менять яроксть надо 40 раз за период (туда обратно) */
if((tickcurrent - led->tickprev) > led->LED_Period/(LED_PWM_TICKS*2))
{
/* Формирование разтухания */
if(direction == 0)
{
if(++duty >= LED_PWM_TICKS)
{
direction = 1;
duty = LED_PWM_TICKS;
}
}
/* Формирование затухания */
else
{
if(--duty <= 0)
{
direction = 0;
duty = 0;
}
}
led->tickprev = tickcurrent;
}
/* Формирование ШИМ для изменения яркости */
int duty_crt = (duty*duty/LED_PWM_TICKS);
if(tickcurrent%LED_PWM_TICKS < duty_crt)
{
HAL_GPIO_WritePin(led->LED_Port, led->LED_Pin, led->LED_ActiveLvl);
}
else
{
HAL_GPIO_WritePin(led->LED_Port, led->LED_Pin, !led->LED_ActiveLvl);
}
}
}
//------------------------GPIO LED FUNCTIONS-------------------------
//-------------------------------------------------------------------
//-------------------------------------------------------------------
//------------------------GPIO SW FUNCTIONS-------------------------
/**
* @brief Инициализировать кнопку (структуру кнопки)
* @param sw - указатель на структуру кнопки
* @param GPIOx - указатель на структуру порта для кнопки
* @param GPIO_PIN_X - пин для кнопки
* @param SW_ActiveLevel - состояния пина, когда кнопка нажата
*/
HAL_StatusTypeDef GPIO_Switch_Init(GPIO_SwitchTypeDef *sw, GPIO_TypeDef *GPIOx, uint32_t GPIO_PIN_X, uint8_t SW_ActiveLevel)
{
if(check_null_ptr_2(sw, GPIOx))
return HAL_ERROR;
sw->Sw_Port = GPIOx;
sw->Sw_Pin = GPIO_PIN_X;
sw->Sw_ActiveLvl = SW_ActiveLevel;
if(sw->Sw_FilterDelay == 0)
sw->Sw_FilterDelay = 50;
return HAL_OK;
}
/**
* @brief Считать состоянии кнопки
* @param sw - указатель на структуру кнопки
* @return 1 - если кнопка нажата, 0 - если отжата
* @details Функция включает в себя неблокирующую проверку на дребезг
* Т.е. функцию надо вызывать постоянно, чтобы она мониторила состояние кнопки
*/
uint8_t GPIO_Read_Swich(GPIO_SwitchTypeDef *sw)
{
if(check_null_ptr_1(sw))
return 0;
sw->Sw_GrandPrevState = sw->Sw_PrevState;
if(HAL_GPIO_ReadPin(sw->Sw_Port, sw->Sw_Pin) == sw->Sw_ActiveLvl)
{
sw->Sw_PrevState = 1;
if(sw->tickprev == 0)
sw->tickprev = HAL_GetTick();
if((HAL_GetTick() - sw->tickprev) >= sw->Sw_FilterDelay)
{
if(HAL_GPIO_ReadPin(sw->Sw_Port, sw->Sw_Pin) == sw->Sw_ActiveLvl)
{
return 1;
}
else
{
sw->tickprev = 0;
return 0;
}
}
}
else
{
sw->Sw_PrevState = 0;
}
return 0;
}
//------------------------GPIO SW FUNCTIONS-------------------------
//-------------------------------------------------------------------

View File

@@ -0,0 +1,66 @@
/**
**************************************************************************
* @file general_gpio.h
* @brief Заголовочный файл для модуля инициализации портов.
*************************************************************************/
#ifndef __GPIO_GENERAL_H_
#define __GPIO_GENERAL_H_
#include "mylibs_defs.h"
typedef enum
{
LED_IS_OFF = 0,
LED_IS_ON = 1,
LED_IS_BLINKING = 2,
LED_IS_FADING = 3,
}GPIO_LEDStateTypeDef;
typedef struct
{
GPIO_LEDStateTypeDef state;
GPIO_TypeDef *LED_Port;
uint32_t LED_Pin;
uint8_t LED_ActiveLvl;
uint32_t LED_Period;
uint32_t tickprev;
}GPIO_LEDTypeDef;
typedef struct
{
GPIO_TypeDef *Sw_Port;
uint32_t Sw_Pin;
uint8_t Sw_ActiveLvl;
uint32_t Sw_PrevState;
uint32_t Sw_FilterDelay;
uint32_t Sw_GrandPrevState;
uint32_t tickprev;
}GPIO_SwitchTypeDef;
/////////////////////////////////////////////////////////////////////
///////////////////////////---FUNCTIONS---///////////////////////////
HAL_StatusTypeDef GPIO_Clock_Enable(GPIO_TypeDef *GPIOx);
/* Инициализировать кнопку (структуру кнопки) */
HAL_StatusTypeDef GPIO_Switch_Init(GPIO_SwitchTypeDef *sw, GPIO_TypeDef *GPIOx, uint32_t GPIO_PIN_X, uint8_t SW_On_State);
/* Считать состоянии кнопки запуска */
uint8_t GPIO_Read_Swich(GPIO_SwitchTypeDef *swstart);
/* Инициализировать светодиод (структуру светодиода) */
HAL_StatusTypeDef GPIO_LED_Init(GPIO_LEDTypeDef *led, GPIO_TypeDef *GPIOx, uint32_t GPIO_PIN_X, uint8_t LED_On_State);
/* Включить светодиод */
HAL_StatusTypeDef GPIO_LED_On(GPIO_LEDTypeDef *led);
/* Выключить светодиод */
HAL_StatusTypeDef GPIO_LED_Off(GPIO_LEDTypeDef *led);
/* Активировать моргание светодиодом */
HAL_StatusTypeDef GPIO_LED_Blink_Start(GPIO_LEDTypeDef *led, uint32_t period);
/* Активировать моргание светодиодом */
HAL_StatusTypeDef GPIO_LED_Fading_Start(GPIO_LEDTypeDef *led, uint32_t period);
/* Управление динамическими режимами свечения светодиода */
void GPIO_LED_Dynamic_Handle(GPIO_LEDTypeDef *led);
///////////////////////////---FUNCTIONS---///////////////////////////
#endif // __GPIO_GENERAL_H_

View File

@@ -0,0 +1,314 @@
#include "gfx_oled_example.h"
#include "math.h"
int menu_white_theme = 0;
//#define SINE_EXAMPLE
//#define ECG_EXAMPLE
#define PLAYER_EXAMPLE
#define ECG_SIZE 550
// Примерный массив, симулирующий ЭКГ-сигнал (нормализованный от 0 до 1)
const float ecg_data[ECG_SIZE] = {1.05893, 0.999357, 0.933132, 0.744792, 0.664672, 0.328846, 0.136133, -0.00837916, -0.131494,
-0.1437, -0.182276, -0.215992, -0.128979, -0.131278, -0.0675223, 0.0027252, 0.0467067, -0.078859, -0.0658536, 0.0626352,
-0.0462435, 0.0476623, 0.0535328, 0.122938, 0.0501136, 0.034033, 0.0919253, 0.108374, 0.0667457, 0.0351678, -0.00115748,
0.0896459, 0.0288452, -0.0102636, 0.136738, 0.0397245, 0.0856079, 0.141222, 0.0826385, 0.165799, 0.105852, 0.172638,
0.186488, 0.144543, 0.0710717, 0.145054, 0.176092, 0.158212, 0.157025, 0.29588, 0.231833, 0.338024, 0.253539, 0.344064,
0.284527, 0.381661,0.385494, 0.324123, 0.305506, 0.433373, 0.477326, 0.364201,0.44309, 0.405536, 0.4922, 0.485606,
0.370194, 0.512566, 0.540046, 0.445303, 0.518052, 0.456006, 0.364917, 0.367834, 0.40163, 0.460996, 0.466174, 0.447784,
0.341301,0.371422, 0.268949, 0.259113, 0.249429, 0.343, 0.291218, 0.214958, 0.260874, 0.176372, 0.143037, 0.287679,
0.21553, 0.275687, 0.215986, 0.180708, 0.215402, 0.217034, 0.228714, 0.0215511,0.18583, 0.1273, 0.195534, 0.0965174,
0.0809704, 0.140033, 0.0206099, 0.0704855, 0.147377, 0.0789603, 0.130335, 0.106715, 0.074257, 0.00483191,0.0875146,
-0.0300366, 0.0777518, 0.084268, 0.0977437, 0.129822, 0.148143, 0.105601,0.0682866, 0.137946, 0.068663, -0.0435304,
-0.0222684, 0.12664, 0.0515385, 0.12427, -0.00217019, 0.0670832, 0.0832982, -0.0355677, 0.081701,0.031973, -0.0298655,
0.0588815, 0.000209182, -0.0129383, 0.0042788, -0.00678231,0.00246806, -0.0260747, 0.0931759, 0.0232501,0.075334, 0.107382,
0.0689022, 0.0769642, 0.0595603, -0.00397555, 0.0700185, 0.143251, 0.148137, 0.028107, 0.0164351, 0.0884327, 0.104194, 0.060235,
0.0187268, 0.167828, -0.00462437, 0.000835874, 0.00885075, 0.0145025, 0.106193, 0.0975606, -0.00591114, 0.17083, 0.131315, 0.134244,
0.000579408, 0.161378, 0.177776, 0.189649, 0.16676, 0.154687, 0.103331, 0.0398174, 0.0883113, 0.0404233, 0.0256448, 0.214035,
0.0942273, 0.101924, 0.119377, 0.157289, 0.205664, 0.0941939, 0.271559, 0.229571, 0.303699, 0.217788, 0.252682, 0.189268,
0.228094, 0.338367, 0.283619, 0.407, 0.258733, 0.438339, 0.351821, 0.385913, 0.442646, 0.296084, 0.314822, 0.315994, 0.364966,
0.36342, 0.206273, 0.207504, 0.228995, 0.153435, 0.231611, 0.179904, 0.133949, 0.127457, 0.254484, 0.197385, 0.146029, 0.225966,
0.0566748, 0.178446, 0.171133, 0.131769, 0.0525685, 0.132109, 0.069929, 0.0340608, 0.0468317, 0.180335, 0.0104617, 0.0354713,
-0.0163161, 0.0425572, -0.0653781, 0.0877674, -0.0742378, -0.110943, -0.0746231, -0.0359488, -0.073415, 0.168732, 0.13128,
0.249452, 0.351835, 0.563543, 0.679657, 0.92211, 1.08445, 1.1125, 0.993184, 0.916222, 0.925942, 0.786796, 0.53263, 0.270246,
0.25373, 0.0244354, -0.0842442, -0.0607408, -0.243356, -0.243292, -0.105114, -0.0890295, -0.0677865, 0.0111256, 0.0417756,
0.0859112, 0.00967447, 0.10676, 0.0906405, 0.0659345, 0.00378074, 0.150838, 0.0649321, 0.121398, 0.15057, 0.0259133, 0.0332993,
0.120676, 0.111174, 0.195936, 0.181734, 0.173334, 0.0417151, 0.0514996, 0.0606249, 0.209138, 0.245178, 0.201025, 0.0990306,
0.226141, 0.113311, 0.125047, 0.240658, 0.189883, 0.267101, 0.298959, 0.279095, 0.324262, 0.237427, 0.351991, 0.413902, 0.408103,
0.266948, 0.337957, 0.353324, 0.430994, 0.427623, 0.479357, 0.407738, 0.387289, 0.374333, 0.521238, 0.416679, 0.460645, 0.499469,
0.439634, 0.525509, 0.495788, 0.429484, 0.55411, 0.414761, 0.448777, 0.431282, 0.482458, 0.385804, 0.438642, 0.367588, 0.357191,
0.478922, 0.366946, 0.415339, 0.473029, 0.351773, 0.389086, 0.386449, 0.305993, 0.335247, 0.210934, 0.360828, 0.197025, 0.198693,
0.291518, 0.216643, 0.260826, 0.174855, 0.139573, 0.082479, 0.200454, 0.14318, 0.13979, 0.164275, 0.0477158, 0.0931762, 0.179358,
0.159488, 0.0412108, 0.0386311, 0.0279973, 0.00843795, 0.0892224, 0.133798, 0.145674, 0.106026, 0.0205011, 0.124274, 0.0226069,
0.0237319, 0.0163099, 0.024851, 0.030066, 0.0357348, 0.0601346, 0.0601495, 0.0406621, 0.0476954, 0.176459, 0.138954, 0.109933,
0.0361806, 0.0422346, 0.0158523, 0.183712, 0.142873, 0.113671, 0.065383, 0.0365197, 0.128355, 0.202013, 0.0390733, 0.0570969,
0.0854399, 0.0214106, 0.143953, 0.0881267, 0.204725, 0.0891005, 0.133303, 0.04055, 0.0864498, 0.0429089, 0.162802, 0.185894,
0.0823151, 0.14975, 0.0719509, 0.119721, 0.180551, 0.134033, 0.0820637, 0.0753133, 0.106455, 0.100938, 0.0888068, 0.129034,
0.166379, 0.103271, 0.104842, 0.0445476, 0.0251081, 0.0789694, 0.0852342, 0.153383, 0.215103, 0.212132, 0.118084, 0.0764331,
0.183322, 0.185061, 0.184503, 0.188901, 0.0658428, 0.186253, 0.148702, 0.105533, 0.0908859, 0.245061, 0.125606, 0.134644, 0.247456,
0.306363, 0.244781, 0.29657, 0.201664, 0.376652, 0.308954, 0.351074, 0.236012, 0.40292, 0.401634, 0.284931, 0.372803, 0.337598,
0.383977, 0.35428, 0.3549, 0.303027, 0.310696, 0.25438, 0.423706, 0.356807, 0.398502, 0.229798, 0.365983, 0.325231, 0.266461,
0.224066, 0.173261, 0.258585, 0.141305, 0.0968079, 0.226929, 0.198325, 0.198878, 0.177088, 0.126345, 0.115497, 0.196221,
0.092804, 0.18902, 0.18094, 0.190455, 0.11711, 0.137381, 0.192176, 0.0792287, -0.0132089, 0.128102, 0.0579884, -0.0206506,
0.0874069, -0.0799489, 0.0058573, 0.015077, 0.0137692, 0.0355411, 0.113175, 0.321936, 0.427422, 0.70414, 0.801907, 1.04001,
1.11783, 1.1273, 1.02789, 1.10223, 0.829465, 0.792606, 0.470991, 0.324366, 0.108762, 0.0881276, -0.102915, -0.195709, -0.0950335,
-0.178844, -0.103735, -0.131323, -0.0461341, -0.129231, 0.0830591, 0.0903014, 0.102478, 0.132797, 0.0580604, 0.111787, 0.108011,
0.102112, 0.0534435, 0.0500927, 0.0925822, 0.0498444, 0.167477, 0.206324, 0.0179187, 0.12221, 0.0360253, 0.18297, 0.224765, 0.0451847,
0.225041, 0.0467012, 0.186295, 0.213311, 0.171037, 0.249559, 0.261215, 0.216183, 0.128802};
void GFX_Draw_LoopIcon(uint8_t *Buffer_Frame, uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t pxColor);
GFXIconsTypeDef icons;
void Example_GFX_IconInit(void)
{
// play
icons.StopPlay.stop.xPos1 = play_icon_x_left-1;
icons.StopPlay.stop.yPos1 = play_icon_y_up;
icons.StopPlay.stop.xPos2 = play_icon_x_left-1;
icons.StopPlay.stop.yPos2 = play_icon_y_down;
icons.StopPlay.stop.xPos3 = play_icon_x_rigth+1;
icons.StopPlay.stop.yPos3 = play_icon_y_mid;
icons.StopPlay.stop.pxColor = 1;
// stop
icons.StopPlay.play_lines[0].xPos_Start = play_icon_x_left+1;
icons.StopPlay.play_lines[0].yPos_Start = play_icon_y_up;
icons.StopPlay.play_lines[0].xPos_End = play_icon_x_left+1;
icons.StopPlay.play_lines[0].yPos_End = play_icon_y_down;
icons.StopPlay.play_lines[0].pxColor = 1;
icons.StopPlay.play_lines[1].xPos_Start = play_icon_x_rigth;
icons.StopPlay.play_lines[1].yPos_Start = play_icon_y_up;
icons.StopPlay.play_lines[1].xPos_End = play_icon_x_rigth;
icons.StopPlay.play_lines[1].yPos_End = play_icon_y_down;
icons.StopPlay.play_lines[1].pxColor = 1;
// stop/play pressed
icons.StopPlay.PressedArea.selected_Width = selected_width;
icons.StopPlay.PressedArea.xPos_Start = play_icon_x_left-1-selected_width;
icons.StopPlay.PressedArea.yPos_Start = play_icon_y_up-selected_width;
icons.StopPlay.PressedArea.area_Width = play_icon_x_rigth+2-(play_icon_x_left-1)+2*selected_width+1;
icons.StopPlay.PressedArea.area_Height = play_icon_y_down-play_icon_y_up+2*selected_width+1;
// forward
icons.Forward.line.xPos_Start = forward_icon_x_rigth;
icons.Forward.line.yPos_Start = forward_icon_y_up;
icons.Forward.line.xPos_End = forward_icon_x_rigth;
icons.Forward.line.yPos_End = forward_icon_y_down;
icons.Forward.line.pxColor = 1;
icons.Forward.trig.xPos1 = forward_icon_x_left;
icons.Forward.trig.yPos1 = forward_icon_y_up;
icons.Forward.trig.xPos2 = forward_icon_x_left;
icons.Forward.trig.yPos2 = forward_icon_y_down;
icons.Forward.trig.xPos3 = forward_icon_x_rigth-1;
icons.Forward.trig.yPos3 = forward_icon_y_mid;
icons.Forward.trig.pxColor = 1;
// forward pressed
icons.Forward.PressedArea.selected_Width = selected_width;
icons.Forward.PressedArea.xPos_Start = forward_icon_x_left-selected_width;
icons.Forward.PressedArea.yPos_Start = forward_icon_y_up-selected_width;
icons.Forward.PressedArea.area_Width = forward_icon_x_rigth-(forward_icon_x_left)+2*selected_width+1;
icons.Forward.PressedArea.area_Height = forward_icon_y_down-forward_icon_y_up+2*selected_width+1;
// backward
icons.Backward.line.xPos_Start = backward_icon_x_left;
icons.Backward.line.yPos_Start = backward_icon_y_up;
icons.Backward.line.xPos_End = backward_icon_x_left;
icons.Backward.line.yPos_End = backward_icon_y_down;
icons.Backward.line.pxColor = 1;
icons.Backward.trig.xPos1 = backward_icon_x_rigth;
icons.Backward.trig.yPos1 = backward_icon_y_up;
icons.Backward.trig.xPos2 = backward_icon_x_rigth;
icons.Backward.trig.yPos2 = backward_icon_y_down;
icons.Backward.trig.xPos3 = backward_icon_x_left+1;
icons.Backward.trig.yPos3 = backward_icon_y_mid;
icons.Backward.trig.pxColor = 1;
// backward pressed
icons.Backward.PressedArea.xPos_Start = backward_icon_x_left-selected_width;
icons.Backward.PressedArea.yPos_Start = backward_icon_y_up-selected_width;
icons.Backward.PressedArea.area_Width = backward_icon_x_rigth-(backward_icon_x_left)+2*selected_width+1;
icons.Backward.PressedArea.area_Height = backward_icon_y_down-backward_icon_y_up+2*selected_width+1;
// loop
icons.Loop.xPos_Start = loop_icon_x_start;
icons.Loop.yPos_Start = loop_icon_y_start;
icons.Loop.icon_Width = loop_icon_width;
icons.Loop.icon_Height = loop_icon_height;
// loop pressed
icons.Loop.PressedArea.xPos_Start = loop_icon_x_start+3;
icons.Loop.PressedArea.yPos_Start = loop_icon_y_start+3;
icons.Loop.PressedArea.area_Width = loop_icon_width-5;
icons.Loop.PressedArea.area_Height = loop_icon_height-5;
// иконка зацикливания
GFX_Draw_LoopIcon(oled_buf, loop_icon_x_start, loop_icon_y_start, loop_icon_width, loop_icon_height, 1);
}
void Example_OLED_GFX_Update(PlayerTypeDef *player)
{
static uint32_t oled_prevtick = 0;
uint32_t oled_period = 50;
if(uwTick - oled_prevtick > oled_period)
{
oled_prevtick = uwTick;
Example_GFX_CreateFrame(player);
oled_refresh();
}
}
float sine_cnt_step = 0.01;
int shift = 1;
float ecg_cnt = 0;
float ecg_cnt_step = 1;
float ecg_scale = 16;
void Example_GFX_CreateFrame(PlayerTypeDef *player)
{
#if defined(SINE_EXAMPLE) || defined(ECG_EXAMPLE)
static float sine_cnt;
static int display_cnt;
static int pix_y_prev = 0;
#if defined(SINE_EXAMPLE)
int pix_y = (int)((float)(sinf(sine_cnt)+shift)*((float)32/(1+shift)));
#elif defined(ECG_EXAMPLE)
int pix_y = (ecg_data[(int)ecg_cnt]*ecg_scale)+16;
ecg_cnt += ecg_cnt_step;
if(ecg_cnt > ECG_SIZE)
ecg_cnt = 0;
#endif
if(pix_y - pix_y_prev > 0)
{
for(int y = pix_y_prev+1; y <= pix_y; y++)
{
if(y<=32)
GFX_Draw_Pixel(oled_buf, display_cnt, 32 - y, 1);
}
}
else if (pix_y - pix_y_prev < 0)
{
for(int y = pix_y_prev-1; y >= pix_y; y--)
{
if(y<=32)
GFX_Draw_Pixel(oled_buf, display_cnt, 32 - y, 1);
}
}
else
GFX_Draw_Pixel(oled_buf, display_cnt, 32 - pix_y, 1);
display_cnt++;
sine_cnt += sine_cnt_step;
pix_y_prev = pix_y;
if(display_cnt>GFX_BufferWidth)
{
display_cnt = 0;
GFX_Clean_Buffer_Frame(oled_buf, sizeof(oled_buf));
}
#elif defined(PLAYER_EXAMPLE)
GFX_Clean_Buffer_Frame(oled_buf, sizeof(oled_buf));
// название песни
GFX_Output_String(oled_buf, 0, 0, "Harry Potter Theme", 0, 0);
// кнопка стоп/плей
// GFX_Draw_Circle(oled_buf, circle_stopplay_x, circle_stopplay_y, circle_stopplay_r, 1);
// иконка "плей"
if(player->play)
{
GFX_Draw_Line(oled_buf, &icons.StopPlay.play_lines[0]);
GFX_Draw_Line(oled_buf, &icons.StopPlay.play_lines[1]);
}
// иконка "стоп"
else
{
GFX_Draw_Triangle(oled_buf, &icons.StopPlay.stop);
}
if(player->pressed_start)
GFX_Invertion_Area(oled_buf, icons.StopPlay.PressedArea.xPos_Start, icons.StopPlay.PressedArea.yPos_Start, icons.StopPlay.PressedArea.area_Width, icons.StopPlay.PressedArea.area_Height);
// дорожка песни
__GFX_Draw_Line(oled_buf, 0, GFX_BufferHeight-2, player->currenttime*GFX_BufferWidth, GFX_BufferHeight-2, 1);
// перемотка вперед
GFX_Draw_Triangle(oled_buf, &icons.Forward.trig);
GFX_Draw_Line(oled_buf, &icons.Forward.line);
if(player->pressed_forward)
GFX_Invertion_Area(oled_buf, icons.Forward.PressedArea.xPos_Start, icons.Forward.PressedArea.yPos_Start, icons.Forward.PressedArea.area_Width, icons.Forward.PressedArea.area_Height);
// перемотка назад
GFX_Draw_Triangle(oled_buf, &icons.Backward.trig);
GFX_Draw_Line(oled_buf, &icons.Backward.line);
if(player->pressed_backward)
GFX_Invertion_Area(oled_buf, icons.Backward.PressedArea.xPos_Start, icons.Backward.PressedArea.yPos_Start, icons.Backward.PressedArea.area_Width, icons.Backward.PressedArea.area_Height);
// индикация скорости
char buff_speed[5];
sprintf(buff_speed, "x%.1f", player->speed);
if((player->speed < 1.05) && player->speed > 0.95)
GFX_Output_String(oled_buf, speed_x_cursore, speed_y_cursore, buff_speed, 0, 0);
else
{
GFX_Output_String(oled_buf, speed_x_cursore, speed_y_cursore, buff_speed, 0, 1);
}
// GFX_Draw_Line(oled_buf, speed_underline_x_left, speed_underline_y, speed_underline_x_rigth, speed_underline_y, 1);
// иконка зацикливания
GFX_Draw_LoopIcon(oled_buf, icons.Loop.xPos_Start, icons.Loop.yPos_Start, icons.Loop.icon_Width, icons.Loop.icon_Height, 1);
if(player->loop)
GFX_Invertion_Area(oled_buf, icons.Loop.PressedArea.xPos_Start, icons.Loop.PressedArea.yPos_Start, icons.Loop.PressedArea.area_Width, icons.Loop.PressedArea.area_Height);
#endif // PLAYER_EXAMPLE
if(menu_white_theme)
{
GFX_Invertion_Display(oled_buf);
}
}
/* Функция рисования значка "зациклить песню" */
/* Сгенерировано чат гпт */
void GFX_Draw_LoopIcon(uint8_t *Buffer_Frame, uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t pxColor)
{
#define arr_size 2
#define spot_width 2
uint8_t r = (width < height ? width : height) / 4; // Радиус закруглений ограничен минимальным размером
// Четыре дуги по углам
__GFX_Draw_Arc(Buffer_Frame, x + width - r, y + r, r, 270, 360, pxColor); // Верхний правый угол
__GFX_Draw_Arc(Buffer_Frame, x + r, y + r, r, 180, 270, pxColor); // Верхний левый угол
__GFX_Draw_Arc(Buffer_Frame, x + r, y + height - r, r, 90, 180, pxColor); // Нижний левый угол
__GFX_Draw_Arc(Buffer_Frame, x + width - r, y + height - r, r, 0, 90, pxColor); // Нижний правый угол
// Прямые линии между дугами
__GFX_Draw_Line(Buffer_Frame, x + r, y, x + width - r-spot_width, y, pxColor); // Верхняя горизонталь
__GFX_Draw_Line(Buffer_Frame, x, y + r, x, y + height - r, pxColor); // Левая вертикаль
__GFX_Draw_Line(Buffer_Frame, x + r+spot_width, y + height, x + width - r, y + height, pxColor); // Нижняя горизонталь
__GFX_Draw_Line(Buffer_Frame, x + width, y + r, x + width, y + height - r, pxColor); // Правая вертикаль
// Стрелки
__GFX_Draw_Line(Buffer_Frame, x + width - r-spot_width, y, x + width - r - arr_size-spot_width, y - arr_size, pxColor); // Верхняя стрелка
__GFX_Draw_Line(Buffer_Frame, x + width - r-spot_width, y, x + width - r - arr_size-spot_width, y + arr_size, pxColor);
__GFX_Draw_Line(Buffer_Frame, x + r+spot_width, y + height, x + r + arr_size+spot_width, y + height - arr_size, pxColor); // Нижняя стрелка
__GFX_Draw_Line(Buffer_Frame, x + r+spot_width, y + height, x + r + arr_size+spot_width, y + height + arr_size, pxColor);
}

View File

@@ -0,0 +1,111 @@
#ifndef GFX_OLED_EXAMPLE_H
#define GFX_OLED_EXAMPLE_H
#include "stm32f1xx_hal.h"
#include "menu_interface.h"
#include "gfx_buffer.h"
#include "oled.h"
#define font_size 10 //refer to font_tahoma_8_prop
#define displaycenter_x (62)
#define displaycenter_y (18)
#define control_panel_y_shift (2)
#define control_panel_y_height (8)
#define control_panel_y_mid (displaycenter_y + control_panel_y_shift)
#define control_panel_y_up (control_panel_y_mid - (control_panel_y_height/2))
#define control_panel_y_down (control_panel_y_mid + (control_panel_y_height/2))
#define play_icon_x_widht (3)
#define play_icon_y_size control_panel_y_height//(8)
#define play_icon_x_left (displaycenter_x - play_icon_x_widht)
#define play_icon_x_rigth (displaycenter_x + play_icon_x_widht)
#define play_icon_y_up (control_panel_y_up)
#define play_icon_y_down (control_panel_y_down)
#define play_icon_y_mid (control_panel_y_mid)
#define forward_backward_icon_x_shift (18)
#define forward_icon_x_left (play_icon_x_left + forward_backward_icon_x_shift)
#define forward_icon_x_rigth (play_icon_x_rigth + forward_backward_icon_x_shift+3)
#define forward_icon_y_up (control_panel_y_up)
#define forward_icon_y_down (control_panel_y_down)
#define forward_icon_y_mid (control_panel_y_mid)
#define backward_icon_x_left (play_icon_x_left - forward_backward_icon_x_shift-3)
#define backward_icon_x_rigth (play_icon_x_rigth - forward_backward_icon_x_shift)
#define backward_icon_y_up (control_panel_y_up)
#define backward_icon_y_down (control_panel_y_down)
#define backward_icon_y_mid (control_panel_y_mid)
#define speed_x_shift (39)
#define speed_y_shift (-3)
#define speed_x_cursore (displaycenter_x+speed_x_shift)
#define speed_y_cursore (displaycenter_y+speed_y_shift)
#define loop_icon_x_shift (speed_x_shift+3)
#define loop_icon_y_shift (-2)
#define loop_icon_x_start (displaycenter_x-loop_icon_x_shift-loop_icon_width)
#define loop_icon_y_start (displaycenter_y+loop_icon_y_shift)
#define loop_icon_width (11)
#define loop_icon_height 8
#define selected_width (1)
typedef struct
{
uint8_t xPos_Start;
uint8_t yPos_Start;
uint8_t area_Width;
uint8_t area_Height;
uint8_t selected_Width;
}PresesIconTypeDef;
typedef struct
{
GFX_LineHandleTypeDef play_lines[2];
GFX_TriangleHandleTypeDef stop;
PresesIconTypeDef PressedArea;
}StopPlayIconTypeDef;
typedef struct
{
GFX_LineHandleTypeDef line;
GFX_TriangleHandleTypeDef trig;
PresesIconTypeDef PressedArea;
}ForwardBackwardIconTypeDef;
typedef struct
{
// GFX_ArcHandleTypeDef arc[4];
// GFX_LineHandleTypeDef line[4];
// GFX_LineHandleTypeDef line_arrow1[2];
// GFX_LineHandleTypeDef line_arrow2[2];
uint8_t xPos_Start;
uint8_t yPos_Start;
uint8_t icon_Width;
uint8_t icon_Height;
PresesIconTypeDef PressedArea;
}LoopIconTypeDef;
typedef struct
{
StopPlayIconTypeDef StopPlay;
ForwardBackwardIconTypeDef Forward;
ForwardBackwardIconTypeDef Backward;
LoopIconTypeDef Loop;
}GFXIconsTypeDef;
void Example_GFX_IconInit(void);
void Example_GFX_CreateFrame(PlayerTypeDef *player);
void Example_OLED_GFX_Update(PlayerTypeDef *player);
#endif //GFX_OLED_EXAMPLE_H

View File

@@ -0,0 +1,145 @@
#include "menu_interface.h"
void Menu_Control_Init(PlayerTypeDef *player)
{
GPIO_Switch_Init(&player->SwTheme, GPIO_SwTheme, GPIO_Pin_SwTheme, SW_ON);
GPIO_Switch_Init(&player->SwPlay, GPIO_SwPlay, GPIO_Pin_SwPlay, SW_ON);
GPIO_Switch_Init(&player->SwForward, GPIO_SwForward, GPIO_Pin_SwForward, SW_ON);
GPIO_Switch_Init(&player->SwBackward, GPIO_SwBackward, GPIO_Pin_SwBackward, SW_ON);
GPIO_Switch_Init(&player->SwSpeed, GPIO_SwSpeed, GPIO_Pin_SwSpeed, SW_ON);
GPIO_Switch_Init(&player->SwLoop, GPIO_SwLoop, GPIO_Pin_SwLoop, SW_ON);
player->SwTheme.Sw_FilterDelay = 70;
player->SwPlay.Sw_FilterDelay = 70;
player->SwForward.Sw_FilterDelay = 70;
player->SwBackward.Sw_FilterDelay = 70;
player->SwSpeed.Sw_FilterDelay = 70;
player->SwLoop.Sw_FilterDelay = 70;
player->speed = 1;
}
extern int menu_white_theme;
void Menu_Control_ReadGPIO(PlayerTypeDef *player)
{
#ifdef GPIO_CONTROL
/* Обработка кнопки темы меню */
if(GPIO_Read_Swich(&player->SwTheme))
{
if(player->SwTheme.Sw_GrandPrevState == 0)
menu_white_theme ^= 1;
}
/* Обработка кнопки плей */
if(GPIO_Read_Swich(&player->SwPlay))
{
if(player->SwPlay.Sw_GrandPrevState == 0)
player->play ^= 1;
player->pressed_start = 1;
}
else
{
player->pressed_start = 0;
}
/* Обработка кнопки прокрутки вперед */
if(GPIO_Read_Swich(&player->SwForward))
{
player->pressed_forward = 1;
}
else
{
player->pressed_forward = 0;
}
/* Обработка кнопки прокрутки назад */
if(GPIO_Read_Swich(&player->SwBackward))
{
player->pressed_backward = 1;
}
else
{
player->pressed_backward = 0;
}
/* Обработка кнопки зацикливания */
if(GPIO_Read_Swich(&player->SwLoop))
{
if(player->SwLoop.Sw_GrandPrevState == 0)
player->loop ^= 1;
}
/* Обработка кнопки скорости */
if(GPIO_Read_Swich(&player->SwSpeed))
{
if(player->SwSpeed.Sw_GrandPrevState == 0)
player->speed += 0.5;
if(player->speed > 0.05)
player->speed = 0.5;
}
#endif
}
float sim_music_long_sec = 10;
float sim_music_step = 0;
void Menu_Control_Music(PlayerTypeDef *player)
{
if(player->currenttime > 1)
{
player->currenttime = 0;
if(player->loop == 0)
player->play = 0;
}
else if(player->currenttime < 0)
{
if(player->loop)
player->currenttime = 1;
else
player->currenttime = 0;
}
sim_music_step = 1/(sim_music_long_sec*100);
// если шкатулка запущена
if(player->play)
{
// если кнопки перемотки не нажаты, то подтягивает заданную скорость воспроизведения
if((player->pressed_backward == 0) && (player->pressed_forward == 0) )
{
sim_music_step *= player->speed;
}
}
else
{
sim_music_step = 0;
}
// перемотка назад
if((player->pressed_backward == 1) && (player->pressed_forward == 0) )
{
if(player->currenttime > 0)
{
sim_music_step = -1/(sim_music_long_sec*100);
}
}
// перемотка вперед
if((player->pressed_forward == 1) && (player->pressed_backward == 0) )
{
sim_music_step = 1/(sim_music_long_sec*100)*2;
}
static uint32_t prevtick = 0;
if(uwTick - prevtick > 10)
{
prevtick = uwTick;
player->currenttime += sim_music_step;
}
}

View File

@@ -0,0 +1,53 @@
#ifndef MENU_INTERFACE_H
#define MENU_INTERFACE_H
#include "stm32f1xx_hal.h"
#include "general_gpio.h"
#include "main.h"
#define GPIO_CONTROL //comment for control from watch window
#define GPIO_SwTheme SW_THEME_GPIO_Port
#define GPIO_Pin_SwTheme SW_THEME_Pin
#define GPIO_SwSpeed SW_SPEED_GPIO_Port
#define GPIO_Pin_SwSpeed SW_SPEED_Pin
#define GPIO_SwForward SW_FORWARD_GPIO_Port
#define GPIO_Pin_SwForward SW_FORWARD_Pin
#define GPIO_SwPlay SW_PLAY_GPIO_Port
#define GPIO_Pin_SwPlay SW_PLAY_Pin
#define GPIO_SwBackward SW_BACKWARD_GPIO_Port
#define GPIO_Pin_SwBackward SW_BACKWARD_Pin
#define GPIO_SwLoop SW_LOOP_GPIO_Port
#define GPIO_Pin_SwLoop SW_LOOP_Pin
typedef struct
{
unsigned play:1;
unsigned loop:1;
unsigned pressed_start:1;
unsigned pressed_forward:1;
unsigned pressed_backward:1;
float currenttime;
float speed;
GPIO_SwitchTypeDef SwTheme;
GPIO_SwitchTypeDef SwPlay;
GPIO_SwitchTypeDef SwForward;
GPIO_SwitchTypeDef SwBackward;
GPIO_SwitchTypeDef SwSpeed;
GPIO_SwitchTypeDef SwLoop;
}PlayerTypeDef;
extern PlayerTypeDef Player;
void Menu_Control_Init(PlayerTypeDef *player);
void Menu_Control_ReadGPIO(PlayerTypeDef *player);
void Menu_Control_Music(PlayerTypeDef *player);
#endif //MENU_INTERFACE_H

View File

@@ -0,0 +1,29 @@
/**
**************************************************************************
* @file mylibs_config.h
* @brief Конфигурации для библиотек MyLibs
**************************************************************************
* @defgroup MYLIBS_CONFIG Configs My Libs
* @ingroup MYLIBS_ALL
* @brief Конфигурации для библиотек MyLibs
@{
*************************************************************************/
#ifndef __MYLIBS_CONFIG_H_
#define __MYLIBS_CONFIG_H_
#include "stm32f1xx_hal.h"
// user includes
//#define INCLUDE_BIT_ACCESS_LIB
//#define INCLUDE_TRACKERS_LIB
//#define INCLUDE_TRACE_LIB
#define INCLUDE_GENERAL_PERIPH_LIBS
//#define FREERTOS_DELAY
#define SW_ON 0
#define SW_OFF 1
/** MYLIBS_CONFIG
* @}
*/
#endif //__MYLIBS_CONFIG_H_

155
Core/Example/mylibs_defs.h Normal file
View File

@@ -0,0 +1,155 @@
/**
**************************************************************************
* @file mylibs_defs.h
* @brief Заголочный файл для дефайнов библиотеки MyLibsGeneral.
**************************************************************************
* @defgroup MYLIBS_DEFINES My Libs defines
* @brief Базовые дефайны для всего проекта
*
*************************************************************************/
#ifndef __MYLIBS_DEFINES_H_
#define __MYLIBS_DEFINES_H_
#include "mylibs_config.h"
/***************************************************************************
******************************ERROR_HANDLER********************************/
/**
* @addtogroup ERROR_HANDLER_DEFINES Error Handler defines
* @ingroup MYLIBS_DEFINES
* @brief Дефайны для определения функции обработки ошибок
@{
*/
/* extern Error_Handler from main.h */
extern void Error_Handler(void);
/* Define error handler for MyLibs */
#define MyLibs_Error_Handler(_params_) Error_Handler(_params_)
/* If error handler not defined - set void */
#ifndef MyLibs_Error_Handler
#define ((void)0U)
#endif // MyLibs_Error_Handler
/** @brief Check one pointer */
#define check_null_ptr_1(_p1_) (_p1_ == NULL)
/** @brief Check two pointers */
#define check_null_ptr_2(_p1_, _p2_) ((_p1_ == NULL) || (_p2_ == NULL))
/** @brief Check three pointers */
#define check_null_ptr_3(_p1_, _p2_, _p3_) ((_p1_ == NULL) || (_p2_ == NULL) || (_p3_ == NULL))
/** @brief Check four pointers */
#define check_null_ptr_4(_p1_, _p2_, _p3_, _p4_) ((_p1_ == NULL) || (_p2_ == NULL) || (_p3_ == NULL) || (_p4_ == NULL))
/** @brief Check five pointers */
#define check_null_ptr_5(_p1_, _p2_, _p3_, _p4_, _p5_) ((_p1_ == NULL) || (_p2_ == NULL) || (_p3_ == NULL) || (_p4_ == NULL) || (_p5_ == NULL))
/** ERROR_HANDLER_DEFINES
* @}
*/
/***************************************************************************
********************************ACCESS_DEFINES*****************************/
#define ClearStruct(_struct_) memset(&(_struct_), 0, sizeof(_struct_))
/***************************************************************************
******************************DELAYS_DEFINES*******************************/
/**
* @addtogroup DELAYS_DEFINES Delays defines
* @ingroup MYLIBS_DEFINES
* @brief Дефайны для реализации задержек
@{
*/
#ifdef FREERTOS_DELAY
#define msDelay(_ms_) osDelay(_ms_)
#else
#define msDelay(_ms_) HAL_Delay(_ms_)
#endif
/**
* @brief Save tick at starting delay (tickstart in HAL)
* @param _pvar_ - указатель для переменной для сохранения тиков.
* @details Сохраняет начало отсчета задержки (текущее количество тиков)
*/
#define msDelayStart(_pvar_) *(_pvar_) = HAL_GetTick()
/**
* @brief Wait for delay after tickstart in _pvar_
* @param _pvar_ - указатель для переменной для сохранения тиков.
* @details Выставляет 1, когда задержка активна
*/
#define msDelayWhileActive(_ms_, _pvar_) (HAL_GetTick() - *(_pvar_) < _ms_)
/**
* @brief Wait until delay is done tickstart in _pvar_
* @param _pvar_ - указатель для переменной для сохранения тиков.
* @details Выставляет 1, когда задержка истекла
*/
#define msDelayWaitDone(_ms_, _pvar_) (HAL_GetTick() - *(_pvar_) >= _ms_)
/** DELAYS_DEFINES
* @}
*/
/***************************************************************************
*******************************MATH_DEFINES********************************/
/**
* @addtogroup MATH_DEFINES Math defines
* @ingroup MYLIBS_DEFINES
* @brief Дефайны для различных математических функций
@{
*/
/**
* @brief Calc dividing including remainder
* @param _val_ - делимое.
* @param _div_ - делитель.
* @details Если результат деления без остатка: он возвращается как есть
Если с остатком - округляется вверх
*/
//#define Divide_Up(_val_, _div_) (((_val_)%(_div_))? (_val_)/(_div_)+1 : (_val_)/_div_) /* через тернарный оператор */
#define Divide_Up(_val_, _div_) ((_val_ - 1) / _div_) + 1 /* через мат выражение */
/**
* @brief Swap between Little Endian and Big Endian
* @param v - Переменная для свапа.
* @return v (new) - Свапнутая переменная.
* @details Переключения между двумя типами хранения слова: HI-LO байты и LO-HI байты.
*/
#define ByteSwap16(v) (((v&0xFF00) >> (8)) | ((v&0x00FF) << (8)))
/**
* @brief Absolute
* @param x - Переменная для модудя.
* @return x (new) - Число по модулю.
* @details Берет число по модулю. Хз как работает библиотечный abs в stdlib.h, мб это быстрее, но вряд ли конечно.
*/
#define ABS(x) ( ((x) > 0)? (x) : -(x))
/** MATH_DEFINES
* @}
*/
#ifndef LED_PWM_TICKS
#define LED_PWM_TICKS 15
#endif
#ifndef LED_ON
#define LED_ON 1
#endif
#ifndef LED_OFF
#define LED_OFF 0
#endif
#ifndef SW_ON
#define SW_ON 1
#endif
#ifndef SW_OFF
#define SW_OFF 0
#endif
#endif //__MYLIBS_DEFINES_H_

106
Core/GFX_Buffer/font.c Normal file
View File

@@ -0,0 +1,106 @@
/*
* font.c
*
* Created on: Nov 17, 2021
* Author: wvv
*/
#include <stdint.h>
const uint8_t f5x8[] = {
0x00, 0x00, 0x00, 0x00, 0x00, // ' '
0x00, 0x00, 0x5F, 0x00, 0x00, // '!'
0x00, 0x07, 0x00, 0x07, 0x00,
0x14, 0x7F, 0x14, 0x7F, 0x14,
0x24, 0x2A, 0x07, 0x2A, 0x12,
0x23, 0x13, 0x08, 0x64, 0x62,
0x37, 0x49, 0x55, 0x22, 0x50,
0x00, 0x05, 0x03, 0x00, 0x00,
0x00, 0x1C, 0x22, 0x41, 0x00,
0x00, 0x41, 0x22, 0x1C, 0x00,
0x08, 0x2A, 0x1C, 0x2A, 0x08,
0x08, 0x08, 0x3E, 0x08, 0x08,
0x00, 0x50, 0x30, 0x00, 0x00,
0x08, 0x08, 0x08, 0x08, 0x08,
0x00, 0x60, 0x60, 0x00, 0x00,
0x20, 0x10, 0x08, 0x04, 0x02,
0x3E, 0x51, 0x49, 0x45, 0x3E,
0x00, 0x42, 0x7F, 0x40, 0x00,
0x42, 0x61, 0x51, 0x49, 0x46,
0x21, 0x41, 0x45, 0x4B, 0x31,
0x18, 0x14, 0x12, 0x7F, 0x10,
0x27, 0x45, 0x45, 0x45, 0x39,
0x3C, 0x4A, 0x49, 0x49, 0x30,
0x01, 0x71, 0x09, 0x05, 0x03,
0x36, 0x49, 0x49, 0x49, 0x36,
0x06, 0x49, 0x49, 0x29, 0x1E,
0x00, 0x36, 0x36, 0x00, 0x00,
0x00, 0x56, 0x36, 0x00, 0x00,
0x00, 0x08, 0x14, 0x22, 0x41,
0x14, 0x14, 0x14, 0x14, 0x14,
0x41, 0x22, 0x14, 0x08, 0x00,
0x02, 0x01, 0x51, 0x09, 0x06,
0x32, 0x49, 0x79, 0x41, 0x3E,
0x7E, 0x11, 0x11, 0x11, 0x7E,
0x7F, 0x49, 0x49, 0x49, 0x36,
0x3E, 0x41, 0x41, 0x41, 0x22,
0x7F, 0x41, 0x41, 0x22, 0x1C,
0x7F, 0x49, 0x49, 0x49, 0x41,
0x7F, 0x09, 0x09, 0x01, 0x01,
0x3E, 0x41, 0x41, 0x51, 0x32,
0x7F, 0x08, 0x08, 0x08, 0x7F,
0x00, 0x41, 0x7F, 0x41, 0x00,
0x20, 0x40, 0x41, 0x3F, 0x01,
0x7F, 0x08, 0x14, 0x22, 0x41,
0x7F, 0x40, 0x40, 0x40, 0x40,
0x7F, 0x02, 0x04, 0x02, 0x7F,
0x7F, 0x04, 0x08, 0x10, 0x7F,
0x3E, 0x41, 0x41, 0x41, 0x3E,
0x7F, 0x09, 0x09, 0x09, 0x06,
0x3E, 0x41, 0x51, 0x21, 0x5E,
0x7F, 0x09, 0x19, 0x29, 0x46,
0x46, 0x49, 0x49, 0x49, 0x31,
0x01, 0x01, 0x7F, 0x01, 0x01,
0x3F, 0x40, 0x40, 0x40, 0x3F,
0x1F, 0x20, 0x40, 0x20, 0x1F,
0x7F, 0x20, 0x18, 0x20, 0x7F,
0x63, 0x14, 0x08, 0x14, 0x63,
0x03, 0x04, 0x78, 0x04, 0x03,
0x61, 0x51, 0x49, 0x45, 0x43,
0x00, 0x00, 0x7F, 0x41, 0x41,
0x02, 0x04, 0x08, 0x10, 0x20,
0x41, 0x41, 0x7F, 0x00, 0x00,
0x04, 0x02, 0x01, 0x02, 0x04,
0x40, 0x40, 0x40, 0x40, 0x40,
0x00, 0x01, 0x02, 0x04, 0x00,
0x20, 0x54, 0x54, 0x54, 0x78,
0x7F, 0x48, 0x44, 0x44, 0x38,
0x38, 0x44, 0x44, 0x44, 0x20,
0x38, 0x44, 0x44, 0x48, 0x7F,
0x38, 0x54, 0x54, 0x54, 0x18,
0x08, 0x7E, 0x09, 0x01, 0x02,
0x08, 0x14, 0x54, 0x54, 0x3C,
0x7F, 0x08, 0x04, 0x04, 0x78,
0x00, 0x44, 0x7D, 0x40, 0x00,
0x20, 0x40, 0x44, 0x3D, 0x00,
0x00, 0x7F, 0x10, 0x28, 0x44,
0x00, 0x41, 0x7F, 0x40, 0x00,
0x7C, 0x04, 0x18, 0x04, 0x78,
0x7C, 0x08, 0x04, 0x04, 0x78,
0x38, 0x44, 0x44, 0x44, 0x38,
0x7C, 0x14, 0x14, 0x14, 0x08,
0x08, 0x14, 0x14, 0x18, 0x7C,
0x7C, 0x08, 0x04, 0x04, 0x08,
0x48, 0x54, 0x54, 0x54, 0x20,
0x04, 0x3F, 0x44, 0x40, 0x20,
0x3C, 0x40, 0x40, 0x20, 0x7C,
0x1C, 0x20, 0x40, 0x20, 0x1C,
0x3C, 0x40, 0x30, 0x40, 0x3C,
0x44, 0x28, 0x10, 0x28, 0x44,
0x0C, 0x50, 0x50, 0x50, 0x3C,
0x44, 0x64, 0x54, 0x4C, 0x44,
0x00, 0x08, 0x36, 0x41, 0x00,
0x00, 0x00, 0x7F, 0x00, 0x00,
0x00, 0x41, 0x36, 0x08, 0x00,
0x02, 0x01, 0x02, 0x04, 0x02, //
0xff, 0xff, 0xff, 0xff, 0xff, //fill
};

View File

@@ -0,0 +1,267 @@
// Название шрифта Tahoma 8
// Автор шрифта ITS-PC / User
// Дата и время генерации Пт 29.09.23 3:23:12
// Сгенерировано matrixFont v1.2.0.55
// Кодовая страница 1251 (ANSI - кириллица)
// https://gitlab.com/riva-lab/matrixFont
#ifndef FONT_TAHOMA_8_H
#define FONT_TAHOMA_8_H
#ifndef FONT_TYPE_MONOSPACED
#define FONT_TYPE_MONOSPACED 0
#endif
#ifndef FONT_TYPE_PROPORTIONAL
#define FONT_TYPE_PROPORTIONAL 1
#endif
#define FONT_TAHOMA_8_LENGTH 224
#define FONT_TAHOMA_8_START_CHAR 32
#define FONT_TAHOMA_8_CHAR_WIDTH 8
#define FONT_TAHOMA_8_CHAR_HEIGHT 10
#define FONT_TAHOMA_8_FONT_TYPE (FONT_TYPE_PROPORTIONAL)
#define FONT_TAHOMA_8_ARRAY_LENGTH (FONT_TAHOMA_8_LENGTH * (1 + FONT_TAHOMA_8_CHAR_HEIGHT))
const unsigned char font_tahoma_8[FONT_TAHOMA_8_ARRAY_LENGTH] =
{
5, /*N*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Символ 32 < >
2, /*N*/ 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x40, 0x00, // Символ 33 <!>
4, /*N*/ 0x50, 0x50, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Символ 34 <">
8, /*N*/ 0x00, 0x0A, 0x0A, 0x3F, 0x14, 0x14, 0x7E, 0x28, 0x28, 0x00, // Символ 35 <#>
6, /*N*/ 0x10, 0x10, 0x3C, 0x50, 0x50, 0x38, 0x14, 0x14, 0x78, 0x10, // Символ 36 <$>
8, /*N*/ 0x00, 0x30, 0x49, 0x4A, 0x34, 0x08, 0x16, 0x29, 0x49, 0x06, // Символ 37 <%>
8, /*N*/ 0x00, 0x30, 0x48, 0x48, 0x32, 0x4A, 0x44, 0x46, 0x39, 0x00, // Символ 38 <&>
2, /*N*/ 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Символ 39 <'>
4, /*N*/ 0x00, 0x10, 0x20, 0x40, 0x40, 0x40, 0x40, 0x40, 0x20, 0x10, // Символ 40 <(>
4, /*N*/ 0x00, 0x40, 0x20, 0x10, 0x10, 0x10, 0x10, 0x10, 0x20, 0x40, // Символ 41 <)>
6, /*N*/ 0x10, 0x54, 0x38, 0x54, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // Символ 42 <*>
8, /*N*/ 0x00, 0x00, 0x08, 0x08, 0x08, 0x7F, 0x08, 0x08, 0x08, 0x00, // Символ 43 <+>
3, /*N*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, // Символ 44 <,>
4, /*N*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, // Символ 45 <->
2, /*N*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x00, // Символ 46 <.>
4, /*N*/ 0x00, 0x00, 0x10, 0x10, 0x20, 0x20, 0x20, 0x40, 0x40, 0x00, // Символ 47 </>
// Digits / Цифры
6, /*N*/ 0x00, 0x38, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, // Символ 48 <0>
4, /*N*/ 0x00, 0x20, 0x60, 0x20, 0x20, 0x20, 0x20, 0x20, 0x70, 0x00, // Символ 49 <1>
6, /*N*/ 0x00, 0x38, 0x44, 0x04, 0x08, 0x10, 0x20, 0x40, 0x7C, 0x00, // Символ 50 <2>
6, /*N*/ 0x00, 0x38, 0x44, 0x04, 0x18, 0x04, 0x04, 0x44, 0x38, 0x00, // Символ 51 <3>
6, /*N*/ 0x00, 0x08, 0x18, 0x28, 0x48, 0x7C, 0x08, 0x08, 0x08, 0x00, // Символ 52 <4>
6, /*N*/ 0x00, 0x7C, 0x40, 0x40, 0x78, 0x04, 0x04, 0x44, 0x38, 0x00, // Символ 53 <5>
6, /*N*/ 0x00, 0x18, 0x20, 0x40, 0x78, 0x44, 0x44, 0x44, 0x38, 0x00, // Символ 54 <6>
6, /*N*/ 0x00, 0x7C, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x00, // Символ 55 <7>
6, /*N*/ 0x00, 0x38, 0x44, 0x44, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, // Символ 56 <8>
6, /*N*/ 0x00, 0x38, 0x44, 0x44, 0x44, 0x3C, 0x04, 0x08, 0x30, 0x00, // Символ 57 <9>
2, /*N*/ 0x00, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x40, 0x40, 0x00, // Символ 58 <:>
3, /*N*/ 0x00, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00, 0x20, 0x20, 0x20, // Символ 59 <;>
7, /*N*/ 0x00, 0x00, 0x02, 0x0C, 0x30, 0x40, 0x30, 0x0C, 0x02, 0x00, // Символ 60 <<>
8, /*N*/ 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x7F, 0x00, 0x00, 0x00, // Символ 61 <=>
7, /*N*/ 0x00, 0x00, 0x40, 0x30, 0x0C, 0x02, 0x0C, 0x30, 0x40, 0x00, // Символ 62 <>>
5, /*N*/ 0x00, 0x70, 0x08, 0x08, 0x10, 0x20, 0x20, 0x00, 0x20, 0x00, // Символ 63 <?>
8, /*N*/ 0x3E, 0x41, 0x9D, 0xA5, 0xA5, 0xA5, 0x9F, 0x40, 0x3C, 0x00, // Символ 64 <@>
// Roman Capitals / Латиница, прописные
7, /*N*/ 0x00, 0x18, 0x18, 0x24, 0x24, 0x24, 0x7E, 0x42, 0x42, 0x00, // Символ 65 <A>
6, /*N*/ 0x00, 0x78, 0x44, 0x44, 0x78, 0x44, 0x44, 0x44, 0x78, 0x00, // Символ 66 <B>
7, /*N*/ 0x00, 0x1E, 0x20, 0x40, 0x40, 0x40, 0x40, 0x20, 0x1E, 0x00, // Символ 67 <C>
7, /*N*/ 0x00, 0x78, 0x44, 0x42, 0x42, 0x42, 0x42, 0x44, 0x78, 0x00, // Символ 68 <D>
6, /*N*/ 0x00, 0x7C, 0x40, 0x40, 0x78, 0x40, 0x40, 0x40, 0x7C, 0x00, // Символ 69 <E>
6, /*N*/ 0x00, 0x7C, 0x40, 0x40, 0x7C, 0x40, 0x40, 0x40, 0x40, 0x00, // Символ 70 <F>
7, /*N*/ 0x00, 0x1E, 0x20, 0x40, 0x40, 0x4E, 0x42, 0x22, 0x1E, 0x00, // Символ 71 <G>
7, /*N*/ 0x00, 0x42, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x00, // Символ 72 <H>
4, /*N*/ 0x00, 0x70, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x70, 0x00, // Символ 73 <I>
5, /*N*/ 0x00, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x70, 0x00, // Символ 74 <J>
6, /*N*/ 0x00, 0x44, 0x48, 0x50, 0x60, 0x60, 0x50, 0x48, 0x44, 0x00, // Символ 75 <K>
5, /*N*/ 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x78, 0x00, // Символ 76 <L>
8, /*N*/ 0x00, 0x63, 0x63, 0x55, 0x55, 0x49, 0x49, 0x41, 0x41, 0x00, // Символ 77 <M>
7, /*N*/ 0x00, 0x62, 0x62, 0x52, 0x52, 0x4A, 0x4A, 0x46, 0x46, 0x00, // Символ 78 <N>
8, /*N*/ 0x00, 0x1C, 0x22, 0x41, 0x41, 0x41, 0x41, 0x22, 0x1C, 0x00, // Символ 79 <O>
6, /*N*/ 0x00, 0x78, 0x44, 0x44, 0x44, 0x78, 0x40, 0x40, 0x40, 0x00, // Символ 80 <P>
8, /*N*/ 0x00, 0x1C, 0x22, 0x41, 0x41, 0x41, 0x41, 0x22, 0x1C, 0x04, // Символ 81 <Q>
7, /*N*/ 0x00, 0x78, 0x44, 0x44, 0x44, 0x78, 0x48, 0x44, 0x42, 0x00, // Символ 82 <R>
6, /*N*/ 0x00, 0x3C, 0x40, 0x40, 0x38, 0x04, 0x04, 0x04, 0x78, 0x00, // Символ 83 <S>
6, /*N*/ 0x00, 0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, // Символ 84 <T>
7, /*N*/ 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, // Символ 85 <U>
6, /*N*/ 0x00, 0x44, 0x44, 0x44, 0x28, 0x28, 0x28, 0x10, 0x10, 0x00, // Символ 86 <V>
8, /*N*/ 0x00, 0x49, 0x49, 0x49, 0x36, 0x36, 0x36, 0x12, 0x12, 0x00, // Символ 87 <W>
6, /*N*/ 0x00, 0x44, 0x44, 0x28, 0x10, 0x10, 0x28, 0x44, 0x44, 0x00, // Символ 88 <X>
6, /*N*/ 0x00, 0x44, 0x44, 0x28, 0x28, 0x10, 0x10, 0x10, 0x10, 0x00, // Символ 89 <Y>
6, /*N*/ 0x00, 0x7C, 0x04, 0x08, 0x10, 0x10, 0x20, 0x40, 0x7C, 0x00, // Символ 90 <Z>
4, /*N*/ 0x70, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x70, 0x00, // Символ 91 <[>
4, /*N*/ 0x00, 0x40, 0x40, 0x20, 0x20, 0x20, 0x20, 0x10, 0x10, 0x00, // Символ 92 <\>
4, /*N*/ 0x70, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x70, 0x00, // Символ 93 <]>
8, /*N*/ 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, // Символ 94 <^>
7, /*N*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, // Символ 95 <_>
3, /*N*/ 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Символ 96 <`>
// Roman Smalls / Латиница, строчные
6, /*N*/ 0x00, 0x00, 0x00, 0x38, 0x04, 0x3C, 0x44, 0x44, 0x3C, 0x00, // Символ 97 <a>
6, /*N*/ 0x40, 0x40, 0x40, 0x78, 0x44, 0x44, 0x44, 0x44, 0x78, 0x00, // Символ 98 <b>
5, /*N*/ 0x00, 0x00, 0x00, 0x38, 0x40, 0x40, 0x40, 0x40, 0x38, 0x00, // Символ 99 <c>
6, /*N*/ 0x04, 0x04, 0x04, 0x3C, 0x44, 0x44, 0x44, 0x44, 0x3C, 0x00, // Символ 100 <d>
6, /*N*/ 0x00, 0x00, 0x00, 0x38, 0x44, 0x7C, 0x40, 0x44, 0x38, 0x00, // Символ 101 <e>
4, /*N*/ 0x30, 0x40, 0x40, 0x70, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, // Символ 102 <f>
6, /*N*/ 0x00, 0x00, 0x00, 0x3C, 0x44, 0x44, 0x44, 0x44, 0x3C, 0x04, // Символ 103 <g>
6, /*N*/ 0x40, 0x40, 0x40, 0x78, 0x44, 0x44, 0x44, 0x44, 0x44, 0x00, // Символ 104 <h>
2, /*N*/ 0x00, 0x40, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, // Символ 105 <i>
3, /*N*/ 0x00, 0x20, 0x00, 0x60, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // Символ 106 <j>
6, /*N*/ 0x40, 0x40, 0x40, 0x48, 0x50, 0x60, 0x50, 0x48, 0x44, 0x00, // Символ 107 <k>
2, /*N*/ 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, // Символ 108 <l>
8, /*N*/ 0x00, 0x00, 0x00, 0x76, 0x49, 0x49, 0x49, 0x49, 0x49, 0x00, // Символ 109 <m>
6, /*N*/ 0x00, 0x00, 0x00, 0x78, 0x44, 0x44, 0x44, 0x44, 0x44, 0x00, // Символ 110 <n>
6, /*N*/ 0x00, 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, // Символ 111 <o>
6, /*N*/ 0x00, 0x00, 0x00, 0x78, 0x44, 0x44, 0x44, 0x44, 0x78, 0x40, // Символ 112 <p>
6, /*N*/ 0x00, 0x00, 0x00, 0x3C, 0x44, 0x44, 0x44, 0x44, 0x3C, 0x04, // Символ 113 <q>
4, /*N*/ 0x00, 0x00, 0x00, 0x50, 0x60, 0x40, 0x40, 0x40, 0x40, 0x00, // Символ 114 <r>
5, /*N*/ 0x00, 0x00, 0x00, 0x38, 0x40, 0x60, 0x18, 0x08, 0x70, 0x00, // Символ 115 <s>
4, /*N*/ 0x00, 0x40, 0x40, 0x70, 0x40, 0x40, 0x40, 0x40, 0x30, 0x00, // Символ 116 <t>
6, /*N*/ 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x44, 0x44, 0x3C, 0x00, // Символ 117 <u>
6, /*N*/ 0x00, 0x00, 0x00, 0x44, 0x44, 0x28, 0x28, 0x10, 0x10, 0x00, // Символ 118 <v>
8, /*N*/ 0x00, 0x00, 0x00, 0x49, 0x49, 0x55, 0x55, 0x22, 0x22, 0x00, // Символ 119 <w>
6, /*N*/ 0x00, 0x00, 0x00, 0x44, 0x28, 0x10, 0x10, 0x28, 0x44, 0x00, // Символ 120 <x>
6, /*N*/ 0x00, 0x00, 0x00, 0x44, 0x44, 0x28, 0x28, 0x10, 0x10, 0x20, // Символ 121 <y>
5, /*N*/ 0x00, 0x00, 0x00, 0x78, 0x08, 0x10, 0x20, 0x40, 0x78, 0x00, // Символ 122 <z>
4, /*N*/ 0x10, 0x20, 0x20, 0x20, 0x40, 0x40, 0x20, 0x20, 0x20, 0x10, // Символ 123 <{>
2, /*N*/ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // Символ 124 <|>
4, /*N*/ 0x40, 0x20, 0x20, 0x20, 0x10, 0x10, 0x20, 0x20, 0x20, 0x40, // Символ 125 <}>
8, /*N*/ 0x00, 0x00, 0x00, 0x00, 0x31, 0x49, 0x46, 0x00, 0x00, 0x00, // Символ 126 <~>
4, /*N*/ 0x00, 0x70, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x70, 0x00, // Символ 127 <DELETE>
8, /*N*/ 0x00, 0x7E, 0x10, 0x10, 0x1E, 0x11, 0x11, 0x11, 0x12, 0x00, // Символ 128 <Ђ>
6, /*N*/ 0x00, 0x7C, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, // Символ 129 <Ѓ>
3, /*N*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x40, // Символ 130 <>
5, /*N*/ 0x08, 0x10, 0x00, 0x78, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, // Символ 131 <ѓ>
5, /*N*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x28, 0x50, // Символ 132 <„>
8, /*N*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x00, // Символ 133 <…>
6, /*N*/ 0x10, 0x10, 0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, // Символ 134 <†>
6, /*N*/ 0x10, 0x10, 0x7C, 0x10, 0x10, 0x7C, 0x10, 0x10, 0x00, 0x00, // Символ 135 <‡>
7, /*N*/ 0x00, 0x1C, 0x22, 0x78, 0x20, 0x78, 0x20, 0x12, 0x0C, 0x00, // Символ 136 <€>
7, /*N*/ 0x60, 0x90, 0x90, 0x62, 0x1C, 0xE0, 0x62, 0x94, 0x94, 0x62, // Символ 137 <‰>
8, /*N*/ 0x00, 0x38, 0x28, 0x28, 0x28, 0x2E, 0x29, 0x29, 0x4E, 0x00, // Символ 138 <Љ>
4, /*N*/ 0x00, 0x00, 0x00, 0x10, 0x20, 0x40, 0x20, 0x10, 0x00, 0x00, // Символ 139 <>
8, /*N*/ 0x00, 0x48, 0x48, 0x48, 0x7E, 0x49, 0x49, 0x49, 0x4E, 0x00, // Символ 140 <Њ>
7, /*N*/ 0x00, 0x46, 0x48, 0x48, 0x70, 0x50, 0x48, 0x44, 0x42, 0x00, // Символ 141 <Ќ>
8, /*N*/ 0x00, 0x7E, 0x10, 0x10, 0x1E, 0x11, 0x11, 0x11, 0x11, 0x00, // Символ 142 <Ћ>
7, /*N*/ 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x08, 0x08, 0x00, // Символ 143 <Џ>
7, /*N*/ 0x20, 0x78, 0x20, 0x3C, 0x22, 0x22, 0x22, 0x22, 0x22, 0x04, // Символ 144 <ђ>
3, /*N*/ 0x40, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Символ 145 <>
3, /*N*/ 0x20, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Символ 146 <>
5, /*N*/ 0x50, 0x50, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Символ 147 <“>
5, /*N*/ 0x28, 0x28, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Символ 148 <”>
5, /*N*/ 0x00, 0x00, 0x00, 0x00, 0x30, 0x78, 0x78, 0x30, 0x00, 0x00, // Символ 149 <•>
7, /*N*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, // Символ 150 <>
8, /*N*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, // Символ 151 <—>
5, /*N*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Символ 152 <˜>
7, /*N*/ 0x00, 0xEA, 0x4E, 0x4A, 0x4A, 0x00, 0x00, 0x00, 0x00, 0x00, // Символ 153 <™>
8, /*N*/ 0x00, 0x00, 0x00, 0x78, 0x48, 0x4E, 0x49, 0x49, 0x8E, 0x00, // Символ 154 <љ>
4, /*N*/ 0x00, 0x00, 0x00, 0x40, 0x20, 0x10, 0x20, 0x40, 0x00, 0x00, // Символ 155 <>
8, /*N*/ 0x00, 0x00, 0x00, 0x48, 0x48, 0x7E, 0x49, 0x49, 0x4E, 0x00, // Символ 156 <њ>
6, /*N*/ 0x08, 0x10, 0x00, 0x4C, 0x50, 0x60, 0x50, 0x48, 0x44, 0x00, // Символ 157 <ќ>
7, /*N*/ 0x20, 0x78, 0x20, 0x3C, 0x22, 0x22, 0x22, 0x22, 0x22, 0x00, // Символ 158 <ћ>
6, /*N*/ 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x7C, 0x10, 0x10, 0x00, // Символ 159 <џ>
5, /*N*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Символ 160 < >
5, /*N*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Символ 161 <Ў>
5, /*N*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Символ 162 <ў>
5, /*N*/ 0x00, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x70, 0x00, // Символ 163 <Ј>
6, /*N*/ 0x00, 0x00, 0x00, 0x44, 0x38, 0x28, 0x38, 0x44, 0x00, 0x00, // Символ 164 <¤>
6, /*N*/ 0x04, 0x7C, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, // Символ 165 <Ґ>
2, /*N*/ 0x00, 0x40, 0x40, 0x40, 0x00, 0x00, 0x40, 0x40, 0x40, 0x00, // Символ 166 <¦>
6, /*N*/ 0x3C, 0x40, 0x40, 0x38, 0x44, 0x44, 0x38, 0x04, 0x04, 0x78, // Символ 167 <§>
6, /*N*/ 0x00, 0x7C, 0x40, 0x40, 0x78, 0x40, 0x40, 0x40, 0x7C, 0x00, // Символ 168 <Ё>
8, /*N*/ 0x00, 0x3C, 0x42, 0x99, 0xA1, 0xA1, 0xA1, 0x99, 0x42, 0x3C, // Символ 169 <©>
6, /*N*/ 0x00, 0x1C, 0x20, 0x40, 0x78, 0x40, 0x40, 0x20, 0x1C, 0x00, // Символ 170 <Є>
6, /*N*/ 0x00, 0x00, 0x00, 0x14, 0x28, 0x50, 0x28, 0x14, 0x00, 0x00, // Символ 171 <«>
7, /*N*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x02, 0x02, 0x02, 0x00, // Символ 172 <¬>
4, /*N*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, // Символ 173 <­>
8, /*N*/ 0x00, 0x3C, 0x42, 0x99, 0x95, 0x99, 0x95, 0x95, 0x42, 0x3C, // Символ 174 <®>
4, /*N*/ 0x50, 0x00, 0x70, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x70, // Символ 175 <Ї>
5, /*N*/ 0x00, 0x30, 0x48, 0x48, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, // Символ 176 <°>
6, /*N*/ 0x00, 0x00, 0x10, 0x10, 0x7C, 0x10, 0x10, 0x00, 0x7C, 0x00, // Символ 177 <±>
4, /*N*/ 0x00, 0x70, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x70, 0x00, // Символ 178 <І>
2, /*N*/ 0x00, 0x40, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, // Символ 179 <і>
5, /*N*/ 0x00, 0x08, 0x08, 0x78, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, // Символ 180 <ґ>
6, /*N*/ 0x00, 0x44, 0x44, 0x44, 0x44, 0x4C, 0x74, 0x40, 0x40, 0x00, // Символ 181 <µ>
6, /*N*/ 0x00, 0x3C, 0x74, 0x74, 0x74, 0x34, 0x14, 0x14, 0x14, 0x00, // Символ 182 <¶>
2, /*N*/ 0x00, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, // Символ 183 <·>
6, /*N*/ 0x00, 0x28, 0x00, 0x38, 0x44, 0x7C, 0x40, 0x44, 0x38, 0x00, // Символ 184 <ё>
8, /*N*/ 0x00, 0x8A, 0xCD, 0xCA, 0xA8, 0xAF, 0x98, 0x98, 0x88, 0x00, // Символ 185 <№>
5, /*N*/ 0x00, 0x00, 0x00, 0x38, 0x40, 0x70, 0x40, 0x40, 0x38, 0x00, // Символ 186 <є>
6, /*N*/ 0x00, 0x00, 0x00, 0x50, 0x28, 0x14, 0x28, 0x50, 0x00, 0x00, // Символ 187 <»>
3, /*N*/ 0x20, 0x00, 0x60, 0x20, 0x20, 0x20, 0x20, 0x40, 0x00, 0x00, // Символ 188 <ј>
6, /*N*/ 0x00, 0x3C, 0x40, 0x40, 0x38, 0x04, 0x04, 0x04, 0x78, 0x00, // Символ 189 <Ѕ>
5, /*N*/ 0x00, 0x00, 0x00, 0x38, 0x40, 0x60, 0x18, 0x08, 0x70, 0x00, // Символ 190 <ѕ>
4, /*N*/ 0x00, 0x50, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, // Символ 191 <ї>
// Cyrillic Capitals / Кириллица, прописные
7, /*N*/ 0x00, 0x18, 0x18, 0x24, 0x24, 0x24, 0x7E, 0x42, 0x42, 0x00, // Символ 192 <А>
6, /*N*/ 0x00, 0x7C, 0x40, 0x40, 0x78, 0x44, 0x44, 0x44, 0x78, 0x00, // Символ 193 <Б>
6, /*N*/ 0x00, 0x78, 0x44, 0x44, 0x78, 0x44, 0x44, 0x44, 0x78, 0x00, // Символ 194 <В>
6, /*N*/ 0x00, 0x7C, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, // Символ 195 <Г>
8, /*N*/ 0x00, 0x0E, 0x0A, 0x12, 0x12, 0x12, 0x7F, 0x41, 0x41, 0x00, // Символ 196 <Д>
6, /*N*/ 0x00, 0x7C, 0x40, 0x40, 0x78, 0x40, 0x40, 0x40, 0x7C, 0x00, // Символ 197 <Е>
8, /*N*/ 0x00, 0x49, 0x49, 0x2A, 0x2A, 0x1C, 0x2A, 0x49, 0x08, 0x00, // Символ 198 <Ж>
6, /*N*/ 0x00, 0x78, 0x04, 0x04, 0x38, 0x04, 0x04, 0x04, 0x78, 0x00, // Символ 199 <З>
7, /*N*/ 0x00, 0x42, 0x46, 0x4A, 0x4A, 0x52, 0x52, 0x62, 0x42, 0x00, // Символ 200 <И>
7, /*N*/ 0x24, 0x18, 0x42, 0x46, 0x4A, 0x4A, 0x52, 0x62, 0x42, 0x00, // Символ 201 <Й>
7, /*N*/ 0x00, 0x46, 0x48, 0x48, 0x70, 0x50, 0x48, 0x44, 0x42, 0x00, // Символ 202 <К>
7, /*N*/ 0x00, 0x3E, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x42, 0x00, // Символ 203 <Л>
8, /*N*/ 0x00, 0x63, 0x63, 0x55, 0x55, 0x49, 0x49, 0x41, 0x41, 0x00, // Символ 204 <М>
7, /*N*/ 0x00, 0x42, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x00, // Символ 205 <Н>
8, /*N*/ 0x00, 0x1C, 0x22, 0x41, 0x41, 0x41, 0x41, 0x22, 0x1C, 0x00, // Символ 206 <О>
7, /*N*/ 0x00, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, // Символ 207 <П>
6, /*N*/ 0x00, 0x78, 0x44, 0x44, 0x44, 0x78, 0x40, 0x40, 0x40, 0x00, // Символ 208 <Р>
7, /*N*/ 0x00, 0x1E, 0x20, 0x40, 0x40, 0x40, 0x40, 0x20, 0x1E, 0x00, // Символ 209 <С>
6, /*N*/ 0x00, 0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, // Символ 210 <Т>
7, /*N*/ 0x00, 0x42, 0x42, 0x24, 0x24, 0x18, 0x18, 0x10, 0x60, 0x00, // Символ 211 <У>
8, /*N*/ 0x00, 0x08, 0x3E, 0x49, 0x49, 0x49, 0x49, 0x3E, 0x08, 0x00, // Символ 212 <Ф>
6, /*N*/ 0x00, 0x44, 0x44, 0x28, 0x10, 0x10, 0x28, 0x44, 0x44, 0x00, // Символ 213 <Х>
8, /*N*/ 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7F, 0x01, 0x01, 0x00, // Символ 214 <Ц>
7, /*N*/ 0x00, 0x42, 0x42, 0x42, 0x42, 0x3E, 0x02, 0x02, 0x02, 0x00, // Символ 215 <Ч>
8, /*N*/ 0x00, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x7F, 0x00, // Символ 216 <Ш>
8, /*N*/ 0x00, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0xFF, 0x80, // Символ 217 <Щ>
8, /*N*/ 0x00, 0x70, 0x10, 0x10, 0x1E, 0x11, 0x11, 0x11, 0x1E, 0x00, // Символ 218 <Ъ>
8, /*N*/ 0x00, 0x41, 0x41, 0x41, 0x79, 0x45, 0x45, 0x45, 0x79, 0x00, // Символ 219 <Ы>
6, /*N*/ 0x00, 0x40, 0x40, 0x40, 0x78, 0x44, 0x44, 0x44, 0x78, 0x00, // Символ 220 <Ь>
7, /*N*/ 0x00, 0x78, 0x04, 0x02, 0x3E, 0x02, 0x02, 0x04, 0x78, 0x00, // Символ 221 <Э>
8, /*N*/ 0x00, 0x4E, 0x51, 0x51, 0x71, 0x51, 0x51, 0x51, 0x4E, 0x00, // Символ 222 <Ю>
7, /*N*/ 0x00, 0x1E, 0x22, 0x22, 0x22, 0x1E, 0x12, 0x22, 0x42, 0x00, // Символ 223 <Я>
// Cyrillic Smalls / Кириллица, строчные
6, /*N*/ 0x00, 0x00, 0x00, 0x38, 0x04, 0x3C, 0x44, 0x44, 0x3C, 0x00, // Символ 224 <а>
6, /*N*/ 0x1C, 0x20, 0x40, 0x78, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, // Символ 225 <б>
6, /*N*/ 0x00, 0x00, 0x00, 0x78, 0x44, 0x78, 0x44, 0x44, 0x78, 0x00, // Символ 226 <в>
5, /*N*/ 0x00, 0x00, 0x00, 0x78, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, // Символ 227 <г>
7, /*N*/ 0x00, 0x00, 0x1C, 0x14, 0x14, 0x24, 0x24, 0x7E, 0x42, 0x00, // Символ 228 <д>
6, /*N*/ 0x00, 0x00, 0x00, 0x38, 0x44, 0x7C, 0x40, 0x44, 0x38, 0x00, // Символ 229 <е>
8, /*N*/ 0x00, 0x00, 0x00, 0x49, 0x2A, 0x2A, 0x1C, 0x2A, 0x49, 0x00, // Символ 230 <ж>
5, /*N*/ 0x00, 0x00, 0x00, 0x70, 0x08, 0x30, 0x08, 0x08, 0x70, 0x00, // Символ 231 <з>
6, /*N*/ 0x00, 0x00, 0x00, 0x44, 0x4C, 0x54, 0x64, 0x44, 0x44, 0x00, // Символ 232 <и>
6, /*N*/ 0x24, 0x18, 0x00, 0x44, 0x4C, 0x54, 0x64, 0x44, 0x44, 0x00, // Символ 233 <й>
6, /*N*/ 0x00, 0x00, 0x00, 0x4C, 0x50, 0x60, 0x50, 0x48, 0x44, 0x00, // Символ 234 <к>
6, /*N*/ 0x00, 0x00, 0x00, 0x3C, 0x24, 0x24, 0x24, 0x24, 0x44, 0x00, // Символ 235 <л>
6, /*N*/ 0x00, 0x00, 0x00, 0x44, 0x6C, 0x54, 0x54, 0x44, 0x44, 0x00, // Символ 236 <м>
6, /*N*/ 0x00, 0x00, 0x00, 0x44, 0x44, 0x7C, 0x44, 0x44, 0x44, 0x00, // Символ 237 <н>
6, /*N*/ 0x00, 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, // Символ 238 <о>
6, /*N*/ 0x00, 0x00, 0x00, 0x7C, 0x44, 0x44, 0x44, 0x44, 0x44, 0x00, // Символ 239 <п>
6, /*N*/ 0x00, 0x00, 0x00, 0x78, 0x44, 0x44, 0x78, 0x40, 0x40, 0x00, // Символ 240 <р>
5, /*N*/ 0x00, 0x00, 0x00, 0x38, 0x40, 0x40, 0x40, 0x40, 0x38, 0x00, // Символ 241 <с>
6, /*N*/ 0x00, 0x00, 0x00, 0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, // Символ 242 <т>
6, /*N*/ 0x00, 0x00, 0x00, 0x44, 0x44, 0x28, 0x28, 0x10, 0x10, 0x20, // Символ 243 <у>
8, /*N*/ 0x08, 0x08, 0x08, 0x3E, 0x49, 0x49, 0x49, 0x49, 0x3E, 0x08, // Символ 244 <ф>
6, /*N*/ 0x00, 0x00, 0x00, 0x44, 0x28, 0x10, 0x10, 0x28, 0x44, 0x00, // Символ 245 <х>
6, /*N*/ 0x00, 0x00, 0x00, 0x48, 0x48, 0x48, 0x48, 0x48, 0x7C, 0x04, // Символ 246 <ц>
6, /*N*/ 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x3C, 0x04, 0x04, 0x00, // Символ 247 <ч>
8, /*N*/ 0x00, 0x00, 0x00, 0x49, 0x49, 0x49, 0x49, 0x49, 0x7F, 0x00, // Символ 248 <ш>
8, /*N*/ 0x00, 0x00, 0x00, 0x49, 0x49, 0x49, 0x49, 0x49, 0xFF, 0x80, // Символ 249 <щ>
7, /*N*/ 0x00, 0x00, 0x00, 0x70, 0x10, 0x1C, 0x12, 0x12, 0x1C, 0x00, // Символ 250 <ъ>
8, /*N*/ 0x00, 0x00, 0x00, 0x41, 0x41, 0x79, 0x45, 0x45, 0x79, 0x00, // Символ 251 <ы>
6, /*N*/ 0x00, 0x00, 0x00, 0x40, 0x40, 0x78, 0x44, 0x44, 0x78, 0x00, // Символ 252 <ь>
5, /*N*/ 0x00, 0x00, 0x00, 0x70, 0x08, 0x38, 0x08, 0x08, 0x70, 0x00, // Символ 253 <э>
8, /*N*/ 0x00, 0x00, 0x00, 0x8E, 0x91, 0xF1, 0x91, 0x91, 0x8E, 0x00, // Символ 254 <ю>
6, /*N*/ 0x00, 0x00, 0x00, 0x3C, 0x44, 0x44, 0x3C, 0x24, 0x44, 0x00 // Символ 255 <я>
};
#endif // FONT_TAHOMA_8_H

View File

@@ -0,0 +1,42 @@
// Название шрифта Terminus (TTF) for Windows 15
// Автор шрифта ITS-PC / User
// Дата и время генерации Ср 27.09.23 15:02:48
// Сгенерировано matrixFont v1.2.0.55
// Кодовая страница ANSI (ASCII 7-битная)
// https://gitlab.com/riva-lab/matrixFont
#ifndef FONT_TERMINUS_10X15__H
#define FONT_TERMINUS_10X15__H
#ifndef FONT_TYPE_MONOSPACED
#define FONT_TYPE_MONOSPACED 0
#endif
#ifndef FONT_TYPE_PROPORTIONAL
#define FONT_TYPE_PROPORTIONAL 1
#endif
#define FONT_TERMINUS_10X15__LENGTH 10
#define FONT_TERMINUS_10X15__START_CHAR 48
#define FONT_TERMINUS_10X15__CHAR_WIDTH 10
#define FONT_TERMINUS_10X15__CHAR_HEIGHT 15
#define FONT_TERMINUS_10X15__FONT_TYPE (FONT_TYPE_MONOSPACED)
#define FONT_TERMINUS_10X15__ARRAY_LENGTH (FONT_TERMINUS_10X15__LENGTH * FONT_TERMINUS_10X15__CHAR_HEIGHT * 2)
const unsigned char font_terminus_10x15_[FONT_TERMINUS_10X15__ARRAY_LENGTH] =
{
// Digits / Цифры
0x00, 0x00, 0xFC, 0x00, 0x86, 0x01, 0x86, 0x01, 0x86, 0x01, 0x8E, 0x01, 0x9E, 0x01, 0xB6, 0x01, 0xE6, 0x01, 0xC6, 0x01, 0x86, 0x01, 0x86, 0x01, 0x86, 0x01, 0xFC, 0x00, 0x00, 0x00, // Символ 48 <0>
0x00, 0x00, 0x30, 0x00, 0x70, 0x00, 0xF0, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0xFC, 0x00, 0x00, 0x00, // Символ 49 <1>
0x00, 0x00, 0xFC, 0x00, 0x86, 0x01, 0x86, 0x01, 0x86, 0x01, 0x06, 0x00, 0x06, 0x00, 0x0C, 0x00, 0x18, 0x00, 0x30, 0x00, 0x60, 0x00, 0xC0, 0x00, 0x80, 0x01, 0xFE, 0x01, 0x00, 0x00, // Символ 50 <2>
0x00, 0x00, 0xFC, 0x00, 0x86, 0x01, 0x86, 0x01, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x7C, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x86, 0x01, 0x86, 0x01, 0xFC, 0x00, 0x00, 0x00, // Символ 51 <3>
0x00, 0x00, 0x06, 0x00, 0x0E, 0x00, 0x1E, 0x00, 0x36, 0x00, 0x66, 0x00, 0xC6, 0x00, 0x86, 0x01, 0x86, 0x01, 0x86, 0x01, 0xFE, 0x01, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, // Символ 52 <4>
0x00, 0x00, 0xFE, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xFC, 0x01, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x86, 0x01, 0x86, 0x01, 0xFC, 0x00, 0x00, 0x00, // Символ 53 <5>
0x00, 0x00, 0x7C, 0x00, 0xC0, 0x00, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xFC, 0x01, 0x86, 0x01, 0x86, 0x01, 0x86, 0x01, 0x86, 0x01, 0x86, 0x01, 0x86, 0x01, 0xFC, 0x00, 0x00, 0x00, // Символ 54 <6>
0x00, 0x00, 0xFE, 0x01, 0x86, 0x01, 0x86, 0x01, 0x06, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x18, 0x00, 0x18, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, // Символ 55 <7>
0x00, 0x00, 0xFC, 0x00, 0x86, 0x01, 0x86, 0x01, 0x86, 0x01, 0x86, 0x01, 0x86, 0x01, 0xFC, 0x00, 0x86, 0x01, 0x86, 0x01, 0x86, 0x01, 0x86, 0x01, 0x86, 0x01, 0xFC, 0x00, 0x00, 0x00, // Символ 56 <8>
0x00, 0x00, 0xFC, 0x00, 0x86, 0x01, 0x86, 0x01, 0x86, 0x01, 0x86, 0x01, 0x86, 0x01, 0x86, 0x01, 0xFE, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x0C, 0x00, 0xF8, 0x00, 0x00, 0x00 // Символ 57 <9>
};
#endif // FONT_TERMINUS_10X15__H

View File

@@ -0,0 +1,564 @@
/*
* gfx_buffer.c
*
* Библиотека для заполнения буфера дисплея
*
* Для разработки библиотеки иcпользовались материалы:
* https://www.youtube.com/watch?v=ajEqZN5s5xc
* https://narodstream.ru/stm-urok-37-displej-tft-240x320-8bit-chast-1/
* https://hubstub.ru/display/126-vyvod-simvolov-i-strok-na-tft-displey-na-primere-ili9341.html
*/
#include "gfx_buffer.h"
#include "font_tahoma_8_prop.h"
#include "math.h"
/* переменные */
//uint8_t Buffer_Frame[128 * 32] = {0,0}; //буфер кадра
uint8_t chSpacing = 0; //межсимвольный интервал в px
/* функция очистки буфера кадра */
void GFX_Clean_Buffer_Frame(uint8_t *Buffer_Frame, uint32_t Buffer_Frame_Size)
{
if(Buffer_Frame == NULL)
return;
memset(Buffer_Frame, 0x00, Buffer_Frame_Size);
}
/* функция прорисовки пикселя */
void GFX_Draw_Pixel(uint8_t *Buffer_Frame, uint8_t xPos, uint8_t yPos, uint8_t pxColor)
{
if(Buffer_Frame == NULL)
return;
if ((xPos >= GFX_BufferWidth)||(xPos < 0)||(yPos >= GFX_BufferHeight)||(yPos < 0))
{
//если значения по x и y больше пределов то выходим из функции
return;
}
else
{
uint16_t arrayPos = xPos + ((yPos/8)*GFX_BufferWidth);
//заполняем буфер кадра
if (pxColor)
{
Buffer_Frame[arrayPos] |= 1 << (yPos % 8);
}
else
{
Buffer_Frame[arrayPos] &= 0xFF ^ 1 << (yPos % 8);
}
}
}
/* функция инверсии любой области в буфере кадра */
void GFX_Invertion_Area(uint8_t *Buffer_Frame, uint16_t xPos_Start, uint16_t yPos_Start, uint16_t width, uint16_t height)
{
if(Buffer_Frame == NULL)
return;
if ((xPos_Start+width > GFX_BufferWidth)||(xPos_Start < 0)||(yPos_Start+ height> GFX_BufferHeight)||(yPos_Start < 0))
{
//если значения по x и y больше пределов то выходим из функции
return;
}
for (uint16_t xPos = xPos_Start; xPos < xPos_Start + width; xPos++)
{
for(uint16_t yPos = yPos_Start; yPos < yPos_Start + height; yPos++)
{
uint16_t arrayPos = xPos + ((yPos/8)*GFX_BufferWidth);
Buffer_Frame[arrayPos] ^= (1 << (yPos % 8)); // Инвертируем бит, отвечающий за пиксель
}
}
}
/* работа со шрифтами */
/* функция прорисовки однобайтового символа шрифта */
void GFX_Draw_Char_1_Byte(uint8_t *Buffer_Frame, uint8_t xPos, uint8_t yPos, char Symbol, uint8_t Inversion)
{
/*
* выгрузка кода шрифта в "h" файл из программы matrixFont
* https://habr.com/ru/articles/575332/
* параметры выгрузки:
* сначала строки, справа на лево, сверху вниз, пропорциональный, HEX, нули, 8(uint8_t, unsigned char), С99
* ниже циклы для однобайтового символа шрифта, т.е. ширина символа не более 8 пикселей
*/
if(Buffer_Frame == NULL)
return;
/* если ASCII номер символа в диапазоне 32...255, то рисуем символы шрифта */
if ((Symbol >= 32) && (Symbol <= 255))
{
uint8_t pxChView;
uint8_t pxBkView;
//включение/выключении инверсии символа
if (!(Inversion & GFX_ChInvers))
{
pxChView = GFX_pxView_On;
pxBkView = GFX_pxView_Off;
}
else
{
pxChView = GFX_pxView_Off;
pxBkView = GFX_pxView_On;
}
//извлекаем ширину символа + 1px для минимального межсимвольного интервала
uint8_t chWidth = font_tahoma_8[(Symbol - 0x20) * (1 + FONT_TAHOMA_8_CHAR_HEIGHT)] + 1;
//запоминаем ширину данного символа
chSpacing = chWidth;
//рисуем заданный символ шрифта
for (uint8_t y = 1; y <= FONT_TAHOMA_8_CHAR_HEIGHT; y++) //высота холста шрифта в пикселях
{
for (uint8_t x = 0; x < chWidth; x++) //ширина холста символа шрифта
{
/*
* извлекаем из массива шрифта байт строки пикселей символа
* и с помощью операции побитового И определяем где 1 и где 0
* 0x20 на 32
*/
if (font_tahoma_8[((Symbol - 0x20) * (1 + FONT_TAHOMA_8_CHAR_HEIGHT)) + y] >> (7 - x) & 0x01)
{
GFX_Draw_Pixel(Buffer_Frame, xPos + x, yPos + y, pxChView);
}
else
{
GFX_Draw_Pixel(Buffer_Frame, xPos + x, yPos + y, pxBkView);
}
}
/*
* заполняем фоном справа от символа если ширина символа меньше ширины холста шрифта
* с учетом заданного минимального межсимвольного интервала в 1px
*/
if (chWidth < FONT_TAHOMA_8_CHAR_WIDTH)
{
for (uint8_t n = chWidth; n < (FONT_TAHOMA_8_CHAR_WIDTH + 1); n++)
{
if (!(Inversion & GFX_ChInvers))
{
GFX_Draw_Pixel(Buffer_Frame, xPos + n, yPos + y, pxBkView);
}
else
{
GFX_Draw_Pixel(Buffer_Frame, xPos + n, yPos + y, pxChView);
}
}
}
}
}
}
/* функция прорисовки двухбайтового символа шрифта */
void GFX_Draw_Char_2_Byte(uint8_t *Buffer_Frame, uint8_t xPos, uint8_t yPos, uint8_t Symbol, uint8_t Inversion)
{
// /*
// * выгрузка кода шрифта в "h" файл из программы matrixFont
// * https://habr.com/ru/articles/575332/
// * параметры выгрузки:
// * сначала строки, справа на лево, сверху вниз, моноширный, HEX, нули, 8(uint8_t, unsigned char), С99
// * ниже циклы для двухбайтового символа шрифта, т.е. ширина символа более 8 пикселей
// */
// /* если ASCII номер символа в диапазоне 48...57, то рисуем символы цифр шрифта */
// if ((Symbol >= 48) && (Symbol <= 57))
// {
// Symbol = (Symbol - 48) * 15;
// uint8_t pxChView;
// uint8_t pxBkView;
// //включение/выключении инверсии символа
// if (!(Inversion & GFX_ChInvers))
// {
// pxChView = GFX_pxView_On;
// pxBkView = GFX_pxView_Off;
// }
// else
// {
// pxChView = GFX_pxView_Off;
// pxBkView = GFX_pxView_On;
// }
// //рисуем заданный символ шрифта
// for (uint8_t y = 0; y < FONT_TERMINUS_10X15__CHAR_HEIGHT; y++) //высота холста шрифта в пикселях
// {
// for (uint8_t x = 0; x < 8; x++) //8 - один байт
// {
// /*
// * извлекаем из массива шрифта правый байт строки пикселей символа
// * и с помощью операции побитового И определяем где 1 а где 0
// */
// if (font_terminus_10x15_[(Symbol + y) * 2 + 1] >> (7 - x) & 0x01)
// {
// /*
// * рисуем только нужную нам часть из правого байта
// * пикселя символа, -6 смещаем картинку на заданную позицию
// */
// if (x > 5)
// {
// GFX_Draw_Pixel(Buffer_Frame, xPos + x - 6, yPos + y, pxChView);
// }
// }
// else
// {
// /*
// * рисуем только нужную нам часть из правого байта
// * пикселя фона символа, -6 смещаем картинку на заданную позицию
// */
// if (x > 5)
// {
// GFX_Draw_Pixel(Buffer_Frame, xPos + x - 6, yPos + y, pxBkView);
// }
// }
// /*
// * извлекаем из массива шрифта левый байт строки пикселей символа
// * и с помощью операции побитового И определяем где 1 а где 0
// */
// if (font_terminus_10x15_[(Symbol + y) * 2] >> (7 - x) & 0x01)
// {
// /*
// * смещаем картинку на 8 пикселей вправо
// * т.е. "склеиваем" картинку символа и рисуем пиксель символа,
// * -6 смещаем картинку на заданную позицию
// */
// GFX_Draw_Pixel(Buffer_Frame, xPos + x + 8 - 6, yPos + y, pxChView);
// }
// else
// {
// /*
// * смещаем картинку на 8 пикселей вправо
// * т.е. "склеиваем" картинку символа и рисуем пиксель фона символа,
// * -6 смещаем картинку на заданную позицию
// */
// GFX_Draw_Pixel(Buffer_Frame, xPos + x + 8 - 6, yPos + y, pxBkView);
// }
// }
// }
// }
}
/* функция вывода строки на дисплей */
void GFX_Output_String(uint8_t *Buffer_Frame, uint8_t xPos, uint8_t yPos, char *String, uint8_t setChSpacing, uint8_t Inversion)
{
/*
* вывод строки шрифтом font_tahoma_8
* параметры функции:
* xPos - позиция по X
* yPos - позиция по Y
* *String - строка для вывода
* setChSpacing - межсимвольный интервал в px
* Inversion - включение/выключени инверсии
*/
//uint8_t xPos_Start = xPos; //px начала вывода строки по X
if((Buffer_Frame == NULL) || (String == NULL))
return;
//посимвольный вывод строки
while(*String)
{
//проверяем не вылезем ли мы за пределы экрана при отрисовке следующего символа,
// если да, то переходим на следующую строчку
/*if((xPos + 8) > GFX_BufferWidth)
{
xPos = xPos_Start;
yPos = yPos + 10;
}*/
//вывод текущего символа строки
GFX_Draw_Char_1_Byte(Buffer_Frame, xPos, yPos, *String, Inversion);
//изменяем координату для отрисовки следующего символа
xPos += chSpacing - 1 + setChSpacing;
//инкремент указателя на следующий символ в строке
String++;
}
}
/* геометрические примитивы */
/* функция рисования линии */
void GFX_Draw_Line(uint8_t *Buffer_Frame, GFX_LineHandleTypeDef *hLine)
{
if((Buffer_Frame == NULL) || (hLine == NULL))
return;
uint8_t xPos_Start = hLine->xPos_Start;
uint8_t yPos_Start = hLine->yPos_Start;
uint8_t xPos_End = hLine->xPos_End;
uint8_t yPos_End = hLine->yPos_End;
uint8_t pxColor = hLine->pxColor;
int dx = (xPos_End >= xPos_Start) ? xPos_End - xPos_Start : xPos_Start - xPos_End;
int dy = (yPos_End >= yPos_Start) ? yPos_End - yPos_Start : yPos_Start - yPos_End;
int sx = (xPos_Start < xPos_End) ? 1 : -1;
int sy = (yPos_Start < yPos_End) ? 1 : -1;
int err = dx - dy;
for (;;)
{
GFX_Draw_Pixel(Buffer_Frame, xPos_Start, yPos_Start, pxColor);
if (xPos_Start == xPos_End && yPos_Start == yPos_End)
break;
int e2 = err + err;
if (e2 > -dy)
{
err -= dy;
xPos_Start += sx;
}
if (e2 < dx)
{
err += dx;
yPos_Start += sy;
}
}
}
/* функция рисования пустотелого прямоугольника */
void GFX_Draw_Rectangle(uint8_t *Buffer_Frame, GFX_RectangleHandleTypeDef *hRectangle)
{
if((Buffer_Frame == NULL) || (hRectangle == NULL))
return;
uint8_t xPos_Start = hRectangle->xPos_Start;
uint8_t yPos_Start = hRectangle->yPos_Start;
uint8_t rectangle_Width = hRectangle->rectangle_Width;
uint8_t rectangle_Height = hRectangle->rectangle_Height;
uint8_t pxColor = hRectangle->pxColor;
if(hRectangle->Filled)
__GFX_Draw_Rectangle_Filled(Buffer_Frame, xPos_Start, yPos_Start, rectangle_Width, rectangle_Height, pxColor);
else
__GFX_Draw_Rectangle(Buffer_Frame, xPos_Start, yPos_Start, rectangle_Width, rectangle_Height, pxColor);
}
/* функция рисования пустотелой окружности */
void GFX_Draw_Circle(uint8_t *Buffer_Frame, GFX_CircleHandleTypeDef *hCircle)
{
if((Buffer_Frame == NULL) || (hCircle == NULL))
return;
uint8_t xPos = hCircle->xPos;
uint8_t yPos = hCircle->yPos;
uint8_t circle_Radius = hCircle->circle_Radius;
uint8_t pxColor = hCircle->pxColor;
if(hCircle->Filled)
__GFX_Draw_Circle_Filled(Buffer_Frame, xPos, yPos, circle_Radius, pxColor);
else
__GFX_Draw_Circle(Buffer_Frame, xPos, yPos, circle_Radius, pxColor);
}
/* функция рисования треугольника */
void GFX_Draw_Triangle(uint8_t *Buffer_Frame, GFX_TriangleHandleTypeDef *hTriangle)
{
uint8_t xPos1 = hTriangle->xPos1;
uint8_t xPos2 = hTriangle->xPos2;
uint8_t xPos3 = hTriangle->xPos3;
uint8_t yPos1 = hTriangle->yPos1;
uint8_t yPos2 = hTriangle->yPos2;
uint8_t yPos3 = hTriangle->yPos3;
uint8_t pxColor = hTriangle->pxColor;
if((Buffer_Frame == NULL) || (hTriangle == NULL))
return;
__GFX_Draw_Line(Buffer_Frame, xPos1, yPos1, xPos2, yPos2, pxColor);
__GFX_Draw_Line(Buffer_Frame, xPos2, yPos2, xPos3, yPos3, pxColor);
__GFX_Draw_Line(Buffer_Frame, xPos3, yPos3, xPos1, yPos1, pxColor);
}
/* Функция рисования дуги (четверти окружности) */
void GFX_Draw_Arc(uint8_t *Buffer_Frame, GFX_ArcHandleTypeDef *hArc)
{
if((Buffer_Frame == NULL) || (hArc == NULL))
return;
uint8_t xPos = hArc->xPos;
uint8_t yPos = hArc->yPos;
uint8_t radius = hArc->radius;
uint8_t startAngle = hArc->startAngle;
uint8_t endAngle = hArc->endAngle;
uint8_t pxColor = hArc->pxColor;
int xPos_tmp = 0;
int yPos_tmp = 0;
for (int angle = startAngle; angle <= endAngle; angle++)
{
xPos_tmp = roundf(xPos + (radius * cosf(angle * 3.14159 / 180)));
yPos_tmp = roundf(yPos + (radius * sinf(angle * 3.14159 / 180)));
GFX_Draw_Pixel(Buffer_Frame, xPos_tmp, yPos_tmp, pxColor);
}
}
/* Функция инвертирования прямоугольной области */
void GFX_Invertion_Display(uint8_t *Buffer_Frame)
{
if(Buffer_Frame == NULL)
return;
GFX_Invertion_Area(Buffer_Frame, 0, 0, GFX_BufferWidth-1, GFX_BufferHeight-1);
}
/* Низкоуровневая функция рисования линии */
void __GFX_Draw_Line(uint8_t *Buffer_Frame, uint8_t xPos_Start, uint8_t yPos_Start, uint8_t xPos_End, uint8_t yPos_End, uint8_t pxColor)
{
int dx = (xPos_End >= xPos_Start) ? xPos_End - xPos_Start : xPos_Start - xPos_End;
int dy = (yPos_End >= yPos_Start) ? yPos_End - yPos_Start : yPos_Start - yPos_End;
int sx = (xPos_Start < xPos_End) ? 1 : -1;
int sy = (yPos_Start < yPos_End) ? 1 : -1;
int err = dx - dy;
for (;;)
{
GFX_Draw_Pixel(Buffer_Frame, xPos_Start, yPos_Start, pxColor);
if (xPos_Start == xPos_End && yPos_Start == yPos_End)
break;
int e2 = err + err;
if (e2 > -dy)
{
err -= dy;
xPos_Start += sx;
}
if (e2 < dx)
{
err += dx;
yPos_Start += sy;
}
}
}
/* функция рисования пустотелого прямоугольника */
void __GFX_Draw_Rectangle(uint8_t *Buffer_Frame, uint8_t xPos_Start, uint8_t yPos_Start, uint8_t rectangle_Width, uint8_t rectangle_Height, uint8_t pxColor)
{
/* рисуем стороны прямоугольника */
//левая сторона прямоугольника
__GFX_Draw_Line(Buffer_Frame, xPos_Start, yPos_Start, xPos_Start, yPos_Start + rectangle_Height, pxColor);
//верх прямоугольника
__GFX_Draw_Line(Buffer_Frame, xPos_Start, yPos_Start, xPos_Start + rectangle_Width, yPos_Start, pxColor);
//правая сторона прямоугольника
__GFX_Draw_Line(Buffer_Frame, xPos_Start + rectangle_Width, yPos_Start, xPos_Start + rectangle_Width, yPos_Start + rectangle_Height, pxColor);
//низ прямоугольника
__GFX_Draw_Line(Buffer_Frame, xPos_Start, yPos_Start + rectangle_Height, xPos_Start + rectangle_Width, yPos_Start + rectangle_Height, pxColor);
}
/* функция рисования закрашенного прямоугольника */
void __GFX_Draw_Rectangle_Filled(uint8_t *Buffer_Frame, uint8_t xPos_Start, uint8_t yPos_Start, uint8_t rectangle_Width, uint8_t rectangle_Height, uint8_t pxColor)
{
for (uint8_t i = 0; i <= rectangle_Height; i++)
{
__GFX_Draw_Line(Buffer_Frame, xPos_Start, yPos_Start + i, xPos_Start + rectangle_Width, yPos_Start + i, pxColor);
}
}
/* функция рисования пустотелой окружности */
void __GFX_Draw_Circle(uint8_t *Buffer_Frame, uint8_t xPos, uint8_t yPos, uint8_t circle_Radius, uint8_t pxColor)
{
int f = 1 - (int)circle_Radius;
int ddF_x = 1;
int ddF_y = -2 * (int)circle_Radius;
int x_0 = 0;
GFX_Draw_Pixel(Buffer_Frame, xPos, yPos + circle_Radius, pxColor);
GFX_Draw_Pixel(Buffer_Frame, xPos, yPos - circle_Radius, pxColor);
GFX_Draw_Pixel(Buffer_Frame, xPos + circle_Radius, yPos, pxColor);
GFX_Draw_Pixel(Buffer_Frame, xPos - circle_Radius, yPos, pxColor);
int y_0 = circle_Radius;
while (x_0 < y_0)
{
if (f >= 0)
{
y_0--;
ddF_y += 2;
f += ddF_y;
}
x_0++;
ddF_x += 2;
f += ddF_x;
GFX_Draw_Pixel(Buffer_Frame, xPos + x_0, yPos + y_0, pxColor);
GFX_Draw_Pixel(Buffer_Frame, xPos - x_0, yPos + y_0, pxColor);
GFX_Draw_Pixel(Buffer_Frame, xPos + x_0, yPos - y_0, pxColor);
GFX_Draw_Pixel(Buffer_Frame, xPos - x_0, yPos - y_0, pxColor);
GFX_Draw_Pixel(Buffer_Frame, xPos + y_0, yPos + x_0, pxColor);
GFX_Draw_Pixel(Buffer_Frame, xPos - y_0, yPos + x_0, pxColor);
GFX_Draw_Pixel(Buffer_Frame, xPos + y_0, yPos - x_0, pxColor);
GFX_Draw_Pixel(Buffer_Frame, xPos - y_0, yPos - x_0, pxColor);
}
}
/* функция рисования закрашенной окружности */
void __GFX_Draw_Circle_Filled(uint8_t *Buffer_Frame, int8_t xPos, int8_t yPos, int8_t circle_Radius, uint8_t pxColor)
{
int16_t f = 1 - circle_Radius;
int16_t ddF_x = 1;
int16_t ddF_y = -2 * circle_Radius;
int16_t x_0 = 0;
int16_t y_0 = circle_Radius;
GFX_Draw_Pixel(Buffer_Frame, xPos, yPos + circle_Radius, pxColor);
GFX_Draw_Pixel(Buffer_Frame, xPos, yPos - circle_Radius, pxColor);
GFX_Draw_Pixel(Buffer_Frame, xPos + circle_Radius, yPos, pxColor);
GFX_Draw_Pixel(Buffer_Frame, xPos - circle_Radius, yPos, pxColor);
__GFX_Draw_Line(Buffer_Frame, xPos - circle_Radius, yPos, xPos + circle_Radius, yPos, pxColor);
while (x_0 < y_0)
{
if (f >= 0)
{
y_0--;
ddF_y += 2;
f += ddF_y;
}
x_0++;
ddF_x += 2;
f += ddF_x;
__GFX_Draw_Line(Buffer_Frame, xPos - x_0, yPos + y_0, xPos + x_0, yPos + y_0, pxColor);
__GFX_Draw_Line(Buffer_Frame, xPos + x_0, yPos - y_0, xPos - x_0, yPos - y_0, pxColor);
__GFX_Draw_Line(Buffer_Frame, xPos + y_0, yPos + x_0, xPos - y_0, yPos + x_0, pxColor);
__GFX_Draw_Line(Buffer_Frame, xPos + y_0, yPos - x_0, xPos - y_0, yPos - x_0, pxColor);
}
}
/* функция рисования треугольника */
void __GFX_Draw_Triangle(uint8_t *Buffer_Frame,
uint8_t xPos1, uint8_t yPos1,
uint8_t xPos2, uint8_t yPos2,
uint8_t xPos3, uint8_t yPos3,
uint8_t pxColor)
{
__GFX_Draw_Line(Buffer_Frame, xPos1, yPos1, xPos2, yPos2, pxColor);
__GFX_Draw_Line(Buffer_Frame, xPos2, yPos2, xPos3, yPos3, pxColor);
__GFX_Draw_Line(Buffer_Frame, xPos3, yPos3, xPos1, yPos1, pxColor);
}
/* Функция рисования дуги (четверти окружности) */
void __GFX_Draw_Arc(uint8_t *Buffer_Frame, uint8_t xPos, uint8_t yPos, uint8_t radius, uint16_t startAngle, uint16_t endAngle, uint8_t pxColor)
{
int xPos_tmp = 0;
int yPos_tmp = 0;
for (int angle = startAngle; angle <= endAngle; angle++)
{
xPos_tmp = roundf(xPos + (radius * cosf(angle * 3.14159 / 180)));
yPos_tmp = roundf(yPos + (radius * sinf(angle * 3.14159 / 180)));
GFX_Draw_Pixel(Buffer_Frame, xPos_tmp, yPos_tmp, pxColor);
}
}

View File

@@ -0,0 +1,108 @@
/*
* PixelGraphics.h
*
*/
#ifndef INC_PIXEL_GRAPHICS_H_
#define INC_PIXEL_GRAPHICS_H_
/* инклюды */
#include "main.h"
#include "string.h"
#include "stdio.h"
#include "oled.h"
#define GFX_BufferWidth 128 //ширина дисплея в пикселях
#define GFX_BufferHeight 32 //высота дисплея в пикселях
#define GFX_pxView_On 1 //закраска пикселя On
#define GFX_pxView_Off 0 //закраска пикселя Off
#define GFX_ChInvers 1 //инверсия символа шрифта On
#define GFX_ChUnInvers 0 //инверсия символа шрифта Off
typedef struct
{
uint8_t xPos_Start;
uint8_t yPos_Start;
uint8_t xPos_End;
uint8_t yPos_End;
uint8_t pxColor;
}GFX_LineHandleTypeDef;
typedef struct
{
uint8_t xPos_Start;
uint8_t yPos_Start;
uint8_t rectangle_Width;
uint8_t rectangle_Height;
uint8_t pxColor;
uint8_t Filled;
}GFX_RectangleHandleTypeDef;
typedef struct
{
uint8_t xPos;
uint8_t yPos;
uint8_t circle_Radius;
uint8_t pxColor;
uint8_t Filled;
}GFX_CircleHandleTypeDef;
typedef struct
{
uint8_t xPos1;
uint8_t yPos1;
uint8_t xPos2;
uint8_t yPos2;
uint8_t xPos3;
uint8_t yPos3;
uint8_t pxColor;
uint8_t Filled;
}GFX_TriangleHandleTypeDef;
typedef struct
{
uint8_t xPos;
uint8_t yPos;
uint8_t radius;
uint16_t startAngle;
uint16_t endAngle;
uint8_t pxColor;
uint8_t Filled;
}GFX_ArcHandleTypeDef;
/* прототипы функций */
void GFX_Clean_Buffer_Frame(uint8_t *Buffer_Frame, uint32_t Buffer_Frame_Size);
void GFX_Draw_Pixel(uint8_t *Buffer_Frame, uint8_t xPos, uint8_t yPos, uint8_t pxColor);
void GFX_Invertion_Area(uint8_t *Buffer_Frame, uint16_t xPos_Start, uint16_t yPos_Start, uint16_t width, uint16_t height);
void GFX_Invertion_Display(uint8_t *Buffer_Frame);
void GFX_Draw_Char_1_Byte(uint8_t *Buffer_Frame, uint8_t xPos, uint8_t yPos, char Symbol, uint8_t Inversion);
void GFX_Draw_Char_2_Byte(uint8_t *Buffer_Frame, uint8_t xPos, uint8_t yPos, uint8_t Symbol, uint8_t inversion);
void GFX_Output_String(uint8_t *Buffer_Frame, uint8_t xPos, uint8_t yPos, char *String, uint8_t setChSpacing, uint8_t Inversion);
void GFX_Draw_Line(uint8_t *Buffer_Frame, GFX_LineHandleTypeDef *hLine);
void GFX_Draw_Rectangle(uint8_t *Buffer_Frame, GFX_RectangleHandleTypeDef *hRectangle);
void GFX_Draw_Circle(uint8_t *Buffer_Frame, GFX_CircleHandleTypeDef *hCircle);
void GFX_Draw_Triangle(uint8_t *Buffer_Frame, GFX_TriangleHandleTypeDef *hTriangle);
void GFX_Draw_Arc(uint8_t *Buffer_Frame, GFX_ArcHandleTypeDef *hArc);
void __GFX_Draw_Line(uint8_t *Buffer_Frame, uint8_t xPos_Start, uint8_t yPos_Start, uint8_t xPos_End, uint8_t yPos_End, uint8_t pxColor);
void __GFX_Draw_Rectangle(uint8_t *Buffer_Frame, uint8_t xPos_Start, uint8_t yPos_Start, uint8_t rectangle_Width, uint8_t rectangle_Height, uint8_t pxColor);
void __GFX_Draw_Rectangle_Filled(uint8_t *Buffer_Frame, uint8_t xPos_Start, uint8_t yPos_Start, uint8_t rectangle_Width, uint8_t rectangle_Height, uint8_t pxColor);
void __GFX_Draw_Circle(uint8_t *Buffer_Frame, uint8_t xPos, uint8_t yPos, uint8_t circle_Radius, uint8_t pxColor);
void __GFX_Draw_Circle_Filled(uint8_t *Buffer_Frame, int8_t xPos, int8_t yPos, int8_t circle_Radius, uint8_t pxColor);
void __GFX_Draw_Triangle(uint8_t *Buffer_Frame,
uint8_t xPos1, uint8_t yPos1,
uint8_t xPos2, uint8_t yPos2,
uint8_t xPos3, uint8_t yPos3,
uint8_t pxColor);
void __GFX_Draw_Arc(uint8_t *Buffer_Frame, uint8_t xPos, uint8_t yPos, uint8_t radius, uint16_t startAngle, uint16_t endAngle, uint8_t pxColor);
#endif /* INC_PIXEL_GRAPHICS_H_ */

49
Core/Inc/gpio.h Normal file
View File

@@ -0,0 +1,49 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file gpio.h
* @brief This file contains all the function prototypes for
* the gpio.c file
******************************************************************************
* @attention
*
* Copyright (c) 2025 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __GPIO_H__
#define __GPIO_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */
void MX_GPIO_Init(void);
/* USER CODE BEGIN Prototypes */
/* USER CODE END Prototypes */
#ifdef __cplusplus
}
#endif
#endif /*__ GPIO_H__ */

52
Core/Inc/i2c.h Normal file
View File

@@ -0,0 +1,52 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file i2c.h
* @brief This file contains all the function prototypes for
* the i2c.c file
******************************************************************************
* @attention
*
* Copyright (c) 2025 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __I2C_H__
#define __I2C_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
extern I2C_HandleTypeDef hi2c1;
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */
void MX_I2C1_Init(void);
/* USER CODE BEGIN Prototypes */
/* USER CODE END Prototypes */
#ifdef __cplusplus
}
#endif
#endif /* __I2C_H__ */

82
Core/Inc/main.h Normal file
View File

@@ -0,0 +1,82 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.h
* @brief : Header for main.c file.
* This file contains the common defines of the application.
******************************************************************************
* @attention
*
* Copyright (c) 2025 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32f1xx_hal.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */
/* USER CODE END ET */
/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */
/* USER CODE END EC */
/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */
/* USER CODE END EM */
/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);
/* USER CODE BEGIN EFP */
/* USER CODE END EFP */
/* Private defines -----------------------------------------------------------*/
#define hpwmtim htim1
#define SW_THEME_Pin GPIO_PIN_6
#define SW_THEME_GPIO_Port GPIOA
#define SW_LOOP_Pin GPIO_PIN_7
#define SW_LOOP_GPIO_Port GPIOA
#define SW_BACKWARD_Pin GPIO_PIN_0
#define SW_BACKWARD_GPIO_Port GPIOB
#define SW_PLAY_Pin GPIO_PIN_1
#define SW_PLAY_GPIO_Port GPIOB
#define SW_FORWARD_Pin GPIO_PIN_10
#define SW_FORWARD_GPIO_Port GPIOB
#define SW_SPEED_Pin GPIO_PIN_11
#define SW_SPEED_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */
#ifdef __cplusplus
}
#endif
#endif /* __MAIN_H */

View File

@@ -0,0 +1,391 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f1xx_hal_conf.h
* @brief HAL configuration file.
******************************************************************************
* @attention
*
* Copyright (c) 2017 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F1xx_HAL_CONF_H
#define __STM32F1xx_HAL_CONF_H
#ifdef __cplusplus
extern "C" {
#endif
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* ########################## Module Selection ############################## */
/**
* @brief This is the list of modules to be used in the HAL driver
*/
#define HAL_MODULE_ENABLED
/*#define HAL_ADC_MODULE_ENABLED */
/*#define HAL_CRYP_MODULE_ENABLED */
/*#define HAL_CAN_MODULE_ENABLED */
/*#define HAL_CAN_LEGACY_MODULE_ENABLED */
/*#define HAL_CEC_MODULE_ENABLED */
/*#define HAL_CORTEX_MODULE_ENABLED */
/*#define HAL_CRC_MODULE_ENABLED */
/*#define HAL_DAC_MODULE_ENABLED */
/*#define HAL_DMA_MODULE_ENABLED */
/*#define HAL_ETH_MODULE_ENABLED */
/*#define HAL_FLASH_MODULE_ENABLED */
#define HAL_GPIO_MODULE_ENABLED
#define HAL_I2C_MODULE_ENABLED
/*#define HAL_I2S_MODULE_ENABLED */
/*#define HAL_IRDA_MODULE_ENABLED */
/*#define HAL_IWDG_MODULE_ENABLED */
/*#define HAL_NOR_MODULE_ENABLED */
/*#define HAL_NAND_MODULE_ENABLED */
/*#define HAL_PCCARD_MODULE_ENABLED */
/*#define HAL_PCD_MODULE_ENABLED */
/*#define HAL_HCD_MODULE_ENABLED */
/*#define HAL_PWR_MODULE_ENABLED */
/*#define HAL_RCC_MODULE_ENABLED */
/*#define HAL_RTC_MODULE_ENABLED */
/*#define HAL_SD_MODULE_ENABLED */
/*#define HAL_MMC_MODULE_ENABLED */
/*#define HAL_SDRAM_MODULE_ENABLED */
/*#define HAL_SMARTCARD_MODULE_ENABLED */
/*#define HAL_SPI_MODULE_ENABLED */
/*#define HAL_SRAM_MODULE_ENABLED */
/*#define HAL_TIM_MODULE_ENABLED */
/*#define HAL_UART_MODULE_ENABLED */
/*#define HAL_USART_MODULE_ENABLED */
/*#define HAL_WWDG_MODULE_ENABLED */
#define HAL_CORTEX_MODULE_ENABLED
#define HAL_DMA_MODULE_ENABLED
#define HAL_FLASH_MODULE_ENABLED
#define HAL_EXTI_MODULE_ENABLED
#define HAL_GPIO_MODULE_ENABLED
#define HAL_PWR_MODULE_ENABLED
#define HAL_RCC_MODULE_ENABLED
/* ########################## Oscillator Values adaptation ####################*/
/**
* @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
* This value is used by the RCC HAL module to compute the system frequency
* (when HSE is used as system clock source, directly or through the PLL).
*/
#if !defined (HSE_VALUE)
#define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */
#endif /* HSE_VALUE */
#if !defined (HSE_STARTUP_TIMEOUT)
#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */
/**
* @brief Internal High Speed oscillator (HSI) value.
* This value is used by the RCC HAL module to compute the system frequency
* (when HSI is used as system clock source, directly or through the PLL).
*/
#if !defined (HSI_VALUE)
#define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz*/
#endif /* HSI_VALUE */
/**
* @brief Internal Low Speed oscillator (LSI) value.
*/
#if !defined (LSI_VALUE)
#define LSI_VALUE 40000U /*!< LSI Typical Value in Hz */
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
The real value may vary depending on the variations
in voltage and temperature. */
/**
* @brief External Low Speed oscillator (LSE) value.
* This value is used by the UART, RTC HAL module to compute the system frequency
*/
#if !defined (LSE_VALUE)
#define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/
#endif /* LSE_VALUE */
#if !defined (LSE_STARTUP_TIMEOUT)
#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */
#endif /* LSE_STARTUP_TIMEOUT */
/* Tip: To avoid modifying this file each time you need to use different HSE,
=== you can define the HSE value in your toolchain compiler preprocessor. */
/* ########################### System Configuration ######################### */
/**
* @brief This is the HAL system configuration section
*/
#define VDD_VALUE 3300U /*!< Value of VDD in mv */
#define TICK_INT_PRIORITY 15U /*!< tick interrupt priority (lowest by default) */
#define USE_RTOS 0U
#define PREFETCH_ENABLE 1U
#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */
#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
/* ########################## Assert Selection ############################## */
/**
* @brief Uncomment the line below to expanse the "assert_param" macro in the
* HAL drivers code
*/
/* #define USE_FULL_ASSERT 1U */
/* ################## Ethernet peripheral configuration ##################### */
/* Section 1 : Ethernet peripheral configuration */
/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
#define MAC_ADDR0 2U
#define MAC_ADDR1 0U
#define MAC_ADDR2 0U
#define MAC_ADDR3 0U
#define MAC_ADDR4 0U
#define MAC_ADDR5 0U
/* Definition of the Ethernet driver buffers size and count */
#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
#define ETH_RXBUFNB 8U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
/* Section 2: PHY configuration section */
/* DP83848_PHY_ADDRESS Address*/
#define DP83848_PHY_ADDRESS 0x01U
/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
#define PHY_RESET_DELAY 0x000000FFU
/* PHY Configuration delay */
#define PHY_CONFIG_DELAY 0x00000FFFU
#define PHY_READ_TO 0x0000FFFFU
#define PHY_WRITE_TO 0x0000FFFFU
/* Section 3: Common PHY Registers */
#define PHY_BCR ((uint16_t)0x00) /*!< Transceiver Basic Control Register */
#define PHY_BSR ((uint16_t)0x01) /*!< Transceiver Basic Status Register */
#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
/* Section 4: Extended PHY Registers */
#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */
#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */
#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */
/* ################## SPI peripheral configuration ########################## */
/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
* Activated: CRC code is present inside driver
* Deactivated: CRC code cleaned from driver
*/
#define USE_SPI_CRC 0U
/* Includes ------------------------------------------------------------------*/
/**
* @brief Include module's header file
*/
#ifdef HAL_RCC_MODULE_ENABLED
#include "stm32f1xx_hal_rcc.h"
#endif /* HAL_RCC_MODULE_ENABLED */
#ifdef HAL_GPIO_MODULE_ENABLED
#include "stm32f1xx_hal_gpio.h"
#endif /* HAL_GPIO_MODULE_ENABLED */
#ifdef HAL_EXTI_MODULE_ENABLED
#include "stm32f1xx_hal_exti.h"
#endif /* HAL_EXTI_MODULE_ENABLED */
#ifdef HAL_DMA_MODULE_ENABLED
#include "stm32f1xx_hal_dma.h"
#endif /* HAL_DMA_MODULE_ENABLED */
#ifdef HAL_ETH_MODULE_ENABLED
#include "stm32f1xx_hal_eth.h"
#endif /* HAL_ETH_MODULE_ENABLED */
#ifdef HAL_CAN_MODULE_ENABLED
#include "stm32f1xx_hal_can.h"
#endif /* HAL_CAN_MODULE_ENABLED */
#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
#include "Legacy/stm32f1xx_hal_can_legacy.h"
#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
#ifdef HAL_CEC_MODULE_ENABLED
#include "stm32f1xx_hal_cec.h"
#endif /* HAL_CEC_MODULE_ENABLED */
#ifdef HAL_CORTEX_MODULE_ENABLED
#include "stm32f1xx_hal_cortex.h"
#endif /* HAL_CORTEX_MODULE_ENABLED */
#ifdef HAL_ADC_MODULE_ENABLED
#include "stm32f1xx_hal_adc.h"
#endif /* HAL_ADC_MODULE_ENABLED */
#ifdef HAL_CRC_MODULE_ENABLED
#include "stm32f1xx_hal_crc.h"
#endif /* HAL_CRC_MODULE_ENABLED */
#ifdef HAL_DAC_MODULE_ENABLED
#include "stm32f1xx_hal_dac.h"
#endif /* HAL_DAC_MODULE_ENABLED */
#ifdef HAL_FLASH_MODULE_ENABLED
#include "stm32f1xx_hal_flash.h"
#endif /* HAL_FLASH_MODULE_ENABLED */
#ifdef HAL_SRAM_MODULE_ENABLED
#include "stm32f1xx_hal_sram.h"
#endif /* HAL_SRAM_MODULE_ENABLED */
#ifdef HAL_NOR_MODULE_ENABLED
#include "stm32f1xx_hal_nor.h"
#endif /* HAL_NOR_MODULE_ENABLED */
#ifdef HAL_I2C_MODULE_ENABLED
#include "stm32f1xx_hal_i2c.h"
#endif /* HAL_I2C_MODULE_ENABLED */
#ifdef HAL_I2S_MODULE_ENABLED
#include "stm32f1xx_hal_i2s.h"
#endif /* HAL_I2S_MODULE_ENABLED */
#ifdef HAL_IWDG_MODULE_ENABLED
#include "stm32f1xx_hal_iwdg.h"
#endif /* HAL_IWDG_MODULE_ENABLED */
#ifdef HAL_PWR_MODULE_ENABLED
#include "stm32f1xx_hal_pwr.h"
#endif /* HAL_PWR_MODULE_ENABLED */
#ifdef HAL_RTC_MODULE_ENABLED
#include "stm32f1xx_hal_rtc.h"
#endif /* HAL_RTC_MODULE_ENABLED */
#ifdef HAL_PCCARD_MODULE_ENABLED
#include "stm32f1xx_hal_pccard.h"
#endif /* HAL_PCCARD_MODULE_ENABLED */
#ifdef HAL_SD_MODULE_ENABLED
#include "stm32f1xx_hal_sd.h"
#endif /* HAL_SD_MODULE_ENABLED */
#ifdef HAL_NAND_MODULE_ENABLED
#include "stm32f1xx_hal_nand.h"
#endif /* HAL_NAND_MODULE_ENABLED */
#ifdef HAL_SPI_MODULE_ENABLED
#include "stm32f1xx_hal_spi.h"
#endif /* HAL_SPI_MODULE_ENABLED */
#ifdef HAL_TIM_MODULE_ENABLED
#include "stm32f1xx_hal_tim.h"
#endif /* HAL_TIM_MODULE_ENABLED */
#ifdef HAL_UART_MODULE_ENABLED
#include "stm32f1xx_hal_uart.h"
#endif /* HAL_UART_MODULE_ENABLED */
#ifdef HAL_USART_MODULE_ENABLED
#include "stm32f1xx_hal_usart.h"
#endif /* HAL_USART_MODULE_ENABLED */
#ifdef HAL_IRDA_MODULE_ENABLED
#include "stm32f1xx_hal_irda.h"
#endif /* HAL_IRDA_MODULE_ENABLED */
#ifdef HAL_SMARTCARD_MODULE_ENABLED
#include "stm32f1xx_hal_smartcard.h"
#endif /* HAL_SMARTCARD_MODULE_ENABLED */
#ifdef HAL_WWDG_MODULE_ENABLED
#include "stm32f1xx_hal_wwdg.h"
#endif /* HAL_WWDG_MODULE_ENABLED */
#ifdef HAL_PCD_MODULE_ENABLED
#include "stm32f1xx_hal_pcd.h"
#endif /* HAL_PCD_MODULE_ENABLED */
#ifdef HAL_HCD_MODULE_ENABLED
#include "stm32f1xx_hal_hcd.h"
#endif /* HAL_HCD_MODULE_ENABLED */
#ifdef HAL_MMC_MODULE_ENABLED
#include "stm32f1xx_hal_mmc.h"
#endif /* HAL_MMC_MODULE_ENABLED */
/* Exported macro ------------------------------------------------------------*/
#ifdef USE_FULL_ASSERT
/**
* @brief The assert_param macro is used for function's parameters check.
* @param expr If expr is false, it calls assert_failed function
* which reports the name of the source file and the source
* line number of the call that failed.
* If expr is true, it returns no value.
* @retval None
*/
#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
void assert_failed(uint8_t* file, uint32_t line);
#else
#define assert_param(expr) ((void)0U)
#endif /* USE_FULL_ASSERT */
#ifdef __cplusplus
}
#endif
#endif /* __STM32F1xx_HAL_CONF_H */

66
Core/Inc/stm32f1xx_it.h Normal file
View File

@@ -0,0 +1,66 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f1xx_it.h
* @brief This file contains the headers of the interrupt handlers.
******************************************************************************
* @attention
*
* Copyright (c) 2025 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F1xx_IT_H
#define __STM32F1xx_IT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */
/* USER CODE END ET */
/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */
/* USER CODE END EC */
/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */
/* USER CODE END EM */
/* Exported functions prototypes ---------------------------------------------*/
void NMI_Handler(void);
void HardFault_Handler(void);
void MemManage_Handler(void);
void BusFault_Handler(void);
void UsageFault_Handler(void);
void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
/* USER CODE BEGIN EFP */
/* USER CODE END EFP */
#ifdef __cplusplus
}
#endif
#endif /* __STM32F1xx_IT_H */

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;
}

69
Core/Src/gpio.c Normal file
View File

@@ -0,0 +1,69 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file gpio.c
* @brief This file provides code for the configuration
* of all used GPIO pins.
******************************************************************************
* @attention
*
* Copyright (c) 2025 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "gpio.h"
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/*----------------------------------------------------------------------------*/
/* Configure GPIO */
/*----------------------------------------------------------------------------*/
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/** Configure pins as
* Analog
* Input
* Output
* EVENT_OUT
* EXTI
*/
void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
/*Configure GPIO pins : PAPin PAPin */
GPIO_InitStruct.Pin = SW_THEME_Pin|SW_LOOP_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pins : PBPin PBPin PBPin PBPin */
GPIO_InitStruct.Pin = SW_BACKWARD_Pin|SW_PLAY_Pin|SW_FORWARD_Pin|SW_SPEED_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
}
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */

114
Core/Src/i2c.c Normal file
View File

@@ -0,0 +1,114 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file i2c.c
* @brief This file provides code for the configuration
* of the I2C instances.
******************************************************************************
* @attention
*
* Copyright (c) 2025 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "i2c.h"
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
I2C_HandleTypeDef hi2c1;
/* I2C1 init function */
void MX_I2C1_Init(void)
{
/* USER CODE BEGIN I2C1_Init 0 */
/* USER CODE END I2C1_Init 0 */
/* USER CODE BEGIN I2C1_Init 1 */
/* USER CODE END I2C1_Init 1 */
hi2c1.Instance = I2C1;
hi2c1.Init.ClockSpeed = 400000;
hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
hi2c1.Init.OwnAddress1 = 0;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c1.Init.OwnAddress2 = 0;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_I2C_Init(&hi2c1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN I2C1_Init 2 */
/* USER CODE END I2C1_Init 2 */
}
void HAL_I2C_MspInit(I2C_HandleTypeDef* i2cHandle)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(i2cHandle->Instance==I2C1)
{
/* USER CODE BEGIN I2C1_MspInit 0 */
/* USER CODE END I2C1_MspInit 0 */
__HAL_RCC_GPIOB_CLK_ENABLE();
/**I2C1 GPIO Configuration
PB6 ------> I2C1_SCL
PB7 ------> I2C1_SDA
*/
GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* I2C1 clock enable */
__HAL_RCC_I2C1_CLK_ENABLE();
/* USER CODE BEGIN I2C1_MspInit 1 */
/* USER CODE END I2C1_MspInit 1 */
}
}
void HAL_I2C_MspDeInit(I2C_HandleTypeDef* i2cHandle)
{
if(i2cHandle->Instance==I2C1)
{
/* USER CODE BEGIN I2C1_MspDeInit 0 */
/* USER CODE END I2C1_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_I2C1_CLK_DISABLE();
/**I2C1 GPIO Configuration
PB6 ------> I2C1_SCL
PB7 ------> I2C1_SDA
*/
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6);
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_7);
/* USER CODE BEGIN I2C1_MspDeInit 1 */
/* USER CODE END I2C1_MspDeInit 1 */
}
}
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */

184
Core/Src/main.c Normal file
View File

@@ -0,0 +1,184 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.c
* @brief : Main program body
******************************************************************************
* @attention
*
* Copyright (c) 2025 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "i2c.h"
#include "gpio.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "gfx_oled_example.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
PlayerTypeDef player;
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_I2C1_Init();
/* USER CODE BEGIN 2 */
Menu_Control_Init(&player);
Example_GFX_IconInit();
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
Menu_Control_ReadGPIO(&player);
Menu_Control_Music(&player);
Example_OLED_GFX_Update(&player);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
/**
* @brief System Clock Configuration
* @retval None
*/
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
{
Error_Handler();
}
}
/* USER CODE BEGIN 4 */
/* USER CODE END 4 */
/**
* @brief This function is executed in case of error occurrence.
* @retval None
*/
void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */
__disable_irq();
while (1)
{
}
/* USER CODE END Error_Handler_Debug */
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t *file, uint32_t line)
{
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */

View File

@@ -0,0 +1,87 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f1xx_hal_msp.c
* @brief This file provides code for the MSP Initialization
* and de-Initialization codes.
******************************************************************************
* @attention
*
* Copyright (c) 2025 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN TD */
/* USER CODE END TD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN Define */
/* USER CODE END Define */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN Macro */
/* USER CODE END Macro */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* External functions --------------------------------------------------------*/
/* USER CODE BEGIN ExternalFunctions */
/* USER CODE END ExternalFunctions */
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/**
* Initializes the Global MSP.
*/
void HAL_MspInit(void)
{
/* USER CODE BEGIN MspInit 0 */
/* USER CODE END MspInit 0 */
__HAL_RCC_AFIO_CLK_ENABLE();
__HAL_RCC_PWR_CLK_ENABLE();
/* System interrupt init*/
/** NOJTAG: JTAG-DP Disabled and SW-DP Enabled
*/
__HAL_AFIO_REMAP_SWJ_NOJTAG();
/* USER CODE BEGIN MspInit 1 */
/* USER CODE END MspInit 1 */
}
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */

203
Core/Src/stm32f1xx_it.c Normal file
View File

@@ -0,0 +1,203 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f1xx_it.c
* @brief Interrupt Service Routines.
******************************************************************************
* @attention
*
* Copyright (c) 2025 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "stm32f1xx_it.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN TD */
/* USER CODE END TD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/* External variables --------------------------------------------------------*/
/* USER CODE BEGIN EV */
/* USER CODE END EV */
/******************************************************************************/
/* Cortex-M3 Processor Interruption and Exception Handlers */
/******************************************************************************/
/**
* @brief This function handles Non maskable interrupt.
*/
void NMI_Handler(void)
{
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
/* USER CODE END NonMaskableInt_IRQn 0 */
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
while (1)
{
}
/* USER CODE END NonMaskableInt_IRQn 1 */
}
/**
* @brief This function handles Hard fault interrupt.
*/
void HardFault_Handler(void)
{
/* USER CODE BEGIN HardFault_IRQn 0 */
/* USER CODE END HardFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
/* USER CODE END W1_HardFault_IRQn 0 */
}
}
/**
* @brief This function handles Memory management fault.
*/
void MemManage_Handler(void)
{
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
/* USER CODE END MemoryManagement_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
/* USER CODE END W1_MemoryManagement_IRQn 0 */
}
}
/**
* @brief This function handles Prefetch fault, memory access fault.
*/
void BusFault_Handler(void)
{
/* USER CODE BEGIN BusFault_IRQn 0 */
/* USER CODE END BusFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_BusFault_IRQn 0 */
/* USER CODE END W1_BusFault_IRQn 0 */
}
}
/**
* @brief This function handles Undefined instruction or illegal state.
*/
void UsageFault_Handler(void)
{
/* USER CODE BEGIN UsageFault_IRQn 0 */
/* USER CODE END UsageFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_UsageFault_IRQn 0 */
/* USER CODE END W1_UsageFault_IRQn 0 */
}
}
/**
* @brief This function handles System service call via SWI instruction.
*/
void SVC_Handler(void)
{
/* USER CODE BEGIN SVCall_IRQn 0 */
/* USER CODE END SVCall_IRQn 0 */
/* USER CODE BEGIN SVCall_IRQn 1 */
/* USER CODE END SVCall_IRQn 1 */
}
/**
* @brief This function handles Debug monitor.
*/
void DebugMon_Handler(void)
{
/* USER CODE BEGIN DebugMonitor_IRQn 0 */
/* USER CODE END DebugMonitor_IRQn 0 */
/* USER CODE BEGIN DebugMonitor_IRQn 1 */
/* USER CODE END DebugMonitor_IRQn 1 */
}
/**
* @brief This function handles Pendable request for system service.
*/
void PendSV_Handler(void)
{
/* USER CODE BEGIN PendSV_IRQn 0 */
/* USER CODE END PendSV_IRQn 0 */
/* USER CODE BEGIN PendSV_IRQn 1 */
/* USER CODE END PendSV_IRQn 1 */
}
/**
* @brief This function handles System tick timer.
*/
void SysTick_Handler(void)
{
/* USER CODE BEGIN SysTick_IRQn 0 */
/* USER CODE END SysTick_IRQn 0 */
HAL_IncTick();
/* USER CODE BEGIN SysTick_IRQn 1 */
/* USER CODE END SysTick_IRQn 1 */
}
/******************************************************************************/
/* STM32F1xx Peripheral Interrupt Handlers */
/* Add here the Interrupt Handlers for the used peripherals. */
/* For the available peripheral interrupt handler names, */
/* please refer to the startup file (startup_stm32f1xx.s). */
/******************************************************************************/
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */

406
Core/Src/system_stm32f1xx.c Normal file
View File

@@ -0,0 +1,406 @@
/**
******************************************************************************
* @file system_stm32f1xx.c
* @author MCD Application Team
* @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Source File.
*
* 1. This file provides two functions and one global variable to be called from
* user application:
* - SystemInit(): Setups the system clock (System clock source, PLL Multiplier
* factors, AHB/APBx prescalers and Flash settings).
* This function is called at startup just after reset and
* before branch to main program. This call is made inside
* the "startup_stm32f1xx_xx.s" file.
*
* - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
* by the user application to setup the SysTick
* timer or configure other parameters.
*
* - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
* be called whenever the core clock is changed
* during program execution.
*
* 2. After each device reset the HSI (8 MHz) is used as system clock source.
* Then SystemInit() function is called, in "startup_stm32f1xx_xx.s" file, to
* configure the system clock before to branch to main program.
*
* 4. The default value of HSE crystal is set to 8 MHz (or 25 MHz, depending on
* the product used), refer to "HSE_VALUE".
* When HSE is used as system clock source, directly or through PLL, and you
* are using different crystal you have to adapt the HSE value to your own
* configuration.
*
******************************************************************************
* @attention
*
* Copyright (c) 2017-2021 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/** @addtogroup CMSIS
* @{
*/
/** @addtogroup stm32f1xx_system
* @{
*/
/** @addtogroup STM32F1xx_System_Private_Includes
* @{
*/
#include "stm32f1xx.h"
/**
* @}
*/
/** @addtogroup STM32F1xx_System_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @addtogroup STM32F1xx_System_Private_Defines
* @{
*/
#if !defined (HSE_VALUE)
#define HSE_VALUE 8000000U /*!< Default value of the External oscillator in Hz.
This value can be provided and adapted by the user application. */
#endif /* HSE_VALUE */
#if !defined (HSI_VALUE)
#define HSI_VALUE 8000000U /*!< Default value of the Internal oscillator in Hz.
This value can be provided and adapted by the user application. */
#endif /* HSI_VALUE */
/*!< Uncomment the following line if you need to use external SRAM */
#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG)
/* #define DATA_IN_ExtSRAM */
#endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */
/* Note: Following vector table addresses must be defined in line with linker
configuration. */
/*!< Uncomment the following line if you need to relocate the vector table
anywhere in Flash or Sram, else the vector table is kept at the automatic
remap of boot address selected */
/* #define USER_VECT_TAB_ADDRESS */
#if defined(USER_VECT_TAB_ADDRESS)
/*!< Uncomment the following line if you need to relocate your vector Table
in Sram else user remap will be done in Flash. */
/* #define VECT_TAB_SRAM */
#if defined(VECT_TAB_SRAM)
#define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field.
This value must be a multiple of 0x200. */
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
This value must be a multiple of 0x200. */
#else
#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
This value must be a multiple of 0x200. */
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
This value must be a multiple of 0x200. */
#endif /* VECT_TAB_SRAM */
#endif /* USER_VECT_TAB_ADDRESS */
/******************************************************************************/
/**
* @}
*/
/** @addtogroup STM32F1xx_System_Private_Macros
* @{
*/
/**
* @}
*/
/** @addtogroup STM32F1xx_System_Private_Variables
* @{
*/
/* This variable is updated in three ways:
1) by calling CMSIS function SystemCoreClockUpdate()
2) by calling HAL API function HAL_RCC_GetHCLKFreq()
3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
Note: If you use this function to configure the system clock; then there
is no need to call the 2 first functions listed above, since SystemCoreClock
variable is updated automatically.
*/
uint32_t SystemCoreClock = 8000000;
const uint8_t AHBPrescTable[16U] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
const uint8_t APBPrescTable[8U] = {0, 0, 0, 0, 1, 2, 3, 4};
/**
* @}
*/
/** @addtogroup STM32F1xx_System_Private_FunctionPrototypes
* @{
*/
#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG)
#ifdef DATA_IN_ExtSRAM
static void SystemInit_ExtMemCtl(void);
#endif /* DATA_IN_ExtSRAM */
#endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */
/**
* @}
*/
/** @addtogroup STM32F1xx_System_Private_Functions
* @{
*/
/**
* @brief Setup the microcontroller system
* Initialize the Embedded Flash Interface, the PLL and update the
* SystemCoreClock variable.
* @note This function should be used only after reset.
* @param None
* @retval None
*/
void SystemInit (void)
{
#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG)
#ifdef DATA_IN_ExtSRAM
SystemInit_ExtMemCtl();
#endif /* DATA_IN_ExtSRAM */
#endif
/* Configure the Vector Table location -------------------------------------*/
#if defined(USER_VECT_TAB_ADDRESS)
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */
#endif /* USER_VECT_TAB_ADDRESS */
}
/**
* @brief Update SystemCoreClock variable according to Clock Register Values.
* The SystemCoreClock variable contains the core clock (HCLK), it can
* be used by the user application to setup the SysTick timer or configure
* other parameters.
*
* @note Each time the core clock (HCLK) changes, this function must be called
* to update SystemCoreClock variable value. Otherwise, any configuration
* based on this variable will be incorrect.
*
* @note - The system frequency computed by this function is not the real
* frequency in the chip. It is calculated based on the predefined
* constant and the selected clock source:
*
* - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
*
* - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
*
* - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
* or HSI_VALUE(*) multiplied by the PLL factors.
*
* (*) HSI_VALUE is a constant defined in stm32f1xx.h file (default value
* 8 MHz) but the real value may vary depending on the variations
* in voltage and temperature.
*
* (**) HSE_VALUE is a constant defined in stm32f1xx.h file (default value
* 8 MHz or 25 MHz, depending on the product used), user has to ensure
* that HSE_VALUE is same as the real frequency of the crystal used.
* Otherwise, this function may have wrong result.
*
* - The result of this function could be not correct when using fractional
* value for HSE crystal.
* @param None
* @retval None
*/
void SystemCoreClockUpdate (void)
{
uint32_t tmp = 0U, pllmull = 0U, pllsource = 0U;
#if defined(STM32F105xC) || defined(STM32F107xC)
uint32_t prediv1source = 0U, prediv1factor = 0U, prediv2factor = 0U, pll2mull = 0U;
#endif /* STM32F105xC */
#if defined(STM32F100xB) || defined(STM32F100xE)
uint32_t prediv1factor = 0U;
#endif /* STM32F100xB or STM32F100xE */
/* Get SYSCLK source -------------------------------------------------------*/
tmp = RCC->CFGR & RCC_CFGR_SWS;
switch (tmp)
{
case 0x00U: /* HSI used as system clock */
SystemCoreClock = HSI_VALUE;
break;
case 0x04U: /* HSE used as system clock */
SystemCoreClock = HSE_VALUE;
break;
case 0x08U: /* PLL used as system clock */
/* Get PLL clock source and multiplication factor ----------------------*/
pllmull = RCC->CFGR & RCC_CFGR_PLLMULL;
pllsource = RCC->CFGR & RCC_CFGR_PLLSRC;
#if !defined(STM32F105xC) && !defined(STM32F107xC)
pllmull = ( pllmull >> 18U) + 2U;
if (pllsource == 0x00U)
{
/* HSI oscillator clock divided by 2 selected as PLL clock entry */
SystemCoreClock = (HSI_VALUE >> 1U) * pllmull;
}
else
{
#if defined(STM32F100xB) || defined(STM32F100xE)
prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1U;
/* HSE oscillator clock selected as PREDIV1 clock entry */
SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull;
#else
/* HSE selected as PLL clock entry */
if ((RCC->CFGR & RCC_CFGR_PLLXTPRE) != (uint32_t)RESET)
{/* HSE oscillator clock divided by 2 */
SystemCoreClock = (HSE_VALUE >> 1U) * pllmull;
}
else
{
SystemCoreClock = HSE_VALUE * pllmull;
}
#endif
}
#else
pllmull = pllmull >> 18U;
if (pllmull != 0x0DU)
{
pllmull += 2U;
}
else
{ /* PLL multiplication factor = PLL input clock * 6.5 */
pllmull = 13U / 2U;
}
if (pllsource == 0x00U)
{
/* HSI oscillator clock divided by 2 selected as PLL clock entry */
SystemCoreClock = (HSI_VALUE >> 1U) * pllmull;
}
else
{/* PREDIV1 selected as PLL clock entry */
/* Get PREDIV1 clock source and division factor */
prediv1source = RCC->CFGR2 & RCC_CFGR2_PREDIV1SRC;
prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1U;
if (prediv1source == 0U)
{
/* HSE oscillator clock selected as PREDIV1 clock entry */
SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull;
}
else
{/* PLL2 clock selected as PREDIV1 clock entry */
/* Get PREDIV2 division factor and PLL2 multiplication factor */
prediv2factor = ((RCC->CFGR2 & RCC_CFGR2_PREDIV2) >> 4U) + 1U;
pll2mull = ((RCC->CFGR2 & RCC_CFGR2_PLL2MUL) >> 8U) + 2U;
SystemCoreClock = (((HSE_VALUE / prediv2factor) * pll2mull) / prediv1factor) * pllmull;
}
}
#endif /* STM32F105xC */
break;
default:
SystemCoreClock = HSI_VALUE;
break;
}
/* Compute HCLK clock frequency ----------------*/
/* Get HCLK prescaler */
tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4U)];
/* HCLK clock frequency */
SystemCoreClock >>= tmp;
}
#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG)
/**
* @brief Setup the external memory controller. Called in startup_stm32f1xx.s
* before jump to __main
* @param None
* @retval None
*/
#ifdef DATA_IN_ExtSRAM
/**
* @brief Setup the external memory controller.
* Called in startup_stm32f1xx_xx.s/.c before jump to main.
* This function configures the external SRAM mounted on STM3210E-EVAL
* board (STM32 High density devices). This SRAM will be used as program
* data memory (including heap and stack).
* @param None
* @retval None
*/
void SystemInit_ExtMemCtl(void)
{
__IO uint32_t tmpreg;
/*!< FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL, if another Bank is
required, then adjust the Register Addresses */
/* Enable FSMC clock */
RCC->AHBENR = 0x00000114U;
/* Delay after an RCC peripheral clock enabling */
tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_FSMCEN);
/* Enable GPIOD, GPIOE, GPIOF and GPIOG clocks */
RCC->APB2ENR = 0x000001E0U;
/* Delay after an RCC peripheral clock enabling */
tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPDEN);
(void)(tmpreg);
/* --------------- SRAM Data lines, NOE and NWE configuration ---------------*/
/*---------------- SRAM Address lines configuration -------------------------*/
/*---------------- NOE and NWE configuration --------------------------------*/
/*---------------- NE3 configuration ----------------------------------------*/
/*---------------- NBL0, NBL1 configuration ---------------------------------*/
GPIOD->CRL = 0x44BB44BBU;
GPIOD->CRH = 0xBBBBBBBBU;
GPIOE->CRL = 0xB44444BBU;
GPIOE->CRH = 0xBBBBBBBBU;
GPIOF->CRL = 0x44BBBBBBU;
GPIOF->CRH = 0xBBBB4444U;
GPIOG->CRL = 0x44BBBBBBU;
GPIOG->CRH = 0x444B4B44U;
/*---------------- FSMC Configuration ---------------------------------------*/
/*---------------- Enable FSMC Bank1_SRAM Bank ------------------------------*/
FSMC_Bank1->BTCR[4U] = 0x00001091U;
FSMC_Bank1->BTCR[5U] = 0x00110212U;
}
#endif /* DATA_IN_ExtSRAM */
#endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/