DISCO_H747I_LCD_demo
Dependencies: BSP_DISCO_H747I
main.cpp@1:305555b58102, 2019-09-25 (annotated)
- Committer:
- Jerome Coutant
- Date:
- Wed Sep 25 17:52:00 2019 +0200
- Revision:
- 1:305555b58102
- Parent:
- 0:f1f3c583cf1e
Lib update
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jerome Coutant
0:f1f3c583cf1e
|
1
|
#include "mbed.h"
|
|
Jerome Coutant
0:f1f3c583cf1e
|
2
|
#include "stm32h747i_discovery.h"
|
|
Jerome Coutant
0:f1f3c583cf1e
|
3
|
#include "stm32h747i_discovery_lcd.h"
|
|
Jerome Coutant
0:f1f3c583cf1e
|
4
|
#include "stlogo.h"
|
|
Jerome Coutant
0:f1f3c583cf1e
|
5
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
6
|
static void DISCO_LCD_INIT(void)
|
|
Jerome Coutant
0:f1f3c583cf1e
|
7
|
{
|
|
Jerome Coutant
0:f1f3c583cf1e
|
8
|
BSP_LCD_Init();
|
|
Jerome Coutant
0:f1f3c583cf1e
|
9
|
BSP_LCD_LayerDefaultInit(1, LCD_FB_START_ADDRESS);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
10
|
BSP_LCD_SelectLayer(1);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
11
|
BSP_LCD_SetFont(&LCD_DEFAULT_FONT);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
12
|
BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
13
|
BSP_LCD_Clear(LCD_COLOR_WHITE);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
14
|
}
|
|
Jerome Coutant
0:f1f3c583cf1e
|
15
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
16
|
static void LCD_Demo_Setup(void)
|
|
Jerome Coutant
0:f1f3c583cf1e
|
17
|
{
|
|
Jerome Coutant
0:f1f3c583cf1e
|
18
|
/* Set LCD Demo description */
|
|
Jerome Coutant
0:f1f3c583cf1e
|
19
|
BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
20
|
BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), 80);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
21
|
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
22
|
BSP_LCD_SetBackColor(LCD_COLOR_BLUE);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
23
|
BSP_LCD_SetFont(&Font24);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
24
|
BSP_LCD_DisplayStringAt(0, 10, (uint8_t *)"LCD", CENTER_MODE);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
25
|
BSP_LCD_SetFont(&Font12);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
26
|
BSP_LCD_DisplayStringAt(0, 45, (uint8_t *)"This example shows different feature", CENTER_MODE);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
27
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
28
|
/* Set the LCD Text Color */
|
|
Jerome Coutant
0:f1f3c583cf1e
|
29
|
BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
30
|
BSP_LCD_DrawRect(10, 90, BSP_LCD_GetXSize() - 20, BSP_LCD_GetYSize() - 100);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
31
|
BSP_LCD_DrawRect(11, 91, BSP_LCD_GetXSize() - 22, BSP_LCD_GetYSize() - 102);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
32
|
}
|
|
Jerome Coutant
0:f1f3c583cf1e
|
33
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
34
|
/**
|
|
Jerome Coutant
0:f1f3c583cf1e
|
35
|
* @brief Show LCD Features
|
|
Jerome Coutant
0:f1f3c583cf1e
|
36
|
* @param feature : feature index
|
|
Jerome Coutant
0:f1f3c583cf1e
|
37
|
* @retval None
|
|
Jerome Coutant
0:f1f3c583cf1e
|
38
|
*/
|
|
Jerome Coutant
0:f1f3c583cf1e
|
39
|
static void LCD_Demo_Feature(uint8_t feature)
|
|
Jerome Coutant
0:f1f3c583cf1e
|
40
|
{
|
|
Jerome Coutant
0:f1f3c583cf1e
|
41
|
int32_t i = 0;
|
|
Jerome Coutant
0:f1f3c583cf1e
|
42
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
43
|
Point Points[] = {{20, 150}, {80, 150}, {80, 200}};
|
|
Jerome Coutant
0:f1f3c583cf1e
|
44
|
Point Points2[3];
|
|
Jerome Coutant
0:f1f3c583cf1e
|
45
|
uint8_t text[50];
|
|
Jerome Coutant
0:f1f3c583cf1e
|
46
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
47
|
BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
48
|
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
49
|
BSP_LCD_FillRect(12, 92, BSP_LCD_GetXSize() - 24, BSP_LCD_GetYSize() - 104);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
50
|
BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
51
|
BSP_LCD_SetFont(&Font16);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
52
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
53
|
switch (feature) {
|
|
Jerome Coutant
0:f1f3c583cf1e
|
54
|
case 0:
|
|
Jerome Coutant
0:f1f3c583cf1e
|
55
|
/* Text Feature */
|
|
Jerome Coutant
0:f1f3c583cf1e
|
56
|
BSP_LCD_SetFont(&Font16);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
57
|
BSP_LCD_DisplayStringAt(14, 100, (uint8_t *)"Left aligned Text", LEFT_MODE);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
58
|
BSP_LCD_DisplayStringAt(14, 115, (uint8_t *)"Center aligned Text", CENTER_MODE);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
59
|
BSP_LCD_DisplayStringAt(14, 130, (uint8_t *)"Right aligned Text", RIGHT_MODE);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
60
|
BSP_LCD_SetFont(&Font24);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
61
|
BSP_LCD_DisplayStringAt(14, 180, (uint8_t *)"Font24", LEFT_MODE);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
62
|
BSP_LCD_SetFont(&Font20);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
63
|
BSP_LCD_DisplayStringAt(BSP_LCD_GetXSize() / 2 - 20, 180, (uint8_t *)"Font20", LEFT_MODE);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
64
|
BSP_LCD_SetFont(&Font16);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
65
|
BSP_LCD_DisplayStringAt(BSP_LCD_GetXSize() - 80, 184, (uint8_t *)"Font16", LEFT_MODE);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
66
|
break;
|
|
Jerome Coutant
0:f1f3c583cf1e
|
67
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
68
|
case 1:
|
|
Jerome Coutant
0:f1f3c583cf1e
|
69
|
/* Draw misc. Shapes */
|
|
Jerome Coutant
0:f1f3c583cf1e
|
70
|
BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
71
|
BSP_LCD_DrawRect(20, 100, 60, 40);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
72
|
BSP_LCD_FillRect(100, 100, 60, 40);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
73
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
74
|
BSP_LCD_SetTextColor(LCD_COLOR_GRAY);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
75
|
BSP_LCD_DrawCircle(BSP_LCD_GetXSize() - 120, 120, 20);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
76
|
BSP_LCD_FillCircle(BSP_LCD_GetXSize() - 40, 120, 20);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
77
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
78
|
BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
79
|
BSP_LCD_DrawPolygon(Points, 3);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
80
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
81
|
BSP_LCD_SetTextColor(LCD_COLOR_RED);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
82
|
BSP_LCD_DrawEllipse(130, 170, 30, 20);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
83
|
BSP_LCD_FillEllipse(200, 170, 30, 20);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
84
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
85
|
BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
86
|
BSP_LCD_DrawHLine(20, BSP_LCD_GetYSize() - 30, BSP_LCD_GetXSize() / 5);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
87
|
BSP_LCD_DrawLine(100, BSP_LCD_GetYSize() - 20, 230, BSP_LCD_GetYSize() - 50);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
88
|
BSP_LCD_DrawLine(100, BSP_LCD_GetYSize() - 50, 230, BSP_LCD_GetYSize() - 20);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
89
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
90
|
Points2[0].X = BSP_LCD_GetXSize() - 80;
|
|
Jerome Coutant
0:f1f3c583cf1e
|
91
|
Points2[0].Y = 150;
|
|
Jerome Coutant
0:f1f3c583cf1e
|
92
|
Points2[1].X = BSP_LCD_GetXSize() - 20;
|
|
Jerome Coutant
0:f1f3c583cf1e
|
93
|
Points2[1].Y = 150;
|
|
Jerome Coutant
0:f1f3c583cf1e
|
94
|
Points2[2].X = BSP_LCD_GetXSize() - 20;
|
|
Jerome Coutant
0:f1f3c583cf1e
|
95
|
Points2[2].Y = 200;
|
|
Jerome Coutant
0:f1f3c583cf1e
|
96
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
97
|
BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
98
|
BSP_LCD_FillPolygon(Points2, 3);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
99
|
break;
|
|
Jerome Coutant
0:f1f3c583cf1e
|
100
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
101
|
case 2:
|
|
Jerome Coutant
0:f1f3c583cf1e
|
102
|
/* Draw Bitmap */
|
|
Jerome Coutant
0:f1f3c583cf1e
|
103
|
BSP_LCD_DrawBitmap(20, 100, (uint8_t *)stlogo);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
104
|
HAL_Delay(500);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
105
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
106
|
BSP_LCD_DrawBitmap(BSP_LCD_GetXSize() / 2 - 40, 100, (uint8_t *)stlogo);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
107
|
HAL_Delay(500);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
108
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
109
|
BSP_LCD_DrawBitmap(BSP_LCD_GetXSize() - 100, 100, (uint8_t *)stlogo);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
110
|
HAL_Delay(500);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
111
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
112
|
BSP_LCD_DrawBitmap(20, BSP_LCD_GetYSize() - 80, (uint8_t *)stlogo);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
113
|
HAL_Delay(500);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
114
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
115
|
BSP_LCD_DrawBitmap(BSP_LCD_GetXSize() / 2 - 40, BSP_LCD_GetYSize() - 80, (uint8_t *)stlogo);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
116
|
HAL_Delay(500);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
117
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
118
|
BSP_LCD_DrawBitmap(BSP_LCD_GetXSize() - 100, BSP_LCD_GetYSize() - 80, (uint8_t *)stlogo);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
119
|
HAL_Delay(500);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
120
|
break;
|
|
Jerome Coutant
0:f1f3c583cf1e
|
121
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
122
|
case 3:
|
|
Jerome Coutant
0:f1f3c583cf1e
|
123
|
/* Set the LCD Back Color and Text Color*/
|
|
Jerome Coutant
0:f1f3c583cf1e
|
124
|
BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
125
|
BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
126
|
BSP_LCD_SetFont(&Font24);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
127
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
128
|
/* Set the brightness */
|
|
Jerome Coutant
0:f1f3c583cf1e
|
129
|
for (i = 100; i >= 0; i -= 10) {
|
|
Jerome Coutant
0:f1f3c583cf1e
|
130
|
sprintf((char *)text, " Brightness = %d ", (int)i);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
131
|
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() / 2 + 45, (uint8_t *)text, CENTER_MODE);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
132
|
BSP_LCD_SetBrightness(i);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
133
|
HAL_Delay(300);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
134
|
}
|
|
Jerome Coutant
0:f1f3c583cf1e
|
135
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
136
|
for (i = 0; i <= 100; i += 10) {
|
|
Jerome Coutant
0:f1f3c583cf1e
|
137
|
sprintf((char *)text, " Brightness = %d ", (int)i);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
138
|
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() / 2 + 45, (uint8_t *)text, CENTER_MODE);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
139
|
BSP_LCD_SetBrightness(i);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
140
|
HAL_Delay(300);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
141
|
}
|
|
Jerome Coutant
0:f1f3c583cf1e
|
142
|
break;
|
|
Jerome Coutant
0:f1f3c583cf1e
|
143
|
}
|
|
Jerome Coutant
0:f1f3c583cf1e
|
144
|
}
|
|
Jerome Coutant
0:f1f3c583cf1e
|
145
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
146
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
147
|
int main()
|
|
Jerome Coutant
0:f1f3c583cf1e
|
148
|
{
|
|
Jerome Coutant
0:f1f3c583cf1e
|
149
|
printf("\nSTART\n");
|
|
Jerome Coutant
0:f1f3c583cf1e
|
150
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
151
|
DISCO_LCD_INIT();
|
|
Jerome Coutant
0:f1f3c583cf1e
|
152
|
LCD_Demo_Setup();
|
|
Jerome Coutant
0:f1f3c583cf1e
|
153
|
|
|
Jerome Coutant
0:f1f3c583cf1e
|
154
|
while (1) {
|
|
Jerome Coutant
0:f1f3c583cf1e
|
155
|
for (int LCD_Feature = 0; LCD_Feature < 4; ++LCD_Feature) {
|
|
Jerome Coutant
0:f1f3c583cf1e
|
156
|
printf("Demo LCD feature %d\n", LCD_Feature);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
157
|
LCD_Demo_Feature(LCD_Feature);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
158
|
HAL_Delay(10000);
|
|
Jerome Coutant
0:f1f3c583cf1e
|
159
|
}
|
|
Jerome Coutant
0:f1f3c583cf1e
|
160
|
}
|
|
Jerome Coutant
0:f1f3c583cf1e
|
161
|
}
|
|