根据实际电路版修改对应引脚,LED KEY LCD 正常运行

This commit is contained in:
2026-01-25 13:02:58 +08:00
parent a2224908e3
commit 065f070cfa
93 changed files with 5750 additions and 9255 deletions

View File

@@ -19,14 +19,6 @@
#include <string.h>
#include <stdio.h>
/* ============================================================================
* 编译选项配置
* ============================================================================ */
//#define STATIC_BOX /**< 静态框显示模式(已注释) */
#define DYNAMIC_BOX /**< 动态框显示模式 */
#define TEST_DELAY_TIME 600 /**< 测试延时时间(单位:毫秒) */
#define VERSION_CODE "Ver0.05(XRD)" /**< 版本号字符串 */
/* ============================================================================
* LCD偏置电压配置宏定义
* ============================================================================ */
@@ -146,12 +138,13 @@
#define UC1698U_RST_L() do{HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_RESET);}while(0)
/** @brief 设置背光引脚为关闭 */
#define LCD_BackLight_OFF() do{HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_SET);}while(0)
#define LCD_BackLight_OFF() do{HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET);}while(0)
/** @brief 设置背光引脚为打开 */
#define LCD_BackLight_ON() do{HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET);}while(0)
#define LCD_BackLight_ON() do{HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_SET);}while(0)
volatile static uint32_t BackLightCount = 0;
#define BackLightTimeMax (20000) //五分钟
#define BackLightTimeMax (20000) /* 100s */
/**
* @brief 背光处理函数
@@ -1326,7 +1319,30 @@ void FillBoxScreen(uint8_t x, uint8_t y, uint8_t len, uint8_t high, uint8_t byte
y++; /* 移动到下一行 */
}
}
void LCD_GPIO_Init(void)
{
GPIO_InitTypeDef gpio_init_struct;
__HAL_RCC_GPIOB_CLK_ENABLE(); // 时钟初始化
__HAL_RCC_GPIOE_CLK_ENABLE(); // 时钟初始化
// 配置 LCD 引脚
gpio_init_struct.Pin = GPIO_PIN_14 | GPIO_PIN_13 | GPIO_PIN_12 | GPIO_PIN_11 | GPIO_PIN_10 | GPIO_PIN_0;
gpio_init_struct.Mode = GPIO_MODE_OUTPUT_PP; /*推挽输出模式*/
gpio_init_struct.Pull = GPIO_PULLUP;
gpio_init_struct.Speed = GPIO_SPEED_HIGH;
// 初始化 LCD 选引脚
HAL_GPIO_Init(GPIOB, &gpio_init_struct);
// 配置 LCD 引脚
gpio_init_struct.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;
gpio_init_struct.Mode = GPIO_MODE_OUTPUT_PP; /*推挽输出模式*/
gpio_init_struct.Pull = GPIO_PULLUP;
gpio_init_struct.Speed = GPIO_SPEED_HIGH;
// 初始化 LCD 选引脚
HAL_GPIO_Init(GPIOE, &gpio_init_struct);
}
/**
* @brief LCD初始化总函数
* @note 执行LCD初始化的完整流程
@@ -1337,6 +1353,8 @@ void FillBoxScreen(uint8_t x, uint8_t y, uint8_t len, uint8_t high, uint8_t byte
*/
void LcdInit(void)
{
LCD_GPIO_Init();
LCD_BackLight_ON();
LCD_Reset(); /* 硬件复位 */
LCD_InitXRD(); /* 初始化配置XRD版本 */
ClearScreen(); /* 清屏 */
@@ -1647,22 +1665,6 @@ void DrawPoint(uint8_t x, uint8_t y)
DisplayVerticalLine(x + 1, y + 4, 1, 0x60);
DisplayHorizontalLine(x + 1, y + 5, 1);
}
/**
* @brief 擦除线条(内部函数,用于动态框效果)
* @param x 起始列坐标X坐标
* @param y 起始行坐标Y坐标
* @param len 线条长度(像素单位)
* @param high 线条高度(行数)
* @note 擦除指定区域的线条,用于实现动态框的擦除效果
* 擦除底部3行和右侧1列
* @retval 无
*/
static void EraseLine(uint8_t x, uint8_t y, uint8_t len, uint8_t high)
{
FillBoxScreen(x, y + high, len + 1, 3, 0x00); /* 擦除底部3行 */
FillBoxScreen(x + len, y, 1, high + 1, 0x00); /* 擦除右侧1列 */
}
/**
* @brief 显示消息提示框(静态模式)
* @note 在屏幕指定位置显示一个带阴影的消息提示框