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
54
57
58
61
62
65
66
69
70
71
72
75
76
79
80
81
84
85
88
89
90
91
94
95
98
102
106
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
147
151
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
181
186
187
191
195
196
200
204
205
209
213
214
218
222
223
227
231
232
236
240
241
245
249
250
254
258
259
263
264
265
266
267
268
269
270
271
272
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
308
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
360
361
362
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
393
394
400
401
402
403
404
408
409
410
411
412
418
425
426
432
448
449
455
471
472
479
480
481
482
483
484
485
486
487
488
489
490
491
495
500
501
502
506
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
541
542
543
544
545
546
553
554
555
556
557
558
559
560
561
562
563
564
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
605
610
611
612
613
614
619
620
621
622
623
627
628
629
630
637
638
639
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
667
668
669
670
671
672
678
679
680
681
682
683
684
685
686
687
688
689
690
691
695
696
697
698
699
700
701
702
703
704
705
706
707
717
718
725
734
735
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
761
762
767
771
776
777
778
779
780
781
782
783
788
789
790
791
792
793
794
795
796
797
798
799
803
807
808
809
813
817
818
819
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
876
877
878
879
880
881
884
888
889
892
896
897
898
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
949
950
951
954
955
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
993
994
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1049
1054
1055
1056
1060
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1096
1097
1098
1099
1100
1101
1104
1105
1108
1109
1112
1113
/* ... */
/* ... */
#include "stm32412g_discovery_lcd.h"
#include "../../../Utilities/Fonts/fonts.h"
#include "../../../Utilities/Fonts/font24.c"
#include "../../../Utilities/Fonts/font20.c"
#include "../../../Utilities/Fonts/font16.c"
#include "../../../Utilities/Fonts/font12.c"
#include "../../../Utilities/Fonts/font8.c"
7 includes
/* ... */
/* ... */
/* ... */
/* ... */
#define POLY_X(Z) ((int32_t)((Points + Z)->X))
#define POLY_Y(Z) ((int32_t)((Points + Z)->Y))
#define ABS(X) ((X) > 0 ? (X) : -(X))
/* ... */
/* ... */
LCD_DrawPropTypeDef DrawProp;
static LCD_DrvTypeDef *LcdDrv;
/* ... */
/* ... */
static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c);
static void SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3);
/* ... */
/* ... */
/* ... */
uint8_t BSP_LCD_Init(void)
{
return (BSP_LCD_InitEx(LCD_ORIENTATION_LANDSCAPE));
}{ ... }
/* ... */
uint8_t BSP_LCD_InitEx(uint32_t orientation)
{
uint8_t ret = LCD_ERROR;
DrawProp.BackColor = 0xFFFF;
DrawProp.pFont = &Font24;
DrawProp.TextColor = 0x0000;
BSP_LCD_MspInit();
HAL_GPIO_WritePin(LCD_BL_CTRL_GPIO_PORT, LCD_BL_CTRL_PIN, GPIO_PIN_SET);
HAL_GPIO_WritePin(LCD_RESET_GPIO_PORT, LCD_RESET_PIN, GPIO_PIN_RESET);
HAL_Delay(5);
HAL_GPIO_WritePin(LCD_RESET_GPIO_PORT, LCD_RESET_PIN, GPIO_PIN_SET);
HAL_Delay(10);
HAL_GPIO_WritePin(LCD_RESET_GPIO_PORT, LCD_RESET_PIN, GPIO_PIN_RESET);
HAL_Delay(20);
HAL_GPIO_WritePin(LCD_RESET_GPIO_PORT, LCD_RESET_PIN, GPIO_PIN_SET);
HAL_Delay(10);
if(ST7789H2_drv.ReadID() == ST7789H2_ID)
{
LcdDrv = &ST7789H2_drv;
LcdDrv->Init();
if(orientation == LCD_ORIENTATION_PORTRAIT)
{
ST7789H2_SetOrientation(ST7789H2_ORIENTATION_PORTRAIT);
}if (orientation == LCD_ORIENTATION_PORTRAIT) { ... }
else if(orientation == LCD_ORIENTATION_LANDSCAPE_ROT180)
{
ST7789H2_SetOrientation(ST7789H2_ORIENTATION_LANDSCAPE_ROT180);
}else if (orientation == LCD_ORIENTATION_LANDSCAPE_ROT180) { ... }
else
{
}else { ... }
BSP_LCD_SetFont(&LCD_DEFAULT_FONT);
ret = LCD_OK;
}if (ST7789H2_drv.ReadID() == ST7789H2_ID) { ... }
else if(ls016b8uy_drv.ReadID() == LS016B8UY_ID)
{
LcdDrv = &ls016b8uy_drv;
LcdDrv->Init();
BSP_LCD_SetFont(&LCD_DEFAULT_FONT);
ret = LCD_OK;
}else if (ls016b8uy_drv.ReadID() == LS016B8UY_ID) { ... }
return ret;
}{ ... }
/* ... */
uint8_t BSP_LCD_DeInit(void)
{
return LCD_OK;
}{ ... }
/* ... */
uint32_t BSP_LCD_GetXSize(void)
{
return(LcdDrv->GetLcdPixelWidth());
}{ ... }
/* ... */
uint32_t BSP_LCD_GetYSize(void)
{
return(LcdDrv->GetLcdPixelHeight());
}{ ... }
/* ... */
uint16_t BSP_LCD_GetTextColor(void)
{
return DrawProp.TextColor;
}{ ... }
/* ... */
uint16_t BSP_LCD_GetBackColor(void)
{
return DrawProp.BackColor;
}{ ... }
/* ... */
void BSP_LCD_SetTextColor(uint16_t Color)
{
DrawProp.TextColor = Color;
}{ ... }
/* ... */
void BSP_LCD_SetBackColor(uint16_t Color)
{
DrawProp.BackColor = Color;
}{ ... }
/* ... */
void BSP_LCD_SetFont(sFONT *fonts)
{
DrawProp.pFont = fonts;
}{ ... }
/* ... */
sFONT *BSP_LCD_GetFont(void)
{
return DrawProp.pFont;
}{ ... }
/* ... */
void BSP_LCD_Clear(uint16_t Color)
{
uint32_t counter = 0;
uint32_t y_size = 0;
uint32_t color_backup = DrawProp.TextColor;
DrawProp.TextColor = Color;
y_size = BSP_LCD_GetYSize();
for(counter = 0; counter < y_size; counter++)
{
BSP_LCD_DrawHLine(0, counter, BSP_LCD_GetXSize());
}for (counter = 0; counter < y_size; counter++) { ... }
DrawProp.TextColor = color_backup;
BSP_LCD_SetTextColor(DrawProp.TextColor);
}{ ... }
/* ... */
void BSP_LCD_ClearStringLine(uint16_t Line)
{
uint32_t color_backup = DrawProp.TextColor;
DrawProp.TextColor = DrawProp.BackColor;;
BSP_LCD_FillRect(0, (Line * DrawProp.pFont->Height), BSP_LCD_GetXSize(), DrawProp.pFont->Height);
DrawProp.TextColor = color_backup;
BSP_LCD_SetTextColor(DrawProp.TextColor);
}{ ... }
/* ... */
void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii)
{
DrawChar(Xpos, Ypos, &DrawProp.pFont->table[(Ascii-' ') *\
DrawProp.pFont->Height * ((DrawProp.pFont->Width + 7) / 8)]);
}{ ... }
/* ... */
void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Line_ModeTypdef Mode)
{
uint16_t refcolumn = 1, i = 0;
uint32_t size = 0, xsize = 0;
uint8_t *ptr = Text;
while (*ptr++) size ++ ;
xsize = (BSP_LCD_GetXSize()/DrawProp.pFont->Width);
switch (Mode)
{
case CENTER_MODE:
{
refcolumn = Xpos + ((xsize - size)* DrawProp.pFont->Width) / 2;
break;
...}case CENTER_MODE:
case LEFT_MODE:
{
refcolumn = Xpos;
break;
...}case LEFT_MODE:
case RIGHT_MODE:
{
refcolumn = - Xpos + ((xsize - size)*DrawProp.pFont->Width);
break;
...} case RIGHT_MODE:
default:
{
refcolumn = Xpos;
break;
...}default
}switch (Mode) { ... }
if ((refcolumn < 1) || (refcolumn >= 0x8000))
{
refcolumn = 1;
}if ((refcolumn < 1) || (refcolumn >= 0x8000)) { ... }
while ((*Text != 0) & (((BSP_LCD_GetXSize() - (i*DrawProp.pFont->Width)) & 0xFFFF) >= DrawProp.pFont->Width))
{
BSP_LCD_DisplayChar(refcolumn, Ypos, *Text);
refcolumn += DrawProp.pFont->Width;
Text++;
i++;
}while ((*Text != 0) & (((BSP_LCD_GetXSize() - (i*DrawProp.pFont->Width)) & 0xFFFF) >= DrawProp.pFont->Width)) { ... }
}{ ... }
/* ... */
void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *ptr)
{
BSP_LCD_DisplayStringAt(0, LINE(Line), ptr, LEFT_MODE);
}{ ... }
/* ... */
uint16_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos)
{
uint16_t ret = 0;
if(LcdDrv->ReadPixel != NULL)
{
ret = LcdDrv->ReadPixel(Xpos, Ypos);
}if (LcdDrv->ReadPixel != NULL) { ... }
return ret;
}{ ... }
/* ... */
void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGB_Code)
{
if(LcdDrv->WritePixel != NULL)
{
LcdDrv->WritePixel(Xpos, Ypos, RGB_Code);
}if (LcdDrv->WritePixel != NULL) { ... }
}{ ... }
/* ... */
void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length)
{
uint32_t index = 0;
if(LcdDrv->DrawHLine != NULL)
{
LcdDrv->DrawHLine(DrawProp.TextColor, Xpos, Ypos, Length);
}if (LcdDrv->DrawHLine != NULL) { ... }
else
{
for(index = 0; index < Length; index++)
{
BSP_LCD_DrawPixel((Xpos + index), Ypos, DrawProp.TextColor);
}for (index = 0; index < Length; index++) { ... }
}else { ... }
}{ ... }
/* ... */
void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length)
{
uint32_t index = 0;
if(LcdDrv->DrawVLine != NULL)
{
LcdDrv->DrawVLine(DrawProp.TextColor, Xpos, Ypos, Length);
}if (LcdDrv->DrawVLine != NULL) { ... }
else
{
for(index = 0; index < Length; index++)
{
BSP_LCD_DrawPixel(Xpos, Ypos + index, DrawProp.TextColor);
}for (index = 0; index < Length; index++) { ... }
}else { ... }
}{ ... }
/* ... */
void BSP_LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
{
int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0,
yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0,
curpixel = 0;
deltax = ABS(x2 - x1);
deltay = ABS(y2 - y1);
x = x1;
y = y1;
if (x2 >= x1)
{
xinc1 = 1;
xinc2 = 1;
...}
else
{
xinc1 = -1;
xinc2 = -1;
}else { ... }
if (y2 >= y1)
{
yinc1 = 1;
yinc2 = 1;
...}
else
{
yinc1 = -1;
yinc2 = -1;
}else { ... }
if (deltax >= deltay)
{
xinc1 = 0;
yinc2 = 0;
den = deltax;
num = deltax / 2;
numadd = deltay;
numpixels = deltax;
...}
else
{
xinc2 = 0;
yinc1 = 0;
den = deltay;
num = deltay / 2;
numadd = deltax;
numpixels = deltay;
}else { ... }
for (curpixel = 0; curpixel <= numpixels; curpixel++)
{
BSP_LCD_DrawPixel(x, y, DrawProp.TextColor);
num += numadd;
if (num >= den)
{
num -= den;
x += xinc1;
y += yinc1;
...}
x += xinc2;
y += yinc2;
}for (curpixel = 0; curpixel <= numpixels; curpixel++) { ... }
}{ ... }
/* ... */
void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
{
BSP_LCD_DrawHLine(Xpos, Ypos, Width);
BSP_LCD_DrawHLine(Xpos, (Ypos+ Height), Width);
BSP_LCD_DrawVLine(Xpos, Ypos, Height);
BSP_LCD_DrawVLine((Xpos + Width), Ypos, Height);
}{ ... }
/* ... */
void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius)
{
int32_t decision;
uint32_t current_x;
uint32_t current_y;
decision = 3 - (Radius << 1);
current_x = 0;
current_y = Radius;
while (current_x <= current_y)
{
BSP_LCD_DrawPixel((Xpos + current_x), (Ypos - current_y), DrawProp.TextColor);
BSP_LCD_DrawPixel((Xpos - current_x), (Ypos - current_y), DrawProp.TextColor);
BSP_LCD_DrawPixel((Xpos + current_y), (Ypos - current_x), DrawProp.TextColor);
BSP_LCD_DrawPixel((Xpos - current_y), (Ypos - current_x), DrawProp.TextColor);
BSP_LCD_DrawPixel((Xpos + current_x), (Ypos + current_y), DrawProp.TextColor);
BSP_LCD_DrawPixel((Xpos - current_x), (Ypos + current_y), DrawProp.TextColor);
BSP_LCD_DrawPixel((Xpos + current_y), (Ypos + current_x), DrawProp.TextColor);
BSP_LCD_DrawPixel((Xpos - current_y), (Ypos + current_x), DrawProp.TextColor);
BSP_LCD_SetFont(&LCD_DEFAULT_FONT);
if (decision < 0)
{
decision += (current_x << 2) + 6;
}if (decision < 0) { ... }
else
{
decision += ((current_x - current_y) << 2) + 10;
current_y--;
}else { ... }
current_x++;
}while (current_x <= current_y) { ... }
}{ ... }
/* ... */
void BSP_LCD_DrawPolygon(pPoint Points, uint16_t PointCount)
{
int16_t x = 0, y = 0;
if(PointCount < 2)
{
return;
}if (PointCount < 2) { ... }
BSP_LCD_DrawLine(Points->X, Points->Y, (Points+PointCount-1)->X, (Points+PointCount-1)->Y);
while(--PointCount)
{
x = Points->X;
y = Points->Y;
Points++;
BSP_LCD_DrawLine(x, y, Points->X, Points->Y);
}while (--PointCount) { ... }
}{ ... }
/* ... */
void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius)
{
int x = 0, y = -YRadius, err = 2-2*XRadius, e2;
float k = 0, rad1 = 0, rad2 = 0;
rad1 = XRadius;
rad2 = YRadius;
k = (float)(rad2/rad1);
do {
BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/k)), (Ypos+y), DrawProp.TextColor);
BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/k)), (Ypos+y), DrawProp.TextColor);
BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/k)), (Ypos-y), DrawProp.TextColor);
BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/k)), (Ypos-y), DrawProp.TextColor);
e2 = err;
if (e2 <= x) {
err += ++x*2+1;
if (-y == x && e2 <= y) e2 = 0;
}if (e2 <= x) { ... }
if (e2 > y) err += ++y*2+1;
...}
while (y <= 0);
}{ ... }
/* ... */
void BSP_LCD_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp)
{
uint32_t height = 0;
uint32_t width = 0;
width = pbmp[18] + (pbmp[19] << 8) + (pbmp[20] << 16) + (pbmp[21] << 24);
height = pbmp[22] + (pbmp[23] << 8) + (pbmp[24] << 16) + (pbmp[25] << 24);
SetDisplayWindow(Xpos, Ypos, width, height);
if(LcdDrv->DrawBitmap != NULL)
{
LcdDrv->DrawBitmap(Xpos, Ypos, pbmp);
}if (LcdDrv->DrawBitmap != NULL) { ... }
SetDisplayWindow(0, 0, BSP_LCD_GetXSize(), BSP_LCD_GetYSize());
}{ ... }
/* ... */
void BSP_LCD_DrawRGBImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata)
{
SetDisplayWindow(Xpos, Ypos, Xsize, Ysize);
if(LcdDrv->DrawRGBImage != NULL)
{
LcdDrv->DrawRGBImage(Xpos, Ypos, Xsize, Ysize, pdata);
}if (LcdDrv->DrawRGBImage != NULL) { ... }
SetDisplayWindow(0, 0, BSP_LCD_GetXSize(), BSP_LCD_GetYSize());
}{ ... }
/* ... */
void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
{
BSP_LCD_SetTextColor(DrawProp.TextColor);
do
{
BSP_LCD_DrawHLine(Xpos, Ypos++, Width);
...}
while(Height--);
}{ ... }
/* ... */
void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius)
{
int32_t decision;
uint32_t current_x;
uint32_t current_y;
decision = 3 - (Radius << 1);
current_x = 0;
current_y = Radius;
BSP_LCD_SetTextColor(DrawProp.TextColor);
while (current_x <= current_y)
{
if(current_y > 0)
{
BSP_LCD_DrawHLine(Xpos - current_y, Ypos + current_x, 2*current_y);
BSP_LCD_DrawHLine(Xpos - current_y, Ypos - current_x, 2*current_y);
}if (current_y > 0) { ... }
if(current_x > 0)
{
BSP_LCD_DrawHLine(Xpos - current_x, Ypos - current_y, 2*current_x);
BSP_LCD_DrawHLine(Xpos - current_x, Ypos + current_y, 2*current_x);
}if (current_x > 0) { ... }
if (decision < 0)
{
decision += (current_x << 2) + 6;
}if (decision < 0) { ... }
else
{
decision += ((current_x - current_y) << 2) + 10;
current_y--;
}else { ... }
current_x++;
}while (current_x <= current_y) { ... }
BSP_LCD_SetTextColor(DrawProp.TextColor);
BSP_LCD_DrawCircle(Xpos, Ypos, Radius);
}{ ... }
/* ... */
void BSP_LCD_FillPolygon(pPoint Points, uint16_t PointCount)
{
int16_t X = 0, Y = 0, X2 = 0, Y2 = 0, X_center = 0, Y_center = 0, X_first = 0, Y_first = 0, pixelX = 0, pixelY = 0, counter = 0;
uint16_t IMAGE_LEFT = 0, IMAGE_RIGHT = 0, IMAGE_TOP = 0, IMAGE_BOTTOM = 0;
IMAGE_LEFT = IMAGE_RIGHT = Points->X;
IMAGE_TOP= IMAGE_BOTTOM = Points->Y;
for(counter = 1; counter < PointCount; counter++)
{
pixelX = POLY_X(counter);
if(pixelX < IMAGE_LEFT)
{
IMAGE_LEFT = pixelX;
}if (pixelX < IMAGE_LEFT) { ... }
if(pixelX > IMAGE_RIGHT)
{
IMAGE_RIGHT = pixelX;
}if (pixelX > IMAGE_RIGHT) { ... }
pixelY = POLY_Y(counter);
if(pixelY < IMAGE_TOP)
{
IMAGE_TOP = pixelY;
}if (pixelY < IMAGE_TOP) { ... }
if(pixelY > IMAGE_BOTTOM)
{
IMAGE_BOTTOM = pixelY;
}if (pixelY > IMAGE_BOTTOM) { ... }
}for (counter = 1; counter < PointCount; counter++) { ... }
if(PointCount < 2)
{
return;
}if (PointCount < 2) { ... }
X_center = (IMAGE_LEFT + IMAGE_RIGHT)/2;
Y_center = (IMAGE_BOTTOM + IMAGE_TOP)/2;
X_first = Points->X;
Y_first = Points->Y;
while(--PointCount)
{
X = Points->X;
Y = Points->Y;
Points++;
X2 = Points->X;
Y2 = Points->Y;
FillTriangle(X, X2, X_center, Y, Y2, Y_center);
FillTriangle(X, X_center, X2, Y, Y_center, Y2);
FillTriangle(X_center, X2, X, Y_center, Y2, Y);
}while (--PointCount) { ... }
FillTriangle(X_first, X2, X_center, Y_first, Y2, Y_center);
FillTriangle(X_first, X_center, X2, Y_first, Y_center, Y2);
FillTriangle(X_center, X2, X_first, Y_center, Y2, Y_first);
}{ ... }
/* ... */
void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius)
{
int x = 0, y = -YRadius, err = 2-2*XRadius, e2;
float k = 0, rad1 = 0, rad2 = 0;
rad1 = XRadius;
rad2 = YRadius;
k = (float)(rad2/rad1);
do
{
BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/k)), (Ypos+y), (2*(uint16_t)(x/k) + 1));
BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/k)), (Ypos-y), (2*(uint16_t)(x/k) + 1));
e2 = err;
if (e2 <= x)
{
err += ++x*2+1;
if (-y == x && e2 <= y) e2 = 0;
}if (e2 <= x) { ... }
if (e2 > y) err += ++y*2+1;
...}
while (y <= 0);
}{ ... }
/* ... */
void BSP_LCD_DisplayOn(void)
{
LcdDrv->DisplayOn();
}{ ... }
/* ... */
void BSP_LCD_DisplayOff(void)
{
LcdDrv->DisplayOff();
}{ ... }
/* ... */
__weak void BSP_LCD_MspInit(void)
{
GPIO_InitTypeDef gpio_init_structure;
LCD_RESET_GPIO_CLK_ENABLE();
LCD_TE_GPIO_CLK_ENABLE();
LCD_BL_CTRL_GPIO_CLK_ENABLE();
gpio_init_structure.Pin = LCD_RESET_PIN;
gpio_init_structure.Pull = GPIO_NOPULL;
gpio_init_structure.Speed = GPIO_SPEED_FAST;
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
HAL_GPIO_Init(LCD_RESET_GPIO_PORT, &gpio_init_structure);
gpio_init_structure.Pin = LCD_TE_PIN;
gpio_init_structure.Mode = GPIO_MODE_INPUT;
HAL_GPIO_Init(LCD_TE_GPIO_PORT, &gpio_init_structure);
gpio_init_structure.Pin = LCD_BL_CTRL_PIN;
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
HAL_GPIO_Init(LCD_BL_CTRL_GPIO_PORT, &gpio_init_structure);
}{ ... }
/* ... */
__weak void BSP_LCD_MspDeInit(void)
{
GPIO_InitTypeDef gpio_init_structure;
gpio_init_structure.Pin = LCD_RESET_PIN;
HAL_GPIO_DeInit(LCD_RESET_GPIO_PORT, gpio_init_structure.Pin);
gpio_init_structure.Pin = LCD_TE_PIN;
HAL_GPIO_DeInit(LCD_TE_GPIO_PORT, gpio_init_structure.Pin);
gpio_init_structure.Pin = LCD_BL_CTRL_PIN;
HAL_GPIO_DeInit(LCD_BL_CTRL_GPIO_PORT, gpio_init_structure.Pin);
/* ... */
}{ ... }
/* ... */
/* ... */
static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c)
{
uint32_t i = 0, j = 0;
uint16_t height, width;
uint8_t offset;
uint8_t *pchar;
uint32_t line;
height = DrawProp.pFont->Height;
width = DrawProp.pFont->Width;
offset = 8 *((width + 7)/8) - width ;
for(i = 0; i < height; i++)
{
pchar = ((uint8_t *)c + (width + 7)/8 * i);
switch(((width + 7)/8))
{
case 1:
line = pchar[0];
break;
case 1:
case 2:
line = (pchar[0]<< 8) | pchar[1];
break;
case 2:
case 3:
default:
line = (pchar[0]<< 16) | (pchar[1]<< 8) | pchar[2];
break;default
}switch (((width + 7)/8)) { ... }
for (j = 0; j < width; j++)
{
if(line & (1 << (width- j + offset- 1)))
{
BSP_LCD_DrawPixel((Xpos + j), Ypos, DrawProp.TextColor);
}if (line & (1 << (width- j + offset- 1))) { ... }
else
{
BSP_LCD_DrawPixel((Xpos + j), Ypos, DrawProp.BackColor);
}else { ... }
}for (j = 0; j < width; j++) { ... }
Ypos++;
}for (i = 0; i < height; i++) { ... }
}{ ... }
/* ... */
static void SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
{
if(LcdDrv->SetDisplayWindow != NULL)
{
LcdDrv->SetDisplayWindow(Xpos, Ypos, Width, Height);
}if (LcdDrv->SetDisplayWindow != NULL) { ... }
}{ ... }
/* ... */
static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3)
{
int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0,
yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0,
curpixel = 0;
deltax = ABS(x2 - x1);
deltay = ABS(y2 - y1);
x = x1;
y = y1;
if (x2 >= x1)
{
xinc1 = 1;
xinc2 = 1;
...}
else
{
xinc1 = -1;
xinc2 = -1;
}else { ... }
if (y2 >= y1)
{
yinc1 = 1;
yinc2 = 1;
...}
else
{
yinc1 = -1;
yinc2 = -1;
}else { ... }
if (deltax >= deltay)
{
xinc1 = 0;
yinc2 = 0;
den = deltax;
num = deltax / 2;
numadd = deltay;
numpixels = deltax;
...}
else
{
xinc2 = 0;
yinc1 = 0;
den = deltay;
num = deltay / 2;
numadd = deltax;
numpixels = deltay;
}else { ... }
for (curpixel = 0; curpixel <= numpixels; curpixel++)
{
BSP_LCD_DrawLine(x, y, x3, y3);
num += numadd;
if (num >= den)
{
num -= den;
x += xinc1;
y += yinc1;
...}
x += xinc2;
y += yinc2;
}for (curpixel = 0; curpixel <= numpixels; curpixel++) { ... }
}{ ... }
/* ... */
/* ... */
/* ... */
/* ... */