• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 FuZhou Lockzhiner Electronic Co., Ltd. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef _LCD_H_
16 #define _LCD_H_
17 
18 #include <stdint.h>
19 
20 /* 设置横屏或者竖屏显示 0或1为竖屏 2或3为横屏 */
21 #define USE_HORIZONTAL      0
22 
23 /* 根据LCD是横屏或者竖屏,设置LCD的宽度和高度 */
24 #if ((USE_HORIZONTAL==0) || (USE_HORIZONTAL==1))
25 #define LCD_W 240
26 #define LCD_H 320
27 #else
28 #define LCD_W 320
29 #define LCD_H 240
30 #endif
31 
32 /* 画笔颜色 */
33 #define LCD_WHITE           0xFFFF
34 #define LCD_BLACK           0x0000
35 #define LCD_BLUE            0x001F
36 #define LCD_BRED            0XF81F
37 #define LCD_GRED            0XFFE0
38 #define LCD_GBLUE           0X07FF
39 #define LCD_RED             0xF800
40 #define LCD_MAGENTA         0xF81F
41 #define LCD_GREEN           0x07E0
42 #define LCD_CYAN            0x7FFF
43 #define LCD_YELLOW          0xFFE0
44 #define LCD_BROWN           0XBC40 // 棕色
45 #define LCD_BRRED           0XFC07 // 棕红色
46 #define LCD_GRAY            0X8430 // 灰色
47 #define LCD_DARKBLUE        0X01CF // 深蓝色
48 #define LCD_LIGHTBLUE       0X7D7C // 浅蓝色
49 #define LCD_GRAYBLUE        0X5458 // 灰蓝色
50 #define LCD_LIGHTGREEN      0X841F // 浅绿色
51 #define LCD_LGRAY           0XC618 // 浅灰色(PANNEL),窗体背景色
52 #define LCD_LGRAYBLUE       0XA651 // 浅灰蓝色(中间层颜色)
53 #define LCD_LBBLUE          0X2B12 // 浅棕蓝色(选择条目的反色)
54 
55 /* 字体大小 */
56 #define LCD_FONT_SIZE12     12
57 #define LCD_FONT_SIZE16     16
58 #define LCD_FONT_SIZE24     24
59 #define LCD_FONT_SIZE32     32
60 
61 /***************************************************************
62  * 函数名称: lcd_init
63  * 说    明: Lcd初始化
64  * 参    数: 无
65  * 返 回 值: 返回0为成功,反之为失败
66  ***************************************************************/
67 unsigned int lcd_init(void);
68 
69 
70 /***************************************************************
71  * 函数名称: lcd_deinit
72  * 说    明: Lcd注销
73  * 参    数: 无
74  * 返 回 值: 返回0为成功,反之为失败
75  ***************************************************************/
76 unsigned int lcd_deinit(void);
77 
78 
79 /***************************************************************
80  * 函数名称: lcd_fill
81  * 说    明: 指定区域填充颜色
82  * 参    数:
83  *       @xsta:指定区域的起始点X坐标
84  *       @ysta:指定区域的起始点Y坐标
85  *       @xend:指定区域的结束点X坐标
86  *       @yend:指定区域的结束点Y坐标
87  *       @color:指定区域的颜色
88  * 返 回 值: 无
89  ***************************************************************/
90 void lcd_fill(uint16_t xsta, uint16_t ysta, uint16_t xend, uint16_t yend, uint16_t color);
91 
92 
93 /***************************************************************
94  * 函数名称: lcd_draw_point
95  * 说    明: 指定位置画一个点
96  * 参    数:
97  *       @x:指定点的X坐标
98  *       @y:指定点的Y坐标
99  *       @color:指定点的颜色
100  * 返 回 值: 无
101  ***************************************************************/
102 void lcd_draw_point(uint16_t x, uint16_t y, uint16_t color);
103 
104 
105 /***************************************************************
106  * 函数名称: lcd_draw_line
107  * 说    明: 指定位置画一条线
108  * 参    数:
109  *       @x1:指定线的起始点X坐标
110  *       @y1:指定线的起始点Y坐标
111  *       @x2:指定线的结束点X坐标
112  *       @y2:指定线的结束点Y坐标
113  *       @color:指定点的颜色
114  * 返 回 值: 无
115  ***************************************************************/
116 void lcd_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
117 
118 
119 /***************************************************************
120  * 函数名称: lcd_draw_rectangle
121  * 说    明: 指定位置画矩形
122  * 参    数:
123  *       @x1:指定矩形的起始点X坐标
124  *       @y1:指定矩形的起始点Y坐标
125  *       @x2:指定矩形的结束点X坐标
126  *       @y2:指定矩形的结束点Y坐标
127  *       @color:指定点的颜色
128  * 返 回 值: 无
129  ***************************************************************/
130 void lcd_draw_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
131 
132 
133 /***************************************************************
134  * 函数名称: lcd_draw_circle
135  * 说    明: 指定位置画圆
136  * 参    数:
137  *       @x0:指定圆的中心点X坐标
138  *       @y0:指定圆的中心点Y坐标
139  *       @r:指定圆的半径
140  *       @color:指定点的颜色
141  * 返 回 值: 无
142  ***************************************************************/
143 void lcd_draw_circle(uint16_t x0, uint16_t y0, uint8_t r, uint16_t color);
144 
145 
146 /***************************************************************
147  * 函数名称: lcd_show_chinese
148  * 说    明: 显示汉字串
149  * 参    数:
150  *       @x:指定汉字串的起始位置X坐标
151  *       @y:指定汉字串的起始位置X坐标
152  *       @s:指定汉字串(该汉字串为utf-8)
153  *       @fc: 字的颜色
154  *       @bc: 字的背景色
155  *       @sizey: 字号,可选:12、16、24、32
156  *       @mode: 0为非叠加模式;1为叠加模式
157  * 返 回 值: 无
158  ***************************************************************/
159 void lcd_show_chinese(uint16_t x, uint16_t y, uint8_t *s, uint16_t fc, uint16_t bc, uint8_t sizey, uint8_t mode);
160 
161 
162 /***************************************************************
163  * 函数名称: lcd_show_char
164  * 说    明: 显示一个字符
165  * 参    数:
166  *       @x:指定字符的起始位置X坐标
167  *       @y:指定字串的起始位置X坐标
168  *       @s:指定字串
169  *       @fc: 字的颜色
170  *       @bc: 字的背景色
171  *       @sizey: 字号,可选:12、16、24、32
172  *       @mode: 0为非叠加模式;1为叠加模式
173  * 返 回 值: 无
174  ***************************************************************/
175 void lcd_show_char(uint16_t x, uint16_t y, uint8_t num, uint16_t fc, uint16_t bc, uint8_t sizey, uint8_t mode);
176 
177 
178 /***************************************************************
179  * 函数名称: lcd_show_string
180  * 说    明: 显示字符串
181  * 参    数:
182  *       @x:指定字符的起始位置X坐标
183  *       @y:指定字串的起始位置X坐标
184  *       @s:指定字串
185  *       @fc: 字的颜色
186  *       @bc: 字的背景色
187  *       @sizey: 字号,可选:16、24、32
188  *       @mode: 0为非叠加模式;1为叠加模式
189  * 返 回 值: 无
190  ***************************************************************/
191 void lcd_show_string(uint16_t x, uint16_t y, const uint8_t *p, uint16_t fc, uint16_t bc, uint8_t sizey, uint8_t mode);
192 
193 
194 /***************************************************************
195  * 函数名称: lcd_show_int_num
196  * 说    明: 显示整数变量
197  * 参    数:
198  *       @x:指定整数变量的起始位置X坐标
199  *       @y:指定整数变量的起始位置X坐标
200  *       @num:指定整数变量
201  *       @fc: 整数变量的颜色
202  *       @bc: 整数变量的背景色
203  *       @sizey: 字号,可选:16、24、32
204  * 返 回 值: 无
205  ***************************************************************/
206 void lcd_show_int_num(uint16_t x, uint16_t y, uint16_t num, uint8_t len, uint16_t fc, uint16_t bc, uint8_t sizey);
207 
208 
209 /***************************************************************
210  * 函数名称: lcd_show_float_num1
211  * 说    明: 显示两位小数变量
212  * 参    数:
213  *       @x:指定浮点变量的起始位置X坐标
214  *       @y:指定浮点变量的起始位置X坐标
215  *       @num:指定浮点变量
216  *       @fc: 浮点变量的颜色
217  *       @bc: 浮点变量的背景色
218  *       @sizey: 字号,可选:16、24、32
219  * 返 回 值: 无
220  ***************************************************************/
221 void lcd_show_float_num1(uint16_t x, uint16_t y, float num, uint8_t len, uint16_t fc, uint16_t bc, uint8_t sizey);
222 
223 
224 /***************************************************************
225  * 函数名称: lcd_show_picture
226  * 说    明: 显示图片
227  * 参    数:
228  *       @x:指定图片的起始位置X坐标
229  *       @y:指定图片的起始位置X坐标
230  *       @length:指定图片的长度
231  *       @width:指定图片的宽度
232  *       @pic:指定图片的内容
233  * 返 回 值: 无
234  ***************************************************************/
235 void lcd_show_picture(uint16_t x, uint16_t y, uint16_t length, uint16_t width, const uint8_t *pic);
236 
237 
238 #endif /* _LCD_H_ */
239