Files
STM32F103/STM32F103C8T6/Drivers/BSP/LCD/lcd.h

134 lines
3.8 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* 模块名称LCD 绘图模块
* 模块功能:提供字符、字符串(中英文混合)、线条、矩形、圆形等图形绘制
* 适用平台STM32F103C8T6 + ST7735S + 底层 st7735s.c
* 作者:王建锋
* 创建日期2026-07-14
* 修改记录:
* 2026-07-14 王建锋 从 st7735s.c 拆分
*/
#ifndef __LCD_H
#define __LCD_H
#ifdef __cplusplus
extern "C" {
#endif
#include "st7735s.h"
#include <stdint.h>
/* 字体定义 */
#define FONT_WIDTH_8 8 /* 8x16字体宽度含间距 */
#define FONT_HEIGHT_16 16 /* 8x16字体高度 */
#define FONT_WIDTH_6 6 /* 6x8字体宽度 */
#define FONT_HEIGHT_8 8 /* 6x8字体高度 */
/* === 字符/字符串绘制 === */
/*
* 函数功能显示一个8x16 ASCII字符
* 入口参数x - 列坐标
* y - 行坐标
* ch - 字符 (ASCII 32-126)
* color - 字符颜色 (RGB565)
* bg_color - 背景颜色 (RGB565)
* 返回值:无
*/
void lcd_draw_char(uint16_t x, uint16_t y, char ch, uint16_t color, uint16_t bg_color);
/*
* 函数功能显示字符串ASCII
* 入口参数x - 列坐标
* y - 行坐标
* str - 字符串指针
* color - 字符颜色 (RGB565)
* bg_color - 背景颜色 (RGB565)
* 返回值:无
*/
void lcd_draw_string(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bg_color);
/*
* 函数功能显示一个6x8 ASCII字符
* 入口参数x - 列坐标
* y - 行坐标
* ch - 字符 (ASCII 32-126)
* color - 字符颜色 (RGB565)
* bg_color - 背景颜色 (RGB565)
* 返回值:无
*/
void lcd_draw_char_6x8(uint16_t x, uint16_t y, char ch, uint16_t color, uint16_t bg_color);
/*
* 函数功能显示字符串6x8字体
* 入口参数x - 列坐标
* y - 行坐标
* str - 字符串指针
* color - 字符颜色 (RGB565)
* bg_color - 背景颜色 (RGB565)
* 返回值:无
*/
void lcd_draw_string_6x8(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bg_color);
/*
* 函数功能显示一个16x16 CJK汉字
* 入口参数x - 列坐标
* y - 行坐标
* unicode - Unicode码点 (如 0x4E00="一")
* color - 字符颜色 (RGB565)
* bg_color - 背景颜色 (RGB565)
* 返回值:无
*/
void lcd_draw_chinese(uint16_t x, uint16_t y, uint16_t unicode, uint16_t color, uint16_t bg_color);
/*
* 函数功能显示UTF-8字符串自动中英文混合
* 入口参数x - 列坐标
* y - 行坐标
* str - UTF-8字符串指针
* color - 字符颜色 (RGB565)
* bg_color - 背景颜色 (RGB565)
* 返回值:无
*/
void lcd_draw_chinese_string(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bg_color);
/* === 图形绘制 === */
/*
* 函数功能画线Bresenham算法
* 入口参数x1 - 起始列
* y1 - 起始行
* x2 - 结束列
* y2 - 结束行
* color - 颜色 (RGB565)
* 返回值:无
*/
void lcd_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
/*
* 函数功能:画空心矩形
* 入口参数x - 左上角列
* y - 左上角行
* width - 宽度
* height - 高度
* color - 颜色 (RGB565)
* 返回值:无
*/
void lcd_draw_rect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color);
/*
* 函数功能画空心圆Bresenham算法
* 入口参数x0 - 圆心列
* y0 - 圆心行
* radius - 半径
* color - 颜色 (RGB565)
* 返回值:无
*/
void lcd_draw_circle(uint16_t x0, uint16_t y0, uint16_t radius, uint16_t color);
#ifdef __cplusplus
}
#endif
#endif /* __LCD_H */