Mini_croe_Sick/User/device/lcd.h
2025-04-12 21:32:00 +08:00

37 lines
1.2 KiB
C

#ifndef __LCD_H
#define __LCD_H
#include "spi.h"
#include "gpio.h"
// 屏幕分辨率
#define LCD_WIDTH 135
#define LCD_HEIGHT 240
#define X_OFFSET 52
#define Y_OFFSET 40
// 常用颜色定义
#define BLACK 0x0000
#define WHITE 0xFFFF
#define RED 0xF800
#define GREEN 0x07E0
#define BLUE 0x001F
// 控制引脚
#define LCD_CS_LOW() HAL_GPIO_WritePin(TFT_CS_GPIO_Port, TFT_CS_Pin, GPIO_PIN_RESET)
#define LCD_CS_HIGH() HAL_GPIO_WritePin(TFT_CS_GPIO_Port, TFT_CS_Pin, GPIO_PIN_SET)
#define LCD_DC_LOW() HAL_GPIO_WritePin(TFT_RS_GPIO_Port, TFT_RS_Pin, GPIO_PIN_RESET)
#define LCD_DC_HIGH() HAL_GPIO_WritePin(TFT_RS_GPIO_Port, TFT_RS_Pin, GPIO_PIN_SET)
#define LCD_RST_LOW() HAL_GPIO_WritePin(TFT_RES_GPIO_Port, TFT_RES_Pin, GPIO_PIN_RESET)
#define LCD_RST_HIGH() HAL_GPIO_WritePin(TFT_RES_GPIO_Port, TFT_RES_Pin, GPIO_PIN_SET)
// 函数声明
void LCD_Init(void);
void LCD_Clear(uint16_t color);
void LCD_DrawPixel(uint16_t x, uint16_t y, uint16_t color);
// void LCD_DrawChar(uint16_t x, uint16_t y, char ch, uint16_t color, uint16_t bgColor);
// void LCD_DrawString(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bgColor);
#endif // __LCD_H