2026-07-15 15:57:37 +08:00
|
|
|
|
#ifndef __LCD_H__
|
|
|
|
|
|
#define __LCD_H__
|
|
|
|
|
|
|
|
|
|
|
|
#include "../App/config.h"
|
|
|
|
|
|
#include "stc32g.h"
|
|
|
|
|
|
|
2026-07-17 19:43:02 +08:00
|
|
|
|
/* ====== LHS114TC-IF03 (ST7789V) 屏幕参数与常数定义 ====== */
|
|
|
|
|
|
#define LCD_WIDTH 135 // 屏幕物理宽度
|
|
|
|
|
|
#define LCD_HEIGHT 240 // 屏幕物理高度
|
|
|
|
|
|
#define LCD_X_OFFSET 52 // 水平 X 轴物理偏置量
|
|
|
|
|
|
#define LCD_Y_OFFSET 40 // 垂直 Y 轴物理偏置量
|
2026-07-16 17:52:52 +08:00
|
|
|
|
|
|
|
|
|
|
// 16位 RGB565 颜色常量定义:
|
2026-07-17 19:43:02 +08:00
|
|
|
|
#define COLOR_BLACK 0x0000 // 黑色
|
|
|
|
|
|
#define COLOR_WHITE 0xFFFF // 白色
|
|
|
|
|
|
#define COLOR_CYAN 0x073F // 青色
|
|
|
|
|
|
#define COLOR_RED 0xF800 // 红色
|
|
|
|
|
|
#define COLOR_GREEN 0x07E0 // 绿色
|
|
|
|
|
|
#define COLOR_BLUE 0x001F // 蓝色
|
|
|
|
|
|
#define COLOR_GRAY 0x5AEB // 灰色
|
|
|
|
|
|
#define COLOR_AMBER 0xFDC0 // 琥珀色
|
2026-07-16 17:52:52 +08:00
|
|
|
|
|
|
|
|
|
|
/* ====== 屏幕电源控制与基本驱动接口 ====== */
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2026-07-17 19:43:02 +08:00
|
|
|
|
* @brief 通过脉冲序列为 SGM3833 供电芯片写入配置
|
2026-07-16 17:52:52 +08:00
|
|
|
|
*/
|
2026-07-15 15:57:37 +08:00
|
|
|
|
void SGM_SendPulse(u8 pulse_cnt);
|
2026-07-16 17:52:52 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2026-07-17 19:43:02 +08:00
|
|
|
|
* @brief 执行 LHS114TC-IF03 屏幕的硬件复位
|
2026-07-16 17:52:52 +08:00
|
|
|
|
*/
|
2026-07-15 15:57:37 +08:00
|
|
|
|
void LCD_Reset(void);
|
2026-07-16 17:52:52 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2026-07-17 19:43:02 +08:00
|
|
|
|
* @brief 初始化 LHS114TC-IF03 (ST7789V) 屏幕控制器
|
2026-07-16 17:52:52 +08:00
|
|
|
|
*/
|
2026-07-15 15:57:37 +08:00
|
|
|
|
void LCD_Init(void);
|
2026-07-16 17:52:52 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2026-07-17 19:43:02 +08:00
|
|
|
|
* @brief 向屏幕写入 1 字节控制命令
|
2026-07-16 17:52:52 +08:00
|
|
|
|
*/
|
2026-07-15 15:57:37 +08:00
|
|
|
|
void WriteComm(u8 cmd);
|
2026-07-16 17:52:52 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2026-07-17 19:43:02 +08:00
|
|
|
|
* @brief 向屏幕写入 1 字节显示数据
|
|
|
|
|
|
*/
|
|
|
|
|
|
void WriteData(u8 dat);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 设定屏幕的数据更新绘制窗口区域
|
2026-07-16 17:52:52 +08:00
|
|
|
|
*/
|
2026-07-15 15:57:37 +08:00
|
|
|
|
void LCD_SetWindow(u16 x_start, u16 x_end, u16 y_start, u16 y_end);
|
2026-07-16 17:52:52 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2026-07-17 19:43:02 +08:00
|
|
|
|
* @brief 用指定色彩刷写清空全屏幕
|
2026-07-16 17:52:52 +08:00
|
|
|
|
*/
|
2026-07-15 15:57:37 +08:00
|
|
|
|
void LCD_Clear(u16 color);
|
|
|
|
|
|
|
2026-07-17 19:43:02 +08:00
|
|
|
|
/* ====== 关键图形与点阵字符渲染接口 ====== */
|
2026-07-16 17:52:52 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2026-07-17 19:43:02 +08:00
|
|
|
|
* @brief 在屏幕指定视口绘制实心矩形
|
2026-07-16 17:52:52 +08:00
|
|
|
|
*/
|
2026-07-15 15:57:37 +08:00
|
|
|
|
void LCD_FillRect(u16 x, u16 y, u16 w, u16 h, u16 color);
|
2026-07-16 17:52:52 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2026-07-17 19:43:02 +08:00
|
|
|
|
* @brief 绘制空心矩形边界框
|
2026-07-16 17:52:52 +08:00
|
|
|
|
*/
|
2026-07-15 15:57:37 +08:00
|
|
|
|
void LCD_DrawRectBorder(u16 x, u16 y, u16 w, u16 h, u16 color);
|
2026-07-16 17:52:52 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2026-07-17 19:43:02 +08:00
|
|
|
|
* @brief 渲染显示一个单色字模位图资源
|
2026-07-16 17:52:52 +08:00
|
|
|
|
*/
|
2026-07-15 15:57:37 +08:00
|
|
|
|
void LCD_DrawMonoBitmap(u16 x, u16 y, u16 w, u16 h, unsigned char code *bmp, u16 color, u16 bg_color);
|
2026-07-16 17:52:52 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2026-07-17 19:43:02 +08:00
|
|
|
|
* @brief 在指定坐标渲染输出一个 8x16 尺寸的普通英文 ASCII 字符
|
2026-07-16 17:52:52 +08:00
|
|
|
|
*/
|
2026-07-15 15:57:37 +08:00
|
|
|
|
void LCD_ShowChar8x16(u16 x, u16 y, char ch, u16 color, u16 bg_color);
|
2026-07-16 17:52:52 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2026-07-17 19:43:02 +08:00
|
|
|
|
* @brief 在指定坐标打印一行普通英文 ASCII 字符串 (左对齐)
|
2026-07-16 17:52:52 +08:00
|
|
|
|
*/
|
2026-07-15 15:57:37 +08:00
|
|
|
|
void LCD_ShowString(u16 x, u16 y, char *str, u16 color, u16 bg_color);
|
2026-07-16 17:52:52 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2026-07-17 19:43:02 +08:00
|
|
|
|
* @brief 在指定 Y 轴高度上,自动计算偏移以实现字符串水平居中显示
|
2026-07-16 17:52:52 +08:00
|
|
|
|
*/
|
2026-07-15 15:57:37 +08:00
|
|
|
|
void LCD_ShowStringCentered(u16 y, char *str, u16 color, u16 bg_color);
|
2026-07-16 17:52:52 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2026-07-17 19:43:02 +08:00
|
|
|
|
* @brief 渲染大号特粗 16x32 尺寸的英文/数字字符
|
2026-07-16 17:52:52 +08:00
|
|
|
|
*/
|
2026-07-15 15:57:37 +08:00
|
|
|
|
void LCD_ShowChar16x32(u16 x, u16 y, char ch, u16 color, u16 bg_color);
|
2026-07-16 17:52:52 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2026-07-17 19:43:02 +08:00
|
|
|
|
* @brief 在指定坐标绘制特大 16x32 规格的数字/英文字串
|
2026-07-16 17:52:52 +08:00
|
|
|
|
*/
|
2026-07-15 15:57:37 +08:00
|
|
|
|
void LCD_ShowString16x32(u16 x, u16 y, char *str, u16 color, u16 bg_color);
|
2026-07-16 17:52:52 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2026-07-17 19:43:02 +08:00
|
|
|
|
* @brief 在指定 Y 轴高度上,水平居中渲染显示特大 16x32 规格字符串
|
2026-07-16 17:52:52 +08:00
|
|
|
|
*/
|
2026-07-15 15:57:37 +08:00
|
|
|
|
void LCD_ShowString16x32Centered(u16 y, char *str, u16 color, u16 bg_color);
|
|
|
|
|
|
|
2026-07-17 19:43:02 +08:00
|
|
|
|
/* ====== 图标外部点阵数据声明 ====== */
|
|
|
|
|
|
extern unsigned char code FONT_8x16[95][16]; // 8x16 英文点阵字库
|
|
|
|
|
|
extern unsigned char code bmp_battery_20x10[]; // 20x10 电池指示位图
|
|
|
|
|
|
extern unsigned char code bmp_lock_16x16[]; // 16x16 闭合锁头位图
|
|
|
|
|
|
extern unsigned char code bmp_unlock_16x16[]; // 16x16 开启锁头位图
|
|
|
|
|
|
extern unsigned char code bmp_radar_32x32_f1[]; // 32x32 雷达扩散帧1
|
|
|
|
|
|
extern unsigned char code bmp_radar_32x32_f2[]; // 32x32 雷达扩散帧2
|
|
|
|
|
|
extern unsigned char code bmp_radar_32x32_f3[]; // 32x32 雷达扩散帧3
|
|
|
|
|
|
extern unsigned char code bmp_confirm_lock_32x32[]; // 32x32 锁型常规大图标
|
|
|
|
|
|
extern unsigned char code bmp_checkmark_32x32[]; // 32x32 成功大对勾
|
|
|
|
|
|
extern unsigned char code bmp_cross_32x32[]; // 32x32 失败大红叉
|
|
|
|
|
|
extern unsigned char code bmp_door_32x32[]; // 32x32 门磁大警示图
|
|
|
|
|
|
extern unsigned char code bmp_siren_32x32[]; // 32x32 烟感喇叭大警示图
|
2026-07-15 15:57:37 +08:00
|
|
|
|
|
2026-07-16 17:52:52 +08:00
|
|
|
|
#endif // __LCD_H__
|