refactor(gbk_text): 重构GBK文本常量定义并优化命名 移除过时的文本定义,使用更简洁通用的名称替换原有特定功能的文本 常量,并更新相应的长度定义和别名映射。 BREAKING CHANGE: 原有的特定功能文本常量已被移除,需使用新的通 用名称进行访问。 ```
144 lines
4.9 KiB
C
144 lines
4.9 KiB
C
/* USER CODE BEGIN Header */
|
||
/**
|
||
******************************************************************************
|
||
* @file screen.h
|
||
* @brief 串口屏驱动接口(用于 JC 系列串口屏,使用 USART1)
|
||
******************************************************************************
|
||
*/
|
||
/* USER CODE END Header */
|
||
|
||
#ifndef __SCREEN_H__
|
||
#define __SCREEN_H__
|
||
|
||
#ifdef __cplusplus
|
||
extern "C" {
|
||
#endif
|
||
|
||
#include <stdint.h>
|
||
#include <stdbool.h>
|
||
|
||
/* 颜色使用统一的标志 */
|
||
#define TEXT_COLOR 15 /* 白色 */
|
||
#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
|
||
};
|
||
|
||
|
||
|
||
|
||
/**
|
||
* @brief 发送原始命令字符串到屏幕(阻塞直到发送完成)
|
||
* @param cmd C 字符串,命令应以";\r\n"结尾
|
||
* @return 0 成功, 负值 错误
|
||
*/
|
||
int Screen_SendCmd(const char *cmd);
|
||
|
||
void Screen_Init(void);
|
||
|
||
/* 常用封装 - 简短说明见各函数 */
|
||
/** 清屏,layer: 要清除的层号(通常为0) */
|
||
void Screen_Clear(uint8_t layer);
|
||
/** 按地址显示图片(addr 为闪存地址) */
|
||
void Screen_DisplayImage(uint32_t addr);
|
||
/** 设置背光,val: 0 最亮,255 最暗 */
|
||
void Screen_SetBrightness(uint8_t val);
|
||
/** 绘制 16 字号文本(不带背景) */
|
||
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_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_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(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_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);
|
||
|
||
/* 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);
|
||
|
||
/* 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);
|
||
|
||
// 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_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_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);
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|
||
|
||
#endif /* __SCREEN_H__ */
|