1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
31
32
36
37
38
41
42
43
48
71
72
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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
158
159
160
161
164
165
/* ... */
#include "main.h"
#include "image_f4.h"
/* ... */
/* ... */
Includes
#define LCD_FEATURES_NUM 4
#define HEADBAND_HEIGHT 64
Private define
static uint8_t LCD_Feature = 0;
static void LCD_SetHint(void);
static void LCD_Show_Feature(uint8_t feature);Private function prototypes
/* ... */
void LCD_demo (void)
{
LCD_SetHint();
LCD_Feature = 0;
LCD_Show_Feature (LCD_Feature);
while (1)
{
if(CheckForUserInput() > 0)
{
if(++LCD_Feature < LCD_FEATURES_NUM)
{
LCD_Show_Feature (LCD_Feature);
}if (++LCD_Feature < LCD_FEATURES_NUM) { ... }
else
{
return;
}else { ... }
}if (CheckForUserInput() > 0) { ... }
HAL_Delay(100);
}while (1) { ... }
}{ ... }
/* ... */
static void LCD_SetHint(void)
{
BSP_LCD_Clear(LCD_COLOR_WHITE);
BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), HEADBAND_HEIGHT);
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_SetBackColor(LCD_COLOR_BLUE);
BSP_LCD_SetFont(&Font16);
BSP_LCD_DisplayStringAt(0, 1, (uint8_t *)"LCD", CENTER_MODE);
BSP_LCD_SetFont(&Font12);
BSP_LCD_DisplayStringAt(0, 20, (uint8_t *)"This example shows LCD", CENTER_MODE);
BSP_LCD_DisplayStringAt(0, 35, (uint8_t *)"features, press button", CENTER_MODE);
BSP_LCD_DisplayStringAt(0, 50, (uint8_t *)"to display next page", CENTER_MODE);
}{ ... }
/* ... */
static void LCD_Show_Feature(uint8_t feature)
{
Point Points[]= {{20, 120}, {80, 120}, {80, 170}};
Point Points2[]= {{100, 120}, {160, 120}, {160, 170}};
BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_FillRect(0, HEADBAND_HEIGHT, BSP_LCD_GetXSize(), BSP_LCD_GetYSize() - HEADBAND_HEIGHT);
BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
switch (feature)
{
case 0:
BSP_LCD_DisplayStringAt(0, 70, (uint8_t *)"Left aligned Text", LEFT_MODE);
BSP_LCD_DisplayStringAt(0, 85, (uint8_t *)"Center aligned Text", CENTER_MODE);
BSP_LCD_DisplayStringAt(0, 100, (uint8_t *)"Right aligned Text", RIGHT_MODE);
BSP_LCD_SetFont(&Font24);
BSP_LCD_DisplayStringAt(0, 118, (uint8_t *)"Font24", CENTER_MODE);
BSP_LCD_SetFont(&Font20);
BSP_LCD_DisplayStringAt(0, 140, (uint8_t *)"Font20", CENTER_MODE);
BSP_LCD_SetFont(&Font16);
BSP_LCD_DisplayStringAt(0, 160, (uint8_t *)"Font16", CENTER_MODE);
break;
case 0:
case 1:
BSP_LCD_SetTextColor(LCD_COLOR_GRAY);
BSP_LCD_DrawCircle(BSP_LCD_GetXSize() - 120, 90, 20);
BSP_LCD_FillCircle(BSP_LCD_GetXSize() - 40, 90, 20);
BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
BSP_LCD_DrawPolygon(Points, 3);
BSP_LCD_FillPolygon(Points2, 3);
break;
case 1:
case 2:
BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
BSP_LCD_DrawRect(20, 70, 60 , 40);
BSP_LCD_FillRect(100, 70, 60 , 40);
BSP_LCD_SetTextColor(LCD_COLOR_RED);
BSP_LCD_DrawEllipse(50, 140, 30, 20);
BSP_LCD_FillEllipse(BSP_LCD_GetXSize() - 50, 140, 30, 20);
BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
BSP_LCD_DrawHLine(20, BSP_LCD_GetYSize() - 5, BSP_LCD_GetXSize() - 40);
BSP_LCD_DrawVLine(BSP_LCD_GetXSize()/2, HEADBAND_HEIGHT + 5, BSP_LCD_GetYSize() - HEADBAND_HEIGHT - 10);
BSP_LCD_DrawLine (20, BSP_LCD_GetYSize()- 20, BSP_LCD_GetXSize()- 20, BSP_LCD_GetYSize()- 60);
BSP_LCD_DrawLine (20, BSP_LCD_GetYSize()- 60, BSP_LCD_GetXSize()- 20, BSP_LCD_GetYSize()- 20);
break;
case 2:
case 3:
BSP_LCD_DrawBitmap(0, 0, (uint8_t *)ImageF4);
break;case 3:
}switch (feature) { ... }
}{ ... }
/* ... */
/* ... */