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
37
38
41
42
45
46
50
51
54
57
58
59
62
63
66
67
68
69
70
73
76
77
78
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
100
101
102
105
106
109
110
111
114
115
116
121
122
123
124
125
126
127
128
129
130
131
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
206
207
208
209
210
214
215
216
217
218
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
246
247
248
265
266
270
271
272
273
274
275
276
277
278
284
285
289
290
291
292
293
294
295
300
301
302
303
304
305
306
313
314
315
316
321
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
367
368
369
375
376
377
378
379
380
381
382
393
394
395
396
401
402
403
407
408
409
410
411
412
413
414
415
420
421
422
423
424
425
426
427
428
429
430
431
440
441
442
448
449
450
451
452
453
454
455
456
460
461
462
463
464
465
466
467
472
473
474
475
478
479
482
483
486
487
490
491
494
/* ... */
#include <stdio.h>
#include "lcd_log.h"
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
#define YWINDOW_MIN 4
/* ... */
/* ... */
/* ... */
LCD_LOG_line LCD_CacheBuffer [LCD_CACHE_DEPTH];
uint32_t LCD_LineColor;
uint16_t LCD_CacheBuffer_xptr;
uint16_t LCD_CacheBuffer_yptr_top;
uint16_t LCD_CacheBuffer_yptr_bottom;
uint16_t LCD_CacheBuffer_yptr_top_bak;
uint16_t LCD_CacheBuffer_yptr_bottom_bak;
FunctionalState LCD_CacheBuffer_yptr_invert;
FunctionalState LCD_ScrollActive;
FunctionalState LCD_Lock;
FunctionalState LCD_Scrolled;
uint16_t LCD_ScrollBackStep;
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
void LCD_LOG_Init ( void)
{
LCD_LOG_DeInit();
BSP_LCD_Clear(LCD_LOG_BACKGROUND_COLOR);
}{ ... }
/* ... */
void LCD_LOG_DeInit(void)
{
LCD_LineColor = LCD_LOG_TEXT_COLOR;
LCD_CacheBuffer_xptr = 0;
LCD_CacheBuffer_yptr_top = 0;
LCD_CacheBuffer_yptr_bottom = 0;
LCD_CacheBuffer_yptr_top_bak = 0;
LCD_CacheBuffer_yptr_bottom_bak = 0;
LCD_CacheBuffer_yptr_invert= ENABLE;
LCD_ScrollActive = DISABLE;
LCD_Lock = DISABLE;
LCD_Scrolled = DISABLE;
LCD_ScrollBackStep = 0;
}{ ... }
/* ... */
void LCD_LOG_SetHeader (uint8_t *header)
{
BSP_LCD_SetFont (&LCD_LOG_HEADER_FONT);
BSP_LCD_SetTextColor(LCD_LOG_SOLID_BACKGROUND_COLOR);
BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), LCD_LOG_HEADER_FONT.Height * 3);
BSP_LCD_SetTextColor(LCD_LOG_SOLID_TEXT_COLOR);
BSP_LCD_SetBackColor(LCD_LOG_SOLID_BACKGROUND_COLOR);
BSP_LCD_DisplayStringAt(0, LCD_LOG_HEADER_FONT.Height, header, CENTER_MODE);
BSP_LCD_SetBackColor(LCD_LOG_BACKGROUND_COLOR);
BSP_LCD_SetTextColor(LCD_LOG_TEXT_COLOR);
BSP_LCD_SetFont (&LCD_LOG_TEXT_FONT);
}{ ... }
/* ... */
void LCD_LOG_SetFooter(uint8_t *footer)
{
BSP_LCD_SetFont (&LCD_LOG_FOOTER_FONT);
BSP_LCD_SetTextColor(LCD_LOG_SOLID_BACKGROUND_COLOR);
BSP_LCD_FillRect(0, BSP_LCD_GetYSize() - LCD_LOG_FOOTER_FONT.Height - 4, BSP_LCD_GetXSize(), LCD_LOG_FOOTER_FONT.Height + 4);
BSP_LCD_SetTextColor(LCD_LOG_SOLID_TEXT_COLOR);
BSP_LCD_SetBackColor(LCD_LOG_SOLID_BACKGROUND_COLOR);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - LCD_LOG_FOOTER_FONT.Height, footer, CENTER_MODE);
BSP_LCD_SetBackColor(LCD_LOG_BACKGROUND_COLOR);
BSP_LCD_SetTextColor(LCD_LOG_TEXT_COLOR);
BSP_LCD_SetFont (&LCD_LOG_TEXT_FONT);
}{ ... }
/* ... */
void LCD_LOG_ClearTextZone(void)
{
uint8_t i=0;
for (i= 0 ; i < YWINDOW_SIZE; i++)
{
BSP_LCD_ClearStringLine(i + YWINDOW_MIN);
}for (i= 0 ; i < YWINDOW_SIZE; i++) { ... }
LCD_LOG_DeInit();
}{ ... }
/* ... */
LCD_LOG_PUTCHAR
{
sFONT *cFont = BSP_LCD_GetFont();
uint32_t idx;
if(LCD_Lock == DISABLE)
{
if(LCD_ScrollActive == ENABLE)
{
LCD_CacheBuffer_yptr_bottom = LCD_CacheBuffer_yptr_bottom_bak;
LCD_CacheBuffer_yptr_top = LCD_CacheBuffer_yptr_top_bak;
LCD_ScrollActive = DISABLE;
LCD_Scrolled = DISABLE;
LCD_ScrollBackStep = 0;
}if (LCD_ScrollActive == ENABLE) { ... }
if(( LCD_CacheBuffer_xptr < (BSP_LCD_GetXSize()) /cFont->Width ) && ( ch != '\n'))
{
LCD_CacheBuffer[LCD_CacheBuffer_yptr_bottom].line[LCD_CacheBuffer_xptr++] = (uint16_t)ch;
}if (( LCD_CacheBuffer_xptr < (BSP_LCD_GetXSize()) /cFont->Width ) && ( ch != '\n')) { ... }
else
{
if(LCD_CacheBuffer_yptr_top >= LCD_CacheBuffer_yptr_bottom)
{
if(LCD_CacheBuffer_yptr_invert == DISABLE)
{
LCD_CacheBuffer_yptr_top++;
if(LCD_CacheBuffer_yptr_top == LCD_CACHE_DEPTH)
{
LCD_CacheBuffer_yptr_top = 0;
}if (LCD_CacheBuffer_yptr_top == LCD_CACHE_DEPTH) { ... }
}if (LCD_CacheBuffer_yptr_invert == DISABLE) { ... }
else
{
LCD_CacheBuffer_yptr_invert= DISABLE;
}else { ... }
}if (LCD_CacheBuffer_yptr_top >= LCD_CacheBuffer_yptr_bottom) { ... }
for(idx = LCD_CacheBuffer_xptr ; idx < (BSP_LCD_GetXSize()) /cFont->Width; idx++)
{
LCD_CacheBuffer[LCD_CacheBuffer_yptr_bottom].line[LCD_CacheBuffer_xptr++] = ' ';
}for (idx = LCD_CacheBuffer_xptr ; idx < (BSP_LCD_GetXSize()) /cFont->Width; idx++) { ... }
LCD_CacheBuffer[LCD_CacheBuffer_yptr_bottom].color = LCD_LineColor;
LCD_CacheBuffer_xptr = 0;
LCD_LOG_UpdateDisplay ();
LCD_CacheBuffer_yptr_bottom ++;
if (LCD_CacheBuffer_yptr_bottom == LCD_CACHE_DEPTH)
{
LCD_CacheBuffer_yptr_bottom = 0;
LCD_CacheBuffer_yptr_top = 1;
LCD_CacheBuffer_yptr_invert = ENABLE;
}if (LCD_CacheBuffer_yptr_bottom == LCD_CACHE_DEPTH) { ... }
if( ch != '\n')
{
LCD_CacheBuffer[LCD_CacheBuffer_yptr_bottom].line[LCD_CacheBuffer_xptr++] = (uint16_t)ch;
}if (ch != '\n') { ... }
}else { ... }
}if (LCD_Lock == DISABLE) { ... }
return ch;
...}
/* ... */
void LCD_LOG_UpdateDisplay (void)
{
uint8_t cnt = 0 ;
uint16_t length = 0 ;
uint16_t ptr = 0, index = 0;
if((LCD_CacheBuffer_yptr_bottom < (YWINDOW_SIZE -1)) &&
(LCD_CacheBuffer_yptr_bottom >= LCD_CacheBuffer_yptr_top))
{
BSP_LCD_SetTextColor(LCD_CacheBuffer[cnt + LCD_CacheBuffer_yptr_bottom].color);
BSP_LCD_DisplayStringAtLine ((YWINDOW_MIN + LCD_CacheBuffer_yptr_bottom),
(uint8_t *)(LCD_CacheBuffer[cnt + LCD_CacheBuffer_yptr_bottom].line));
}if ((LCD_CacheBuffer_yptr_bottom < (YWINDOW_SIZE -1)) && (LCD_CacheBuffer_yptr_bottom >= LCD_CacheBuffer_yptr_top)) { ... }
else
{
if(LCD_CacheBuffer_yptr_bottom < LCD_CacheBuffer_yptr_top)
{
length = LCD_CACHE_DEPTH + LCD_CacheBuffer_yptr_bottom ;
}if (LCD_CacheBuffer_yptr_bottom < LCD_CacheBuffer_yptr_top) { ... }
else
{
length = LCD_CacheBuffer_yptr_bottom;
}else { ... }
ptr = length - YWINDOW_SIZE + 1;
for (cnt = 0 ; cnt < YWINDOW_SIZE ; cnt ++)
{
index = (cnt + ptr )% LCD_CACHE_DEPTH ;
BSP_LCD_SetTextColor(LCD_CacheBuffer[index].color);
BSP_LCD_DisplayStringAtLine ((cnt + YWINDOW_MIN),
(uint8_t *)(LCD_CacheBuffer[index].line));
}for (cnt = 0 ; cnt < YWINDOW_SIZE ; cnt ++) { ... }
}else { ... }
}{ ... }
#if( LCD_SCROLL_ENABLED == 1)
/* ... */
ErrorStatus LCD_LOG_ScrollBack(void)
{
if(LCD_ScrollActive == DISABLE)
{
LCD_CacheBuffer_yptr_bottom_bak = LCD_CacheBuffer_yptr_bottom;
LCD_CacheBuffer_yptr_top_bak = LCD_CacheBuffer_yptr_top;
if(LCD_CacheBuffer_yptr_bottom > LCD_CacheBuffer_yptr_top)
{
if ((LCD_CacheBuffer_yptr_bottom - LCD_CacheBuffer_yptr_top) <= YWINDOW_SIZE)
{
LCD_Lock = DISABLE;
return ERROR;
}if ((LCD_CacheBuffer_yptr_bottom - LCD_CacheBuffer_yptr_top) <= YWINDOW_SIZE) { ... }
}if (LCD_CacheBuffer_yptr_bottom > LCD_CacheBuffer_yptr_top) { ... }
LCD_ScrollActive = ENABLE;
if((LCD_CacheBuffer_yptr_bottom > LCD_CacheBuffer_yptr_top)&&
(LCD_Scrolled == DISABLE ))
{
LCD_CacheBuffer_yptr_bottom--;
LCD_Scrolled = ENABLE;
}if ((LCD_CacheBuffer_yptr_bottom > LCD_CacheBuffer_yptr_top)&& (LCD_Scrolled == DISABLE )) { ... }
}if (LCD_ScrollActive == DISABLE) { ... }
if(LCD_ScrollActive == ENABLE)
{
LCD_Lock = ENABLE;
if(LCD_CacheBuffer_yptr_bottom > LCD_CacheBuffer_yptr_top)
{
if((LCD_CacheBuffer_yptr_bottom - LCD_CacheBuffer_yptr_top) < YWINDOW_SIZE )
{
LCD_Lock = DISABLE;
return ERROR;
}if ((LCD_CacheBuffer_yptr_bottom - LCD_CacheBuffer_yptr_top) < YWINDOW_SIZE) { ... }
LCD_CacheBuffer_yptr_bottom --;
}if (LCD_CacheBuffer_yptr_bottom > LCD_CacheBuffer_yptr_top) { ... }
else if(LCD_CacheBuffer_yptr_bottom <= LCD_CacheBuffer_yptr_top)
{
if((LCD_CACHE_DEPTH - LCD_CacheBuffer_yptr_top + LCD_CacheBuffer_yptr_bottom) < YWINDOW_SIZE)
{
LCD_Lock = DISABLE;
return ERROR;
}if ((LCD_CACHE_DEPTH - LCD_CacheBuffer_yptr_top + LCD_CacheBuffer_yptr_bottom) < YWINDOW_SIZE) { ... }
LCD_CacheBuffer_yptr_bottom --;
if(LCD_CacheBuffer_yptr_bottom == 0xFFFF)
{
LCD_CacheBuffer_yptr_bottom = LCD_CACHE_DEPTH - 2;
}if (LCD_CacheBuffer_yptr_bottom == 0xFFFF) { ... }
}else if (LCD_CacheBuffer_yptr_bottom <= LCD_CacheBuffer_yptr_top) { ... }
LCD_ScrollBackStep++;
LCD_LOG_UpdateDisplay();
LCD_Lock = DISABLE;
}if (LCD_ScrollActive == ENABLE) { ... }
return SUCCESS;
}{ ... }
/* ... */
ErrorStatus LCD_LOG_ScrollForward(void)
{
if(LCD_ScrollBackStep != 0)
{
if(LCD_ScrollActive == DISABLE)
{
LCD_CacheBuffer_yptr_bottom_bak = LCD_CacheBuffer_yptr_bottom;
LCD_CacheBuffer_yptr_top_bak = LCD_CacheBuffer_yptr_top;
if(LCD_CacheBuffer_yptr_bottom > LCD_CacheBuffer_yptr_top)
{
if ((LCD_CacheBuffer_yptr_bottom - LCD_CacheBuffer_yptr_top) <= YWINDOW_SIZE)
{
LCD_Lock = DISABLE;
return ERROR;
}if ((LCD_CacheBuffer_yptr_bottom - LCD_CacheBuffer_yptr_top) <= YWINDOW_SIZE) { ... }
}if (LCD_CacheBuffer_yptr_bottom > LCD_CacheBuffer_yptr_top) { ... }
LCD_ScrollActive = ENABLE;
if((LCD_CacheBuffer_yptr_bottom > LCD_CacheBuffer_yptr_top)&&
(LCD_Scrolled == DISABLE ))
{
LCD_CacheBuffer_yptr_bottom--;
LCD_Scrolled = ENABLE;
}if ((LCD_CacheBuffer_yptr_bottom > LCD_CacheBuffer_yptr_top)&& (LCD_Scrolled == DISABLE )) { ... }
}if (LCD_ScrollActive == DISABLE) { ... }
if(LCD_ScrollActive == ENABLE)
{
LCD_Lock = ENABLE;
LCD_ScrollBackStep--;
if(++LCD_CacheBuffer_yptr_bottom == LCD_CACHE_DEPTH)
{
LCD_CacheBuffer_yptr_bottom = 0;
}if (++LCD_CacheBuffer_yptr_bottom == LCD_CACHE_DEPTH) { ... }
LCD_LOG_UpdateDisplay();
LCD_Lock = DISABLE;
}if (LCD_ScrollActive == ENABLE) { ... }
return SUCCESS;
}if (LCD_ScrollBackStep != 0) { ... }
else
{
LCD_Lock = DISABLE;
return ERROR;
}else { ... }
}{ ... }
#endif/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
Includes