-
Notifications
You must be signed in to change notification settings - Fork 3
/
ui.c
398 lines (335 loc) · 11.4 KB
/
ui.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
// #include "version.h"
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "ql_rtos.h"
#include "ql_power.h"
#include "ql_fs.h"
#include "general_include.h"
#include "lcd.h"
#include "font.h"
#include "ui.h"
#include "charging.h"
#include "analog_view.h"
#define STATE_ICON_MARGIN_RIGHT 3
#define TIME_DIS_POS_OFF 22
#ifdef LANGUAGE_SETTING_CH
#define WEEK_DIS_POS_OFF 73
#endif
#ifdef LANGUAGE_SETTING_EN
#define WEEK_DIS_POS_OFF 70
#endif
#ifdef LANGUAGE_SETTING_TU
#define WEEK_DIS_POS_OFF 70
#endif
#define TIME_DIS_POS_Y 97 /*-5*/
#define UI_POC_NET_MODE_UNKNOW 0
#define UI_POC_NET_MODE_4G 1
#define UI_POC_NET_MODE_3G 2
#define UI_POC_NET_MODE_2G 3
#if DEBUG_EN
#if DEBUG_TO_USB
#define _DEBUG(fmtString, ...) CPUartLogPrintf(fmtString, ##__VA_ARGS__)
#else
#define _DEBUG(fmtString, ...) printf(fmtString, ##__VA_ARGS__)
#endif
#else
#define _DEBUG(fmtString, ...)
#endif
stUiPar iUiPar;
void ui_init(void)
{
}
unsigned char ui_ascii_to_char(unsigned char nib_h, unsigned char nib_l)
{
nib_h = (nib_h <= '9') ? (nib_h - 0x30) : ((nib_h <= 'F') ? (nib_h - 0x37) : (nib_h - 0x57));
nib_l = (nib_l <= '9') ? (nib_l - 0x30) : ((nib_l <= 'F') ? (nib_l - 0x37) : (nib_l - 0x57));
return ((nib_h << 4) | nib_l);
}
void ui_disp_icon_signal(unsigned char ucCsq)
{
if (ucCsq < 32)
{
lcd_disp_tan(2, 3, 12, 3, 7, 9, 1, COLOR_NET_ICO_FONT);
lcd_disp_LineH(6, 8, 6, 2, COLOR_NET_ICO_FONT);
lcd_disp_LineH(9, 9, 5, 2, COLOR_NET_ICO_BACKGROUND);
lcd_disp_LineH(13, 7, 7, 2, COLOR_NET_ICO_BACKGROUND);
lcd_disp_LineH(17, 5, 9, 2, COLOR_NET_ICO_BACKGROUND);
lcd_disp_LineH(21, 3, 11, 2, COLOR_NET_ICO_BACKGROUND);
if (ucCsq > 3)
lcd_disp_LineH(9, 9, 5, 2, COLOR_NET_ICO_FONT);
if (ucCsq > 12)
lcd_disp_LineH(13, 7, 7, 2, COLOR_NET_ICO_FONT);
if (ucCsq > 16)
lcd_disp_LineH(17, 5, 9, 2, COLOR_NET_ICO_FONT);
if (ucCsq > 24)
lcd_disp_LineH(21, 3, 11, 2, COLOR_NET_ICO_FONT);
}
}
void ui_disp_icon_bat(unsigned short usVal, E_BAT_CHARG_TYPE eCha)
{
unsigned short usColor = COLOR_NET_ICO_FONT;
unsigned short usCharCol;
if (usVal <= 2)
usColor = COLOR_RED;
if (eCha == E_BAT_CHARGING)
usCharCol = COLOR_RED;
else if (eCha == E_BAT_CHAR_TRE)
usCharCol = COLOR_GREEN;
else
usCharCol = usColor;
lcd_disp_range((LCD_WIDTH - 20) - STATE_ICON_MARGIN_RIGHT, 2, 18, 12, 1, usCharCol);
lcd_disp_box((LCD_WIDTH - 2) - STATE_ICON_MARGIN_RIGHT, 2, usCharCol, 1, 12);
lcd_disp_box((LCD_WIDTH - 1) - STATE_ICON_MARGIN_RIGHT, 6, usCharCol, 1, 4);
lcd_disp_box((LCD_WIDTH - 18) - STATE_ICON_MARGIN_RIGHT, 4, COLOR_NET_ICO_BACKGROUND, 15, 8);
if (usVal >= 3)
lcd_disp_box((LCD_WIDTH - 18) - STATE_ICON_MARGIN_RIGHT, 4, usColor, 2, 8);
if (usVal >= 5)
lcd_disp_box((LCD_WIDTH - 15) - STATE_ICON_MARGIN_RIGHT, 4, usColor, 2, 8);
if (usVal >= 7)
lcd_disp_box((LCD_WIDTH - 12) - STATE_ICON_MARGIN_RIGHT, 4, usColor, 2, 8);
if (usVal >= 9)
lcd_disp_box((LCD_WIDTH - 9) - STATE_ICON_MARGIN_RIGHT, 4, usColor, 2, 8);
if (usVal >= 10)
lcd_disp_box((LCD_WIDTH - 6) - STATE_ICON_MARGIN_RIGHT, 4, usColor, 2, 8);
}
void ui_disp_icon_net_status(unsigned char ucNetMode)
{
switch (ucNetMode)
{
case 0:
lcd_disp_bit1bmp_SingleByte(26, 4, (unsigned char *)(bmpNetMode[0]), 12, 8, COLOR_NET_ICO_FONT, COLOR_NET_ICO_BACKGROUND);
break;
case 1:
ui_disp_ascii_str_11x12(26, 3, "2G", COLOR_NET_ICO_BACKGROUND, COLOR_NET_ICO_FONT);
break;
case 2:
ui_disp_ascii_str_11x12(26, 3, "3G", COLOR_NET_ICO_BACKGROUND, COLOR_NET_ICO_FONT);
break;
case 3:
ui_disp_ascii_str_11x12(26, 3, "4G", COLOR_NET_ICO_BACKGROUND, COLOR_NET_ICO_FONT);
break;
}
}
void ui_disp_icon_mute(unsigned char ucMute)
{
char cVol[2];
cVol[0] = 'x';
cVol[1] = 0;
if (ucMute)
{
lcd_disp_bit1bmp_SingleByte((LCD_WIDTH - 40), 2, (unsigned char *)bmpMute, 12, 12, COLOR_RED, COLOR_NET_BACKGROUND);
lcd_disp_box((LCD_WIDTH - 35), 2, COLOR_NET_BACKGROUND, 8, 12);
ui_disp_ascii_str_11x12((LCD_WIDTH - 33), 1, cVol, COLOR_NET_BACKGROUND, COLOR_RED);
}
else
lcd_disp_box((LCD_WIDTH - 40), 2, COLOR_NET_ICO_BACKGROUND, 12, 12);
}
void ui_disp_icon_vol(unsigned char ucLvl)
{
char cVol[2];
cVol[0] = ucLvl + '1';
cVol[1] = 0;
lcd_disp_bit1bmp_SingleByte((LCD_WIDTH - 40), 2, (unsigned char *)bmpMute, 12, 12, COLOR_NET_ICO_FONT, COLOR_NET_ICO_BACKGROUND);
lcd_disp_box((LCD_WIDTH - 34), 2, COLOR_NET_ICO_BACKGROUND, 8, 12);
ui_disp_ascii_str_11x12((LCD_WIDTH - 32), 2, cVol, COLOR_NET_BACKGROUND, COLOR_NET_ICO_FONT);
}
void ui_disp_icon_gps(unsigned char ucEnable, unsigned char ucState)
{
if ((ucEnable == 0x00) || (ucEnable == 0x30))
{
lcd_disp_bit1bmp_SingleByte(44, 3, (unsigned char *)bmpGpsSta, 12, 12, COLOR_NET_ICO_BACKGROUND, COLOR_NET_ICO_BACKGROUND);
}
else if (ucState == '1' || ucState == '2')
{
lcd_disp_bit1bmp_SingleByte(44, 3, (unsigned char *)bmpGpsSta, 12, 12, COLOR_NET_ICO_FONT, COLOR_NET_ICO_BACKGROUND);
}
else if (ucEnable == 0x31 || ucEnable == 0x01)
{
if (iRunPar.iGpsInfo.cLocSta != 0xff)
lcd_disp_bit1bmp_SingleByte(44, 3, (unsigned char *)bmpGpsSta, 12, 12, COLOR_RED, COLOR_NET_ICO_BACKGROUND);
else
lcd_disp_bit1bmp_SingleByte(44, 3, (unsigned char *)bmpGpsSta, 12, 12, COLOR_NET_ICO_BACKGROUND, COLOR_NET_ICO_BACKGROUND);
}
}
void ui_disp_icon_time(stTime *pTime)
{
char cDate[11];
sprintf(cDate, "%02d:%02d", pTime->ucHour, pTime->ucMint);
ui_disp_ascii_str_11x12(52, 2, cDate, COLOR_NET_ICO_BACKGROUND, COLOR_NET_ICO_FONT);
}
void ui_disp_srceen_time(stTime *pTime)
{
lcd_disp_bit1bmp_SingleByte(30 + 16, 34, (unsigned char *)bmpNum[pTime->ucHour / 10], 12, 24, COLOR_NET_ICO_FONT, COLOR_NET_BACKGROUND);
lcd_disp_bit1bmp_SingleByte(44 + 16, 34, (unsigned char *)bmpNum[pTime->ucHour % 10], 12, 24, COLOR_NET_ICO_FONT, COLOR_NET_BACKGROUND);
lcd_disp_bit1bmp_SingleByte(56 + 16, 34, (unsigned char *)bmpNum[10], 12, 24, COLOR_NET_ICO_FONT, COLOR_NET_BACKGROUND);
lcd_disp_bit1bmp_SingleByte(70 + 16, 34, (unsigned char *)bmpNum[pTime->ucMint / 10], 12, 24, COLOR_NET_ICO_FONT, COLOR_NET_BACKGROUND);
lcd_disp_bit1bmp_SingleByte(84 + 16, 34, (unsigned char *)bmpNum[pTime->ucMint % 10], 12, 24, COLOR_NET_ICO_FONT, COLOR_NET_BACKGROUND);
}
int ui_get_font_disp_pixel(char *pUnicodeStr, enFontType font, euFontEds eds)
{
unsigned short usUnicode;
int iPixel = 0;
if (strlen((char *)pUnicodeStr) % 4 != 0)
{
_DEBUG("ui16 invalid length!!\r\n");
return 0;
}
while (*pUnicodeStr)
{
if (eds == UI_FONT_BIG_EDS)
usUnicode = ((unsigned short)(ui_ascii_to_char(*pUnicodeStr, *(pUnicodeStr + 1))) << 8) + ui_ascii_to_char(*(pUnicodeStr + 2), *(pUnicodeStr + 3));
else
usUnicode = ((unsigned short)(ui_ascii_to_char(*(pUnicodeStr + 2), *(pUnicodeStr + 3))) << 8) + ui_ascii_to_char(*(pUnicodeStr), *(pUnicodeStr + 1));
if (usUnicode <= 0x007e)
{
if (font == PTT_FONT_TYPE_16)
iPixel += 8;
else
iPixel += 6;
}
else
{
if (font == PTT_FONT_TYPE_16)
iPixel += 16;
else
iPixel += 12;
}
pUnicodeStr += 4;
}
return iPixel;
}
void ui_disp_font_15x16(unsigned short x, unsigned short y, const char *pUnicodeStr, unsigned short usBkColor, unsigned short usColor)
{
unsigned short usUnicode, i = 0;
unsigned char ucMapDat[32];
if (strlen((char *)pUnicodeStr) % 2 != 0)
{
_DEBUG("ui16 invalid length!!\r\n");
return;
}
while (*pUnicodeStr)
{
usUnicode = ((unsigned short)(ui_ascii_to_char(*pUnicodeStr, *(pUnicodeStr + 1))) << 8) + ui_ascii_to_char(*(pUnicodeStr + 2), *(pUnicodeStr + 3));
if (0 == font_get_data(usUnicode, PTT_FONT_TYPE_16, ucMapDat))
{
if (usUnicode <= 0x007e)
{
lcd_disp_bit1bmp_SingleByte(x + i * 8, y, ucMapDat, 8, 8, usColor, usBkColor);
lcd_disp_bit1bmp_SingleByte(x + i * 8, y + 8, &ucMapDat[8], 8, 8, usColor, usBkColor);
}
else
{
lcd_disp_bit1bmp_SingleByte(x + i * 8, y, ucMapDat, 16, 8, usColor, usBkColor);
lcd_disp_bit1bmp_SingleByte(x + i * 8, y + 8, &ucMapDat[16], 16, 8, usColor, usBkColor);
i++;
}
}
i++;
pUnicodeStr += 4;
}
}
void ui_disp_font_11x12(DISPLAY_TYPE display_type, unsigned short x, unsigned short y, const char *pStr, unsigned short usBkColor,
unsigned short usColor, euFontEds iEds, euCodeType iCodeType)
{
unsigned short single_data_size = 3;
unsigned short data_len = 0;
unsigned short usUnicode, i = 0;
unsigned char ucMapDat[32];
if (iCodeType == UI_MENU_CODE_ASCII)
{
while (*pStr)
{
usUnicode = *pStr;
if (0 == font_get_data(usUnicode, PTT_FONT_TYPE_12, ucMapDat))
{
if (usUnicode <= 0x007e)
{
lcd_disp_bit1bmp_SingleByte(x + i * 6, y, ucMapDat, 6, 8, usColor, usBkColor);
lcd_disp_bit1bmp_SingleByte(x + i * 6, y + 8, &ucMapDat[6], 6, 4, usColor, usBkColor);
}
}
i++;
pStr++;
}
}
else
{
if (strlen((char *)pStr) % 2 != 0)
{
_DEBUG("ui12 invalid length!!\r\n");
return;
}
data_len = strlen((char *)pStr);
if (display_type == display_middle) //居中
{
x = (LCD_WIDTH - x - single_data_size * data_len) / 2;
}
else //居右和自定义
{
x = x;
}
while (*pStr)
{
if (iEds == UI_FONT_BIG_EDS)
usUnicode = ((unsigned short)(ui_ascii_to_char(*pStr, *(pStr + 1))) << 8) + ui_ascii_to_char(*(pStr + 2), *(pStr + 3));
else
usUnicode = ((unsigned short)(ui_ascii_to_char(*(pStr + 2), *(pStr + 3))) << 8) + ui_ascii_to_char(*(pStr), *(pStr + 1));
if (0 == font_get_data(usUnicode, PTT_FONT_TYPE_12, ucMapDat))
{
if (usUnicode <= 0x007e)
{
lcd_disp_bit1bmp_SingleByte(x + i * 6, y, ucMapDat, 6, 8, usColor, usBkColor);
lcd_disp_bit1bmp_SingleByte(x + i * 6, y + 8, &ucMapDat[6], 6, 4, usColor, usBkColor);
}
else
{
lcd_disp_bit1bmp_SingleByte(x + i * 6, y, ucMapDat, 12, 8, usColor, usBkColor);
lcd_disp_bit1bmp_SingleByte(x + i * 6, y + 8, &ucMapDat[12], 12, 4, usColor, usBkColor);
i++;
}
}
i++;
pStr += 4;
}
}
}
void ui_disp_ascii_str_11x12(unsigned short x, unsigned short y, char *pAscii, unsigned short usBkColor, unsigned short usColor)
{
unsigned short usUnicode, i = 0;
unsigned char ucMapDat[32];
while (*pAscii)
{
usUnicode = *pAscii;
if (0 == font_get_data(usUnicode, PTT_FONT_TYPE_12, ucMapDat))
{
if (usUnicode <= 0x007e)
{
lcd_disp_bit1bmp_SingleByte(x + i * 6, y, ucMapDat, 6, 8, usColor, usBkColor);
lcd_disp_bit1bmp_SingleByte(x + i * 6, y + 8, &ucMapDat[6], 6, 4, usColor, usBkColor);
}
}
i++;
pAscii++;
}
}
void ui_dips_clean_a_line(unsigned short x, unsigned short y, unsigned short usColor)
{
ui_disp_ascii_str_11x12(x, y, " ", usColor, usColor);
}
void ui_disp_date(stTime *pTime)
{
char cDate[11];
sprintf(cDate, "%d-", pTime->iYear);
ui_disp_ascii_str_11x12(0 + 16 + TIME_DIS_POS_OFF, TIME_DIS_POS_Y, (char *)cDate, COLOR_NET_BACKGROUND, COLOR_FONT);
sprintf(cDate, "%02d", pTime->iMonth);
ui_disp_ascii_str_11x12(32 + 16 + TIME_DIS_POS_OFF, TIME_DIS_POS_Y, (char *)cDate, COLOR_NET_BACKGROUND, COLOR_FONT);
ui_disp_ascii_str_11x12(44 + 16 + TIME_DIS_POS_OFF, TIME_DIS_POS_Y, "-", COLOR_NET_BACKGROUND, COLOR_FONT);
sprintf(cDate, "%02d", pTime->iMDay);
ui_disp_ascii_str_11x12(52 + 16 + TIME_DIS_POS_OFF, TIME_DIS_POS_Y, (char *)cDate, COLOR_NET_BACKGROUND, COLOR_FONT);
ui_disp_ascii_str_11x12(64 + 16 + TIME_DIS_POS_OFF, TIME_DIS_POS_Y, "(", COLOR_NET_BACKGROUND, COLOR_FONT);
ui_disp_font_11x12(display_left, 70 + 16 + TIME_DIS_POS_OFF, TIME_DIS_POS_Y, ucWeek[pTime->iWDay], COLOR_NET_BACKGROUND, COLOR_FONT, UI_FONT_BIG_EDS, UI_MENU_CODE_UNICODE);
ui_disp_ascii_str_11x12(82 + 16 + TIME_DIS_POS_OFF, TIME_DIS_POS_Y, ")", COLOR_NET_BACKGROUND, COLOR_FONT);
}