基于CW32的电压电流表 V1.0.0
一款物联网多功能电压电流表
 
载入中...
搜索中...
未找到
Lcd_Driver.h
浏览该文件的文档.
1
11#ifndef LCD_DRIVER_H_
12#define LCD_DRIVER_H_
13
14 #include "board.h"
15
16 #define WHITE 0xFFFF
17 #define BLACK 0x0000
18 #define ORANGE 0XFD20
19 #define BLUE 0x001F
20 #define BRED 0XF81F
21 #define GRED 0XFFE0
22 #define GBLUE 0X07FF
23 #define RED 0xF800
24 #define MAGENTA 0xF81F
25 #define GREEN 0x07E0
26 #define CYAN 0x7FFF
27 #define YELLOW 0xFFE0
28 #define PURPLE 0x780F //紫色
29 #define BROWN 0XBC40 //棕色
30 #define BRRED 0XFC07 //棕红色
31 #define GRAY 0X8430 //灰色
32 #define DARKBLUE 0x4C1C //深蓝色
33 #define LIGHTBLUE 0x67A //浅蓝色
34 #define GRAYBLUE 0X5458 //灰蓝色
35 #define LIGHTGREEN 0X841F //浅绿色
36 #define LGRAY 0XC618 //浅灰色(PANNEL),窗体背景色
37 #define LGRAYBLUE 0XA651 //浅灰蓝色(中间层颜色)
38 #define LBBLUE 0X2B12 //浅棕蓝色(选择条目的反色)
39
40
41
42
43
44 #define LCD_CTRLA CW_GPIOA //定义TFT数据端口
45 #define LCD_CTRLC CW_GPIOC //定义TFT数据端口
46
47
48
49 #define LCD_SCL GPIO_PIN_4 //PA4--->>TFT --SCL/SCK
50 #define LCD_SDA GPIO_PIN_3 //PA3 MOSI--->>TFT --SDA/DIN
51 #define LCD_CS GPIO_PIN_0 //PA0--->>TFT --CS/CE
52
53 #define LCD_LED GPIO_PIN_15 //PC15--->>TFT --BL
54 #define LCD_RS GPIO_PIN_1 //PA1--->>TFT --RS/DC
55 #define LCD_RST GPIO_PIN_2 //PA2--->>TFT --RST
56
57 //#define LCD_CS_SET(x) LCD_CTRL->ODR=(LCD_CTRL->ODR&~LCD_CS)|(x ? LCD_CS:0)
58
59 //液晶控制口置1操作语句宏定义
60 #define LCD_SCL_SET LCD_CTRLA->BSRR=LCD_SCL
61 #define LCD_SDA_SET LCD_CTRLA->BSRR=LCD_SDA
62 #define LCD_CS_SET LCD_CTRLA->BSRR=LCD_CS
63
64
65 #define LCD_LED_SET LCD_CTRLC->BSRR=LCD_LED
66 #define LCD_RS_SET LCD_CTRLA->BSRR=LCD_RS
67 #define LCD_RST_SET LCD_CTRLA->BSRR=LCD_RST
68 //液晶控制口置0操作语句宏定义
69 #define LCD_SCL_CLR LCD_CTRLA->BRR=LCD_SCL
70 #define LCD_SDA_CLR LCD_CTRLA->BRR=LCD_SDA
71 #define LCD_CS_CLR LCD_CTRLA->BRR=LCD_CS
72
73 #define LCD_LED_CLR LCD_CTRLC->BRR=LCD_LED
74 #define LCD_RST_CLR LCD_CTRLA->BRR=LCD_RST
75 #define LCD_RS_CLR LCD_CTRLA->BRR=LCD_RS
76
77 #define LCD_DATAOUT(x) LCD_DATA->ODR=x; //数据输出
78 #define LCD_DATAIN LCD_DATA->IDR; //数据输入
79
80 #define LCD_WR_DATA(data){\
81 LCD_RS_SET;\
82 LCD_CS_CLR;\
83 LCD_DATAOUT(data);\
84 LCD_WR_CLR;\
85 LCD_WR_SET;\
86 LCD_CS_SET;\
87 }
88
89 //竖屏
90 //#define X_MAX_PIXEL 128
91 //#define Y_MAX_PIXEL 160
92
93 //横屏
94 #define X_MAX_PIXEL 160
95 #define Y_MAX_PIXEL 128
96
97
98
99 void LCD_GPIO_Init(void);
100 void Lcd_WriteIndex(uint8_t Index);
101 void Lcd_WriteData(uint8_t Data);
102 void Lcd_WriteReg(uint8_t Index,uint8_t Data);
103 uint16_t Lcd_ReadReg(uint8_t LCD_Reg);
104 void Lcd_Reset(void);
105 void Lcd_Init(void);
106 void Lcd_Clear(uint16_t Color);
107 void Lcd_SetXY(uint16_t x,uint16_t y);
108 void Gui_DrawPoint(uint16_t x,uint16_t y,uint16_t Data);
109 uint32_t Lcd_ReadPoint(uint16_t x,uint16_t y);
110 void Lcd_SetRegion(uint16_t x_start,uint16_t y_start,uint16_t x_end,uint16_t y_end);
111 void LCD_WriteData_16Bit(uint16_t Data);
112 void Lcd_Part_Clear(uint8_t x1,uint8_t y1,uint8_t x2,uint8_t y2,uint16_t Color);
113 void Set_Lcd_Brightness(uint8_t light);
114 extern uint8_t lcd_brightness;
115
116#endif
void Lcd_SetXY(uint16_t x, uint16_t y)
设置lcd显示起始点
定义 Lcd_Driver.c:300
void Lcd_Clear(uint16_t Color)
全屏清屏函数
定义 Lcd_Driver.c:346
void Lcd_WriteReg(uint8_t Index, uint8_t Data)
向液晶屏寄存器写数据
定义 Lcd_Driver.c:122
void Gui_DrawPoint(uint16_t x, uint16_t y, uint16_t Data)
画一个点
定义 Lcd_Driver.c:314
void Lcd_SetRegion(uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end)
设置lcd显示区域,在此区域写点数据自动换行
定义 Lcd_Driver.c:274
void LCD_WriteData_16Bit(uint16_t Data)
向SPI总线传输一个16位数据
定义 Lcd_Driver.c:106
void LCD_GPIO_Init(void)
初始化LCD屏幕的GPIO配置
定义 Lcd_Driver.c:31
uint8_t lcd_brightness
LCD屏幕亮度
定义 Lcd_Driver.c:24
void Set_Lcd_Brightness(uint8_t light)
设置LCD屏幕的亮度
定义 Lcd_Driver.c:386
uint32_t Lcd_ReadPoint(uint16_t x, uint16_t y)
读TFT某一点的颜色
定义 Lcd_Driver.c:329
void Lcd_WriteIndex(uint8_t Index)
向液晶屏写一个8位指令
定义 Lcd_Driver.c:77
void Lcd_Part_Clear(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint16_t Color)
部分区域清屏函数
定义 Lcd_Driver.c:368
void Lcd_Reset(void)
重置LCD屏幕
定义 Lcd_Driver.c:133
void Lcd_WriteData(uint8_t Data)
向液晶屏写一个8位数据
定义 Lcd_Driver.c:92
void Lcd_Init(void)
LCD屏幕初始化
定义 Lcd_Driver.c:147