BSP
Select one of the symbols to view example projects that use it.
 
Outline
Includes
#include "main.h"
Private define
#define LCD_FEATURES_NUM
Private variables
LCD_Feature
Private function prototypes
LCD_demo()
LCD_SetHint()
LCD_Show_Feature(uint8_t)
Files
loading...
CodeScopeSTM32 Libraries and SamplesBSPSrc/lcd.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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * @file BSP/Src/lcd.c * @author MCD Application Team * @brief This example code shows how to use LCD drawing features. ****************************************************************************** * @attention * * Copyright (c) 2017 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** *//* ... */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /** @addtogroup STM32F4xx_HAL_Examples * @{ *//* ... */ /** @addtogroup BSP * @{ *//* ... */ Includes /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ #define LCD_FEATURES_NUM 3 Private define /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ static uint8_t LCD_Feature = 0; Private variables /* Private function prototypes -----------------------------------------------*/ static void LCD_SetHint(void); static void LCD_Show_Feature(uint8_t feature); Private function prototypes /* Private functions ---------------------------------------------------------*/ /** * @brief LCD demo * @param None * @retval None *//* ... */ 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) { ... } }{ ... } /** * @brief Display LCD demo hint * @param None * @retval None *//* ... */ static void LCD_SetHint(void) { /* Clear the LCD */ BSP_LCD_Clear(LCD_COLOR_WHITE); /* Set LCD Demo description */ BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), 80); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_SetBackColor(LCD_COLOR_BLUE); BSP_LCD_SetFont(&Font24); BSP_LCD_DisplayStringAt(0, 0, (uint8_t *)"LCD", CENTER_MODE); BSP_LCD_SetFont(&Font12); BSP_LCD_DisplayStringAt(0, 30, (uint8_t *)"This example shows the different", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 45, (uint8_t *)"LCD Features, use BUTTON to display", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 60, (uint8_t *)"next page", CENTER_MODE); /* Set the LCD Text Color */ BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_DrawRect(10, 90, BSP_LCD_GetXSize() - 20, BSP_LCD_GetYSize()- 100); BSP_LCD_DrawRect(11, 91, BSP_LCD_GetXSize() - 22, BSP_LCD_GetYSize()- 102); }{ ... } /** * @brief Show LCD Features * @param feature: feature index * @retval None *//* ... */ static void LCD_Show_Feature(uint8_t feature) { Point Points[]= {{20, 150}, {80, 150}, {80, 200}}; Point Points2[]= {{100, 150}, {160, 150}, {160, 200}}; BSP_LCD_SetBackColor(LCD_COLOR_WHITE); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_FillRect(12, 92, BSP_LCD_GetXSize() - 24, BSP_LCD_GetYSize()- 104); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); switch (feature) { case 0: /* Text Feature */ BSP_LCD_DisplayStringAt(14, 100, (uint8_t *)"Left aligned Text", LEFT_MODE); BSP_LCD_DisplayStringAt(0, 115, (uint8_t *)"Center aligned Text", CENTER_MODE); BSP_LCD_DisplayStringAt(14, 130, (uint8_t *)"Right aligned Text", RIGHT_MODE); BSP_LCD_SetFont(&Font24); BSP_LCD_DisplayStringAt(14, 180, (uint8_t *)"Font24", LEFT_MODE); BSP_LCD_SetFont(&Font20); BSP_LCD_DisplayStringAt(BSP_LCD_GetXSize()/2 -20, 180, (uint8_t *)"Font20", LEFT_MODE); BSP_LCD_SetFont(&Font16); BSP_LCD_DisplayStringAt(BSP_LCD_GetXSize() - 80, 184, (uint8_t *)"Font16", LEFT_MODE); break; case 0: case 1: /* Draw misc. Shapes */ BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_DrawRect(20, 100, 60 , 40); BSP_LCD_FillRect(100, 100, 60 , 40); BSP_LCD_SetTextColor(LCD_COLOR_GRAY); BSP_LCD_DrawCircle(BSP_LCD_GetXSize() - 120, 120, 20); BSP_LCD_FillCircle(BSP_LCD_GetXSize() - 40, 120, 20); BSP_LCD_SetTextColor(LCD_COLOR_GREEN); BSP_LCD_DrawPolygon(Points, 3); BSP_LCD_FillPolygon(Points2, 3); BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DrawEllipse(BSP_LCD_GetXSize() - 120, 170, 30, 20); BSP_LCD_FillEllipse(BSP_LCD_GetXSize() - 50, 170, 30, 20); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_DrawHLine(20, BSP_LCD_GetYSize() - 30, BSP_LCD_GetXSize() / 5); BSP_LCD_DrawLine (BSP_LCD_GetXSize() - 150, BSP_LCD_GetYSize()- 20, BSP_LCD_GetXSize()- 20, BSP_LCD_GetYSize()- 50); BSP_LCD_DrawLine (BSP_LCD_GetXSize() - 150, BSP_LCD_GetYSize()- 50, BSP_LCD_GetXSize()- 20, BSP_LCD_GetYSize()- 20); break; case 1: case 2: /* Draw Bitmap */ BSP_LCD_DrawBitmap(20, 100, (uint8_t *)stlogo); HAL_Delay(500); BSP_LCD_DrawBitmap(BSP_LCD_GetXSize()/2 - 40, 100, (uint8_t *)stlogo); HAL_Delay(500); BSP_LCD_DrawBitmap(BSP_LCD_GetXSize()-100, 100, (uint8_t *)stlogo); HAL_Delay(500); BSP_LCD_DrawBitmap(20, BSP_LCD_GetYSize()- 80, (uint8_t *)stlogo); HAL_Delay(500); BSP_LCD_DrawBitmap(BSP_LCD_GetXSize()/2 - 40, BSP_LCD_GetYSize()- 80, (uint8_t *)stlogo); HAL_Delay(500); BSP_LCD_DrawBitmap(BSP_LCD_GetXSize()-100, BSP_LCD_GetYSize()- 80, (uint8_t *)stlogo); HAL_Delay(500); break;case 2: }switch (feature) { ... } }{ ... } /** * @} *//* ... */ /** * @} *//* ... */