STM32F469NI Discovery board drivers
Dependents: DISCO-F469NI_LCDTS_GUI_demo Configurable_Robots DISCO-F469NI_LCD_demo DISCO-F469NI_SD_demo ... more
Drivers/BSP/STM32469I-Discovery/stm32469i_discovery_lcd.c@3:3cdfcc4f7c9d, 2018-02-28 (annotated)
- Committer:
- Jerome Coutant
- Date:
- Wed Feb 28 13:17:15 2018 +0100
- Revision:
- 3:3cdfcc4f7c9d
- Parent:
- 2:123b894b49dd
- Child:
- 4:27609b3a44ed
STM32Cube_FW_F4_V1.19.0 BSP_DISCO_F469NI
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jerome Coutant
2:123b894b49dd
|
1
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
2
|
******************************************************************************
|
|
Jerome Coutant
2:123b894b49dd
|
3
|
* @file stm32469i_discovery_lcd.c
|
|
Jerome Coutant
2:123b894b49dd
|
4
|
* @author MCD Application Team
|
|
Jerome Coutant
2:123b894b49dd
|
5
|
* @brief This file includes the driver for Liquid Crystal Display (LCD) module
|
|
Jerome Coutant
2:123b894b49dd
|
6
|
* mounted on STM32469I-Discovery evaluation board.
|
|
Jerome Coutant
2:123b894b49dd
|
7
|
******************************************************************************
|
|
Jerome Coutant
2:123b894b49dd
|
8
|
* @attention
|
|
Jerome Coutant
2:123b894b49dd
|
9
|
*
|
|
Jerome Coutant
2:123b894b49dd
|
10
|
* <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
|
|
Jerome Coutant
2:123b894b49dd
|
11
|
*
|
|
Jerome Coutant
2:123b894b49dd
|
12
|
* Redistribution and use in source and binary forms, with or without modification,
|
|
Jerome Coutant
2:123b894b49dd
|
13
|
* are permitted provided that the following conditions are met:
|
|
Jerome Coutant
2:123b894b49dd
|
14
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
Jerome Coutant
2:123b894b49dd
|
15
|
* this list of conditions and the following disclaimer.
|
|
Jerome Coutant
2:123b894b49dd
|
16
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
Jerome Coutant
2:123b894b49dd
|
17
|
* this list of conditions and the following disclaimer in the documentation
|
|
Jerome Coutant
2:123b894b49dd
|
18
|
* and/or other materials provided with the distribution.
|
|
Jerome Coutant
2:123b894b49dd
|
19
|
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
|
Jerome Coutant
2:123b894b49dd
|
20
|
* may be used to endorse or promote products derived from this software
|
|
Jerome Coutant
2:123b894b49dd
|
21
|
* without specific prior written permission.
|
|
Jerome Coutant
2:123b894b49dd
|
22
|
*
|
|
Jerome Coutant
2:123b894b49dd
|
23
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
Jerome Coutant
2:123b894b49dd
|
24
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Jerome Coutant
2:123b894b49dd
|
25
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
Jerome Coutant
2:123b894b49dd
|
26
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
Jerome Coutant
2:123b894b49dd
|
27
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
Jerome Coutant
2:123b894b49dd
|
28
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
Jerome Coutant
2:123b894b49dd
|
29
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
Jerome Coutant
2:123b894b49dd
|
30
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
Jerome Coutant
2:123b894b49dd
|
31
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
Jerome Coutant
2:123b894b49dd
|
32
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Jerome Coutant
2:123b894b49dd
|
33
|
*
|
|
Jerome Coutant
2:123b894b49dd
|
34
|
******************************************************************************
|
|
Jerome Coutant
2:123b894b49dd
|
35
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
36
|
|
|
Jerome Coutant
2:123b894b49dd
|
37
|
/* File Info: ------------------------------------------------------------------
|
|
Jerome Coutant
2:123b894b49dd
|
38
|
User NOTES
|
|
Jerome Coutant
2:123b894b49dd
|
39
|
1. How To use this driver:
|
|
Jerome Coutant
2:123b894b49dd
|
40
|
--------------------------
|
|
Jerome Coutant
2:123b894b49dd
|
41
|
- This driver is used to drive directly in video mode a LCD TFT using the DSI interface.
|
|
Jerome Coutant
2:123b894b49dd
|
42
|
The following IPs are implied : DSI Host IP block working
|
|
Jerome Coutant
2:123b894b49dd
|
43
|
in conjunction to the LTDC controller.
|
|
Jerome Coutant
2:123b894b49dd
|
44
|
- This driver is linked by construction to LCD KoD mounted on board MB1166.
|
|
Jerome Coutant
2:123b894b49dd
|
45
|
|
|
Jerome Coutant
2:123b894b49dd
|
46
|
2. Driver description:
|
|
Jerome Coutant
2:123b894b49dd
|
47
|
---------------------
|
|
Jerome Coutant
2:123b894b49dd
|
48
|
+ Initialization steps:
|
|
Jerome Coutant
2:123b894b49dd
|
49
|
o Initialize the LCD using the BSP_LCD_Init() function.
|
|
Jerome Coutant
2:123b894b49dd
|
50
|
o Select the LCD layer to be used using the BSP_LCD_SelectLayer() function.
|
|
Jerome Coutant
2:123b894b49dd
|
51
|
o Enable the LCD display using the BSP_LCD_DisplayOn() function.
|
|
Jerome Coutant
2:123b894b49dd
|
52
|
|
|
Jerome Coutant
2:123b894b49dd
|
53
|
+ Options
|
|
Jerome Coutant
2:123b894b49dd
|
54
|
o Configure and enable the color keying functionality using the
|
|
Jerome Coutant
2:123b894b49dd
|
55
|
BSP_LCD_SetColorKeying() function.
|
|
Jerome Coutant
2:123b894b49dd
|
56
|
o Modify in the fly the transparency and/or the frame buffer address
|
|
Jerome Coutant
2:123b894b49dd
|
57
|
using the following functions:
|
|
Jerome Coutant
2:123b894b49dd
|
58
|
- BSP_LCD_SetTransparency()
|
|
Jerome Coutant
2:123b894b49dd
|
59
|
- BSP_LCD_SetLayerAddress()
|
|
Jerome Coutant
2:123b894b49dd
|
60
|
|
|
Jerome Coutant
2:123b894b49dd
|
61
|
+ Display on LCD
|
|
Jerome Coutant
2:123b894b49dd
|
62
|
o Clear the whole LCD using BSP_LCD_Clear() function or only one specified string
|
|
Jerome Coutant
2:123b894b49dd
|
63
|
line using the BSP_LCD_ClearStringLine() function.
|
|
Jerome Coutant
2:123b894b49dd
|
64
|
o Display a character on the specified line and column using the BSP_LCD_DisplayChar()
|
|
Jerome Coutant
2:123b894b49dd
|
65
|
function or a complete string line using the BSP_LCD_DisplayStringAtLine() function.
|
|
Jerome Coutant
2:123b894b49dd
|
66
|
o Display a string line on the specified position (x,y in pixel) and align mode
|
|
Jerome Coutant
2:123b894b49dd
|
67
|
using the BSP_LCD_DisplayStringAtLine() function.
|
|
Jerome Coutant
2:123b894b49dd
|
68
|
o Draw and fill a basic shapes (dot, line, rectangle, circle, ellipse, .. bitmap)
|
|
Jerome Coutant
2:123b894b49dd
|
69
|
on LCD using the available set of functions.
|
|
Jerome Coutant
2:123b894b49dd
|
70
|
|
|
Jerome Coutant
2:123b894b49dd
|
71
|
------------------------------------------------------------------------------*/
|
|
Jerome Coutant
2:123b894b49dd
|
72
|
|
|
Jerome Coutant
2:123b894b49dd
|
73
|
/* Includes ------------------------------------------------------------------*/
|
|
Jerome Coutant
2:123b894b49dd
|
74
|
#include "stm32469i_discovery_lcd.h"
|
|
Jerome Coutant
2:123b894b49dd
|
75
|
#include "../Fonts/fonts.h"
|
|
Jerome Coutant
2:123b894b49dd
|
76
|
//#include "../../../Utilities/Fonts/font24.c"
|
|
Jerome Coutant
2:123b894b49dd
|
77
|
//#include "../../../Utilities/Fonts/font20.c"
|
|
Jerome Coutant
2:123b894b49dd
|
78
|
//#include "../../../Utilities/Fonts/font16.c"
|
|
Jerome Coutant
2:123b894b49dd
|
79
|
//#include "../../../Utilities/Fonts/font12.c"
|
|
Jerome Coutant
2:123b894b49dd
|
80
|
//#include "../../../Utilities/Fonts/font8.c"
|
|
Jerome Coutant
2:123b894b49dd
|
81
|
|
|
Jerome Coutant
2:123b894b49dd
|
82
|
/** @addtogroup BSP
|
|
Jerome Coutant
2:123b894b49dd
|
83
|
* @{
|
|
Jerome Coutant
2:123b894b49dd
|
84
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
85
|
|
|
Jerome Coutant
2:123b894b49dd
|
86
|
/** @addtogroup STM32469I_Discovery
|
|
Jerome Coutant
2:123b894b49dd
|
87
|
* @{
|
|
Jerome Coutant
2:123b894b49dd
|
88
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
89
|
|
|
Jerome Coutant
2:123b894b49dd
|
90
|
/** @defgroup STM32469I-Discovery_LCD STM32469I Discovery LCD
|
|
Jerome Coutant
2:123b894b49dd
|
91
|
* @{
|
|
Jerome Coutant
2:123b894b49dd
|
92
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
93
|
|
|
Jerome Coutant
2:123b894b49dd
|
94
|
/** @defgroup STM32469I-Discovery_LCD_Private_TypesDefinitions STM32469I Discovery LCD Private TypesDefinitions
|
|
Jerome Coutant
2:123b894b49dd
|
95
|
* @{
|
|
Jerome Coutant
2:123b894b49dd
|
96
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
97
|
static DSI_VidCfgTypeDef hdsivideo_handle;
|
|
Jerome Coutant
2:123b894b49dd
|
98
|
|
|
Jerome Coutant
2:123b894b49dd
|
99
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
100
|
* @}
|
|
Jerome Coutant
2:123b894b49dd
|
101
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
102
|
|
|
Jerome Coutant
2:123b894b49dd
|
103
|
/** @defgroup STM32469I-Discovery_LCD_Private_Defines STM32469I Discovery LCD Private Defines
|
|
Jerome Coutant
2:123b894b49dd
|
104
|
* @{
|
|
Jerome Coutant
2:123b894b49dd
|
105
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
106
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
107
|
* @}
|
|
Jerome Coutant
2:123b894b49dd
|
108
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
109
|
|
|
Jerome Coutant
2:123b894b49dd
|
110
|
/** @defgroup STM32469I-Discovery_LCD_Private_Macros STM32469I Discovery LCD Private Macros
|
|
Jerome Coutant
2:123b894b49dd
|
111
|
* @{
|
|
Jerome Coutant
2:123b894b49dd
|
112
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
113
|
#define ABS(X) ((X) > 0 ? (X) : -(X))
|
|
Jerome Coutant
2:123b894b49dd
|
114
|
|
|
Jerome Coutant
2:123b894b49dd
|
115
|
#define POLY_X(Z) ((int32_t)((Points + (Z))->X))
|
|
Jerome Coutant
2:123b894b49dd
|
116
|
#define POLY_Y(Z) ((int32_t)((Points + (Z))->Y))
|
|
Jerome Coutant
2:123b894b49dd
|
117
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
118
|
* @}
|
|
Jerome Coutant
2:123b894b49dd
|
119
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
120
|
|
|
Jerome Coutant
2:123b894b49dd
|
121
|
/** @defgroup STM32469I-Discovery_LCD_Exported_Variables STM32469I Discovery LCD Exported Variables
|
|
Jerome Coutant
2:123b894b49dd
|
122
|
* @{
|
|
Jerome Coutant
2:123b894b49dd
|
123
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
124
|
|
|
Jerome Coutant
2:123b894b49dd
|
125
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
126
|
* @}
|
|
Jerome Coutant
2:123b894b49dd
|
127
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
128
|
|
|
Jerome Coutant
2:123b894b49dd
|
129
|
|
|
Jerome Coutant
2:123b894b49dd
|
130
|
/** @defgroup STM32469I-Discovery_LCD_Private_Variables STM32469I Discovery LCD Private Variables
|
|
Jerome Coutant
2:123b894b49dd
|
131
|
* @{
|
|
Jerome Coutant
2:123b894b49dd
|
132
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
133
|
|
|
Jerome Coutant
2:123b894b49dd
|
134
|
DMA2D_HandleTypeDef hdma2d_eval;
|
|
Jerome Coutant
2:123b894b49dd
|
135
|
LTDC_HandleTypeDef hltdc_eval;
|
|
Jerome Coutant
2:123b894b49dd
|
136
|
DSI_HandleTypeDef hdsi_eval;
|
|
Jerome Coutant
2:123b894b49dd
|
137
|
uint32_t lcd_x_size = OTM8009A_800X480_WIDTH;
|
|
Jerome Coutant
2:123b894b49dd
|
138
|
uint32_t lcd_y_size = OTM8009A_800X480_HEIGHT;
|
|
Jerome Coutant
2:123b894b49dd
|
139
|
|
|
Jerome Coutant
2:123b894b49dd
|
140
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
141
|
* @}
|
|
Jerome Coutant
2:123b894b49dd
|
142
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
143
|
|
|
Jerome Coutant
2:123b894b49dd
|
144
|
|
|
Jerome Coutant
2:123b894b49dd
|
145
|
/** @defgroup STM32469I-Discovery_LCD_Private_Variables STM32469I Discovery LCD Private Variables
|
|
Jerome Coutant
2:123b894b49dd
|
146
|
* @{
|
|
Jerome Coutant
2:123b894b49dd
|
147
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
148
|
|
|
Jerome Coutant
2:123b894b49dd
|
149
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
150
|
* @brief Default Active LTDC Layer in which drawing is made is LTDC Layer Background
|
|
Jerome Coutant
2:123b894b49dd
|
151
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
152
|
static uint32_t ActiveLayer = LTDC_ACTIVE_LAYER_BACKGROUND;
|
|
Jerome Coutant
2:123b894b49dd
|
153
|
|
|
Jerome Coutant
2:123b894b49dd
|
154
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
155
|
* @brief Current Drawing Layer properties variable
|
|
Jerome Coutant
2:123b894b49dd
|
156
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
157
|
static LCD_DrawPropTypeDef DrawProp[LTDC_MAX_LAYER_NUMBER];
|
|
Jerome Coutant
2:123b894b49dd
|
158
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
159
|
* @}
|
|
Jerome Coutant
2:123b894b49dd
|
160
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
161
|
|
|
Jerome Coutant
2:123b894b49dd
|
162
|
/** @defgroup STM32469I-Discovery_LCD_Private_FunctionPrototypes STM32469I Discovery LCD Private FunctionPrototypes
|
|
Jerome Coutant
2:123b894b49dd
|
163
|
* @{
|
|
Jerome Coutant
2:123b894b49dd
|
164
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
165
|
static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c);
|
|
Jerome Coutant
2:123b894b49dd
|
166
|
static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3);
|
|
Jerome Coutant
2:123b894b49dd
|
167
|
static void LL_FillBuffer(uint32_t LayerIndex, void *pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLine, uint32_t ColorIndex);
|
|
Jerome Coutant
2:123b894b49dd
|
168
|
static void LL_ConvertLineToARGB8888(void * pSrc, void *pDst, uint32_t xSize, uint32_t ColorMode);
|
|
Jerome Coutant
2:123b894b49dd
|
169
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
170
|
* @}
|
|
Jerome Coutant
2:123b894b49dd
|
171
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
172
|
|
|
Jerome Coutant
2:123b894b49dd
|
173
|
/** @defgroup STM32469I-Discovery_LCD_Exported_Functions STM32469I Discovery LCD Exported Functions
|
|
Jerome Coutant
2:123b894b49dd
|
174
|
* @{
|
|
Jerome Coutant
2:123b894b49dd
|
175
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
176
|
|
|
Jerome Coutant
2:123b894b49dd
|
177
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
178
|
* @brief Initializes the DSI LCD.
|
|
Jerome Coutant
2:123b894b49dd
|
179
|
* @retval LCD state
|
|
Jerome Coutant
2:123b894b49dd
|
180
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
181
|
uint8_t BSP_LCD_Init(void)
|
|
Jerome Coutant
2:123b894b49dd
|
182
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
183
|
return (BSP_LCD_InitEx(LCD_ORIENTATION_LANDSCAPE));
|
|
Jerome Coutant
2:123b894b49dd
|
184
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
185
|
|
|
Jerome Coutant
2:123b894b49dd
|
186
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
187
|
* @brief Initializes the DSI LCD.
|
|
Jerome Coutant
2:123b894b49dd
|
188
|
* The ititialization is done as below:
|
|
Jerome Coutant
2:123b894b49dd
|
189
|
* - DSI PLL ititialization
|
|
Jerome Coutant
2:123b894b49dd
|
190
|
* - DSI ititialization
|
|
Jerome Coutant
2:123b894b49dd
|
191
|
* - LTDC ititialization
|
|
Jerome Coutant
2:123b894b49dd
|
192
|
* - OTM8009A LCD Display IC Driver ititialization
|
|
Jerome Coutant
2:123b894b49dd
|
193
|
* @retval LCD state
|
|
Jerome Coutant
2:123b894b49dd
|
194
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
195
|
uint8_t BSP_LCD_InitEx(LCD_OrientationTypeDef orientation)
|
|
Jerome Coutant
2:123b894b49dd
|
196
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
197
|
DSI_PLLInitTypeDef dsiPllInit;
|
|
Jerome Coutant
2:123b894b49dd
|
198
|
DSI_PHY_TimerTypeDef PhyTimings;
|
|
Jerome Coutant
2:123b894b49dd
|
199
|
static RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
|
|
Jerome Coutant
2:123b894b49dd
|
200
|
uint32_t LcdClock = 27429; /*!< LcdClk = 27429 kHz */
|
|
Jerome Coutant
2:123b894b49dd
|
201
|
|
|
Jerome Coutant
2:123b894b49dd
|
202
|
uint32_t laneByteClk_kHz = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
203
|
uint32_t VSA; /*!< Vertical start active time in units of lines */
|
|
Jerome Coutant
2:123b894b49dd
|
204
|
uint32_t VBP; /*!< Vertical Back Porch time in units of lines */
|
|
Jerome Coutant
2:123b894b49dd
|
205
|
uint32_t VFP; /*!< Vertical Front Porch time in units of lines */
|
|
Jerome Coutant
2:123b894b49dd
|
206
|
uint32_t VACT; /*!< Vertical Active time in units of lines = imageSize Y in pixels to display */
|
|
Jerome Coutant
2:123b894b49dd
|
207
|
uint32_t HSA; /*!< Horizontal start active time in units of lcdClk */
|
|
Jerome Coutant
2:123b894b49dd
|
208
|
uint32_t HBP; /*!< Horizontal Back Porch time in units of lcdClk */
|
|
Jerome Coutant
2:123b894b49dd
|
209
|
uint32_t HFP; /*!< Horizontal Front Porch time in units of lcdClk */
|
|
Jerome Coutant
2:123b894b49dd
|
210
|
uint32_t HACT; /*!< Horizontal Active time in units of lcdClk = imageSize X in pixels to display */
|
|
Jerome Coutant
2:123b894b49dd
|
211
|
|
|
Jerome Coutant
2:123b894b49dd
|
212
|
|
|
Jerome Coutant
2:123b894b49dd
|
213
|
/* Toggle Hardware Reset of the DSI LCD using
|
|
Jerome Coutant
2:123b894b49dd
|
214
|
* its XRES signal (active low) */
|
|
Jerome Coutant
2:123b894b49dd
|
215
|
BSP_LCD_Reset();
|
|
Jerome Coutant
2:123b894b49dd
|
216
|
|
|
Jerome Coutant
2:123b894b49dd
|
217
|
/* Call first MSP Initialize only in case of first initialization
|
|
Jerome Coutant
2:123b894b49dd
|
218
|
* This will set IP blocks LTDC, DSI and DMA2D
|
|
Jerome Coutant
2:123b894b49dd
|
219
|
* - out of reset
|
|
Jerome Coutant
2:123b894b49dd
|
220
|
* - clocked
|
|
Jerome Coutant
2:123b894b49dd
|
221
|
* - NVIC IRQ related to IP blocks enabled
|
|
Jerome Coutant
2:123b894b49dd
|
222
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
223
|
BSP_LCD_MspInit();
|
|
Jerome Coutant
2:123b894b49dd
|
224
|
|
|
Jerome Coutant
2:123b894b49dd
|
225
|
/*************************DSI Initialization***********************************/
|
|
Jerome Coutant
2:123b894b49dd
|
226
|
|
|
Jerome Coutant
2:123b894b49dd
|
227
|
/* Base address of DSI Host/Wrapper registers to be set before calling De-Init */
|
|
Jerome Coutant
2:123b894b49dd
|
228
|
hdsi_eval.Instance = DSI;
|
|
Jerome Coutant
2:123b894b49dd
|
229
|
|
|
Jerome Coutant
2:123b894b49dd
|
230
|
HAL_DSI_DeInit(&(hdsi_eval));
|
|
Jerome Coutant
2:123b894b49dd
|
231
|
|
|
Jerome Coutant
2:123b894b49dd
|
232
|
#if !defined(USE_STM32469I_DISCO_REVA)
|
|
Jerome Coutant
2:123b894b49dd
|
233
|
dsiPllInit.PLLNDIV = 125;
|
|
Jerome Coutant
2:123b894b49dd
|
234
|
dsiPllInit.PLLIDF = DSI_PLL_IN_DIV2;
|
|
Jerome Coutant
2:123b894b49dd
|
235
|
dsiPllInit.PLLODF = DSI_PLL_OUT_DIV1;
|
|
Jerome Coutant
2:123b894b49dd
|
236
|
#else
|
|
Jerome Coutant
2:123b894b49dd
|
237
|
dsiPllInit.PLLNDIV = 100;
|
|
Jerome Coutant
2:123b894b49dd
|
238
|
dsiPllInit.PLLIDF = DSI_PLL_IN_DIV5;
|
|
Jerome Coutant
2:123b894b49dd
|
239
|
dsiPllInit.PLLODF = DSI_PLL_OUT_DIV1;
|
|
Jerome Coutant
2:123b894b49dd
|
240
|
#endif
|
|
Jerome Coutant
2:123b894b49dd
|
241
|
laneByteClk_kHz = 62500; /* 500 MHz / 8 = 62.5 MHz = 62500 kHz */
|
|
Jerome Coutant
2:123b894b49dd
|
242
|
|
|
Jerome Coutant
2:123b894b49dd
|
243
|
/* Set number of Lanes */
|
|
Jerome Coutant
2:123b894b49dd
|
244
|
hdsi_eval.Init.NumberOfLanes = DSI_TWO_DATA_LANES;
|
|
Jerome Coutant
2:123b894b49dd
|
245
|
|
|
Jerome Coutant
2:123b894b49dd
|
246
|
/* TXEscapeCkdiv = f(LaneByteClk)/15.62 = 4 */
|
|
Jerome Coutant
2:123b894b49dd
|
247
|
hdsi_eval.Init.TXEscapeCkdiv = laneByteClk_kHz/15620;
|
|
Jerome Coutant
2:123b894b49dd
|
248
|
|
|
Jerome Coutant
2:123b894b49dd
|
249
|
HAL_DSI_Init(&(hdsi_eval), &(dsiPllInit));
|
|
Jerome Coutant
2:123b894b49dd
|
250
|
|
|
Jerome Coutant
2:123b894b49dd
|
251
|
/* Timing parameters for all Video modes
|
|
Jerome Coutant
2:123b894b49dd
|
252
|
* Set Timing parameters of LTDC depending on its chosen orientation
|
|
Jerome Coutant
2:123b894b49dd
|
253
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
254
|
if(orientation == LCD_ORIENTATION_PORTRAIT)
|
|
Jerome Coutant
2:123b894b49dd
|
255
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
256
|
lcd_x_size = OTM8009A_480X800_WIDTH; /* 480 */
|
|
Jerome Coutant
2:123b894b49dd
|
257
|
lcd_y_size = OTM8009A_480X800_HEIGHT; /* 800 */
|
|
Jerome Coutant
2:123b894b49dd
|
258
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
259
|
else
|
|
Jerome Coutant
2:123b894b49dd
|
260
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
261
|
/* lcd_orientation == LCD_ORIENTATION_LANDSCAPE */
|
|
Jerome Coutant
2:123b894b49dd
|
262
|
lcd_x_size = OTM8009A_800X480_WIDTH; /* 800 */
|
|
Jerome Coutant
2:123b894b49dd
|
263
|
lcd_y_size = OTM8009A_800X480_HEIGHT; /* 480 */
|
|
Jerome Coutant
2:123b894b49dd
|
264
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
265
|
|
|
Jerome Coutant
2:123b894b49dd
|
266
|
HACT = lcd_x_size;
|
|
Jerome Coutant
2:123b894b49dd
|
267
|
VACT = lcd_y_size;
|
|
Jerome Coutant
2:123b894b49dd
|
268
|
|
|
Jerome Coutant
2:123b894b49dd
|
269
|
/* The following values are same for portrait and landscape orientations */
|
|
Jerome Coutant
2:123b894b49dd
|
270
|
VSA = OTM8009A_480X800_VSYNC;
|
|
Jerome Coutant
2:123b894b49dd
|
271
|
VBP = OTM8009A_480X800_VBP;
|
|
Jerome Coutant
2:123b894b49dd
|
272
|
VFP = OTM8009A_480X800_VFP;
|
|
Jerome Coutant
2:123b894b49dd
|
273
|
HSA = OTM8009A_480X800_HSYNC;
|
|
Jerome Coutant
2:123b894b49dd
|
274
|
HBP = OTM8009A_480X800_HBP;
|
|
Jerome Coutant
2:123b894b49dd
|
275
|
HFP = OTM8009A_480X800_HFP;
|
|
Jerome Coutant
2:123b894b49dd
|
276
|
|
|
Jerome Coutant
2:123b894b49dd
|
277
|
|
|
Jerome Coutant
2:123b894b49dd
|
278
|
hdsivideo_handle.VirtualChannelID = LCD_OTM8009A_ID;
|
|
Jerome Coutant
2:123b894b49dd
|
279
|
hdsivideo_handle.ColorCoding = LCD_DSI_PIXEL_DATA_FMT_RBG888;
|
|
Jerome Coutant
2:123b894b49dd
|
280
|
hdsivideo_handle.VSPolarity = DSI_VSYNC_ACTIVE_HIGH;
|
|
Jerome Coutant
2:123b894b49dd
|
281
|
hdsivideo_handle.HSPolarity = DSI_HSYNC_ACTIVE_HIGH;
|
|
Jerome Coutant
2:123b894b49dd
|
282
|
hdsivideo_handle.DEPolarity = DSI_DATA_ENABLE_ACTIVE_HIGH;
|
|
Jerome Coutant
2:123b894b49dd
|
283
|
hdsivideo_handle.Mode = DSI_VID_MODE_BURST; /* Mode Video burst ie : one LgP per line */
|
|
Jerome Coutant
2:123b894b49dd
|
284
|
hdsivideo_handle.NullPacketSize = 0xFFF;
|
|
Jerome Coutant
2:123b894b49dd
|
285
|
hdsivideo_handle.NumberOfChunks = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
286
|
hdsivideo_handle.PacketSize = HACT; /* Value depending on display orientation choice portrait/landscape */
|
|
Jerome Coutant
2:123b894b49dd
|
287
|
hdsivideo_handle.HorizontalSyncActive = (HSA * laneByteClk_kHz) / LcdClock;
|
|
Jerome Coutant
2:123b894b49dd
|
288
|
hdsivideo_handle.HorizontalBackPorch = (HBP * laneByteClk_kHz) / LcdClock;
|
|
Jerome Coutant
2:123b894b49dd
|
289
|
hdsivideo_handle.HorizontalLine = ((HACT + HSA + HBP + HFP) * laneByteClk_kHz) / LcdClock; /* Value depending on display orientation choice portrait/landscape */
|
|
Jerome Coutant
2:123b894b49dd
|
290
|
hdsivideo_handle.VerticalSyncActive = VSA;
|
|
Jerome Coutant
2:123b894b49dd
|
291
|
hdsivideo_handle.VerticalBackPorch = VBP;
|
|
Jerome Coutant
2:123b894b49dd
|
292
|
hdsivideo_handle.VerticalFrontPorch = VFP;
|
|
Jerome Coutant
2:123b894b49dd
|
293
|
hdsivideo_handle.VerticalActive = VACT; /* Value depending on display orientation choice portrait/landscape */
|
|
Jerome Coutant
2:123b894b49dd
|
294
|
|
|
Jerome Coutant
2:123b894b49dd
|
295
|
/* Enable or disable sending LP command while streaming is active in video mode */
|
|
Jerome Coutant
2:123b894b49dd
|
296
|
hdsivideo_handle.LPCommandEnable = DSI_LP_COMMAND_ENABLE; /* Enable sending commands in mode LP (Low Power) */
|
|
Jerome Coutant
2:123b894b49dd
|
297
|
|
|
Jerome Coutant
2:123b894b49dd
|
298
|
/* Largest packet size possible to transmit in LP mode in VSA, VBP, VFP regions */
|
|
Jerome Coutant
2:123b894b49dd
|
299
|
/* Only useful when sending LP packets is allowed while streaming is active in video mode */
|
|
Jerome Coutant
2:123b894b49dd
|
300
|
hdsivideo_handle.LPLargestPacketSize = 16;
|
|
Jerome Coutant
2:123b894b49dd
|
301
|
|
|
Jerome Coutant
2:123b894b49dd
|
302
|
/* Largest packet size possible to transmit in LP mode in HFP region during VACT period */
|
|
Jerome Coutant
2:123b894b49dd
|
303
|
/* Only useful when sending LP packets is allowed while streaming is active in video mode */
|
|
Jerome Coutant
2:123b894b49dd
|
304
|
hdsivideo_handle.LPVACTLargestPacketSize = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
305
|
|
|
Jerome Coutant
2:123b894b49dd
|
306
|
|
|
Jerome Coutant
2:123b894b49dd
|
307
|
/* Specify for each region of the video frame, if the transmission of command in LP mode is allowed in this region */
|
|
Jerome Coutant
2:123b894b49dd
|
308
|
/* while streaming is active in video mode */
|
|
Jerome Coutant
2:123b894b49dd
|
309
|
hdsivideo_handle.LPHorizontalFrontPorchEnable = DSI_LP_HFP_ENABLE; /* Allow sending LP commands during HFP period */
|
|
Jerome Coutant
2:123b894b49dd
|
310
|
hdsivideo_handle.LPHorizontalBackPorchEnable = DSI_LP_HBP_ENABLE; /* Allow sending LP commands during HBP period */
|
|
Jerome Coutant
2:123b894b49dd
|
311
|
hdsivideo_handle.LPVerticalActiveEnable = DSI_LP_VACT_ENABLE; /* Allow sending LP commands during VACT period */
|
|
Jerome Coutant
2:123b894b49dd
|
312
|
hdsivideo_handle.LPVerticalFrontPorchEnable = DSI_LP_VFP_ENABLE; /* Allow sending LP commands during VFP period */
|
|
Jerome Coutant
2:123b894b49dd
|
313
|
hdsivideo_handle.LPVerticalBackPorchEnable = DSI_LP_VBP_ENABLE; /* Allow sending LP commands during VBP period */
|
|
Jerome Coutant
2:123b894b49dd
|
314
|
hdsivideo_handle.LPVerticalSyncActiveEnable = DSI_LP_VSYNC_ENABLE; /* Allow sending LP commands during VSync = VSA period */
|
|
Jerome Coutant
2:123b894b49dd
|
315
|
|
|
Jerome Coutant
2:123b894b49dd
|
316
|
/* Configure DSI Video mode timings with settings set above */
|
|
Jerome Coutant
2:123b894b49dd
|
317
|
HAL_DSI_ConfigVideoMode(&(hdsi_eval), &(hdsivideo_handle));
|
|
Jerome Coutant
2:123b894b49dd
|
318
|
|
|
Jerome Coutant
2:123b894b49dd
|
319
|
/* Configure DSI PHY HS2LP and LP2HS timings */
|
|
Jerome Coutant
2:123b894b49dd
|
320
|
PhyTimings.ClockLaneHS2LPTime = 35;
|
|
Jerome Coutant
2:123b894b49dd
|
321
|
PhyTimings.ClockLaneLP2HSTime = 35;
|
|
Jerome Coutant
2:123b894b49dd
|
322
|
PhyTimings.DataLaneHS2LPTime = 35;
|
|
Jerome Coutant
2:123b894b49dd
|
323
|
PhyTimings.DataLaneLP2HSTime = 35;
|
|
Jerome Coutant
2:123b894b49dd
|
324
|
PhyTimings.DataLaneMaxReadTime = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
325
|
PhyTimings.StopWaitTime = 10;
|
|
Jerome Coutant
2:123b894b49dd
|
326
|
HAL_DSI_ConfigPhyTimer(&hdsi_eval, &PhyTimings);
|
|
Jerome Coutant
2:123b894b49dd
|
327
|
|
|
Jerome Coutant
2:123b894b49dd
|
328
|
/*************************End DSI Initialization*******************************/
|
|
Jerome Coutant
2:123b894b49dd
|
329
|
|
|
Jerome Coutant
2:123b894b49dd
|
330
|
|
|
Jerome Coutant
2:123b894b49dd
|
331
|
/************************LTDC Initialization***********************************/
|
|
Jerome Coutant
2:123b894b49dd
|
332
|
|
|
Jerome Coutant
2:123b894b49dd
|
333
|
/* Timing Configuration */
|
|
Jerome Coutant
2:123b894b49dd
|
334
|
hltdc_eval.Init.HorizontalSync = (HSA - 1);
|
|
Jerome Coutant
2:123b894b49dd
|
335
|
hltdc_eval.Init.AccumulatedHBP = (HSA + HBP - 1);
|
|
Jerome Coutant
2:123b894b49dd
|
336
|
hltdc_eval.Init.AccumulatedActiveW = (lcd_x_size + HSA + HBP - 1);
|
|
Jerome Coutant
2:123b894b49dd
|
337
|
hltdc_eval.Init.TotalWidth = (lcd_x_size + HSA + HBP + HFP - 1);
|
|
Jerome Coutant
2:123b894b49dd
|
338
|
|
|
Jerome Coutant
2:123b894b49dd
|
339
|
/* Initialize the LCD pixel width and pixel height */
|
|
Jerome Coutant
2:123b894b49dd
|
340
|
hltdc_eval.LayerCfg->ImageWidth = lcd_x_size;
|
|
Jerome Coutant
2:123b894b49dd
|
341
|
hltdc_eval.LayerCfg->ImageHeight = lcd_y_size;
|
|
Jerome Coutant
2:123b894b49dd
|
342
|
|
|
Jerome Coutant
2:123b894b49dd
|
343
|
|
|
Jerome Coutant
2:123b894b49dd
|
344
|
/* LCD clock configuration */
|
|
Jerome Coutant
2:123b894b49dd
|
345
|
/* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */
|
|
Jerome Coutant
2:123b894b49dd
|
346
|
/* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 384 Mhz */
|
|
Jerome Coutant
2:123b894b49dd
|
347
|
/* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 384 MHz / 7 = 54.857 MHz */
|
|
Jerome Coutant
2:123b894b49dd
|
348
|
/* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_2 = 54.857 MHz / 2 = 27.429 MHz */
|
|
Jerome Coutant
2:123b894b49dd
|
349
|
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
|
|
Jerome Coutant
2:123b894b49dd
|
350
|
PeriphClkInitStruct.PLLSAI.PLLSAIN = 384;
|
|
Jerome Coutant
2:123b894b49dd
|
351
|
PeriphClkInitStruct.PLLSAI.PLLSAIR = 7;
|
|
Jerome Coutant
2:123b894b49dd
|
352
|
PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2;
|
|
Jerome Coutant
2:123b894b49dd
|
353
|
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
|
|
Jerome Coutant
2:123b894b49dd
|
354
|
|
|
Jerome Coutant
2:123b894b49dd
|
355
|
/* Background value */
|
|
Jerome Coutant
2:123b894b49dd
|
356
|
hltdc_eval.Init.Backcolor.Blue = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
357
|
hltdc_eval.Init.Backcolor.Green = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
358
|
hltdc_eval.Init.Backcolor.Red = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
359
|
hltdc_eval.Init.PCPolarity = LTDC_PCPOLARITY_IPC;
|
|
Jerome Coutant
2:123b894b49dd
|
360
|
hltdc_eval.Instance = LTDC;
|
|
Jerome Coutant
2:123b894b49dd
|
361
|
|
|
Jerome Coutant
2:123b894b49dd
|
362
|
/* Get LTDC Configuration from DSI Configuration */
|
|
Jerome Coutant
2:123b894b49dd
|
363
|
HAL_LTDCEx_StructInitFromVideoConfig(&(hltdc_eval), &(hdsivideo_handle));
|
|
Jerome Coutant
2:123b894b49dd
|
364
|
|
|
Jerome Coutant
2:123b894b49dd
|
365
|
/* Initialize the LTDC */
|
|
Jerome Coutant
2:123b894b49dd
|
366
|
HAL_LTDC_Init(&hltdc_eval);
|
|
Jerome Coutant
2:123b894b49dd
|
367
|
|
|
Jerome Coutant
2:123b894b49dd
|
368
|
/* Enable the DSI host and wrapper after the LTDC initialization
|
|
Jerome Coutant
2:123b894b49dd
|
369
|
To avoid any synchronization issue, the DSI shall be started after enabling the LTDC */
|
|
Jerome Coutant
2:123b894b49dd
|
370
|
HAL_DSI_Start(&(hdsi_eval));
|
|
Jerome Coutant
2:123b894b49dd
|
371
|
|
|
Jerome Coutant
2:123b894b49dd
|
372
|
#if !defined(DATA_IN_ExtSDRAM)
|
|
Jerome Coutant
2:123b894b49dd
|
373
|
/* Initialize the SDRAM */
|
|
Jerome Coutant
2:123b894b49dd
|
374
|
BSP_SDRAM_Init();
|
|
Jerome Coutant
2:123b894b49dd
|
375
|
#endif /* DATA_IN_ExtSDRAM */
|
|
Jerome Coutant
2:123b894b49dd
|
376
|
|
|
Jerome Coutant
2:123b894b49dd
|
377
|
/* Initialize the font */
|
|
Jerome Coutant
2:123b894b49dd
|
378
|
BSP_LCD_SetFont(&LCD_DEFAULT_FONT);
|
|
Jerome Coutant
2:123b894b49dd
|
379
|
|
|
Jerome Coutant
2:123b894b49dd
|
380
|
/************************End LTDC Initialization*******************************/
|
|
Jerome Coutant
2:123b894b49dd
|
381
|
|
|
Jerome Coutant
2:123b894b49dd
|
382
|
|
|
Jerome Coutant
2:123b894b49dd
|
383
|
/***********************OTM8009A Initialization********************************/
|
|
Jerome Coutant
2:123b894b49dd
|
384
|
|
|
Jerome Coutant
2:123b894b49dd
|
385
|
/* Initialize the OTM8009A LCD Display IC Driver (KoD LCD IC Driver)
|
|
Jerome Coutant
2:123b894b49dd
|
386
|
* depending on configuration set in 'hdsivideo_handle'.
|
|
Jerome Coutant
2:123b894b49dd
|
387
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
388
|
OTM8009A_Init(OTM8009A_FORMAT_RGB888, orientation);
|
|
Jerome Coutant
2:123b894b49dd
|
389
|
|
|
Jerome Coutant
2:123b894b49dd
|
390
|
/***********************End OTM8009A Initialization****************************/
|
|
Jerome Coutant
2:123b894b49dd
|
391
|
|
|
Jerome Coutant
2:123b894b49dd
|
392
|
return LCD_OK;
|
|
Jerome Coutant
2:123b894b49dd
|
393
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
394
|
|
|
Jerome Coutant
2:123b894b49dd
|
395
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
396
|
* @brief BSP LCD Reset
|
|
Jerome Coutant
2:123b894b49dd
|
397
|
* Hw reset the LCD DSI activating its XRES signal (active low for some time)
|
|
Jerome Coutant
2:123b894b49dd
|
398
|
* and desactivating it later.
|
|
Jerome Coutant
2:123b894b49dd
|
399
|
* This signal is only cabled on Discovery Rev B and beyond.
|
|
Jerome Coutant
2:123b894b49dd
|
400
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
401
|
void BSP_LCD_Reset(void)
|
|
Jerome Coutant
2:123b894b49dd
|
402
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
403
|
#if !defined(USE_STM32469I_DISCO_REVA)
|
|
Jerome Coutant
2:123b894b49dd
|
404
|
/* EVAL Rev B and beyond : reset the LCD by activation of XRES (active low) connected to PH7 */
|
|
Jerome Coutant
2:123b894b49dd
|
405
|
GPIO_InitTypeDef gpio_init_structure;
|
|
Jerome Coutant
2:123b894b49dd
|
406
|
|
|
Jerome Coutant
2:123b894b49dd
|
407
|
__HAL_RCC_GPIOH_CLK_ENABLE();
|
|
Jerome Coutant
2:123b894b49dd
|
408
|
|
|
Jerome Coutant
2:123b894b49dd
|
409
|
/* Configure the GPIO on PH7 */
|
|
Jerome Coutant
2:123b894b49dd
|
410
|
gpio_init_structure.Pin = GPIO_PIN_7;
|
|
Jerome Coutant
2:123b894b49dd
|
411
|
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_OD;
|
|
Jerome Coutant
2:123b894b49dd
|
412
|
gpio_init_structure.Pull = GPIO_NOPULL;
|
|
Jerome Coutant
2:123b894b49dd
|
413
|
gpio_init_structure.Speed = GPIO_SPEED_HIGH;
|
|
Jerome Coutant
2:123b894b49dd
|
414
|
|
|
Jerome Coutant
2:123b894b49dd
|
415
|
HAL_GPIO_Init(GPIOH, &gpio_init_structure);
|
|
Jerome Coutant
2:123b894b49dd
|
416
|
|
|
Jerome Coutant
2:123b894b49dd
|
417
|
/* Activate XRES active low */
|
|
Jerome Coutant
2:123b894b49dd
|
418
|
HAL_GPIO_WritePin(GPIOH, GPIO_PIN_7, GPIO_PIN_RESET);
|
|
Jerome Coutant
2:123b894b49dd
|
419
|
|
|
Jerome Coutant
2:123b894b49dd
|
420
|
//HAL_Delay(20); /* wait 20 ms */
|
|
Jerome Coutant
2:123b894b49dd
|
421
|
wait_ms(20);
|
|
Jerome Coutant
2:123b894b49dd
|
422
|
|
|
Jerome Coutant
2:123b894b49dd
|
423
|
/* Desactivate XRES */
|
|
Jerome Coutant
2:123b894b49dd
|
424
|
HAL_GPIO_WritePin(GPIOH, GPIO_PIN_7, GPIO_PIN_SET);
|
|
Jerome Coutant
2:123b894b49dd
|
425
|
|
|
Jerome Coutant
2:123b894b49dd
|
426
|
/* Wait for 10ms after releasing XRES before sending commands */
|
|
Jerome Coutant
2:123b894b49dd
|
427
|
//HAL_Delay(10);
|
|
Jerome Coutant
2:123b894b49dd
|
428
|
wait_ms(10);
|
|
Jerome Coutant
2:123b894b49dd
|
429
|
#else
|
|
Jerome Coutant
2:123b894b49dd
|
430
|
|
|
Jerome Coutant
2:123b894b49dd
|
431
|
#endif /* USE_STM32469I_DISCO_REVA == 0 */
|
|
Jerome Coutant
2:123b894b49dd
|
432
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
433
|
|
|
Jerome Coutant
2:123b894b49dd
|
434
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
435
|
* @brief Gets the LCD X size.
|
|
Jerome Coutant
2:123b894b49dd
|
436
|
* @retval Used LCD X size
|
|
Jerome Coutant
2:123b894b49dd
|
437
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
438
|
uint32_t BSP_LCD_GetXSize(void)
|
|
Jerome Coutant
2:123b894b49dd
|
439
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
440
|
return (lcd_x_size);
|
|
Jerome Coutant
2:123b894b49dd
|
441
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
442
|
|
|
Jerome Coutant
2:123b894b49dd
|
443
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
444
|
* @brief Gets the LCD Y size.
|
|
Jerome Coutant
2:123b894b49dd
|
445
|
* @retval Used LCD Y size
|
|
Jerome Coutant
2:123b894b49dd
|
446
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
447
|
uint32_t BSP_LCD_GetYSize(void)
|
|
Jerome Coutant
2:123b894b49dd
|
448
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
449
|
return (lcd_y_size);
|
|
Jerome Coutant
2:123b894b49dd
|
450
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
451
|
|
|
Jerome Coutant
2:123b894b49dd
|
452
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
453
|
* @brief Set the LCD X size.
|
|
Jerome Coutant
2:123b894b49dd
|
454
|
* @param imageWidthPixels : uint32_t image width in pixels unit
|
|
Jerome Coutant
2:123b894b49dd
|
455
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
456
|
void BSP_LCD_SetXSize(uint32_t imageWidthPixels)
|
|
Jerome Coutant
2:123b894b49dd
|
457
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
458
|
hltdc_eval.LayerCfg[ActiveLayer].ImageWidth = imageWidthPixels;
|
|
Jerome Coutant
2:123b894b49dd
|
459
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
460
|
|
|
Jerome Coutant
2:123b894b49dd
|
461
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
462
|
* @brief Set the LCD Y size.
|
|
Jerome Coutant
2:123b894b49dd
|
463
|
* @param imageHeightPixels : uint32_t image height in lines unit
|
|
Jerome Coutant
2:123b894b49dd
|
464
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
465
|
void BSP_LCD_SetYSize(uint32_t imageHeightPixels)
|
|
Jerome Coutant
2:123b894b49dd
|
466
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
467
|
hltdc_eval.LayerCfg[ActiveLayer].ImageHeight = imageHeightPixels;
|
|
Jerome Coutant
2:123b894b49dd
|
468
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
469
|
|
|
Jerome Coutant
2:123b894b49dd
|
470
|
|
|
Jerome Coutant
2:123b894b49dd
|
471
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
472
|
* @brief Initializes the LCD layers.
|
|
Jerome Coutant
2:123b894b49dd
|
473
|
* @param LayerIndex: Layer foreground or background
|
|
Jerome Coutant
2:123b894b49dd
|
474
|
* @param FB_Address: Layer frame buffer
|
|
Jerome Coutant
2:123b894b49dd
|
475
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
476
|
void BSP_LCD_LayerDefaultInit(uint16_t LayerIndex, uint32_t FB_Address)
|
|
Jerome Coutant
2:123b894b49dd
|
477
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
478
|
LCD_LayerCfgTypeDef Layercfg;
|
|
Jerome Coutant
2:123b894b49dd
|
479
|
|
|
Jerome Coutant
2:123b894b49dd
|
480
|
/* Layer Init */
|
|
Jerome Coutant
2:123b894b49dd
|
481
|
Layercfg.WindowX0 = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
482
|
Layercfg.WindowX1 = BSP_LCD_GetXSize();
|
|
Jerome Coutant
2:123b894b49dd
|
483
|
Layercfg.WindowY0 = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
484
|
Layercfg.WindowY1 = BSP_LCD_GetYSize();
|
|
Jerome Coutant
2:123b894b49dd
|
485
|
Layercfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888;
|
|
Jerome Coutant
2:123b894b49dd
|
486
|
Layercfg.FBStartAdress = FB_Address;
|
|
Jerome Coutant
2:123b894b49dd
|
487
|
Layercfg.Alpha = 255;
|
|
Jerome Coutant
2:123b894b49dd
|
488
|
Layercfg.Alpha0 = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
489
|
Layercfg.Backcolor.Blue = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
490
|
Layercfg.Backcolor.Green = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
491
|
Layercfg.Backcolor.Red = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
492
|
Layercfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA;
|
|
Jerome Coutant
2:123b894b49dd
|
493
|
Layercfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA;
|
|
Jerome Coutant
2:123b894b49dd
|
494
|
Layercfg.ImageWidth = BSP_LCD_GetXSize();
|
|
Jerome Coutant
2:123b894b49dd
|
495
|
Layercfg.ImageHeight = BSP_LCD_GetYSize();
|
|
Jerome Coutant
2:123b894b49dd
|
496
|
|
|
Jerome Coutant
2:123b894b49dd
|
497
|
HAL_LTDC_ConfigLayer(&hltdc_eval, &Layercfg, LayerIndex);
|
|
Jerome Coutant
2:123b894b49dd
|
498
|
|
|
Jerome Coutant
2:123b894b49dd
|
499
|
DrawProp[LayerIndex].BackColor = LCD_COLOR_WHITE;
|
|
Jerome Coutant
2:123b894b49dd
|
500
|
DrawProp[LayerIndex].pFont = &Font24;
|
|
Jerome Coutant
2:123b894b49dd
|
501
|
DrawProp[LayerIndex].TextColor = LCD_COLOR_BLACK;
|
|
Jerome Coutant
2:123b894b49dd
|
502
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
503
|
|
|
Jerome Coutant
2:123b894b49dd
|
504
|
|
|
Jerome Coutant
2:123b894b49dd
|
505
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
506
|
* @brief Selects the LCD Layer.
|
|
Jerome Coutant
2:123b894b49dd
|
507
|
* @param LayerIndex: Layer foreground or background
|
|
Jerome Coutant
2:123b894b49dd
|
508
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
509
|
void BSP_LCD_SelectLayer(uint32_t LayerIndex)
|
|
Jerome Coutant
2:123b894b49dd
|
510
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
511
|
ActiveLayer = LayerIndex;
|
|
Jerome Coutant
2:123b894b49dd
|
512
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
513
|
|
|
Jerome Coutant
2:123b894b49dd
|
514
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
515
|
* @brief Sets an LCD Layer visible
|
|
Jerome Coutant
2:123b894b49dd
|
516
|
* @param LayerIndex: Visible Layer
|
|
Jerome Coutant
2:123b894b49dd
|
517
|
* @param State: New state of the specified layer
|
|
Jerome Coutant
2:123b894b49dd
|
518
|
* This parameter can be one of the following values:
|
|
Jerome Coutant
2:123b894b49dd
|
519
|
* @arg ENABLE
|
|
Jerome Coutant
2:123b894b49dd
|
520
|
* @arg DISABLE
|
|
Jerome Coutant
2:123b894b49dd
|
521
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
522
|
void BSP_LCD_SetLayerVisible(uint32_t LayerIndex, FunctionalState State)
|
|
Jerome Coutant
2:123b894b49dd
|
523
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
524
|
if(State == ENABLE)
|
|
Jerome Coutant
2:123b894b49dd
|
525
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
526
|
__HAL_LTDC_LAYER_ENABLE(&(hltdc_eval), LayerIndex);
|
|
Jerome Coutant
2:123b894b49dd
|
527
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
528
|
else
|
|
Jerome Coutant
2:123b894b49dd
|
529
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
530
|
__HAL_LTDC_LAYER_DISABLE(&(hltdc_eval), LayerIndex);
|
|
Jerome Coutant
2:123b894b49dd
|
531
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
532
|
__HAL_LTDC_RELOAD_IMMEDIATE_CONFIG(&(hltdc_eval));
|
|
Jerome Coutant
2:123b894b49dd
|
533
|
|
|
Jerome Coutant
2:123b894b49dd
|
534
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
535
|
|
|
Jerome Coutant
2:123b894b49dd
|
536
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
537
|
* @brief Configures the transparency.
|
|
Jerome Coutant
2:123b894b49dd
|
538
|
* @param LayerIndex: Layer foreground or background.
|
|
Jerome Coutant
2:123b894b49dd
|
539
|
* @param Transparency: Transparency
|
|
Jerome Coutant
2:123b894b49dd
|
540
|
* This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF
|
|
Jerome Coutant
2:123b894b49dd
|
541
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
542
|
void BSP_LCD_SetTransparency(uint32_t LayerIndex, uint8_t Transparency)
|
|
Jerome Coutant
2:123b894b49dd
|
543
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
544
|
|
|
Jerome Coutant
2:123b894b49dd
|
545
|
HAL_LTDC_SetAlpha(&(hltdc_eval), Transparency, LayerIndex);
|
|
Jerome Coutant
2:123b894b49dd
|
546
|
|
|
Jerome Coutant
2:123b894b49dd
|
547
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
548
|
|
|
Jerome Coutant
2:123b894b49dd
|
549
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
550
|
* @brief Sets an LCD layer frame buffer address.
|
|
Jerome Coutant
2:123b894b49dd
|
551
|
* @param LayerIndex: Layer foreground or background
|
|
Jerome Coutant
2:123b894b49dd
|
552
|
* @param Address: New LCD frame buffer value
|
|
Jerome Coutant
2:123b894b49dd
|
553
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
554
|
void BSP_LCD_SetLayerAddress(uint32_t LayerIndex, uint32_t Address)
|
|
Jerome Coutant
2:123b894b49dd
|
555
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
556
|
|
|
Jerome Coutant
2:123b894b49dd
|
557
|
HAL_LTDC_SetAddress(&(hltdc_eval), Address, LayerIndex);
|
|
Jerome Coutant
2:123b894b49dd
|
558
|
|
|
Jerome Coutant
2:123b894b49dd
|
559
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
560
|
|
|
Jerome Coutant
2:123b894b49dd
|
561
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
562
|
* @brief Sets display window.
|
|
Jerome Coutant
2:123b894b49dd
|
563
|
* @param LayerIndex: Layer index
|
|
Jerome Coutant
2:123b894b49dd
|
564
|
* @param Xpos: LCD X position
|
|
Jerome Coutant
2:123b894b49dd
|
565
|
* @param Ypos: LCD Y position
|
|
Jerome Coutant
2:123b894b49dd
|
566
|
* @param Width: LCD window width
|
|
Jerome Coutant
2:123b894b49dd
|
567
|
* @param Height: LCD window height
|
|
Jerome Coutant
2:123b894b49dd
|
568
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
569
|
void BSP_LCD_SetLayerWindow(uint16_t LayerIndex, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
|
|
Jerome Coutant
2:123b894b49dd
|
570
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
571
|
/* Reconfigure the layer size */
|
|
Jerome Coutant
2:123b894b49dd
|
572
|
HAL_LTDC_SetWindowSize(&(hltdc_eval), Width, Height, LayerIndex);
|
|
Jerome Coutant
2:123b894b49dd
|
573
|
|
|
Jerome Coutant
2:123b894b49dd
|
574
|
/* Reconfigure the layer position */
|
|
Jerome Coutant
2:123b894b49dd
|
575
|
HAL_LTDC_SetWindowPosition(&(hltdc_eval), Xpos, Ypos, LayerIndex);
|
|
Jerome Coutant
2:123b894b49dd
|
576
|
|
|
Jerome Coutant
2:123b894b49dd
|
577
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
578
|
|
|
Jerome Coutant
2:123b894b49dd
|
579
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
580
|
* @brief Configures and sets the color keying.
|
|
Jerome Coutant
2:123b894b49dd
|
581
|
* @param LayerIndex: Layer foreground or background
|
|
Jerome Coutant
2:123b894b49dd
|
582
|
* @param RGBValue: Color reference
|
|
Jerome Coutant
2:123b894b49dd
|
583
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
584
|
void BSP_LCD_SetColorKeying(uint32_t LayerIndex, uint32_t RGBValue)
|
|
Jerome Coutant
2:123b894b49dd
|
585
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
586
|
/* Configure and Enable the color Keying for LCD Layer */
|
|
Jerome Coutant
2:123b894b49dd
|
587
|
HAL_LTDC_ConfigColorKeying(&(hltdc_eval), RGBValue, LayerIndex);
|
|
Jerome Coutant
2:123b894b49dd
|
588
|
HAL_LTDC_EnableColorKeying(&(hltdc_eval), LayerIndex);
|
|
Jerome Coutant
2:123b894b49dd
|
589
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
590
|
|
|
Jerome Coutant
2:123b894b49dd
|
591
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
592
|
* @brief Disables the color keying.
|
|
Jerome Coutant
2:123b894b49dd
|
593
|
* @param LayerIndex: Layer foreground or background
|
|
Jerome Coutant
2:123b894b49dd
|
594
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
595
|
void BSP_LCD_ResetColorKeying(uint32_t LayerIndex)
|
|
Jerome Coutant
2:123b894b49dd
|
596
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
597
|
/* Disable the color Keying for LCD Layer */
|
|
Jerome Coutant
2:123b894b49dd
|
598
|
HAL_LTDC_DisableColorKeying(&(hltdc_eval), LayerIndex);
|
|
Jerome Coutant
2:123b894b49dd
|
599
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
600
|
|
|
Jerome Coutant
2:123b894b49dd
|
601
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
602
|
* @brief Sets the LCD text color.
|
|
Jerome Coutant
2:123b894b49dd
|
603
|
* @param Color: Text color code ARGB(8-8-8-8)
|
|
Jerome Coutant
2:123b894b49dd
|
604
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
605
|
void BSP_LCD_SetTextColor(uint32_t Color)
|
|
Jerome Coutant
2:123b894b49dd
|
606
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
607
|
DrawProp[ActiveLayer].TextColor = Color;
|
|
Jerome Coutant
2:123b894b49dd
|
608
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
609
|
|
|
Jerome Coutant
2:123b894b49dd
|
610
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
611
|
* @brief Gets the LCD text color.
|
|
Jerome Coutant
2:123b894b49dd
|
612
|
* @retval Used text color.
|
|
Jerome Coutant
2:123b894b49dd
|
613
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
614
|
uint32_t BSP_LCD_GetTextColor(void)
|
|
Jerome Coutant
2:123b894b49dd
|
615
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
616
|
return DrawProp[ActiveLayer].TextColor;
|
|
Jerome Coutant
2:123b894b49dd
|
617
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
618
|
|
|
Jerome Coutant
2:123b894b49dd
|
619
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
620
|
* @brief Sets the LCD background color.
|
|
Jerome Coutant
2:123b894b49dd
|
621
|
* @param Color: Layer background color code ARGB(8-8-8-8)
|
|
Jerome Coutant
2:123b894b49dd
|
622
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
623
|
void BSP_LCD_SetBackColor(uint32_t Color)
|
|
Jerome Coutant
2:123b894b49dd
|
624
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
625
|
DrawProp[ActiveLayer].BackColor = Color;
|
|
Jerome Coutant
2:123b894b49dd
|
626
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
627
|
|
|
Jerome Coutant
2:123b894b49dd
|
628
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
629
|
* @brief Gets the LCD background color.
|
|
Jerome Coutant
2:123b894b49dd
|
630
|
* @retval Used background color
|
|
Jerome Coutant
2:123b894b49dd
|
631
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
632
|
uint32_t BSP_LCD_GetBackColor(void)
|
|
Jerome Coutant
2:123b894b49dd
|
633
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
634
|
return DrawProp[ActiveLayer].BackColor;
|
|
Jerome Coutant
2:123b894b49dd
|
635
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
636
|
|
|
Jerome Coutant
2:123b894b49dd
|
637
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
638
|
* @brief Sets the LCD text font.
|
|
Jerome Coutant
2:123b894b49dd
|
639
|
* @param fonts: Layer font to be used
|
|
Jerome Coutant
2:123b894b49dd
|
640
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
641
|
void BSP_LCD_SetFont(sFONT *fonts)
|
|
Jerome Coutant
2:123b894b49dd
|
642
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
643
|
DrawProp[ActiveLayer].pFont = fonts;
|
|
Jerome Coutant
2:123b894b49dd
|
644
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
645
|
|
|
Jerome Coutant
2:123b894b49dd
|
646
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
647
|
* @brief Gets the LCD text font.
|
|
Jerome Coutant
2:123b894b49dd
|
648
|
* @retval Used layer font
|
|
Jerome Coutant
2:123b894b49dd
|
649
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
650
|
sFONT *BSP_LCD_GetFont(void)
|
|
Jerome Coutant
2:123b894b49dd
|
651
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
652
|
return DrawProp[ActiveLayer].pFont;
|
|
Jerome Coutant
2:123b894b49dd
|
653
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
654
|
|
|
Jerome Coutant
2:123b894b49dd
|
655
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
656
|
* @brief Reads an LCD pixel.
|
|
Jerome Coutant
2:123b894b49dd
|
657
|
* @param Xpos: X position
|
|
Jerome Coutant
2:123b894b49dd
|
658
|
* @param Ypos: Y position
|
|
Jerome Coutant
2:123b894b49dd
|
659
|
* @retval RGB pixel color
|
|
Jerome Coutant
2:123b894b49dd
|
660
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
661
|
uint32_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos)
|
|
Jerome Coutant
2:123b894b49dd
|
662
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
663
|
uint32_t ret = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
664
|
|
|
Jerome Coutant
2:123b894b49dd
|
665
|
if(hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
|
|
Jerome Coutant
2:123b894b49dd
|
666
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
667
|
/* Read data value from SDRAM memory */
|
|
Jerome Coutant
2:123b894b49dd
|
668
|
ret = *(__IO uint32_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (4*(Ypos*BSP_LCD_GetXSize() + Xpos)));
|
|
Jerome Coutant
2:123b894b49dd
|
669
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
670
|
else if(hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB888)
|
|
Jerome Coutant
2:123b894b49dd
|
671
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
672
|
/* Read data value from SDRAM memory */
|
|
Jerome Coutant
2:123b894b49dd
|
673
|
ret = (*(__IO uint32_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (4*(Ypos*BSP_LCD_GetXSize() + Xpos))) & 0x00FFFFFF);
|
|
Jerome Coutant
2:123b894b49dd
|
674
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
675
|
else if((hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \
|
|
Jerome Coutant
2:123b894b49dd
|
676
|
(hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \
|
|
Jerome Coutant
2:123b894b49dd
|
677
|
(hltdc_eval.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_AL88))
|
|
Jerome Coutant
2:123b894b49dd
|
678
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
679
|
/* Read data value from SDRAM memory */
|
|
Jerome Coutant
2:123b894b49dd
|
680
|
ret = *(__IO uint16_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos)));
|
|
Jerome Coutant
2:123b894b49dd
|
681
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
682
|
else
|
|
Jerome Coutant
2:123b894b49dd
|
683
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
684
|
/* Read data value from SDRAM memory */
|
|
Jerome Coutant
2:123b894b49dd
|
685
|
ret = *(__IO uint8_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos)));
|
|
Jerome Coutant
2:123b894b49dd
|
686
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
687
|
|
|
Jerome Coutant
2:123b894b49dd
|
688
|
return ret;
|
|
Jerome Coutant
2:123b894b49dd
|
689
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
690
|
|
|
Jerome Coutant
2:123b894b49dd
|
691
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
692
|
* @brief Clears the whole currently active layer of LTDC.
|
|
Jerome Coutant
2:123b894b49dd
|
693
|
* @param Color: Color of the background
|
|
Jerome Coutant
2:123b894b49dd
|
694
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
695
|
void BSP_LCD_Clear(uint32_t Color)
|
|
Jerome Coutant
2:123b894b49dd
|
696
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
697
|
/* Clear the LCD */
|
|
Jerome Coutant
2:123b894b49dd
|
698
|
LL_FillBuffer(ActiveLayer, (uint32_t *)(hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress), BSP_LCD_GetXSize(), BSP_LCD_GetYSize(), 0, Color);
|
|
Jerome Coutant
2:123b894b49dd
|
699
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
700
|
|
|
Jerome Coutant
2:123b894b49dd
|
701
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
702
|
* @brief Clears the selected line in currently active layer.
|
|
Jerome Coutant
2:123b894b49dd
|
703
|
* @param Line: Line to be cleared
|
|
Jerome Coutant
2:123b894b49dd
|
704
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
705
|
void BSP_LCD_ClearStringLine(uint32_t Line)
|
|
Jerome Coutant
2:123b894b49dd
|
706
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
707
|
uint32_t color_backup = DrawProp[ActiveLayer].TextColor;
|
|
Jerome Coutant
2:123b894b49dd
|
708
|
DrawProp[ActiveLayer].TextColor = DrawProp[ActiveLayer].BackColor;
|
|
Jerome Coutant
2:123b894b49dd
|
709
|
|
|
Jerome Coutant
2:123b894b49dd
|
710
|
/* Draw rectangle with background color */
|
|
Jerome Coutant
2:123b894b49dd
|
711
|
BSP_LCD_FillRect(0, (Line * DrawProp[ActiveLayer].pFont->Height), BSP_LCD_GetXSize(), DrawProp[ActiveLayer].pFont->Height);
|
|
Jerome Coutant
2:123b894b49dd
|
712
|
|
|
Jerome Coutant
2:123b894b49dd
|
713
|
DrawProp[ActiveLayer].TextColor = color_backup;
|
|
Jerome Coutant
2:123b894b49dd
|
714
|
BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor);
|
|
Jerome Coutant
2:123b894b49dd
|
715
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
716
|
|
|
Jerome Coutant
2:123b894b49dd
|
717
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
718
|
* @brief Displays one character in currently active layer.
|
|
Jerome Coutant
2:123b894b49dd
|
719
|
* @param Xpos: Start column address
|
|
Jerome Coutant
2:123b894b49dd
|
720
|
* @param Ypos: Line where to display the character shape.
|
|
Jerome Coutant
2:123b894b49dd
|
721
|
* @param Ascii: Character ascii code
|
|
Jerome Coutant
2:123b894b49dd
|
722
|
* This parameter must be a number between Min_Data = 0x20 and Max_Data = 0x7E
|
|
Jerome Coutant
2:123b894b49dd
|
723
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
724
|
void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii)
|
|
Jerome Coutant
2:123b894b49dd
|
725
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
726
|
DrawChar(Xpos, Ypos, &DrawProp[ActiveLayer].pFont->table[(Ascii-' ') *\
|
|
Jerome Coutant
2:123b894b49dd
|
727
|
DrawProp[ActiveLayer].pFont->Height * ((DrawProp[ActiveLayer].pFont->Width + 7) / 8)]);
|
|
Jerome Coutant
2:123b894b49dd
|
728
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
729
|
|
|
Jerome Coutant
2:123b894b49dd
|
730
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
731
|
* @brief Displays characters in currently active layer.
|
|
Jerome Coutant
2:123b894b49dd
|
732
|
* @param Xpos: X position (in pixel)
|
|
Jerome Coutant
2:123b894b49dd
|
733
|
* @param Ypos: Y position (in pixel)
|
|
Jerome Coutant
2:123b894b49dd
|
734
|
* @param Text: Pointer to string to display on LCD
|
|
Jerome Coutant
2:123b894b49dd
|
735
|
* @param Mode: Display mode
|
|
Jerome Coutant
2:123b894b49dd
|
736
|
* This parameter can be one of the following values:
|
|
Jerome Coutant
2:123b894b49dd
|
737
|
* @arg CENTER_MODE
|
|
Jerome Coutant
2:123b894b49dd
|
738
|
* @arg RIGHT_MODE
|
|
Jerome Coutant
2:123b894b49dd
|
739
|
* @arg LEFT_MODE
|
|
Jerome Coutant
2:123b894b49dd
|
740
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
741
|
void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Text_AlignModeTypdef Mode)
|
|
Jerome Coutant
2:123b894b49dd
|
742
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
743
|
uint16_t refcolumn = 1, i = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
744
|
uint32_t size = 0, xsize = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
745
|
uint8_t *ptr = Text;
|
|
Jerome Coutant
2:123b894b49dd
|
746
|
|
|
Jerome Coutant
2:123b894b49dd
|
747
|
/* Get the text size */
|
|
Jerome Coutant
2:123b894b49dd
|
748
|
while (*ptr++) size ++ ;
|
|
Jerome Coutant
2:123b894b49dd
|
749
|
|
|
Jerome Coutant
2:123b894b49dd
|
750
|
/* Characters number per line */
|
|
Jerome Coutant
2:123b894b49dd
|
751
|
xsize = (BSP_LCD_GetXSize()/DrawProp[ActiveLayer].pFont->Width);
|
|
Jerome Coutant
2:123b894b49dd
|
752
|
|
|
Jerome Coutant
2:123b894b49dd
|
753
|
switch (Mode)
|
|
Jerome Coutant
2:123b894b49dd
|
754
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
755
|
case CENTER_MODE:
|
|
Jerome Coutant
2:123b894b49dd
|
756
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
757
|
refcolumn = Xpos + ((xsize - size)* DrawProp[ActiveLayer].pFont->Width) / 2;
|
|
Jerome Coutant
2:123b894b49dd
|
758
|
break;
|
|
Jerome Coutant
2:123b894b49dd
|
759
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
760
|
case LEFT_MODE:
|
|
Jerome Coutant
2:123b894b49dd
|
761
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
762
|
refcolumn = Xpos;
|
|
Jerome Coutant
2:123b894b49dd
|
763
|
break;
|
|
Jerome Coutant
2:123b894b49dd
|
764
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
765
|
case RIGHT_MODE:
|
|
Jerome Coutant
2:123b894b49dd
|
766
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
767
|
refcolumn = - Xpos + ((xsize - size)*DrawProp[ActiveLayer].pFont->Width);
|
|
Jerome Coutant
2:123b894b49dd
|
768
|
break;
|
|
Jerome Coutant
2:123b894b49dd
|
769
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
770
|
default:
|
|
Jerome Coutant
2:123b894b49dd
|
771
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
772
|
refcolumn = Xpos;
|
|
Jerome Coutant
2:123b894b49dd
|
773
|
break;
|
|
Jerome Coutant
2:123b894b49dd
|
774
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
775
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
776
|
|
|
Jerome Coutant
2:123b894b49dd
|
777
|
/* Check that the Start column is located in the screen */
|
|
Jerome Coutant
2:123b894b49dd
|
778
|
if ((refcolumn < 1) || (refcolumn >= 0x8000))
|
|
Jerome Coutant
2:123b894b49dd
|
779
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
780
|
refcolumn = 1;
|
|
Jerome Coutant
2:123b894b49dd
|
781
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
782
|
|
|
Jerome Coutant
2:123b894b49dd
|
783
|
/* Send the string character by character on LCD */
|
|
Jerome Coutant
2:123b894b49dd
|
784
|
while ((*Text != 0) & (((BSP_LCD_GetXSize() - (i*DrawProp[ActiveLayer].pFont->Width)) & 0xFFFF) >= DrawProp[ActiveLayer].pFont->Width))
|
|
Jerome Coutant
2:123b894b49dd
|
785
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
786
|
/* Display one character on LCD */
|
|
Jerome Coutant
2:123b894b49dd
|
787
|
BSP_LCD_DisplayChar(refcolumn, Ypos, *Text);
|
|
Jerome Coutant
2:123b894b49dd
|
788
|
/* Decrement the column position by 16 */
|
|
Jerome Coutant
2:123b894b49dd
|
789
|
refcolumn += DrawProp[ActiveLayer].pFont->Width;
|
|
Jerome Coutant
2:123b894b49dd
|
790
|
|
|
Jerome Coutant
2:123b894b49dd
|
791
|
/* Point on the next character */
|
|
Jerome Coutant
2:123b894b49dd
|
792
|
Text++;
|
|
Jerome Coutant
2:123b894b49dd
|
793
|
i++;
|
|
Jerome Coutant
2:123b894b49dd
|
794
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
795
|
|
|
Jerome Coutant
2:123b894b49dd
|
796
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
797
|
|
|
Jerome Coutant
2:123b894b49dd
|
798
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
799
|
* @brief Displays a maximum of 60 characters on the LCD.
|
|
Jerome Coutant
2:123b894b49dd
|
800
|
* @param Line: Line where to display the character shape
|
|
Jerome Coutant
2:123b894b49dd
|
801
|
* @param ptr: Pointer to string to display on LCD
|
|
Jerome Coutant
2:123b894b49dd
|
802
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
803
|
void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *ptr)
|
|
Jerome Coutant
2:123b894b49dd
|
804
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
805
|
BSP_LCD_DisplayStringAt(0, LINE(Line), ptr, LEFT_MODE);
|
|
Jerome Coutant
2:123b894b49dd
|
806
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
807
|
|
|
Jerome Coutant
2:123b894b49dd
|
808
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
809
|
* @brief Draws an horizontal line in currently active layer.
|
|
Jerome Coutant
2:123b894b49dd
|
810
|
* @param Xpos: X position
|
|
Jerome Coutant
2:123b894b49dd
|
811
|
* @param Ypos: Y position
|
|
Jerome Coutant
2:123b894b49dd
|
812
|
* @param Length: Line length
|
|
Jerome Coutant
2:123b894b49dd
|
813
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
814
|
void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length)
|
|
Jerome Coutant
2:123b894b49dd
|
815
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
816
|
uint32_t Xaddress = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
817
|
|
|
Jerome Coutant
2:123b894b49dd
|
818
|
/* Get the line address */
|
|
Jerome Coutant
2:123b894b49dd
|
819
|
Xaddress = (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos);
|
|
Jerome Coutant
2:123b894b49dd
|
820
|
|
|
Jerome Coutant
2:123b894b49dd
|
821
|
/* Write line */
|
|
Jerome Coutant
2:123b894b49dd
|
822
|
LL_FillBuffer(ActiveLayer, (uint32_t *)Xaddress, Length, 1, 0, DrawProp[ActiveLayer].TextColor);
|
|
Jerome Coutant
2:123b894b49dd
|
823
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
824
|
|
|
Jerome Coutant
2:123b894b49dd
|
825
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
826
|
* @brief Draws a vertical line in currently active layer.
|
|
Jerome Coutant
2:123b894b49dd
|
827
|
* @param Xpos: X position
|
|
Jerome Coutant
2:123b894b49dd
|
828
|
* @param Ypos: Y position
|
|
Jerome Coutant
2:123b894b49dd
|
829
|
* @param Length: Line length
|
|
Jerome Coutant
2:123b894b49dd
|
830
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
831
|
void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length)
|
|
Jerome Coutant
2:123b894b49dd
|
832
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
833
|
uint32_t Xaddress = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
834
|
|
|
Jerome Coutant
2:123b894b49dd
|
835
|
/* Get the line address */
|
|
Jerome Coutant
2:123b894b49dd
|
836
|
Xaddress = (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos);
|
|
Jerome Coutant
2:123b894b49dd
|
837
|
|
|
Jerome Coutant
2:123b894b49dd
|
838
|
/* Write line */
|
|
Jerome Coutant
2:123b894b49dd
|
839
|
LL_FillBuffer(ActiveLayer, (uint32_t *)Xaddress, 1, Length, (BSP_LCD_GetXSize() - 1), DrawProp[ActiveLayer].TextColor);
|
|
Jerome Coutant
2:123b894b49dd
|
840
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
841
|
|
|
Jerome Coutant
2:123b894b49dd
|
842
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
843
|
* @brief Draws an uni-line (between two points) in currently active layer.
|
|
Jerome Coutant
2:123b894b49dd
|
844
|
* @param x1: Point 1 X position
|
|
Jerome Coutant
2:123b894b49dd
|
845
|
* @param y1: Point 1 Y position
|
|
Jerome Coutant
2:123b894b49dd
|
846
|
* @param x2: Point 2 X position
|
|
Jerome Coutant
2:123b894b49dd
|
847
|
* @param y2: Point 2 Y position
|
|
Jerome Coutant
2:123b894b49dd
|
848
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
849
|
void BSP_LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
|
|
Jerome Coutant
2:123b894b49dd
|
850
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
851
|
int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0,
|
|
Jerome Coutant
2:123b894b49dd
|
852
|
yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0,
|
|
Jerome Coutant
2:123b894b49dd
|
853
|
curpixel = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
854
|
|
|
Jerome Coutant
2:123b894b49dd
|
855
|
deltax = ABS(x2 - x1); /* The difference between the x's */
|
|
Jerome Coutant
2:123b894b49dd
|
856
|
deltay = ABS(y2 - y1); /* The difference between the y's */
|
|
Jerome Coutant
2:123b894b49dd
|
857
|
x = x1; /* Start x off at the first pixel */
|
|
Jerome Coutant
2:123b894b49dd
|
858
|
y = y1; /* Start y off at the first pixel */
|
|
Jerome Coutant
2:123b894b49dd
|
859
|
|
|
Jerome Coutant
2:123b894b49dd
|
860
|
if (x2 >= x1) /* The x-values are increasing */
|
|
Jerome Coutant
2:123b894b49dd
|
861
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
862
|
xinc1 = 1;
|
|
Jerome Coutant
2:123b894b49dd
|
863
|
xinc2 = 1;
|
|
Jerome Coutant
2:123b894b49dd
|
864
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
865
|
else /* The x-values are decreasing */
|
|
Jerome Coutant
2:123b894b49dd
|
866
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
867
|
xinc1 = -1;
|
|
Jerome Coutant
2:123b894b49dd
|
868
|
xinc2 = -1;
|
|
Jerome Coutant
2:123b894b49dd
|
869
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
870
|
|
|
Jerome Coutant
2:123b894b49dd
|
871
|
if (y2 >= y1) /* The y-values are increasing */
|
|
Jerome Coutant
2:123b894b49dd
|
872
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
873
|
yinc1 = 1;
|
|
Jerome Coutant
2:123b894b49dd
|
874
|
yinc2 = 1;
|
|
Jerome Coutant
2:123b894b49dd
|
875
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
876
|
else /* The y-values are decreasing */
|
|
Jerome Coutant
2:123b894b49dd
|
877
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
878
|
yinc1 = -1;
|
|
Jerome Coutant
2:123b894b49dd
|
879
|
yinc2 = -1;
|
|
Jerome Coutant
2:123b894b49dd
|
880
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
881
|
|
|
Jerome Coutant
2:123b894b49dd
|
882
|
if (deltax >= deltay) /* There is at least one x-value for every y-value */
|
|
Jerome Coutant
2:123b894b49dd
|
883
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
884
|
xinc1 = 0; /* Don't change the x when numerator >= denominator */
|
|
Jerome Coutant
2:123b894b49dd
|
885
|
yinc2 = 0; /* Don't change the y for every iteration */
|
|
Jerome Coutant
2:123b894b49dd
|
886
|
den = deltax;
|
|
Jerome Coutant
2:123b894b49dd
|
887
|
num = deltax / 2;
|
|
Jerome Coutant
2:123b894b49dd
|
888
|
numadd = deltay;
|
|
Jerome Coutant
2:123b894b49dd
|
889
|
numpixels = deltax; /* There are more x-values than y-values */
|
|
Jerome Coutant
2:123b894b49dd
|
890
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
891
|
else /* There is at least one y-value for every x-value */
|
|
Jerome Coutant
2:123b894b49dd
|
892
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
893
|
xinc2 = 0; /* Don't change the x for every iteration */
|
|
Jerome Coutant
2:123b894b49dd
|
894
|
yinc1 = 0; /* Don't change the y when numerator >= denominator */
|
|
Jerome Coutant
2:123b894b49dd
|
895
|
den = deltay;
|
|
Jerome Coutant
2:123b894b49dd
|
896
|
num = deltay / 2;
|
|
Jerome Coutant
2:123b894b49dd
|
897
|
numadd = deltax;
|
|
Jerome Coutant
2:123b894b49dd
|
898
|
numpixels = deltay; /* There are more y-values than x-values */
|
|
Jerome Coutant
2:123b894b49dd
|
899
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
900
|
|
|
Jerome Coutant
2:123b894b49dd
|
901
|
for (curpixel = 0; curpixel <= numpixels; curpixel++)
|
|
Jerome Coutant
2:123b894b49dd
|
902
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
903
|
BSP_LCD_DrawPixel(x, y, DrawProp[ActiveLayer].TextColor); /* Draw the current pixel */
|
|
Jerome Coutant
2:123b894b49dd
|
904
|
num += numadd; /* Increase the numerator by the top of the fraction */
|
|
Jerome Coutant
2:123b894b49dd
|
905
|
if (num >= den) /* Check if numerator >= denominator */
|
|
Jerome Coutant
2:123b894b49dd
|
906
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
907
|
num -= den; /* Calculate the new numerator value */
|
|
Jerome Coutant
2:123b894b49dd
|
908
|
x += xinc1; /* Change the x as appropriate */
|
|
Jerome Coutant
2:123b894b49dd
|
909
|
y += yinc1; /* Change the y as appropriate */
|
|
Jerome Coutant
2:123b894b49dd
|
910
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
911
|
x += xinc2; /* Change the x as appropriate */
|
|
Jerome Coutant
2:123b894b49dd
|
912
|
y += yinc2; /* Change the y as appropriate */
|
|
Jerome Coutant
2:123b894b49dd
|
913
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
914
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
915
|
|
|
Jerome Coutant
2:123b894b49dd
|
916
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
917
|
* @brief Draws a rectangle in currently active layer.
|
|
Jerome Coutant
2:123b894b49dd
|
918
|
* @param Xpos: X position
|
|
Jerome Coutant
2:123b894b49dd
|
919
|
* @param Ypos: Y position
|
|
Jerome Coutant
2:123b894b49dd
|
920
|
* @param Width: Rectangle width
|
|
Jerome Coutant
2:123b894b49dd
|
921
|
* @param Height: Rectangle height
|
|
Jerome Coutant
2:123b894b49dd
|
922
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
923
|
void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
|
|
Jerome Coutant
2:123b894b49dd
|
924
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
925
|
/* Draw horizontal lines */
|
|
Jerome Coutant
2:123b894b49dd
|
926
|
BSP_LCD_DrawHLine(Xpos, Ypos, Width);
|
|
Jerome Coutant
2:123b894b49dd
|
927
|
BSP_LCD_DrawHLine(Xpos, (Ypos+ Height), Width);
|
|
Jerome Coutant
2:123b894b49dd
|
928
|
|
|
Jerome Coutant
2:123b894b49dd
|
929
|
/* Draw vertical lines */
|
|
Jerome Coutant
2:123b894b49dd
|
930
|
BSP_LCD_DrawVLine(Xpos, Ypos, Height);
|
|
Jerome Coutant
2:123b894b49dd
|
931
|
BSP_LCD_DrawVLine((Xpos + Width), Ypos, Height);
|
|
Jerome Coutant
2:123b894b49dd
|
932
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
933
|
|
|
Jerome Coutant
2:123b894b49dd
|
934
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
935
|
* @brief Draws a circle in currently active layer.
|
|
Jerome Coutant
2:123b894b49dd
|
936
|
* @param Xpos: X position
|
|
Jerome Coutant
2:123b894b49dd
|
937
|
* @param Ypos: Y position
|
|
Jerome Coutant
2:123b894b49dd
|
938
|
* @param Radius: Circle radius
|
|
Jerome Coutant
2:123b894b49dd
|
939
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
940
|
void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius)
|
|
Jerome Coutant
2:123b894b49dd
|
941
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
942
|
int32_t D; /* Decision Variable */
|
|
Jerome Coutant
2:123b894b49dd
|
943
|
uint32_t CurX; /* Current X Value */
|
|
Jerome Coutant
2:123b894b49dd
|
944
|
uint32_t CurY; /* Current Y Value */
|
|
Jerome Coutant
2:123b894b49dd
|
945
|
|
|
Jerome Coutant
2:123b894b49dd
|
946
|
D = 3 - (Radius << 1);
|
|
Jerome Coutant
2:123b894b49dd
|
947
|
CurX = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
948
|
CurY = Radius;
|
|
Jerome Coutant
2:123b894b49dd
|
949
|
|
|
Jerome Coutant
2:123b894b49dd
|
950
|
while (CurX <= CurY)
|
|
Jerome Coutant
2:123b894b49dd
|
951
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
952
|
BSP_LCD_DrawPixel((Xpos + CurX), (Ypos - CurY), DrawProp[ActiveLayer].TextColor);
|
|
Jerome Coutant
2:123b894b49dd
|
953
|
|
|
Jerome Coutant
2:123b894b49dd
|
954
|
BSP_LCD_DrawPixel((Xpos - CurX), (Ypos - CurY), DrawProp[ActiveLayer].TextColor);
|
|
Jerome Coutant
2:123b894b49dd
|
955
|
|
|
Jerome Coutant
2:123b894b49dd
|
956
|
BSP_LCD_DrawPixel((Xpos + CurY), (Ypos - CurX), DrawProp[ActiveLayer].TextColor);
|
|
Jerome Coutant
2:123b894b49dd
|
957
|
|
|
Jerome Coutant
2:123b894b49dd
|
958
|
BSP_LCD_DrawPixel((Xpos - CurY), (Ypos - CurX), DrawProp[ActiveLayer].TextColor);
|
|
Jerome Coutant
2:123b894b49dd
|
959
|
|
|
Jerome Coutant
2:123b894b49dd
|
960
|
BSP_LCD_DrawPixel((Xpos + CurX), (Ypos + CurY), DrawProp[ActiveLayer].TextColor);
|
|
Jerome Coutant
2:123b894b49dd
|
961
|
|
|
Jerome Coutant
2:123b894b49dd
|
962
|
BSP_LCD_DrawPixel((Xpos - CurX), (Ypos + CurY), DrawProp[ActiveLayer].TextColor);
|
|
Jerome Coutant
2:123b894b49dd
|
963
|
|
|
Jerome Coutant
2:123b894b49dd
|
964
|
BSP_LCD_DrawPixel((Xpos + CurY), (Ypos + CurX), DrawProp[ActiveLayer].TextColor);
|
|
Jerome Coutant
2:123b894b49dd
|
965
|
|
|
Jerome Coutant
2:123b894b49dd
|
966
|
BSP_LCD_DrawPixel((Xpos - CurY), (Ypos + CurX), DrawProp[ActiveLayer].TextColor);
|
|
Jerome Coutant
2:123b894b49dd
|
967
|
|
|
Jerome Coutant
2:123b894b49dd
|
968
|
if (D < 0)
|
|
Jerome Coutant
2:123b894b49dd
|
969
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
970
|
D += (CurX << 2) + 6;
|
|
Jerome Coutant
2:123b894b49dd
|
971
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
972
|
else
|
|
Jerome Coutant
2:123b894b49dd
|
973
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
974
|
D += ((CurX - CurY) << 2) + 10;
|
|
Jerome Coutant
2:123b894b49dd
|
975
|
CurY--;
|
|
Jerome Coutant
2:123b894b49dd
|
976
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
977
|
CurX++;
|
|
Jerome Coutant
2:123b894b49dd
|
978
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
979
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
980
|
|
|
Jerome Coutant
2:123b894b49dd
|
981
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
982
|
* @brief Draws an poly-line (between many points) in currently active layer.
|
|
Jerome Coutant
2:123b894b49dd
|
983
|
* @param Points: Pointer to the points array
|
|
Jerome Coutant
2:123b894b49dd
|
984
|
* @param PointCount: Number of points
|
|
Jerome Coutant
2:123b894b49dd
|
985
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
986
|
void BSP_LCD_DrawPolygon(pPoint Points, uint16_t PointCount)
|
|
Jerome Coutant
2:123b894b49dd
|
987
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
988
|
int16_t X = 0, Y = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
989
|
|
|
Jerome Coutant
2:123b894b49dd
|
990
|
if(PointCount < 2)
|
|
Jerome Coutant
2:123b894b49dd
|
991
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
992
|
return;
|
|
Jerome Coutant
2:123b894b49dd
|
993
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
994
|
|
|
Jerome Coutant
2:123b894b49dd
|
995
|
BSP_LCD_DrawLine(Points->X, Points->Y, (Points+PointCount-1)->X, (Points+PointCount-1)->Y);
|
|
Jerome Coutant
2:123b894b49dd
|
996
|
|
|
Jerome Coutant
2:123b894b49dd
|
997
|
while(--PointCount)
|
|
Jerome Coutant
2:123b894b49dd
|
998
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
999
|
X = Points->X;
|
|
Jerome Coutant
2:123b894b49dd
|
1000
|
Y = Points->Y;
|
|
Jerome Coutant
2:123b894b49dd
|
1001
|
Points++;
|
|
Jerome Coutant
2:123b894b49dd
|
1002
|
BSP_LCD_DrawLine(X, Y, Points->X, Points->Y);
|
|
Jerome Coutant
2:123b894b49dd
|
1003
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1004
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1005
|
|
|
Jerome Coutant
2:123b894b49dd
|
1006
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1007
|
* @brief Draws an ellipse on LCD in currently active layer.
|
|
Jerome Coutant
2:123b894b49dd
|
1008
|
* @param Xpos: X position
|
|
Jerome Coutant
2:123b894b49dd
|
1009
|
* @param Ypos: Y position
|
|
Jerome Coutant
2:123b894b49dd
|
1010
|
* @param XRadius: Ellipse X radius
|
|
Jerome Coutant
2:123b894b49dd
|
1011
|
* @param YRadius: Ellipse Y radius
|
|
Jerome Coutant
2:123b894b49dd
|
1012
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1013
|
void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius)
|
|
Jerome Coutant
2:123b894b49dd
|
1014
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1015
|
int x = 0, y = -YRadius, err = 2-2*XRadius, e2;
|
|
Jerome Coutant
2:123b894b49dd
|
1016
|
float K = 0, rad1 = 0, rad2 = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
1017
|
|
|
Jerome Coutant
2:123b894b49dd
|
1018
|
rad1 = XRadius;
|
|
Jerome Coutant
2:123b894b49dd
|
1019
|
rad2 = YRadius;
|
|
Jerome Coutant
2:123b894b49dd
|
1020
|
|
|
Jerome Coutant
2:123b894b49dd
|
1021
|
K = (float)(rad2/rad1);
|
|
Jerome Coutant
2:123b894b49dd
|
1022
|
|
|
Jerome Coutant
2:123b894b49dd
|
1023
|
do {
|
|
Jerome Coutant
2:123b894b49dd
|
1024
|
BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/K)), (Ypos+y), DrawProp[ActiveLayer].TextColor);
|
|
Jerome Coutant
2:123b894b49dd
|
1025
|
BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/K)), (Ypos+y), DrawProp[ActiveLayer].TextColor);
|
|
Jerome Coutant
2:123b894b49dd
|
1026
|
BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/K)), (Ypos-y), DrawProp[ActiveLayer].TextColor);
|
|
Jerome Coutant
2:123b894b49dd
|
1027
|
BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/K)), (Ypos-y), DrawProp[ActiveLayer].TextColor);
|
|
Jerome Coutant
2:123b894b49dd
|
1028
|
|
|
Jerome Coutant
2:123b894b49dd
|
1029
|
e2 = err;
|
|
Jerome Coutant
2:123b894b49dd
|
1030
|
if (e2 <= x) {
|
|
Jerome Coutant
2:123b894b49dd
|
1031
|
err += ++x*2+1;
|
|
Jerome Coutant
2:123b894b49dd
|
1032
|
if (-y == x && e2 <= y) e2 = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
1033
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1034
|
if (e2 > y) err += ++y*2+1;
|
|
Jerome Coutant
2:123b894b49dd
|
1035
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1036
|
while (y <= 0);
|
|
Jerome Coutant
2:123b894b49dd
|
1037
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1038
|
|
|
Jerome Coutant
2:123b894b49dd
|
1039
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1040
|
* @brief Draws a bitmap picture loaded in the internal Flash (32 bpp) in currently active layer.
|
|
Jerome Coutant
2:123b894b49dd
|
1041
|
* @param Xpos: Bmp X position in the LCD
|
|
Jerome Coutant
2:123b894b49dd
|
1042
|
* @param Ypos: Bmp Y position in the LCD
|
|
Jerome Coutant
2:123b894b49dd
|
1043
|
* @param pbmp: Pointer to Bmp picture address in the internal Flash
|
|
Jerome Coutant
2:123b894b49dd
|
1044
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1045
|
void BSP_LCD_DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp)
|
|
Jerome Coutant
2:123b894b49dd
|
1046
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1047
|
uint32_t index = 0, width = 0, height = 0, bit_pixel = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
1048
|
uint32_t Address;
|
|
Jerome Coutant
2:123b894b49dd
|
1049
|
uint32_t InputColorMode = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
1050
|
|
|
Jerome Coutant
2:123b894b49dd
|
1051
|
/* Get bitmap data address offset */
|
|
Jerome Coutant
3:3cdfcc4f7c9d
|
1052
|
index = pbmp[10] + (pbmp[11] << 8) + (pbmp[12] << 16) + (pbmp[13] << 24);
|
|
Jerome Coutant
2:123b894b49dd
|
1053
|
|
|
Jerome Coutant
2:123b894b49dd
|
1054
|
/* Read bitmap width */
|
|
Jerome Coutant
3:3cdfcc4f7c9d
|
1055
|
width = pbmp[18] + (pbmp[19] << 8) + (pbmp[20] << 16) + (pbmp[21] << 24);
|
|
Jerome Coutant
2:123b894b49dd
|
1056
|
|
|
Jerome Coutant
2:123b894b49dd
|
1057
|
/* Read bitmap height */
|
|
Jerome Coutant
3:3cdfcc4f7c9d
|
1058
|
height = pbmp[22] + (pbmp[23] << 8) + (pbmp[24] << 16) + (pbmp[25] << 24);
|
|
Jerome Coutant
2:123b894b49dd
|
1059
|
|
|
Jerome Coutant
2:123b894b49dd
|
1060
|
/* Read bit/pixel */
|
|
Jerome Coutant
3:3cdfcc4f7c9d
|
1061
|
bit_pixel = pbmp[28] + (pbmp[29] << 8);
|
|
Jerome Coutant
2:123b894b49dd
|
1062
|
|
|
Jerome Coutant
2:123b894b49dd
|
1063
|
/* Set the address */
|
|
Jerome Coutant
2:123b894b49dd
|
1064
|
Address = hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (((BSP_LCD_GetXSize()*Ypos) + Xpos)*(4));
|
|
Jerome Coutant
2:123b894b49dd
|
1065
|
|
|
Jerome Coutant
2:123b894b49dd
|
1066
|
/* Get the layer pixel format */
|
|
Jerome Coutant
2:123b894b49dd
|
1067
|
if ((bit_pixel/8) == 4)
|
|
Jerome Coutant
2:123b894b49dd
|
1068
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1069
|
InputColorMode = CM_ARGB8888;
|
|
Jerome Coutant
2:123b894b49dd
|
1070
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1071
|
else if ((bit_pixel/8) == 2)
|
|
Jerome Coutant
2:123b894b49dd
|
1072
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1073
|
InputColorMode = CM_RGB565;
|
|
Jerome Coutant
2:123b894b49dd
|
1074
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1075
|
else
|
|
Jerome Coutant
2:123b894b49dd
|
1076
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1077
|
InputColorMode = CM_RGB888;
|
|
Jerome Coutant
2:123b894b49dd
|
1078
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1079
|
|
|
Jerome Coutant
2:123b894b49dd
|
1080
|
/* Bypass the bitmap header */
|
|
Jerome Coutant
2:123b894b49dd
|
1081
|
pbmp += (index + (width * (height - 1) * (bit_pixel/8)));
|
|
Jerome Coutant
2:123b894b49dd
|
1082
|
|
|
Jerome Coutant
2:123b894b49dd
|
1083
|
/* Convert picture to ARGB8888 pixel format */
|
|
Jerome Coutant
2:123b894b49dd
|
1084
|
for(index=0; index < height; index++)
|
|
Jerome Coutant
2:123b894b49dd
|
1085
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1086
|
/* Pixel format conversion */
|
|
Jerome Coutant
2:123b894b49dd
|
1087
|
LL_ConvertLineToARGB8888((uint32_t *)pbmp, (uint32_t *)Address, width, InputColorMode);
|
|
Jerome Coutant
2:123b894b49dd
|
1088
|
|
|
Jerome Coutant
2:123b894b49dd
|
1089
|
/* Increment the source and destination buffers */
|
|
Jerome Coutant
2:123b894b49dd
|
1090
|
Address+= (BSP_LCD_GetXSize()*4);
|
|
Jerome Coutant
2:123b894b49dd
|
1091
|
pbmp -= width*(bit_pixel/8);
|
|
Jerome Coutant
2:123b894b49dd
|
1092
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1093
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1094
|
|
|
Jerome Coutant
2:123b894b49dd
|
1095
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1096
|
* @brief Draws a full rectangle in currently active layer.
|
|
Jerome Coutant
2:123b894b49dd
|
1097
|
* @param Xpos: X position
|
|
Jerome Coutant
2:123b894b49dd
|
1098
|
* @param Ypos: Y position
|
|
Jerome Coutant
2:123b894b49dd
|
1099
|
* @param Width: Rectangle width
|
|
Jerome Coutant
2:123b894b49dd
|
1100
|
* @param Height: Rectangle height
|
|
Jerome Coutant
2:123b894b49dd
|
1101
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1102
|
void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
|
|
Jerome Coutant
2:123b894b49dd
|
1103
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1104
|
uint32_t Xaddress = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
1105
|
|
|
Jerome Coutant
2:123b894b49dd
|
1106
|
/* Set the text color */
|
|
Jerome Coutant
2:123b894b49dd
|
1107
|
BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor);
|
|
Jerome Coutant
2:123b894b49dd
|
1108
|
|
|
Jerome Coutant
2:123b894b49dd
|
1109
|
/* Get the rectangle start address */
|
|
Jerome Coutant
2:123b894b49dd
|
1110
|
Xaddress = (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos);
|
|
Jerome Coutant
2:123b894b49dd
|
1111
|
|
|
Jerome Coutant
2:123b894b49dd
|
1112
|
/* Fill the rectangle */
|
|
Jerome Coutant
2:123b894b49dd
|
1113
|
LL_FillBuffer(ActiveLayer, (uint32_t *)Xaddress, Width, Height, (BSP_LCD_GetXSize() - Width), DrawProp[ActiveLayer].TextColor);
|
|
Jerome Coutant
2:123b894b49dd
|
1114
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1115
|
|
|
Jerome Coutant
2:123b894b49dd
|
1116
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1117
|
* @brief Draws a full circle in currently active layer.
|
|
Jerome Coutant
2:123b894b49dd
|
1118
|
* @param Xpos: X position
|
|
Jerome Coutant
2:123b894b49dd
|
1119
|
* @param Ypos: Y position
|
|
Jerome Coutant
2:123b894b49dd
|
1120
|
* @param Radius: Circle radius
|
|
Jerome Coutant
2:123b894b49dd
|
1121
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1122
|
void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius)
|
|
Jerome Coutant
2:123b894b49dd
|
1123
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1124
|
int32_t D; /* Decision Variable */
|
|
Jerome Coutant
2:123b894b49dd
|
1125
|
uint32_t CurX; /* Current X Value */
|
|
Jerome Coutant
2:123b894b49dd
|
1126
|
uint32_t CurY; /* Current Y Value */
|
|
Jerome Coutant
2:123b894b49dd
|
1127
|
|
|
Jerome Coutant
2:123b894b49dd
|
1128
|
D = 3 - (Radius << 1);
|
|
Jerome Coutant
2:123b894b49dd
|
1129
|
|
|
Jerome Coutant
2:123b894b49dd
|
1130
|
CurX = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
1131
|
CurY = Radius;
|
|
Jerome Coutant
2:123b894b49dd
|
1132
|
|
|
Jerome Coutant
2:123b894b49dd
|
1133
|
BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor);
|
|
Jerome Coutant
2:123b894b49dd
|
1134
|
|
|
Jerome Coutant
2:123b894b49dd
|
1135
|
while (CurX <= CurY)
|
|
Jerome Coutant
2:123b894b49dd
|
1136
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1137
|
if(CurY > 0)
|
|
Jerome Coutant
2:123b894b49dd
|
1138
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1139
|
BSP_LCD_DrawHLine(Xpos - CurY, Ypos + CurX, 2*CurY);
|
|
Jerome Coutant
2:123b894b49dd
|
1140
|
BSP_LCD_DrawHLine(Xpos - CurY, Ypos - CurX, 2*CurY);
|
|
Jerome Coutant
2:123b894b49dd
|
1141
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1142
|
|
|
Jerome Coutant
2:123b894b49dd
|
1143
|
if(CurX > 0)
|
|
Jerome Coutant
2:123b894b49dd
|
1144
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1145
|
BSP_LCD_DrawHLine(Xpos - CurX, Ypos - CurY, 2*CurX);
|
|
Jerome Coutant
2:123b894b49dd
|
1146
|
BSP_LCD_DrawHLine(Xpos - CurX, Ypos + CurY, 2*CurX);
|
|
Jerome Coutant
2:123b894b49dd
|
1147
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1148
|
if (D < 0)
|
|
Jerome Coutant
2:123b894b49dd
|
1149
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1150
|
D += (CurX << 2) + 6;
|
|
Jerome Coutant
2:123b894b49dd
|
1151
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1152
|
else
|
|
Jerome Coutant
2:123b894b49dd
|
1153
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1154
|
D += ((CurX - CurY) << 2) + 10;
|
|
Jerome Coutant
2:123b894b49dd
|
1155
|
CurY--;
|
|
Jerome Coutant
2:123b894b49dd
|
1156
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1157
|
CurX++;
|
|
Jerome Coutant
2:123b894b49dd
|
1158
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1159
|
|
|
Jerome Coutant
2:123b894b49dd
|
1160
|
BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor);
|
|
Jerome Coutant
2:123b894b49dd
|
1161
|
BSP_LCD_DrawCircle(Xpos, Ypos, Radius);
|
|
Jerome Coutant
2:123b894b49dd
|
1162
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1163
|
|
|
Jerome Coutant
2:123b894b49dd
|
1164
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1165
|
* @brief Draws a full poly-line (between many points) in currently active layer.
|
|
Jerome Coutant
2:123b894b49dd
|
1166
|
* @param Points: Pointer to the points array
|
|
Jerome Coutant
2:123b894b49dd
|
1167
|
* @param PointCount: Number of points
|
|
Jerome Coutant
2:123b894b49dd
|
1168
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1169
|
void BSP_LCD_FillPolygon(pPoint Points, uint16_t PointCount)
|
|
Jerome Coutant
2:123b894b49dd
|
1170
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1171
|
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;
|
|
Jerome Coutant
2:123b894b49dd
|
1172
|
uint16_t IMAGE_LEFT = 0, IMAGE_RIGHT = 0, IMAGE_TOP = 0, IMAGE_BOTTOM = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
1173
|
|
|
Jerome Coutant
2:123b894b49dd
|
1174
|
IMAGE_LEFT = IMAGE_RIGHT = Points->X;
|
|
Jerome Coutant
2:123b894b49dd
|
1175
|
IMAGE_TOP= IMAGE_BOTTOM = Points->Y;
|
|
Jerome Coutant
2:123b894b49dd
|
1176
|
|
|
Jerome Coutant
2:123b894b49dd
|
1177
|
for(counter = 1; counter < PointCount; counter++)
|
|
Jerome Coutant
2:123b894b49dd
|
1178
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1179
|
pixelX = POLY_X(counter);
|
|
Jerome Coutant
2:123b894b49dd
|
1180
|
if(pixelX < IMAGE_LEFT)
|
|
Jerome Coutant
2:123b894b49dd
|
1181
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1182
|
IMAGE_LEFT = pixelX;
|
|
Jerome Coutant
2:123b894b49dd
|
1183
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1184
|
if(pixelX > IMAGE_RIGHT)
|
|
Jerome Coutant
2:123b894b49dd
|
1185
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1186
|
IMAGE_RIGHT = pixelX;
|
|
Jerome Coutant
2:123b894b49dd
|
1187
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1188
|
|
|
Jerome Coutant
2:123b894b49dd
|
1189
|
pixelY = POLY_Y(counter);
|
|
Jerome Coutant
2:123b894b49dd
|
1190
|
if(pixelY < IMAGE_TOP)
|
|
Jerome Coutant
2:123b894b49dd
|
1191
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1192
|
IMAGE_TOP = pixelY;
|
|
Jerome Coutant
2:123b894b49dd
|
1193
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1194
|
if(pixelY > IMAGE_BOTTOM)
|
|
Jerome Coutant
2:123b894b49dd
|
1195
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1196
|
IMAGE_BOTTOM = pixelY;
|
|
Jerome Coutant
2:123b894b49dd
|
1197
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1198
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1199
|
|
|
Jerome Coutant
2:123b894b49dd
|
1200
|
if(PointCount < 2)
|
|
Jerome Coutant
2:123b894b49dd
|
1201
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1202
|
return;
|
|
Jerome Coutant
2:123b894b49dd
|
1203
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1204
|
|
|
Jerome Coutant
2:123b894b49dd
|
1205
|
X_center = (IMAGE_LEFT + IMAGE_RIGHT)/2;
|
|
Jerome Coutant
2:123b894b49dd
|
1206
|
Y_center = (IMAGE_BOTTOM + IMAGE_TOP)/2;
|
|
Jerome Coutant
2:123b894b49dd
|
1207
|
|
|
Jerome Coutant
2:123b894b49dd
|
1208
|
X_first = Points->X;
|
|
Jerome Coutant
2:123b894b49dd
|
1209
|
Y_first = Points->Y;
|
|
Jerome Coutant
2:123b894b49dd
|
1210
|
|
|
Jerome Coutant
2:123b894b49dd
|
1211
|
while(--PointCount)
|
|
Jerome Coutant
2:123b894b49dd
|
1212
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1213
|
X = Points->X;
|
|
Jerome Coutant
2:123b894b49dd
|
1214
|
Y = Points->Y;
|
|
Jerome Coutant
2:123b894b49dd
|
1215
|
Points++;
|
|
Jerome Coutant
2:123b894b49dd
|
1216
|
X2 = Points->X;
|
|
Jerome Coutant
2:123b894b49dd
|
1217
|
Y2 = Points->Y;
|
|
Jerome Coutant
2:123b894b49dd
|
1218
|
|
|
Jerome Coutant
2:123b894b49dd
|
1219
|
FillTriangle(X, X2, X_center, Y, Y2, Y_center);
|
|
Jerome Coutant
2:123b894b49dd
|
1220
|
FillTriangle(X, X_center, X2, Y, Y_center, Y2);
|
|
Jerome Coutant
2:123b894b49dd
|
1221
|
FillTriangle(X_center, X2, X, Y_center, Y2, Y);
|
|
Jerome Coutant
2:123b894b49dd
|
1222
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1223
|
|
|
Jerome Coutant
2:123b894b49dd
|
1224
|
FillTriangle(X_first, X2, X_center, Y_first, Y2, Y_center);
|
|
Jerome Coutant
2:123b894b49dd
|
1225
|
FillTriangle(X_first, X_center, X2, Y_first, Y_center, Y2);
|
|
Jerome Coutant
2:123b894b49dd
|
1226
|
FillTriangle(X_center, X2, X_first, Y_center, Y2, Y_first);
|
|
Jerome Coutant
2:123b894b49dd
|
1227
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1228
|
|
|
Jerome Coutant
2:123b894b49dd
|
1229
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1230
|
* @brief Draws a full ellipse in currently active layer.
|
|
Jerome Coutant
2:123b894b49dd
|
1231
|
* @param Xpos: X position
|
|
Jerome Coutant
2:123b894b49dd
|
1232
|
* @param Ypos: Y position
|
|
Jerome Coutant
2:123b894b49dd
|
1233
|
* @param XRadius: Ellipse X radius
|
|
Jerome Coutant
2:123b894b49dd
|
1234
|
* @param YRadius: Ellipse Y radius
|
|
Jerome Coutant
2:123b894b49dd
|
1235
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1236
|
void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius)
|
|
Jerome Coutant
2:123b894b49dd
|
1237
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1238
|
int x = 0, y = -YRadius, err = 2-2*XRadius, e2;
|
|
Jerome Coutant
2:123b894b49dd
|
1239
|
float K = 0, rad1 = 0, rad2 = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
1240
|
|
|
Jerome Coutant
2:123b894b49dd
|
1241
|
rad1 = XRadius;
|
|
Jerome Coutant
2:123b894b49dd
|
1242
|
rad2 = YRadius;
|
|
Jerome Coutant
2:123b894b49dd
|
1243
|
|
|
Jerome Coutant
2:123b894b49dd
|
1244
|
K = (float)(rad2/rad1);
|
|
Jerome Coutant
2:123b894b49dd
|
1245
|
|
|
Jerome Coutant
2:123b894b49dd
|
1246
|
do
|
|
Jerome Coutant
2:123b894b49dd
|
1247
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1248
|
BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/K)), (Ypos+y), (2*(uint16_t)(x/K) + 1));
|
|
Jerome Coutant
2:123b894b49dd
|
1249
|
BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/K)), (Ypos-y), (2*(uint16_t)(x/K) + 1));
|
|
Jerome Coutant
2:123b894b49dd
|
1250
|
|
|
Jerome Coutant
2:123b894b49dd
|
1251
|
e2 = err;
|
|
Jerome Coutant
2:123b894b49dd
|
1252
|
if (e2 <= x)
|
|
Jerome Coutant
2:123b894b49dd
|
1253
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1254
|
err += ++x*2+1;
|
|
Jerome Coutant
2:123b894b49dd
|
1255
|
if (-y == x && e2 <= y) e2 = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
1256
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1257
|
if (e2 > y) err += ++y*2+1;
|
|
Jerome Coutant
2:123b894b49dd
|
1258
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1259
|
while (y <= 0);
|
|
Jerome Coutant
2:123b894b49dd
|
1260
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1261
|
|
|
Jerome Coutant
2:123b894b49dd
|
1262
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1263
|
* @brief Switch back on the display if was switched off by previous call of BSP_LCD_DisplayOff().
|
|
Jerome Coutant
2:123b894b49dd
|
1264
|
* Exit DSI ULPM mode if was allowed and configured in Dsi Configuration.
|
|
Jerome Coutant
2:123b894b49dd
|
1265
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1266
|
void BSP_LCD_DisplayOn(void)
|
|
Jerome Coutant
2:123b894b49dd
|
1267
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1268
|
/* Send Display on DCS command to display */
|
|
Jerome Coutant
2:123b894b49dd
|
1269
|
HAL_DSI_ShortWrite(&(hdsi_eval),
|
|
Jerome Coutant
2:123b894b49dd
|
1270
|
hdsivideo_handle.VirtualChannelID,
|
|
Jerome Coutant
2:123b894b49dd
|
1271
|
DSI_DCS_SHORT_PKT_WRITE_P1,
|
|
Jerome Coutant
2:123b894b49dd
|
1272
|
OTM8009A_CMD_DISPON,
|
|
Jerome Coutant
2:123b894b49dd
|
1273
|
0x00);
|
|
Jerome Coutant
2:123b894b49dd
|
1274
|
|
|
Jerome Coutant
2:123b894b49dd
|
1275
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1276
|
|
|
Jerome Coutant
2:123b894b49dd
|
1277
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1278
|
* @brief Switch Off the display.
|
|
Jerome Coutant
2:123b894b49dd
|
1279
|
* Enter DSI ULPM mode if was allowed and configured in Dsi Configuration.
|
|
Jerome Coutant
2:123b894b49dd
|
1280
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1281
|
void BSP_LCD_DisplayOff(void)
|
|
Jerome Coutant
2:123b894b49dd
|
1282
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1283
|
/* Send Display off DCS Command to display */
|
|
Jerome Coutant
2:123b894b49dd
|
1284
|
HAL_DSI_ShortWrite(&(hdsi_eval),
|
|
Jerome Coutant
2:123b894b49dd
|
1285
|
hdsivideo_handle.VirtualChannelID,
|
|
Jerome Coutant
2:123b894b49dd
|
1286
|
DSI_DCS_SHORT_PKT_WRITE_P1,
|
|
Jerome Coutant
2:123b894b49dd
|
1287
|
OTM8009A_CMD_DISPOFF,
|
|
Jerome Coutant
2:123b894b49dd
|
1288
|
0x00);
|
|
Jerome Coutant
2:123b894b49dd
|
1289
|
|
|
Jerome Coutant
2:123b894b49dd
|
1290
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1291
|
|
|
Jerome Coutant
2:123b894b49dd
|
1292
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1293
|
* @brief DCS or Generic short/long write command
|
|
Jerome Coutant
2:123b894b49dd
|
1294
|
* @param NbrParams: Number of parameters. It indicates the write command mode:
|
|
Jerome Coutant
2:123b894b49dd
|
1295
|
* If inferior to 2, a long write command is performed else short.
|
|
Jerome Coutant
2:123b894b49dd
|
1296
|
* @param pParams: Pointer to parameter values table.
|
|
Jerome Coutant
2:123b894b49dd
|
1297
|
* @retval HAL status
|
|
Jerome Coutant
2:123b894b49dd
|
1298
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1299
|
void DSI_IO_WriteCmd(uint32_t NbrParams, uint8_t *pParams)
|
|
Jerome Coutant
2:123b894b49dd
|
1300
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1301
|
if(NbrParams <= 1)
|
|
Jerome Coutant
2:123b894b49dd
|
1302
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1303
|
HAL_DSI_ShortWrite(&hdsi_eval, LCD_OTM8009A_ID, DSI_DCS_SHORT_PKT_WRITE_P1, pParams[0], pParams[1]);
|
|
Jerome Coutant
2:123b894b49dd
|
1304
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1305
|
else
|
|
Jerome Coutant
2:123b894b49dd
|
1306
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1307
|
HAL_DSI_LongWrite(&hdsi_eval, LCD_OTM8009A_ID, DSI_DCS_LONG_PKT_WRITE, NbrParams, pParams[NbrParams], pParams);
|
|
Jerome Coutant
2:123b894b49dd
|
1308
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1309
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1310
|
|
|
Jerome Coutant
2:123b894b49dd
|
1311
|
/*******************************************************************************
|
|
Jerome Coutant
2:123b894b49dd
|
1312
|
LTDC, DMA2D and DSI BSP Routines
|
|
Jerome Coutant
2:123b894b49dd
|
1313
|
*******************************************************************************/
|
|
Jerome Coutant
2:123b894b49dd
|
1314
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1315
|
* @brief Handles DMA2D interrupt request.
|
|
Jerome Coutant
2:123b894b49dd
|
1316
|
* @note : Can be surcharged by application code implementation of the function.
|
|
Jerome Coutant
2:123b894b49dd
|
1317
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1318
|
__weak void BSP_LCD_DMA2D_IRQHandler(void)
|
|
Jerome Coutant
2:123b894b49dd
|
1319
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1320
|
HAL_DMA2D_IRQHandler(&hdma2d_eval);
|
|
Jerome Coutant
2:123b894b49dd
|
1321
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1322
|
|
|
Jerome Coutant
2:123b894b49dd
|
1323
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1324
|
* @brief Handles DSI interrupt request.
|
|
Jerome Coutant
2:123b894b49dd
|
1325
|
* @note : Can be surcharged by application code implementation of the function.
|
|
Jerome Coutant
2:123b894b49dd
|
1326
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1327
|
__weak void BSP_LCD_DSI_IRQHandler(void)
|
|
Jerome Coutant
2:123b894b49dd
|
1328
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1329
|
HAL_DSI_IRQHandler(&(hdsi_eval));
|
|
Jerome Coutant
2:123b894b49dd
|
1330
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1331
|
|
|
Jerome Coutant
2:123b894b49dd
|
1332
|
|
|
Jerome Coutant
2:123b894b49dd
|
1333
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1334
|
* @brief Handles LTDC interrupt request.
|
|
Jerome Coutant
2:123b894b49dd
|
1335
|
* @note : Can be surcharged by application code implementation of the function.
|
|
Jerome Coutant
2:123b894b49dd
|
1336
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1337
|
__weak void BSP_LCD_LTDC_IRQHandler(void)
|
|
Jerome Coutant
2:123b894b49dd
|
1338
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1339
|
HAL_LTDC_IRQHandler(&(hltdc_eval));
|
|
Jerome Coutant
2:123b894b49dd
|
1340
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1341
|
|
|
Jerome Coutant
2:123b894b49dd
|
1342
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1343
|
* @brief De-Initializes the BSP LCD Msp
|
|
Jerome Coutant
2:123b894b49dd
|
1344
|
* Application can surcharge if needed this function implementation.
|
|
Jerome Coutant
2:123b894b49dd
|
1345
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1346
|
__weak void BSP_LCD_MspDeInit(void)
|
|
Jerome Coutant
2:123b894b49dd
|
1347
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1348
|
/** @brief Disable IRQ of LTDC IP */
|
|
Jerome Coutant
2:123b894b49dd
|
1349
|
HAL_NVIC_DisableIRQ(LTDC_IRQn);
|
|
Jerome Coutant
2:123b894b49dd
|
1350
|
|
|
Jerome Coutant
2:123b894b49dd
|
1351
|
/** @brief Disable IRQ of DMA2D IP */
|
|
Jerome Coutant
2:123b894b49dd
|
1352
|
HAL_NVIC_DisableIRQ(DMA2D_IRQn);
|
|
Jerome Coutant
2:123b894b49dd
|
1353
|
|
|
Jerome Coutant
2:123b894b49dd
|
1354
|
/** @brief Disable IRQ of DSI IP */
|
|
Jerome Coutant
2:123b894b49dd
|
1355
|
HAL_NVIC_DisableIRQ(DSI_IRQn);
|
|
Jerome Coutant
2:123b894b49dd
|
1356
|
|
|
Jerome Coutant
2:123b894b49dd
|
1357
|
/** @brief Force and let in reset state LTDC, DMA2D and DSI Host + Wrapper IPs */
|
|
Jerome Coutant
2:123b894b49dd
|
1358
|
__HAL_RCC_LTDC_FORCE_RESET();
|
|
Jerome Coutant
2:123b894b49dd
|
1359
|
__HAL_RCC_DMA2D_FORCE_RESET();
|
|
Jerome Coutant
2:123b894b49dd
|
1360
|
__HAL_RCC_DSI_FORCE_RESET();
|
|
Jerome Coutant
2:123b894b49dd
|
1361
|
|
|
Jerome Coutant
2:123b894b49dd
|
1362
|
/** @brief Disable the LTDC, DMA2D and DSI Host and Wrapper clocks */
|
|
Jerome Coutant
2:123b894b49dd
|
1363
|
__HAL_RCC_LTDC_CLK_DISABLE();
|
|
Jerome Coutant
2:123b894b49dd
|
1364
|
__HAL_RCC_DMA2D_CLK_DISABLE();
|
|
Jerome Coutant
2:123b894b49dd
|
1365
|
__HAL_RCC_DSI_CLK_DISABLE();
|
|
Jerome Coutant
2:123b894b49dd
|
1366
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1367
|
|
|
Jerome Coutant
2:123b894b49dd
|
1368
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1369
|
* @brief Initialize the BSP LCD Msp.
|
|
Jerome Coutant
2:123b894b49dd
|
1370
|
* Application can surcharge if needed this function implementation
|
|
Jerome Coutant
2:123b894b49dd
|
1371
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1372
|
__weak void BSP_LCD_MspInit(void)
|
|
Jerome Coutant
2:123b894b49dd
|
1373
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1374
|
/** @brief Enable the LTDC clock */
|
|
Jerome Coutant
2:123b894b49dd
|
1375
|
__HAL_RCC_LTDC_CLK_ENABLE();
|
|
Jerome Coutant
2:123b894b49dd
|
1376
|
|
|
Jerome Coutant
2:123b894b49dd
|
1377
|
/** @brief Toggle Sw reset of LTDC IP */
|
|
Jerome Coutant
2:123b894b49dd
|
1378
|
__HAL_RCC_LTDC_FORCE_RESET();
|
|
Jerome Coutant
2:123b894b49dd
|
1379
|
__HAL_RCC_LTDC_RELEASE_RESET();
|
|
Jerome Coutant
2:123b894b49dd
|
1380
|
|
|
Jerome Coutant
2:123b894b49dd
|
1381
|
/** @brief Enable the DMA2D clock */
|
|
Jerome Coutant
2:123b894b49dd
|
1382
|
__HAL_RCC_DMA2D_CLK_ENABLE();
|
|
Jerome Coutant
2:123b894b49dd
|
1383
|
|
|
Jerome Coutant
2:123b894b49dd
|
1384
|
/** @brief Toggle Sw reset of DMA2D IP */
|
|
Jerome Coutant
2:123b894b49dd
|
1385
|
__HAL_RCC_DMA2D_FORCE_RESET();
|
|
Jerome Coutant
2:123b894b49dd
|
1386
|
__HAL_RCC_DMA2D_RELEASE_RESET();
|
|
Jerome Coutant
2:123b894b49dd
|
1387
|
|
|
Jerome Coutant
2:123b894b49dd
|
1388
|
/** @brief Enable DSI Host and wrapper clocks */
|
|
Jerome Coutant
2:123b894b49dd
|
1389
|
__HAL_RCC_DSI_CLK_ENABLE();
|
|
Jerome Coutant
2:123b894b49dd
|
1390
|
|
|
Jerome Coutant
2:123b894b49dd
|
1391
|
/** @brief Soft Reset the DSI Host and wrapper */
|
|
Jerome Coutant
2:123b894b49dd
|
1392
|
__HAL_RCC_DSI_FORCE_RESET();
|
|
Jerome Coutant
2:123b894b49dd
|
1393
|
__HAL_RCC_DSI_RELEASE_RESET();
|
|
Jerome Coutant
2:123b894b49dd
|
1394
|
|
|
Jerome Coutant
2:123b894b49dd
|
1395
|
/** @brief NVIC configuration for LTDC interrupt that is now enabled */
|
|
Jerome Coutant
2:123b894b49dd
|
1396
|
HAL_NVIC_SetPriority(LTDC_IRQn, 3, 0);
|
|
Jerome Coutant
2:123b894b49dd
|
1397
|
HAL_NVIC_EnableIRQ(LTDC_IRQn);
|
|
Jerome Coutant
2:123b894b49dd
|
1398
|
|
|
Jerome Coutant
2:123b894b49dd
|
1399
|
/** @brief NVIC configuration for DMA2D interrupt that is now enabled */
|
|
Jerome Coutant
2:123b894b49dd
|
1400
|
HAL_NVIC_SetPriority(DMA2D_IRQn, 3, 0);
|
|
Jerome Coutant
2:123b894b49dd
|
1401
|
HAL_NVIC_EnableIRQ(DMA2D_IRQn);
|
|
Jerome Coutant
2:123b894b49dd
|
1402
|
|
|
Jerome Coutant
2:123b894b49dd
|
1403
|
/** @brief NVIC configuration for DSI interrupt that is now enabled */
|
|
Jerome Coutant
2:123b894b49dd
|
1404
|
HAL_NVIC_SetPriority(DSI_IRQn, 3, 0);
|
|
Jerome Coutant
2:123b894b49dd
|
1405
|
HAL_NVIC_EnableIRQ(DSI_IRQn);
|
|
Jerome Coutant
2:123b894b49dd
|
1406
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1407
|
|
|
Jerome Coutant
2:123b894b49dd
|
1408
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1409
|
* @brief This function handles LTDC Error interrupt Handler.
|
|
Jerome Coutant
2:123b894b49dd
|
1410
|
* @note : Can be surcharged by application code implementation of the function.
|
|
Jerome Coutant
2:123b894b49dd
|
1411
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1412
|
|
|
Jerome Coutant
2:123b894b49dd
|
1413
|
__weak void BSP_LCD_LTDC_ER_IRQHandler(void)
|
|
Jerome Coutant
2:123b894b49dd
|
1414
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1415
|
HAL_LTDC_IRQHandler(&(hltdc_eval));
|
|
Jerome Coutant
2:123b894b49dd
|
1416
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1417
|
|
|
Jerome Coutant
2:123b894b49dd
|
1418
|
|
|
Jerome Coutant
2:123b894b49dd
|
1419
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1420
|
* @brief Draws a pixel on LCD.
|
|
Jerome Coutant
2:123b894b49dd
|
1421
|
* @param Xpos: X position
|
|
Jerome Coutant
2:123b894b49dd
|
1422
|
* @param Ypos: Y position
|
|
Jerome Coutant
2:123b894b49dd
|
1423
|
* @param RGB_Code: Pixel color in ARGB mode (8-8-8-8)
|
|
Jerome Coutant
2:123b894b49dd
|
1424
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1425
|
void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint32_t RGB_Code)
|
|
Jerome Coutant
2:123b894b49dd
|
1426
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1427
|
/* Write data value to all SDRAM memory */
|
|
Jerome Coutant
2:123b894b49dd
|
1428
|
*(__IO uint32_t*) (hltdc_eval.LayerCfg[ActiveLayer].FBStartAdress + (4*(Ypos*BSP_LCD_GetXSize() + Xpos))) = RGB_Code;
|
|
Jerome Coutant
2:123b894b49dd
|
1429
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1430
|
|
|
Jerome Coutant
2:123b894b49dd
|
1431
|
|
|
Jerome Coutant
2:123b894b49dd
|
1432
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1433
|
* @brief Draws a character on LCD.
|
|
Jerome Coutant
2:123b894b49dd
|
1434
|
* @param Xpos: Line where to display the character shape
|
|
Jerome Coutant
2:123b894b49dd
|
1435
|
* @param Ypos: Start column address
|
|
Jerome Coutant
2:123b894b49dd
|
1436
|
* @param c: Pointer to the character data
|
|
Jerome Coutant
2:123b894b49dd
|
1437
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1438
|
static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c)
|
|
Jerome Coutant
2:123b894b49dd
|
1439
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1440
|
uint32_t i = 0, j = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
1441
|
uint16_t height, width;
|
|
Jerome Coutant
2:123b894b49dd
|
1442
|
uint8_t offset;
|
|
Jerome Coutant
2:123b894b49dd
|
1443
|
uint8_t *pchar;
|
|
Jerome Coutant
2:123b894b49dd
|
1444
|
uint32_t line;
|
|
Jerome Coutant
2:123b894b49dd
|
1445
|
|
|
Jerome Coutant
2:123b894b49dd
|
1446
|
height = DrawProp[ActiveLayer].pFont->Height;
|
|
Jerome Coutant
2:123b894b49dd
|
1447
|
width = DrawProp[ActiveLayer].pFont->Width;
|
|
Jerome Coutant
2:123b894b49dd
|
1448
|
|
|
Jerome Coutant
2:123b894b49dd
|
1449
|
offset = 8 *((width + 7)/8) - width ;
|
|
Jerome Coutant
2:123b894b49dd
|
1450
|
|
|
Jerome Coutant
2:123b894b49dd
|
1451
|
for(i = 0; i < height; i++)
|
|
Jerome Coutant
2:123b894b49dd
|
1452
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1453
|
pchar = ((uint8_t *)c + (width + 7)/8 * i);
|
|
Jerome Coutant
2:123b894b49dd
|
1454
|
|
|
Jerome Coutant
2:123b894b49dd
|
1455
|
switch(((width + 7)/8))
|
|
Jerome Coutant
2:123b894b49dd
|
1456
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1457
|
|
|
Jerome Coutant
2:123b894b49dd
|
1458
|
case 1:
|
|
Jerome Coutant
2:123b894b49dd
|
1459
|
line = pchar[0];
|
|
Jerome Coutant
2:123b894b49dd
|
1460
|
break;
|
|
Jerome Coutant
2:123b894b49dd
|
1461
|
|
|
Jerome Coutant
2:123b894b49dd
|
1462
|
case 2:
|
|
Jerome Coutant
2:123b894b49dd
|
1463
|
line = (pchar[0]<< 8) | pchar[1];
|
|
Jerome Coutant
2:123b894b49dd
|
1464
|
break;
|
|
Jerome Coutant
2:123b894b49dd
|
1465
|
|
|
Jerome Coutant
2:123b894b49dd
|
1466
|
case 3:
|
|
Jerome Coutant
2:123b894b49dd
|
1467
|
default:
|
|
Jerome Coutant
2:123b894b49dd
|
1468
|
line = (pchar[0]<< 16) | (pchar[1]<< 8) | pchar[2];
|
|
Jerome Coutant
2:123b894b49dd
|
1469
|
break;
|
|
Jerome Coutant
2:123b894b49dd
|
1470
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1471
|
|
|
Jerome Coutant
2:123b894b49dd
|
1472
|
for (j = 0; j < width; j++)
|
|
Jerome Coutant
2:123b894b49dd
|
1473
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1474
|
if(line & (1 << (width- j + offset- 1)))
|
|
Jerome Coutant
2:123b894b49dd
|
1475
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1476
|
BSP_LCD_DrawPixel((Xpos + j), Ypos, DrawProp[ActiveLayer].TextColor);
|
|
Jerome Coutant
2:123b894b49dd
|
1477
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1478
|
else
|
|
Jerome Coutant
2:123b894b49dd
|
1479
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1480
|
BSP_LCD_DrawPixel((Xpos + j), Ypos, DrawProp[ActiveLayer].BackColor);
|
|
Jerome Coutant
2:123b894b49dd
|
1481
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1482
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1483
|
Ypos++;
|
|
Jerome Coutant
2:123b894b49dd
|
1484
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1485
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1486
|
|
|
Jerome Coutant
2:123b894b49dd
|
1487
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1488
|
* @brief Fills a triangle (between 3 points).
|
|
Jerome Coutant
2:123b894b49dd
|
1489
|
* @param x1: Point 1 X position
|
|
Jerome Coutant
2:123b894b49dd
|
1490
|
* @param y1: Point 1 Y position
|
|
Jerome Coutant
2:123b894b49dd
|
1491
|
* @param x2: Point 2 X position
|
|
Jerome Coutant
2:123b894b49dd
|
1492
|
* @param y2: Point 2 Y position
|
|
Jerome Coutant
2:123b894b49dd
|
1493
|
* @param x3: Point 3 X position
|
|
Jerome Coutant
2:123b894b49dd
|
1494
|
* @param y3: Point 3 Y position
|
|
Jerome Coutant
2:123b894b49dd
|
1495
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1496
|
static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3)
|
|
Jerome Coutant
2:123b894b49dd
|
1497
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1498
|
int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0,
|
|
Jerome Coutant
2:123b894b49dd
|
1499
|
yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0,
|
|
Jerome Coutant
2:123b894b49dd
|
1500
|
curpixel = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
1501
|
|
|
Jerome Coutant
2:123b894b49dd
|
1502
|
deltax = ABS(x2 - x1); /* The difference between the x's */
|
|
Jerome Coutant
2:123b894b49dd
|
1503
|
deltay = ABS(y2 - y1); /* The difference between the y's */
|
|
Jerome Coutant
2:123b894b49dd
|
1504
|
x = x1; /* Start x off at the first pixel */
|
|
Jerome Coutant
2:123b894b49dd
|
1505
|
y = y1; /* Start y off at the first pixel */
|
|
Jerome Coutant
2:123b894b49dd
|
1506
|
|
|
Jerome Coutant
2:123b894b49dd
|
1507
|
if (x2 >= x1) /* The x-values are increasing */
|
|
Jerome Coutant
2:123b894b49dd
|
1508
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1509
|
xinc1 = 1;
|
|
Jerome Coutant
2:123b894b49dd
|
1510
|
xinc2 = 1;
|
|
Jerome Coutant
2:123b894b49dd
|
1511
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1512
|
else /* The x-values are decreasing */
|
|
Jerome Coutant
2:123b894b49dd
|
1513
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1514
|
xinc1 = -1;
|
|
Jerome Coutant
2:123b894b49dd
|
1515
|
xinc2 = -1;
|
|
Jerome Coutant
2:123b894b49dd
|
1516
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1517
|
|
|
Jerome Coutant
2:123b894b49dd
|
1518
|
if (y2 >= y1) /* The y-values are increasing */
|
|
Jerome Coutant
2:123b894b49dd
|
1519
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1520
|
yinc1 = 1;
|
|
Jerome Coutant
2:123b894b49dd
|
1521
|
yinc2 = 1;
|
|
Jerome Coutant
2:123b894b49dd
|
1522
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1523
|
else /* The y-values are decreasing */
|
|
Jerome Coutant
2:123b894b49dd
|
1524
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1525
|
yinc1 = -1;
|
|
Jerome Coutant
2:123b894b49dd
|
1526
|
yinc2 = -1;
|
|
Jerome Coutant
2:123b894b49dd
|
1527
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1528
|
|
|
Jerome Coutant
2:123b894b49dd
|
1529
|
if (deltax >= deltay) /* There is at least one x-value for every y-value */
|
|
Jerome Coutant
2:123b894b49dd
|
1530
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1531
|
xinc1 = 0; /* Don't change the x when numerator >= denominator */
|
|
Jerome Coutant
2:123b894b49dd
|
1532
|
yinc2 = 0; /* Don't change the y for every iteration */
|
|
Jerome Coutant
2:123b894b49dd
|
1533
|
den = deltax;
|
|
Jerome Coutant
2:123b894b49dd
|
1534
|
num = deltax / 2;
|
|
Jerome Coutant
2:123b894b49dd
|
1535
|
numadd = deltay;
|
|
Jerome Coutant
2:123b894b49dd
|
1536
|
numpixels = deltax; /* There are more x-values than y-values */
|
|
Jerome Coutant
2:123b894b49dd
|
1537
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1538
|
else /* There is at least one y-value for every x-value */
|
|
Jerome Coutant
2:123b894b49dd
|
1539
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1540
|
xinc2 = 0; /* Don't change the x for every iteration */
|
|
Jerome Coutant
2:123b894b49dd
|
1541
|
yinc1 = 0; /* Don't change the y when numerator >= denominator */
|
|
Jerome Coutant
2:123b894b49dd
|
1542
|
den = deltay;
|
|
Jerome Coutant
2:123b894b49dd
|
1543
|
num = deltay / 2;
|
|
Jerome Coutant
2:123b894b49dd
|
1544
|
numadd = deltax;
|
|
Jerome Coutant
2:123b894b49dd
|
1545
|
numpixels = deltay; /* There are more y-values than x-values */
|
|
Jerome Coutant
2:123b894b49dd
|
1546
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1547
|
|
|
Jerome Coutant
2:123b894b49dd
|
1548
|
for (curpixel = 0; curpixel <= numpixels; curpixel++)
|
|
Jerome Coutant
2:123b894b49dd
|
1549
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1550
|
BSP_LCD_DrawLine(x, y, x3, y3);
|
|
Jerome Coutant
2:123b894b49dd
|
1551
|
|
|
Jerome Coutant
2:123b894b49dd
|
1552
|
num += numadd; /* Increase the numerator by the top of the fraction */
|
|
Jerome Coutant
2:123b894b49dd
|
1553
|
if (num >= den) /* Check if numerator >= denominator */
|
|
Jerome Coutant
2:123b894b49dd
|
1554
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1555
|
num -= den; /* Calculate the new numerator value */
|
|
Jerome Coutant
2:123b894b49dd
|
1556
|
x += xinc1; /* Change the x as appropriate */
|
|
Jerome Coutant
2:123b894b49dd
|
1557
|
y += yinc1; /* Change the y as appropriate */
|
|
Jerome Coutant
2:123b894b49dd
|
1558
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1559
|
x += xinc2; /* Change the x as appropriate */
|
|
Jerome Coutant
2:123b894b49dd
|
1560
|
y += yinc2; /* Change the y as appropriate */
|
|
Jerome Coutant
2:123b894b49dd
|
1561
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1562
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1563
|
|
|
Jerome Coutant
2:123b894b49dd
|
1564
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1565
|
* @brief Fills a buffer.
|
|
Jerome Coutant
2:123b894b49dd
|
1566
|
* @param LayerIndex: Layer index
|
|
Jerome Coutant
2:123b894b49dd
|
1567
|
* @param pDst: Pointer to destination buffer
|
|
Jerome Coutant
2:123b894b49dd
|
1568
|
* @param xSize: Buffer width
|
|
Jerome Coutant
2:123b894b49dd
|
1569
|
* @param ySize: Buffer height
|
|
Jerome Coutant
2:123b894b49dd
|
1570
|
* @param OffLine: Offset
|
|
Jerome Coutant
2:123b894b49dd
|
1571
|
* @param ColorIndex: Color index
|
|
Jerome Coutant
2:123b894b49dd
|
1572
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1573
|
static void LL_FillBuffer(uint32_t LayerIndex, void *pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLine, uint32_t ColorIndex)
|
|
Jerome Coutant
2:123b894b49dd
|
1574
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1575
|
/* Register to memory mode with ARGB8888 as color Mode */
|
|
Jerome Coutant
2:123b894b49dd
|
1576
|
hdma2d_eval.Init.Mode = DMA2D_R2M;
|
|
Jerome Coutant
2:123b894b49dd
|
1577
|
hdma2d_eval.Init.ColorMode = DMA2D_ARGB8888;
|
|
Jerome Coutant
2:123b894b49dd
|
1578
|
hdma2d_eval.Init.OutputOffset = OffLine;
|
|
Jerome Coutant
2:123b894b49dd
|
1579
|
|
|
Jerome Coutant
2:123b894b49dd
|
1580
|
hdma2d_eval.Instance = DMA2D;
|
|
Jerome Coutant
2:123b894b49dd
|
1581
|
|
|
Jerome Coutant
2:123b894b49dd
|
1582
|
/* DMA2D Initialization */
|
|
Jerome Coutant
2:123b894b49dd
|
1583
|
if(HAL_DMA2D_Init(&hdma2d_eval) == HAL_OK)
|
|
Jerome Coutant
2:123b894b49dd
|
1584
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1585
|
if(HAL_DMA2D_ConfigLayer(&hdma2d_eval, LayerIndex) == HAL_OK)
|
|
Jerome Coutant
2:123b894b49dd
|
1586
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1587
|
if (HAL_DMA2D_Start(&hdma2d_eval, ColorIndex, (uint32_t)pDst, xSize, ySize) == HAL_OK)
|
|
Jerome Coutant
2:123b894b49dd
|
1588
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1589
|
/* Polling For DMA transfer */
|
|
Jerome Coutant
2:123b894b49dd
|
1590
|
HAL_DMA2D_PollForTransfer(&hdma2d_eval, 10);
|
|
Jerome Coutant
2:123b894b49dd
|
1591
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1592
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1593
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1594
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1595
|
|
|
Jerome Coutant
2:123b894b49dd
|
1596
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1597
|
* @brief Converts a line to an ARGB8888 pixel format.
|
|
Jerome Coutant
2:123b894b49dd
|
1598
|
* @param pSrc: Pointer to source buffer
|
|
Jerome Coutant
2:123b894b49dd
|
1599
|
* @param pDst: Output color
|
|
Jerome Coutant
2:123b894b49dd
|
1600
|
* @param xSize: Buffer width
|
|
Jerome Coutant
2:123b894b49dd
|
1601
|
* @param ColorMode: Input color mode
|
|
Jerome Coutant
2:123b894b49dd
|
1602
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1603
|
static void LL_ConvertLineToARGB8888(void *pSrc, void *pDst, uint32_t xSize, uint32_t ColorMode)
|
|
Jerome Coutant
2:123b894b49dd
|
1604
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1605
|
/* Configure the DMA2D Mode, Color Mode and output offset */
|
|
Jerome Coutant
2:123b894b49dd
|
1606
|
hdma2d_eval.Init.Mode = DMA2D_M2M_PFC;
|
|
Jerome Coutant
2:123b894b49dd
|
1607
|
hdma2d_eval.Init.ColorMode = DMA2D_ARGB8888;
|
|
Jerome Coutant
2:123b894b49dd
|
1608
|
hdma2d_eval.Init.OutputOffset = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
1609
|
|
|
Jerome Coutant
2:123b894b49dd
|
1610
|
/* Foreground Configuration */
|
|
Jerome Coutant
2:123b894b49dd
|
1611
|
hdma2d_eval.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA;
|
|
Jerome Coutant
2:123b894b49dd
|
1612
|
hdma2d_eval.LayerCfg[1].InputAlpha = 0xFF;
|
|
Jerome Coutant
2:123b894b49dd
|
1613
|
hdma2d_eval.LayerCfg[1].InputColorMode = ColorMode;
|
|
Jerome Coutant
2:123b894b49dd
|
1614
|
hdma2d_eval.LayerCfg[1].InputOffset = 0;
|
|
Jerome Coutant
2:123b894b49dd
|
1615
|
|
|
Jerome Coutant
2:123b894b49dd
|
1616
|
hdma2d_eval.Instance = DMA2D;
|
|
Jerome Coutant
2:123b894b49dd
|
1617
|
|
|
Jerome Coutant
2:123b894b49dd
|
1618
|
/* DMA2D Initialization */
|
|
Jerome Coutant
2:123b894b49dd
|
1619
|
if(HAL_DMA2D_Init(&hdma2d_eval) == HAL_OK)
|
|
Jerome Coutant
2:123b894b49dd
|
1620
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1621
|
if(HAL_DMA2D_ConfigLayer(&hdma2d_eval, 1) == HAL_OK)
|
|
Jerome Coutant
2:123b894b49dd
|
1622
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1623
|
if (HAL_DMA2D_Start(&hdma2d_eval, (uint32_t)pSrc, (uint32_t)pDst, xSize, 1) == HAL_OK)
|
|
Jerome Coutant
2:123b894b49dd
|
1624
|
{
|
|
Jerome Coutant
2:123b894b49dd
|
1625
|
/* Polling For DMA transfer */
|
|
Jerome Coutant
2:123b894b49dd
|
1626
|
HAL_DMA2D_PollForTransfer(&hdma2d_eval, 10);
|
|
Jerome Coutant
2:123b894b49dd
|
1627
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1628
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1629
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1630
|
}
|
|
Jerome Coutant
2:123b894b49dd
|
1631
|
|
|
Jerome Coutant
2:123b894b49dd
|
1632
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1633
|
* @}
|
|
Jerome Coutant
2:123b894b49dd
|
1634
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1635
|
|
|
Jerome Coutant
2:123b894b49dd
|
1636
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1637
|
* @}
|
|
Jerome Coutant
2:123b894b49dd
|
1638
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1639
|
|
|
Jerome Coutant
2:123b894b49dd
|
1640
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1641
|
* @}
|
|
Jerome Coutant
2:123b894b49dd
|
1642
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1643
|
|
|
Jerome Coutant
2:123b894b49dd
|
1644
|
/**
|
|
Jerome Coutant
2:123b894b49dd
|
1645
|
* @}
|
|
Jerome Coutant
2:123b894b49dd
|
1646
|
*/
|
|
Jerome Coutant
2:123b894b49dd
|
1647
|
|
|
Jerome Coutant
2:123b894b49dd
|
1648
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|