refactor(gbk_text): 重构GBK文本常量定义并优化命名

移除过时的文本定义,使用更简洁通用的名称替换原有特定功能的文本
常量,并更新相应的长度定义和别名映射。

BREAKING CHANGE: 原有的特定功能文本常量已被移除,需使用新的通
用名称进行访问。
```
This commit is contained in:
2026-02-17 18:55:34 +08:00
parent 09c881b4a6
commit 4c37261cc8
12 changed files with 958 additions and 509 deletions

View File

@@ -5,68 +5,47 @@
// GBK文本数组声明定义在gbk_text.c中
extern const uint8_t text_device_name_GBK[];
extern const uint8_t text_device_loading_GBK[];
extern const uint8_t text_start_massage_GBK[];
extern const uint8_t text_start_heating_GBK[];
extern const uint8_t text_stop_massage_GBK[];
extern const uint8_t text_stop_heating_GBK[];
extern const uint8_t text_massage_gear_1_GBK[];
extern const uint8_t text_massage_gear_2_GBK[];
extern const uint8_t text_massage_gear_3_GBK[];
extern const uint8_t text_massage_time_10_GBK[];
extern const uint8_t text_massage_time_15_GBK[];
extern const uint8_t text_massage_time_20_GBK[];
extern const uint8_t text_massage_time_30_GBK[];
extern const uint8_t text_massage_time_cont_GBK[];
extern const uint8_t text_remaining_time_GBK[];
extern const uint8_t text_heating_on_GBK[];
extern const uint8_t text_heating_off_GBK[];
extern const uint8_t text_massage_running_GBK[];
extern const uint8_t text_massage_paused_GBK[];
extern const uint8_t text_massage_ended_GBK[];
extern const uint8_t text_loading_GBK[];
extern const uint8_t text_massage_on_GBK[];
extern const uint8_t text_massage_off_GBK[];
extern const uint8_t text_heat_on_GBK[];
extern const uint8_t text_heat_off_GBK[];
extern const uint8_t text_gear_GBK[];
extern const uint8_t text_time_GBK[];
extern const uint8_t text_cont_GBK[];
extern const uint8_t text_remaining_GBK[];
extern const uint8_t text_running_GBK[];
extern const uint8_t text_paused_GBK[];
extern const uint8_t text_ended_GBK[];
// GBK文本长度宏预计算不含\0
#define text_device_name_LEN (10)
#define text_device_loading_LEN (20)
#define text_start_massage_LEN (10)
#define text_start_heating_LEN (10)
#define text_stop_massage_LEN (10)
#define text_stop_heating_LEN (10)
#define text_massage_gear_1_LEN (13)
#define text_massage_gear_2_LEN (13)
#define text_massage_gear_3_LEN (13)
#define text_massage_time_10_LEN (16)
#define text_massage_time_15_LEN (16)
#define text_massage_time_20_LEN (16)
#define text_massage_time_30_LEN (16)
#define text_massage_time_cont_LEN (14)
#define text_remaining_time_LEN (18)
#define text_heating_on_LEN (12)
#define text_heating_off_LEN (12)
#define text_massage_running_LEN (8)
#define text_massage_paused_LEN (12)
#define text_massage_ended_LEN (12)
#define text_loading_LEN (6)
#define text_massage_on_LEN (8)
#define text_massage_off_LEN (8)
#define text_heat_on_LEN (8)
#define text_heat_off_LEN (8)
#define text_gear_LEN (4)
#define text_time_LEN (6)
#define text_cont_LEN (4)
#define text_remaining_LEN (8)
#define text_running_LEN (6)
#define text_paused_LEN (6)
#define text_ended_LEN (6)
// 兼容旧代码的别名
#define text_device_name text_device_name_GBK
#define text_device_loading text_device_loading_GBK
#define text_start_massage text_start_massage_GBK
#define text_start_heating text_start_heating_GBK
#define text_stop_massage text_stop_massage_GBK
#define text_stop_heating text_stop_heating_GBK
#define text_massage_gear_1 text_massage_gear_1_GBK
#define text_massage_gear_2 text_massage_gear_2_GBK
#define text_massage_gear_3 text_massage_gear_3_GBK
#define text_massage_time_10 text_massage_time_10_GBK
#define text_massage_time_15 text_massage_time_15_GBK
#define text_massage_time_20 text_massage_time_20_GBK
#define text_massage_time_30 text_massage_time_30_GBK
#define text_massage_time_cont text_massage_time_cont_GBK
#define text_remaining_time text_remaining_time_GBK
#define text_heating_on text_heating_on_GBK
#define text_heating_off text_heating_off_GBK
#define text_massage_running text_massage_running_GBK
#define text_massage_paused text_massage_paused_GBK
#define text_massage_ended text_massage_ended_GBK
#define text_loading text_loading_GBK
#define text_massage_on text_massage_on_GBK
#define text_massage_off text_massage_off_GBK
#define text_heat_on text_heat_on_GBK
#define text_heat_off text_heat_off_GBK
#define text_gear text_gear_GBK
#define text_time text_time_GBK
#define text_cont text_cont_GBK
#define text_remaining text_remaining_GBK
#define text_running text_running_GBK
#define text_paused text_paused_GBK
#define text_ended text_ended_GBK
#endif // __GBK_TEXT_H__

View File

@@ -1,10 +1,10 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file screen.h
* @brief 串口屏驱动接口(用于 JC 系列串口屏,使用 USART1
******************************************************************************
*/
******************************************************************************
* @file screen.h
* @brief 串口屏驱动接口(用于 JC 系列串口屏,使用 USART1
******************************************************************************
*/
/* USER CODE END Header */
#ifndef __SCREEN_H__
@@ -15,10 +15,37 @@ extern "C" {
#endif
#include <stdint.h>
#include <stdbool.h>
/* 颜色使用统一的标志 */
#define TEXT_COLOR 15 /* 白色 */
#define BG_COLOR 0 /* 黑色 */
#define BG_COLOR 0 /* 黑色 */
#define SCREEN_LEFT 1
#define SCREEN_RIGHT 126
#define TITLE_LINE_Y 28
#define ZONE1_LINE_Y 60
#define ZONE2_LINE_Y 93
typedef struct
{
uint16_t y_clear_start; // 清除区域起始
uint16_t y_clear_end; // 清除区域结束
uint16_t y_text; // 文本基线
} ScreenZone_t;
static const ScreenZone_t g_zones[3] =
{
{29, 60, 37}, // Zone1
{61, 93, 69}, // Zone2
{94, 126, 102} // Zone3
};
@@ -44,47 +71,71 @@ void Screen_DrawText16(uint16_t x, uint16_t y, const char *text, uint8_t color);
/* 额外封装命令 */
void Screen_SetRotation(uint8_t dir);
void Screen_SetBaud(uint32_t baud);
void Screen_DisplayImageAtAddr(uint32_t addr, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint8_t mode);
void Screen_DisplayImageByIndex(uint32_t index, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint8_t mode);
void Screen_DisplayImageAtAddr(uint32_t addr, uint16_t x, uint16_t y,
uint16_t w, uint16_t h, uint8_t mode);
void Screen_DisplayImageByIndex(uint32_t index, uint16_t x, uint16_t y,
uint16_t w, uint16_t h, uint8_t mode);
void Screen_Pixel(uint16_t x, uint16_t y, uint8_t color);
void Screen_Line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint8_t color);
void Screen_Box(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint8_t color);
void Screen_BoxFill(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint8_t color);
void Screen_Line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2,
uint8_t color);
void Screen_Box(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2,
uint8_t color);
void Screen_BoxFill(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2,
uint8_t color);
void Screen_Circle(uint16_t x, uint16_t y, uint16_t r, uint8_t color);
void Screen_CircleFill(uint16_t x, uint16_t y, uint16_t r, uint8_t color);
void Screen_SetBGColor(uint8_t color);
void Screen_DrawText16V_GBK(uint16_t x, uint16_t y, const uint8_t *gbk_buf, uint16_t gbk_len, uint8_t color);
void Screen_DrawText16V_GBK(uint16_t x, uint16_t y, const uint8_t *gbk_buf,
uint16_t gbk_len, uint8_t color);
/* 带/不带背景的文本 */
void Screen_DrawText16V(uint16_t x, uint16_t y, const char *text, uint8_t color);
void Screen_DrawText16V(uint16_t x, uint16_t y, const char *text,
uint8_t color);
void Screen_DrawText24(uint16_t x, uint16_t y, const char *text, uint8_t color);
void Screen_DrawText24V(uint16_t x, uint16_t y, const char *text, uint8_t color);
void Screen_DrawText24V(uint16_t x, uint16_t y, const char *text,
uint8_t color);
void Screen_DrawText32(uint16_t x, uint16_t y, const char *text, uint8_t color);
void Screen_DrawText32V(uint16_t x, uint16_t y, const char *text, uint8_t color);
void Screen_DrawText48(uint16_t x, uint16_t y, const char *text, uint8_t color, uint8_t transparent);
void Screen_DrawText32V(uint16_t x, uint16_t y, const char *text,
uint8_t color);
void Screen_DrawText48(uint16_t x, uint16_t y, const char *text, uint8_t color,
uint8_t transparent);
/* Button */
void Screen_Button(uint16_t x, uint16_t y, uint16_t w, uint16_t h, const char *label, uint8_t fontColor, uint8_t bgColor, uint8_t pressFlag, uint8_t style);
void Screen_Button(uint16_t x, uint16_t y, uint16_t w, uint16_t h,
const char *label, uint8_t fontColor, uint8_t bgColor,
uint8_t pressFlag, uint8_t style);
/* Qrcode */
void Screen_QRCode(uint16_t x, uint16_t y, const char *url);
void Screen_QRCodeEx(uint16_t x, uint16_t y, const char *url, uint16_t size, uint8_t color);
/* 版本信息 */
void Screen_Ver(void);
void Screen_QRCodeEx(uint16_t x, uint16_t y, const char *url, uint16_t size,
uint8_t color);
// GBK
void Screen_DrawText16_GBK(uint16_t x,uint16_t y,const uint8_t *gbk,uint16_t len,uint8_t color);
void Screen_DrawText16V_GBK(uint16_t x,uint16_t y,const uint8_t *gbk,uint16_t len,uint8_t color);
void Screen_DrawText16_GBK(uint16_t x, uint16_t y, const uint8_t *gbk,
uint16_t len, uint8_t color);
void Screen_DrawText16V_GBK(uint16_t x, uint16_t y, const uint8_t *gbk,
uint16_t len, uint8_t color);
void Screen_DrawText24_GBK(uint16_t x,uint16_t y,const uint8_t *gbk,uint16_t len,uint8_t color);
void Screen_DrawText24V_GBK(uint16_t x,uint16_t y,const uint8_t *gbk,uint16_t len,uint8_t color);
void Screen_DrawText24_GBK(uint16_t x, uint16_t y, const uint8_t *gbk,
uint16_t len, uint8_t color);
void Screen_DrawText24V_GBK(uint16_t x, uint16_t y, const uint8_t *gbk,
uint16_t len, uint8_t color);
void Screen_DrawText32_GBK(uint16_t x,uint16_t y,const uint8_t *gbk,uint16_t len,uint8_t color);
void Screen_DrawText32V_GBK(uint16_t x,uint16_t y,const uint8_t *gbk,uint16_t len,uint8_t color);
void Screen_DrawText32_GBK(uint16_t x, uint16_t y, const uint8_t *gbk,
uint16_t len, uint8_t color);
void Screen_DrawText32V_GBK(uint16_t x, uint16_t y, const uint8_t *gbk,
uint16_t len, uint8_t color);
void Screen_DrawText48_GBK(uint16_t x,uint16_t y,const uint8_t *gbk,uint16_t len,uint8_t color,uint8_t transparent);
void Screen_DrawText48_GBK(uint16_t x, uint16_t y, const uint8_t *gbk,
uint16_t len, uint8_t color, uint8_t transparent);
// 清空屏幕相关
void Screen_ClearZone(uint8_t zone);
void Screen_ClearAllZones(void);
// 显示相关
void Screen_ShowInZone(uint8_t zone, const uint8_t * text,uint16_t text_len);
void Screen_ClearContent(void);
#ifdef __cplusplus
}
#endif

View File

@@ -32,12 +32,15 @@ extern "C" {
/* USER CODE END Includes */
extern TIM_HandleTypeDef htim1;
extern TIM_HandleTypeDef htim4;
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */
void MX_TIM1_Init(void);
void MX_TIM4_Init(void);
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);