Projet
Dependents: DISCO-F746NG_Scope_copy
Fork of BSP_DISCO_F746NG by
stm32746g_discovery_lcd.c@5:5a395e126678, 2016-11-09 (annotated)
- Committer:
- bcostm
- Date:
- Wed Nov 09 18:26:13 2016 +0100
- Revision:
- 5:5a395e126678
- Parent:
- 0:c9112f0c67e3
Add more MBED comments
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bcostm | 0:c9112f0c67e3 | 1 | /** |
bcostm | 0:c9112f0c67e3 | 2 | ****************************************************************************** |
bcostm | 0:c9112f0c67e3 | 3 | * @file stm32746g_discovery_lcd.c |
bcostm | 0:c9112f0c67e3 | 4 | * @author MCD Application Team |
bcostm | 0:c9112f0c67e3 | 5 | * @version V1.0.0 |
bcostm | 0:c9112f0c67e3 | 6 | * @date 25-June-2015 |
bcostm | 0:c9112f0c67e3 | 7 | * @brief This file includes the driver for Liquid Crystal Display (LCD) module |
bcostm | 0:c9112f0c67e3 | 8 | * mounted on STM32746G-Discovery board. |
bcostm | 0:c9112f0c67e3 | 9 | @verbatim |
bcostm | 0:c9112f0c67e3 | 10 | 1. How To use this driver: |
bcostm | 0:c9112f0c67e3 | 11 | -------------------------- |
bcostm | 0:c9112f0c67e3 | 12 | - This driver is used to drive directly an LCD TFT using the LTDC controller. |
bcostm | 0:c9112f0c67e3 | 13 | - This driver uses timing and setting for RK043FN48H LCD. |
bcostm | 0:c9112f0c67e3 | 14 | |
bcostm | 0:c9112f0c67e3 | 15 | 2. Driver description: |
bcostm | 0:c9112f0c67e3 | 16 | --------------------- |
bcostm | 0:c9112f0c67e3 | 17 | + Initialization steps: |
bcostm | 0:c9112f0c67e3 | 18 | o Initialize the LCD using the BSP_LCD_Init() function. |
bcostm | 0:c9112f0c67e3 | 19 | o Apply the Layer configuration using the BSP_LCD_LayerDefaultInit() function. |
bcostm | 0:c9112f0c67e3 | 20 | o Select the LCD layer to be used using the BSP_LCD_SelectLayer() function. |
bcostm | 0:c9112f0c67e3 | 21 | o Enable the LCD display using the BSP_LCD_DisplayOn() function. |
bcostm | 0:c9112f0c67e3 | 22 | |
bcostm | 0:c9112f0c67e3 | 23 | + Options |
bcostm | 0:c9112f0c67e3 | 24 | o Configure and enable the color keying functionality using the |
bcostm | 0:c9112f0c67e3 | 25 | BSP_LCD_SetColorKeying() function. |
bcostm | 0:c9112f0c67e3 | 26 | o Modify in the fly the transparency and/or the frame buffer address |
bcostm | 0:c9112f0c67e3 | 27 | using the following functions: |
bcostm | 0:c9112f0c67e3 | 28 | - BSP_LCD_SetTransparency() |
bcostm | 0:c9112f0c67e3 | 29 | - BSP_LCD_SetLayerAddress() |
bcostm | 0:c9112f0c67e3 | 30 | |
bcostm | 0:c9112f0c67e3 | 31 | + Display on LCD |
bcostm | 0:c9112f0c67e3 | 32 | o Clear the hole LCD using BSP_LCD_Clear() function or only one specified string |
bcostm | 0:c9112f0c67e3 | 33 | line using the BSP_LCD_ClearStringLine() function. |
bcostm | 0:c9112f0c67e3 | 34 | o Display a character on the specified line and column using the BSP_LCD_DisplayChar() |
bcostm | 0:c9112f0c67e3 | 35 | function or a complete string line using the BSP_LCD_DisplayStringAtLine() function. |
bcostm | 0:c9112f0c67e3 | 36 | o Display a string line on the specified position (x,y in pixel) and align mode |
bcostm | 0:c9112f0c67e3 | 37 | using the BSP_LCD_DisplayStringAtLine() function. |
bcostm | 0:c9112f0c67e3 | 38 | o Draw and fill a basic shapes (dot, line, rectangle, circle, ellipse, .. bitmap) |
bcostm | 0:c9112f0c67e3 | 39 | on LCD using the available set of functions. |
bcostm | 0:c9112f0c67e3 | 40 | @endverbatim |
bcostm | 0:c9112f0c67e3 | 41 | ****************************************************************************** |
bcostm | 0:c9112f0c67e3 | 42 | * @attention |
bcostm | 0:c9112f0c67e3 | 43 | * |
bcostm | 0:c9112f0c67e3 | 44 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
bcostm | 0:c9112f0c67e3 | 45 | * |
bcostm | 0:c9112f0c67e3 | 46 | * Redistribution and use in source and binary forms, with or without modification, |
bcostm | 0:c9112f0c67e3 | 47 | * are permitted provided that the following conditions are met: |
bcostm | 0:c9112f0c67e3 | 48 | * 1. Redistributions of source code must retain the above copyright notice, |
bcostm | 0:c9112f0c67e3 | 49 | * this list of conditions and the following disclaimer. |
bcostm | 0:c9112f0c67e3 | 50 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
bcostm | 0:c9112f0c67e3 | 51 | * this list of conditions and the following disclaimer in the documentation |
bcostm | 0:c9112f0c67e3 | 52 | * and/or other materials provided with the distribution. |
bcostm | 0:c9112f0c67e3 | 53 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
bcostm | 0:c9112f0c67e3 | 54 | * may be used to endorse or promote products derived from this software |
bcostm | 0:c9112f0c67e3 | 55 | * without specific prior written permission. |
bcostm | 0:c9112f0c67e3 | 56 | * |
bcostm | 0:c9112f0c67e3 | 57 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
bcostm | 0:c9112f0c67e3 | 58 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
bcostm | 0:c9112f0c67e3 | 59 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
bcostm | 0:c9112f0c67e3 | 60 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
bcostm | 0:c9112f0c67e3 | 61 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
bcostm | 0:c9112f0c67e3 | 62 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
bcostm | 0:c9112f0c67e3 | 63 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
bcostm | 0:c9112f0c67e3 | 64 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
bcostm | 0:c9112f0c67e3 | 65 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
bcostm | 0:c9112f0c67e3 | 66 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
bcostm | 0:c9112f0c67e3 | 67 | * |
bcostm | 0:c9112f0c67e3 | 68 | ****************************************************************************** |
bcostm | 0:c9112f0c67e3 | 69 | */ |
bcostm | 0:c9112f0c67e3 | 70 | |
bcostm | 0:c9112f0c67e3 | 71 | /* Includes ------------------------------------------------------------------*/ |
bcostm | 0:c9112f0c67e3 | 72 | #include "stm32746g_discovery_lcd.h" |
bcostm | 0:c9112f0c67e3 | 73 | #include "fonts.h" |
bcostm | 5:5a395e126678 | 74 | //#include "font24.c" // MBED |
bcostm | 5:5a395e126678 | 75 | //#include "font20.c" // MBED |
bcostm | 5:5a395e126678 | 76 | //#include "font16.c" // MBED |
bcostm | 5:5a395e126678 | 77 | //#include "font12.c" // MBED |
bcostm | 5:5a395e126678 | 78 | //#include "font8.c" // MBED |
bcostm | 0:c9112f0c67e3 | 79 | |
bcostm | 0:c9112f0c67e3 | 80 | /** @addtogroup BSP |
bcostm | 0:c9112f0c67e3 | 81 | * @{ |
bcostm | 0:c9112f0c67e3 | 82 | */ |
bcostm | 0:c9112f0c67e3 | 83 | |
bcostm | 0:c9112f0c67e3 | 84 | /** @addtogroup STM32746G_DISCOVERY |
bcostm | 0:c9112f0c67e3 | 85 | * @{ |
bcostm | 0:c9112f0c67e3 | 86 | */ |
bcostm | 0:c9112f0c67e3 | 87 | |
bcostm | 0:c9112f0c67e3 | 88 | /** @addtogroup STM32746G_DISCOVERY_LCD |
bcostm | 0:c9112f0c67e3 | 89 | * @{ |
bcostm | 0:c9112f0c67e3 | 90 | */ |
bcostm | 0:c9112f0c67e3 | 91 | |
bcostm | 0:c9112f0c67e3 | 92 | /** @defgroup STM32746G_DISCOVERY_LCD_Private_TypesDefinitions STM32746G_DISCOVERY_LCD Private Types Definitions |
bcostm | 0:c9112f0c67e3 | 93 | * @{ |
bcostm | 0:c9112f0c67e3 | 94 | */ |
bcostm | 0:c9112f0c67e3 | 95 | /** |
bcostm | 0:c9112f0c67e3 | 96 | * @} |
bcostm | 0:c9112f0c67e3 | 97 | */ |
bcostm | 0:c9112f0c67e3 | 98 | |
bcostm | 0:c9112f0c67e3 | 99 | /** @defgroup STM32746G_DISCOVERY_LCD_Private_Defines STM32746G_DISCOVERY LCD Private Defines |
bcostm | 0:c9112f0c67e3 | 100 | * @{ |
bcostm | 0:c9112f0c67e3 | 101 | */ |
bcostm | 0:c9112f0c67e3 | 102 | #define POLY_X(Z) ((int32_t)((Points + Z)->X)) |
bcostm | 0:c9112f0c67e3 | 103 | #define POLY_Y(Z) ((int32_t)((Points + Z)->Y)) |
bcostm | 0:c9112f0c67e3 | 104 | /** |
bcostm | 0:c9112f0c67e3 | 105 | * @} |
bcostm | 0:c9112f0c67e3 | 106 | */ |
bcostm | 0:c9112f0c67e3 | 107 | |
bcostm | 0:c9112f0c67e3 | 108 | /** @defgroup STM32746G_DISCOVERY_LCD_Private_Macros STM32746G_DISCOVERY_LCD Private Macros |
bcostm | 0:c9112f0c67e3 | 109 | * @{ |
bcostm | 0:c9112f0c67e3 | 110 | */ |
bcostm | 0:c9112f0c67e3 | 111 | #define ABS(X) ((X) > 0 ? (X) : -(X)) |
bcostm | 0:c9112f0c67e3 | 112 | /** |
bcostm | 0:c9112f0c67e3 | 113 | * @} |
bcostm | 0:c9112f0c67e3 | 114 | */ |
bcostm | 0:c9112f0c67e3 | 115 | |
bcostm | 0:c9112f0c67e3 | 116 | /** @defgroup STM32746G_DISCOVERY_LCD_Private_Variables STM32746G_DISCOVERY_LCD Private Variables |
bcostm | 0:c9112f0c67e3 | 117 | * @{ |
bcostm | 0:c9112f0c67e3 | 118 | */ |
bcostm | 0:c9112f0c67e3 | 119 | static LTDC_HandleTypeDef hLtdcHandler; |
bcostm | 0:c9112f0c67e3 | 120 | static DMA2D_HandleTypeDef hDma2dHandler; |
bcostm | 0:c9112f0c67e3 | 121 | |
bcostm | 0:c9112f0c67e3 | 122 | /* Default LCD configuration with LCD Layer 1 */ |
bcostm | 0:c9112f0c67e3 | 123 | static uint32_t ActiveLayer = 0; |
bcostm | 0:c9112f0c67e3 | 124 | static LCD_DrawPropTypeDef DrawProp[MAX_LAYER_NUMBER]; |
bcostm | 0:c9112f0c67e3 | 125 | /** |
bcostm | 0:c9112f0c67e3 | 126 | * @} |
bcostm | 0:c9112f0c67e3 | 127 | */ |
bcostm | 0:c9112f0c67e3 | 128 | |
bcostm | 0:c9112f0c67e3 | 129 | /** @defgroup STM32746G_DISCOVERY_LCD_Private_FunctionPrototypes STM32746G_DISCOVERY_LCD Private Function Prototypes |
bcostm | 0:c9112f0c67e3 | 130 | * @{ |
bcostm | 0:c9112f0c67e3 | 131 | */ |
bcostm | 0:c9112f0c67e3 | 132 | static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c); |
bcostm | 0:c9112f0c67e3 | 133 | static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3); |
bcostm | 0:c9112f0c67e3 | 134 | static void LL_FillBuffer(uint32_t LayerIndex, void *pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLine, uint32_t ColorIndex); |
bcostm | 0:c9112f0c67e3 | 135 | static void LL_ConvertLineToARGB8888(void * pSrc, void *pDst, uint32_t xSize, uint32_t ColorMode); |
bcostm | 0:c9112f0c67e3 | 136 | /** |
bcostm | 0:c9112f0c67e3 | 137 | * @} |
bcostm | 0:c9112f0c67e3 | 138 | */ |
bcostm | 0:c9112f0c67e3 | 139 | |
bcostm | 0:c9112f0c67e3 | 140 | /** @defgroup STM32746G_DISCOVERY_LCD_Exported_Functions STM32746G_DISCOVERY_LCD Exported Functions |
bcostm | 0:c9112f0c67e3 | 141 | * @{ |
bcostm | 0:c9112f0c67e3 | 142 | */ |
bcostm | 0:c9112f0c67e3 | 143 | |
bcostm | 0:c9112f0c67e3 | 144 | /** |
bcostm | 0:c9112f0c67e3 | 145 | * @brief Initializes the LCD. |
bcostm | 0:c9112f0c67e3 | 146 | * @retval LCD state |
bcostm | 0:c9112f0c67e3 | 147 | */ |
bcostm | 0:c9112f0c67e3 | 148 | uint8_t BSP_LCD_Init(void) |
bcostm | 0:c9112f0c67e3 | 149 | { |
bcostm | 0:c9112f0c67e3 | 150 | /* Select the used LCD */ |
bcostm | 0:c9112f0c67e3 | 151 | |
bcostm | 0:c9112f0c67e3 | 152 | /* The RK043FN48H LCD 480x272 is selected */ |
bcostm | 0:c9112f0c67e3 | 153 | /* Timing Configuration */ |
bcostm | 0:c9112f0c67e3 | 154 | hLtdcHandler.Init.HorizontalSync = (RK043FN48H_HSYNC - 1); |
bcostm | 0:c9112f0c67e3 | 155 | hLtdcHandler.Init.VerticalSync = (RK043FN48H_VSYNC - 1); |
bcostm | 0:c9112f0c67e3 | 156 | hLtdcHandler.Init.AccumulatedHBP = (RK043FN48H_HSYNC + RK043FN48H_HBP - 1); |
bcostm | 0:c9112f0c67e3 | 157 | hLtdcHandler.Init.AccumulatedVBP = (RK043FN48H_VSYNC + RK043FN48H_VBP - 1); |
bcostm | 0:c9112f0c67e3 | 158 | hLtdcHandler.Init.AccumulatedActiveH = (RK043FN48H_HEIGHT + RK043FN48H_VSYNC + RK043FN48H_VBP - 1); |
bcostm | 0:c9112f0c67e3 | 159 | hLtdcHandler.Init.AccumulatedActiveW = (RK043FN48H_WIDTH + RK043FN48H_HSYNC + RK043FN48H_HBP - 1); |
bcostm | 0:c9112f0c67e3 | 160 | hLtdcHandler.Init.TotalHeigh = (RK043FN48H_HEIGHT + RK043FN48H_VSYNC + RK043FN48H_VBP + RK043FN48H_VFP - 1); |
bcostm | 0:c9112f0c67e3 | 161 | hLtdcHandler.Init.TotalWidth = (RK043FN48H_WIDTH + RK043FN48H_HSYNC + RK043FN48H_HBP + RK043FN48H_HFP - 1); |
bcostm | 0:c9112f0c67e3 | 162 | |
bcostm | 0:c9112f0c67e3 | 163 | /* LCD clock configuration */ |
bcostm | 0:c9112f0c67e3 | 164 | BSP_LCD_ClockConfig(&hLtdcHandler, NULL); |
bcostm | 0:c9112f0c67e3 | 165 | |
bcostm | 0:c9112f0c67e3 | 166 | /* Initialize the LCD pixel width and pixel height */ |
bcostm | 0:c9112f0c67e3 | 167 | hLtdcHandler.LayerCfg->ImageWidth = RK043FN48H_WIDTH; |
bcostm | 0:c9112f0c67e3 | 168 | hLtdcHandler.LayerCfg->ImageHeight = RK043FN48H_HEIGHT; |
bcostm | 0:c9112f0c67e3 | 169 | |
bcostm | 0:c9112f0c67e3 | 170 | /* Background value */ |
bcostm | 0:c9112f0c67e3 | 171 | hLtdcHandler.Init.Backcolor.Blue = 0; |
bcostm | 0:c9112f0c67e3 | 172 | hLtdcHandler.Init.Backcolor.Green = 0; |
bcostm | 0:c9112f0c67e3 | 173 | hLtdcHandler.Init.Backcolor.Red = 0; |
bcostm | 0:c9112f0c67e3 | 174 | |
bcostm | 0:c9112f0c67e3 | 175 | /* Polarity */ |
bcostm | 0:c9112f0c67e3 | 176 | hLtdcHandler.Init.HSPolarity = LTDC_HSPOLARITY_AL; |
bcostm | 0:c9112f0c67e3 | 177 | hLtdcHandler.Init.VSPolarity = LTDC_VSPOLARITY_AL; |
bcostm | 0:c9112f0c67e3 | 178 | hLtdcHandler.Init.DEPolarity = LTDC_DEPOLARITY_AL; |
bcostm | 0:c9112f0c67e3 | 179 | hLtdcHandler.Init.PCPolarity = LTDC_PCPOLARITY_IPC; |
bcostm | 0:c9112f0c67e3 | 180 | hLtdcHandler.Instance = LTDC; |
bcostm | 0:c9112f0c67e3 | 181 | |
bcostm | 0:c9112f0c67e3 | 182 | if(HAL_LTDC_GetState(&hLtdcHandler) == HAL_LTDC_STATE_RESET) |
bcostm | 0:c9112f0c67e3 | 183 | { |
bcostm | 0:c9112f0c67e3 | 184 | /* Initialize the LCD Msp: this __weak function can be rewritten by the application */ |
bcostm | 0:c9112f0c67e3 | 185 | BSP_LCD_MspInit(&hLtdcHandler, NULL); |
bcostm | 0:c9112f0c67e3 | 186 | } |
bcostm | 0:c9112f0c67e3 | 187 | HAL_LTDC_Init(&hLtdcHandler); |
bcostm | 0:c9112f0c67e3 | 188 | |
bcostm | 0:c9112f0c67e3 | 189 | /* Assert display enable LCD_DISP pin */ |
bcostm | 0:c9112f0c67e3 | 190 | HAL_GPIO_WritePin(LCD_DISP_GPIO_PORT, LCD_DISP_PIN, GPIO_PIN_SET); |
bcostm | 0:c9112f0c67e3 | 191 | |
bcostm | 0:c9112f0c67e3 | 192 | /* Assert backlight LCD_BL_CTRL pin */ |
bcostm | 0:c9112f0c67e3 | 193 | HAL_GPIO_WritePin(LCD_BL_CTRL_GPIO_PORT, LCD_BL_CTRL_PIN, GPIO_PIN_SET); |
bcostm | 0:c9112f0c67e3 | 194 | |
bcostm | 0:c9112f0c67e3 | 195 | #if !defined(DATA_IN_ExtSDRAM) |
bcostm | 0:c9112f0c67e3 | 196 | /* Initialize the SDRAM */ |
bcostm | 0:c9112f0c67e3 | 197 | BSP_SDRAM_Init(); |
bcostm | 0:c9112f0c67e3 | 198 | #endif |
bcostm | 0:c9112f0c67e3 | 199 | |
bcostm | 0:c9112f0c67e3 | 200 | /* Initialize the font */ |
bcostm | 0:c9112f0c67e3 | 201 | BSP_LCD_SetFont(&LCD_DEFAULT_FONT); |
bcostm | 0:c9112f0c67e3 | 202 | |
bcostm | 0:c9112f0c67e3 | 203 | return LCD_OK; |
bcostm | 0:c9112f0c67e3 | 204 | } |
bcostm | 0:c9112f0c67e3 | 205 | |
bcostm | 0:c9112f0c67e3 | 206 | /** |
bcostm | 0:c9112f0c67e3 | 207 | * @brief DeInitializes the LCD. |
bcostm | 0:c9112f0c67e3 | 208 | * @retval LCD state |
bcostm | 0:c9112f0c67e3 | 209 | */ |
bcostm | 0:c9112f0c67e3 | 210 | uint8_t BSP_LCD_DeInit(void) |
bcostm | 0:c9112f0c67e3 | 211 | { |
bcostm | 0:c9112f0c67e3 | 212 | /* Initialize the hLtdcHandler Instance parameter */ |
bcostm | 0:c9112f0c67e3 | 213 | hLtdcHandler.Instance = LTDC; |
bcostm | 0:c9112f0c67e3 | 214 | |
bcostm | 0:c9112f0c67e3 | 215 | /* Disable LTDC block */ |
bcostm | 0:c9112f0c67e3 | 216 | __HAL_LTDC_DISABLE(&hLtdcHandler); |
bcostm | 0:c9112f0c67e3 | 217 | |
bcostm | 0:c9112f0c67e3 | 218 | /* DeInit the LTDC */ |
bcostm | 0:c9112f0c67e3 | 219 | HAL_LTDC_DeInit(&hLtdcHandler); |
bcostm | 0:c9112f0c67e3 | 220 | |
bcostm | 0:c9112f0c67e3 | 221 | /* DeInit the LTDC MSP : this __weak function can be rewritten by the application */ |
bcostm | 0:c9112f0c67e3 | 222 | BSP_LCD_MspDeInit(&hLtdcHandler, NULL); |
bcostm | 0:c9112f0c67e3 | 223 | |
bcostm | 0:c9112f0c67e3 | 224 | return LCD_OK; |
bcostm | 0:c9112f0c67e3 | 225 | } |
bcostm | 0:c9112f0c67e3 | 226 | |
bcostm | 0:c9112f0c67e3 | 227 | /** |
bcostm | 0:c9112f0c67e3 | 228 | * @brief Gets the LCD X size. |
bcostm | 0:c9112f0c67e3 | 229 | * @retval Used LCD X size |
bcostm | 0:c9112f0c67e3 | 230 | */ |
bcostm | 0:c9112f0c67e3 | 231 | uint32_t BSP_LCD_GetXSize(void) |
bcostm | 0:c9112f0c67e3 | 232 | { |
bcostm | 0:c9112f0c67e3 | 233 | return hLtdcHandler.LayerCfg[ActiveLayer].ImageWidth; |
bcostm | 0:c9112f0c67e3 | 234 | } |
bcostm | 0:c9112f0c67e3 | 235 | |
bcostm | 0:c9112f0c67e3 | 236 | /** |
bcostm | 0:c9112f0c67e3 | 237 | * @brief Gets the LCD Y size. |
bcostm | 0:c9112f0c67e3 | 238 | * @retval Used LCD Y size |
bcostm | 0:c9112f0c67e3 | 239 | */ |
bcostm | 0:c9112f0c67e3 | 240 | uint32_t BSP_LCD_GetYSize(void) |
bcostm | 0:c9112f0c67e3 | 241 | { |
bcostm | 0:c9112f0c67e3 | 242 | return hLtdcHandler.LayerCfg[ActiveLayer].ImageHeight; |
bcostm | 0:c9112f0c67e3 | 243 | } |
bcostm | 0:c9112f0c67e3 | 244 | |
bcostm | 0:c9112f0c67e3 | 245 | /** |
bcostm | 0:c9112f0c67e3 | 246 | * @brief Set the LCD X size. |
bcostm | 0:c9112f0c67e3 | 247 | * @param imageWidthPixels : image width in pixels unit |
bcostm | 0:c9112f0c67e3 | 248 | * @retval None |
bcostm | 0:c9112f0c67e3 | 249 | */ |
bcostm | 0:c9112f0c67e3 | 250 | void BSP_LCD_SetXSize(uint32_t imageWidthPixels) |
bcostm | 0:c9112f0c67e3 | 251 | { |
bcostm | 0:c9112f0c67e3 | 252 | hLtdcHandler.LayerCfg[ActiveLayer].ImageWidth = imageWidthPixels; |
bcostm | 0:c9112f0c67e3 | 253 | } |
bcostm | 0:c9112f0c67e3 | 254 | |
bcostm | 0:c9112f0c67e3 | 255 | /** |
bcostm | 0:c9112f0c67e3 | 256 | * @brief Set the LCD Y size. |
bcostm | 0:c9112f0c67e3 | 257 | * @param imageHeightPixels : image height in lines unit |
bcostm | 0:c9112f0c67e3 | 258 | * @retval None |
bcostm | 0:c9112f0c67e3 | 259 | */ |
bcostm | 0:c9112f0c67e3 | 260 | void BSP_LCD_SetYSize(uint32_t imageHeightPixels) |
bcostm | 0:c9112f0c67e3 | 261 | { |
bcostm | 0:c9112f0c67e3 | 262 | hLtdcHandler.LayerCfg[ActiveLayer].ImageHeight = imageHeightPixels; |
bcostm | 0:c9112f0c67e3 | 263 | } |
bcostm | 0:c9112f0c67e3 | 264 | |
bcostm | 0:c9112f0c67e3 | 265 | /** |
bcostm | 0:c9112f0c67e3 | 266 | * @brief Initializes the LCD layer in ARGB8888 format (32 bits per pixel). |
bcostm | 0:c9112f0c67e3 | 267 | * @param LayerIndex: Layer foreground or background |
bcostm | 0:c9112f0c67e3 | 268 | * @param FB_Address: Layer frame buffer |
bcostm | 0:c9112f0c67e3 | 269 | * @retval None |
bcostm | 0:c9112f0c67e3 | 270 | */ |
bcostm | 0:c9112f0c67e3 | 271 | void BSP_LCD_LayerDefaultInit(uint16_t LayerIndex, uint32_t FB_Address) |
bcostm | 0:c9112f0c67e3 | 272 | { |
bcostm | 0:c9112f0c67e3 | 273 | LCD_LayerCfgTypeDef layer_cfg; |
bcostm | 0:c9112f0c67e3 | 274 | |
bcostm | 0:c9112f0c67e3 | 275 | /* Layer Init */ |
bcostm | 0:c9112f0c67e3 | 276 | layer_cfg.WindowX0 = 0; |
bcostm | 0:c9112f0c67e3 | 277 | layer_cfg.WindowX1 = BSP_LCD_GetXSize(); |
bcostm | 0:c9112f0c67e3 | 278 | layer_cfg.WindowY0 = 0; |
bcostm | 0:c9112f0c67e3 | 279 | layer_cfg.WindowY1 = BSP_LCD_GetYSize(); |
bcostm | 0:c9112f0c67e3 | 280 | layer_cfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888; |
bcostm | 0:c9112f0c67e3 | 281 | layer_cfg.FBStartAdress = FB_Address; |
bcostm | 0:c9112f0c67e3 | 282 | layer_cfg.Alpha = 255; |
bcostm | 0:c9112f0c67e3 | 283 | layer_cfg.Alpha0 = 0; |
bcostm | 0:c9112f0c67e3 | 284 | layer_cfg.Backcolor.Blue = 0; |
bcostm | 0:c9112f0c67e3 | 285 | layer_cfg.Backcolor.Green = 0; |
bcostm | 0:c9112f0c67e3 | 286 | layer_cfg.Backcolor.Red = 0; |
bcostm | 0:c9112f0c67e3 | 287 | layer_cfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA; |
bcostm | 0:c9112f0c67e3 | 288 | layer_cfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; |
bcostm | 0:c9112f0c67e3 | 289 | layer_cfg.ImageWidth = BSP_LCD_GetXSize(); |
bcostm | 0:c9112f0c67e3 | 290 | layer_cfg.ImageHeight = BSP_LCD_GetYSize(); |
bcostm | 0:c9112f0c67e3 | 291 | |
bcostm | 0:c9112f0c67e3 | 292 | HAL_LTDC_ConfigLayer(&hLtdcHandler, &layer_cfg, LayerIndex); |
bcostm | 0:c9112f0c67e3 | 293 | |
bcostm | 0:c9112f0c67e3 | 294 | DrawProp[LayerIndex].BackColor = LCD_COLOR_WHITE; |
bcostm | 0:c9112f0c67e3 | 295 | DrawProp[LayerIndex].pFont = &Font24; |
bcostm | 0:c9112f0c67e3 | 296 | DrawProp[LayerIndex].TextColor = LCD_COLOR_BLACK; |
bcostm | 0:c9112f0c67e3 | 297 | } |
bcostm | 0:c9112f0c67e3 | 298 | |
bcostm | 0:c9112f0c67e3 | 299 | /** |
bcostm | 0:c9112f0c67e3 | 300 | * @brief Initializes the LCD layer in RGB565 format (16 bits per pixel). |
bcostm | 0:c9112f0c67e3 | 301 | * @param LayerIndex: Layer foreground or background |
bcostm | 0:c9112f0c67e3 | 302 | * @param FB_Address: Layer frame buffer |
bcostm | 0:c9112f0c67e3 | 303 | * @retval None |
bcostm | 0:c9112f0c67e3 | 304 | */ |
bcostm | 0:c9112f0c67e3 | 305 | void BSP_LCD_LayerRgb565Init(uint16_t LayerIndex, uint32_t FB_Address) |
bcostm | 0:c9112f0c67e3 | 306 | { |
bcostm | 0:c9112f0c67e3 | 307 | LCD_LayerCfgTypeDef layer_cfg; |
bcostm | 0:c9112f0c67e3 | 308 | |
bcostm | 0:c9112f0c67e3 | 309 | /* Layer Init */ |
bcostm | 0:c9112f0c67e3 | 310 | layer_cfg.WindowX0 = 0; |
bcostm | 0:c9112f0c67e3 | 311 | layer_cfg.WindowX1 = BSP_LCD_GetXSize(); |
bcostm | 0:c9112f0c67e3 | 312 | layer_cfg.WindowY0 = 0; |
bcostm | 0:c9112f0c67e3 | 313 | layer_cfg.WindowY1 = BSP_LCD_GetYSize(); |
bcostm | 0:c9112f0c67e3 | 314 | layer_cfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565; |
bcostm | 0:c9112f0c67e3 | 315 | layer_cfg.FBStartAdress = FB_Address; |
bcostm | 0:c9112f0c67e3 | 316 | layer_cfg.Alpha = 255; |
bcostm | 0:c9112f0c67e3 | 317 | layer_cfg.Alpha0 = 0; |
bcostm | 0:c9112f0c67e3 | 318 | layer_cfg.Backcolor.Blue = 0; |
bcostm | 0:c9112f0c67e3 | 319 | layer_cfg.Backcolor.Green = 0; |
bcostm | 0:c9112f0c67e3 | 320 | layer_cfg.Backcolor.Red = 0; |
bcostm | 0:c9112f0c67e3 | 321 | layer_cfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA; |
bcostm | 0:c9112f0c67e3 | 322 | layer_cfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; |
bcostm | 0:c9112f0c67e3 | 323 | layer_cfg.ImageWidth = BSP_LCD_GetXSize(); |
bcostm | 0:c9112f0c67e3 | 324 | layer_cfg.ImageHeight = BSP_LCD_GetYSize(); |
bcostm | 0:c9112f0c67e3 | 325 | |
bcostm | 0:c9112f0c67e3 | 326 | HAL_LTDC_ConfigLayer(&hLtdcHandler, &layer_cfg, LayerIndex); |
bcostm | 0:c9112f0c67e3 | 327 | |
bcostm | 0:c9112f0c67e3 | 328 | DrawProp[LayerIndex].BackColor = LCD_COLOR_WHITE; |
bcostm | 0:c9112f0c67e3 | 329 | DrawProp[LayerIndex].pFont = &Font24; |
bcostm | 0:c9112f0c67e3 | 330 | DrawProp[LayerIndex].TextColor = LCD_COLOR_BLACK; |
bcostm | 0:c9112f0c67e3 | 331 | } |
bcostm | 0:c9112f0c67e3 | 332 | |
bcostm | 0:c9112f0c67e3 | 333 | /** |
bcostm | 0:c9112f0c67e3 | 334 | * @brief Selects the LCD Layer. |
bcostm | 0:c9112f0c67e3 | 335 | * @param LayerIndex: Layer foreground or background |
bcostm | 0:c9112f0c67e3 | 336 | * @retval None |
bcostm | 0:c9112f0c67e3 | 337 | */ |
bcostm | 0:c9112f0c67e3 | 338 | void BSP_LCD_SelectLayer(uint32_t LayerIndex) |
bcostm | 0:c9112f0c67e3 | 339 | { |
bcostm | 0:c9112f0c67e3 | 340 | ActiveLayer = LayerIndex; |
bcostm | 0:c9112f0c67e3 | 341 | } |
bcostm | 0:c9112f0c67e3 | 342 | |
bcostm | 0:c9112f0c67e3 | 343 | /** |
bcostm | 0:c9112f0c67e3 | 344 | * @brief Sets an LCD Layer visible |
bcostm | 0:c9112f0c67e3 | 345 | * @param LayerIndex: Visible Layer |
bcostm | 0:c9112f0c67e3 | 346 | * @param State: New state of the specified layer |
bcostm | 0:c9112f0c67e3 | 347 | * This parameter can be one of the following values: |
bcostm | 0:c9112f0c67e3 | 348 | * @arg ENABLE |
bcostm | 0:c9112f0c67e3 | 349 | * @arg DISABLE |
bcostm | 0:c9112f0c67e3 | 350 | * @retval None |
bcostm | 0:c9112f0c67e3 | 351 | */ |
bcostm | 0:c9112f0c67e3 | 352 | void BSP_LCD_SetLayerVisible(uint32_t LayerIndex, FunctionalState State) |
bcostm | 0:c9112f0c67e3 | 353 | { |
bcostm | 0:c9112f0c67e3 | 354 | if(State == ENABLE) |
bcostm | 0:c9112f0c67e3 | 355 | { |
bcostm | 0:c9112f0c67e3 | 356 | __HAL_LTDC_LAYER_ENABLE(&hLtdcHandler, LayerIndex); |
bcostm | 0:c9112f0c67e3 | 357 | } |
bcostm | 0:c9112f0c67e3 | 358 | else |
bcostm | 0:c9112f0c67e3 | 359 | { |
bcostm | 0:c9112f0c67e3 | 360 | __HAL_LTDC_LAYER_DISABLE(&hLtdcHandler, LayerIndex); |
bcostm | 0:c9112f0c67e3 | 361 | } |
bcostm | 0:c9112f0c67e3 | 362 | __HAL_LTDC_RELOAD_CONFIG(&hLtdcHandler); |
bcostm | 0:c9112f0c67e3 | 363 | } |
bcostm | 0:c9112f0c67e3 | 364 | |
bcostm | 0:c9112f0c67e3 | 365 | /** |
bcostm | 0:c9112f0c67e3 | 366 | * @brief Configures the transparency. |
bcostm | 0:c9112f0c67e3 | 367 | * @param LayerIndex: Layer foreground or background. |
bcostm | 0:c9112f0c67e3 | 368 | * @param Transparency: Transparency |
bcostm | 0:c9112f0c67e3 | 369 | * This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF |
bcostm | 0:c9112f0c67e3 | 370 | * @retval None |
bcostm | 0:c9112f0c67e3 | 371 | */ |
bcostm | 0:c9112f0c67e3 | 372 | void BSP_LCD_SetTransparency(uint32_t LayerIndex, uint8_t Transparency) |
bcostm | 0:c9112f0c67e3 | 373 | { |
bcostm | 0:c9112f0c67e3 | 374 | HAL_LTDC_SetAlpha(&hLtdcHandler, Transparency, LayerIndex); |
bcostm | 0:c9112f0c67e3 | 375 | } |
bcostm | 0:c9112f0c67e3 | 376 | |
bcostm | 0:c9112f0c67e3 | 377 | /** |
bcostm | 0:c9112f0c67e3 | 378 | * @brief Sets an LCD layer frame buffer address. |
bcostm | 0:c9112f0c67e3 | 379 | * @param LayerIndex: Layer foreground or background |
bcostm | 0:c9112f0c67e3 | 380 | * @param Address: New LCD frame buffer value |
bcostm | 0:c9112f0c67e3 | 381 | * @retval None |
bcostm | 0:c9112f0c67e3 | 382 | */ |
bcostm | 0:c9112f0c67e3 | 383 | void BSP_LCD_SetLayerAddress(uint32_t LayerIndex, uint32_t Address) |
bcostm | 0:c9112f0c67e3 | 384 | { |
bcostm | 0:c9112f0c67e3 | 385 | HAL_LTDC_SetAddress(&hLtdcHandler, Address, LayerIndex); |
bcostm | 0:c9112f0c67e3 | 386 | } |
bcostm | 0:c9112f0c67e3 | 387 | |
bcostm | 0:c9112f0c67e3 | 388 | /** |
bcostm | 0:c9112f0c67e3 | 389 | * @brief Sets display window. |
bcostm | 0:c9112f0c67e3 | 390 | * @param LayerIndex: Layer index |
bcostm | 0:c9112f0c67e3 | 391 | * @param Xpos: LCD X position |
bcostm | 0:c9112f0c67e3 | 392 | * @param Ypos: LCD Y position |
bcostm | 0:c9112f0c67e3 | 393 | * @param Width: LCD window width |
bcostm | 0:c9112f0c67e3 | 394 | * @param Height: LCD window height |
bcostm | 0:c9112f0c67e3 | 395 | * @retval None |
bcostm | 0:c9112f0c67e3 | 396 | */ |
bcostm | 0:c9112f0c67e3 | 397 | void BSP_LCD_SetLayerWindow(uint16_t LayerIndex, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) |
bcostm | 0:c9112f0c67e3 | 398 | { |
bcostm | 0:c9112f0c67e3 | 399 | /* Reconfigure the layer size */ |
bcostm | 0:c9112f0c67e3 | 400 | HAL_LTDC_SetWindowSize(&hLtdcHandler, Width, Height, LayerIndex); |
bcostm | 0:c9112f0c67e3 | 401 | |
bcostm | 0:c9112f0c67e3 | 402 | /* Reconfigure the layer position */ |
bcostm | 0:c9112f0c67e3 | 403 | HAL_LTDC_SetWindowPosition(&hLtdcHandler, Xpos, Ypos, LayerIndex); |
bcostm | 0:c9112f0c67e3 | 404 | } |
bcostm | 0:c9112f0c67e3 | 405 | |
bcostm | 0:c9112f0c67e3 | 406 | /** |
bcostm | 0:c9112f0c67e3 | 407 | * @brief Configures and sets the color keying. |
bcostm | 0:c9112f0c67e3 | 408 | * @param LayerIndex: Layer foreground or background |
bcostm | 0:c9112f0c67e3 | 409 | * @param RGBValue: Color reference |
bcostm | 0:c9112f0c67e3 | 410 | * @retval None |
bcostm | 0:c9112f0c67e3 | 411 | */ |
bcostm | 0:c9112f0c67e3 | 412 | void BSP_LCD_SetColorKeying(uint32_t LayerIndex, uint32_t RGBValue) |
bcostm | 0:c9112f0c67e3 | 413 | { |
bcostm | 0:c9112f0c67e3 | 414 | /* Configure and Enable the color Keying for LCD Layer */ |
bcostm | 0:c9112f0c67e3 | 415 | HAL_LTDC_ConfigColorKeying(&hLtdcHandler, RGBValue, LayerIndex); |
bcostm | 0:c9112f0c67e3 | 416 | HAL_LTDC_EnableColorKeying(&hLtdcHandler, LayerIndex); |
bcostm | 0:c9112f0c67e3 | 417 | } |
bcostm | 0:c9112f0c67e3 | 418 | |
bcostm | 0:c9112f0c67e3 | 419 | /** |
bcostm | 0:c9112f0c67e3 | 420 | * @brief Disables the color keying. |
bcostm | 0:c9112f0c67e3 | 421 | * @param LayerIndex: Layer foreground or background |
bcostm | 0:c9112f0c67e3 | 422 | * @retval None |
bcostm | 0:c9112f0c67e3 | 423 | */ |
bcostm | 0:c9112f0c67e3 | 424 | void BSP_LCD_ResetColorKeying(uint32_t LayerIndex) |
bcostm | 0:c9112f0c67e3 | 425 | { |
bcostm | 0:c9112f0c67e3 | 426 | /* Disable the color Keying for LCD Layer */ |
bcostm | 0:c9112f0c67e3 | 427 | HAL_LTDC_DisableColorKeying(&hLtdcHandler, LayerIndex); |
bcostm | 0:c9112f0c67e3 | 428 | } |
bcostm | 0:c9112f0c67e3 | 429 | |
bcostm | 0:c9112f0c67e3 | 430 | /** |
bcostm | 0:c9112f0c67e3 | 431 | * @brief Sets the LCD text color. |
bcostm | 0:c9112f0c67e3 | 432 | * @param Color: Text color code ARGB(8-8-8-8) |
bcostm | 0:c9112f0c67e3 | 433 | * @retval None |
bcostm | 0:c9112f0c67e3 | 434 | */ |
bcostm | 0:c9112f0c67e3 | 435 | void BSP_LCD_SetTextColor(uint32_t Color) |
bcostm | 0:c9112f0c67e3 | 436 | { |
bcostm | 0:c9112f0c67e3 | 437 | DrawProp[ActiveLayer].TextColor = Color; |
bcostm | 0:c9112f0c67e3 | 438 | } |
bcostm | 0:c9112f0c67e3 | 439 | |
bcostm | 0:c9112f0c67e3 | 440 | /** |
bcostm | 0:c9112f0c67e3 | 441 | * @brief Gets the LCD text color. |
bcostm | 0:c9112f0c67e3 | 442 | * @retval Used text color. |
bcostm | 0:c9112f0c67e3 | 443 | */ |
bcostm | 0:c9112f0c67e3 | 444 | uint32_t BSP_LCD_GetTextColor(void) |
bcostm | 0:c9112f0c67e3 | 445 | { |
bcostm | 0:c9112f0c67e3 | 446 | return DrawProp[ActiveLayer].TextColor; |
bcostm | 0:c9112f0c67e3 | 447 | } |
bcostm | 0:c9112f0c67e3 | 448 | |
bcostm | 0:c9112f0c67e3 | 449 | /** |
bcostm | 0:c9112f0c67e3 | 450 | * @brief Sets the LCD background color. |
bcostm | 0:c9112f0c67e3 | 451 | * @param Color: Layer background color code ARGB(8-8-8-8) |
bcostm | 0:c9112f0c67e3 | 452 | * @retval None |
bcostm | 0:c9112f0c67e3 | 453 | */ |
bcostm | 0:c9112f0c67e3 | 454 | void BSP_LCD_SetBackColor(uint32_t Color) |
bcostm | 0:c9112f0c67e3 | 455 | { |
bcostm | 0:c9112f0c67e3 | 456 | DrawProp[ActiveLayer].BackColor = Color; |
bcostm | 0:c9112f0c67e3 | 457 | } |
bcostm | 0:c9112f0c67e3 | 458 | |
bcostm | 0:c9112f0c67e3 | 459 | /** |
bcostm | 0:c9112f0c67e3 | 460 | * @brief Gets the LCD background color. |
bcostm | 0:c9112f0c67e3 | 461 | * @retval Used background colour |
bcostm | 0:c9112f0c67e3 | 462 | */ |
bcostm | 0:c9112f0c67e3 | 463 | uint32_t BSP_LCD_GetBackColor(void) |
bcostm | 0:c9112f0c67e3 | 464 | { |
bcostm | 0:c9112f0c67e3 | 465 | return DrawProp[ActiveLayer].BackColor; |
bcostm | 0:c9112f0c67e3 | 466 | } |
bcostm | 0:c9112f0c67e3 | 467 | |
bcostm | 0:c9112f0c67e3 | 468 | /** |
bcostm | 0:c9112f0c67e3 | 469 | * @brief Sets the LCD text font. |
bcostm | 0:c9112f0c67e3 | 470 | * @param fonts: Layer font to be used |
bcostm | 0:c9112f0c67e3 | 471 | * @retval None |
bcostm | 0:c9112f0c67e3 | 472 | */ |
bcostm | 0:c9112f0c67e3 | 473 | void BSP_LCD_SetFont(sFONT *fonts) |
bcostm | 0:c9112f0c67e3 | 474 | { |
bcostm | 0:c9112f0c67e3 | 475 | DrawProp[ActiveLayer].pFont = fonts; |
bcostm | 0:c9112f0c67e3 | 476 | } |
bcostm | 0:c9112f0c67e3 | 477 | |
bcostm | 0:c9112f0c67e3 | 478 | /** |
bcostm | 0:c9112f0c67e3 | 479 | * @brief Gets the LCD text font. |
bcostm | 0:c9112f0c67e3 | 480 | * @retval Used layer font |
bcostm | 0:c9112f0c67e3 | 481 | */ |
bcostm | 0:c9112f0c67e3 | 482 | sFONT *BSP_LCD_GetFont(void) |
bcostm | 0:c9112f0c67e3 | 483 | { |
bcostm | 0:c9112f0c67e3 | 484 | return DrawProp[ActiveLayer].pFont; |
bcostm | 0:c9112f0c67e3 | 485 | } |
bcostm | 0:c9112f0c67e3 | 486 | |
bcostm | 0:c9112f0c67e3 | 487 | /** |
bcostm | 0:c9112f0c67e3 | 488 | * @brief Reads an LCD pixel. |
bcostm | 0:c9112f0c67e3 | 489 | * @param Xpos: X position |
bcostm | 0:c9112f0c67e3 | 490 | * @param Ypos: Y position |
bcostm | 0:c9112f0c67e3 | 491 | * @retval RGB pixel color |
bcostm | 0:c9112f0c67e3 | 492 | */ |
bcostm | 0:c9112f0c67e3 | 493 | uint32_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos) |
bcostm | 0:c9112f0c67e3 | 494 | { |
bcostm | 0:c9112f0c67e3 | 495 | uint32_t ret = 0; |
bcostm | 0:c9112f0c67e3 | 496 | |
bcostm | 0:c9112f0c67e3 | 497 | if(hLtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_ARGB8888) |
bcostm | 0:c9112f0c67e3 | 498 | { |
bcostm | 0:c9112f0c67e3 | 499 | /* Read data value from SDRAM memory */ |
bcostm | 0:c9112f0c67e3 | 500 | ret = *(__IO uint32_t*) (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))); |
bcostm | 0:c9112f0c67e3 | 501 | } |
bcostm | 0:c9112f0c67e3 | 502 | else if(hLtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB888) |
bcostm | 0:c9112f0c67e3 | 503 | { |
bcostm | 0:c9112f0c67e3 | 504 | /* Read data value from SDRAM memory */ |
bcostm | 0:c9112f0c67e3 | 505 | ret = (*(__IO uint32_t*) (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))) & 0x00FFFFFF); |
bcostm | 0:c9112f0c67e3 | 506 | } |
bcostm | 0:c9112f0c67e3 | 507 | else if((hLtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \ |
bcostm | 0:c9112f0c67e3 | 508 | (hLtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \ |
bcostm | 0:c9112f0c67e3 | 509 | (hLtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_AL88)) |
bcostm | 0:c9112f0c67e3 | 510 | { |
bcostm | 0:c9112f0c67e3 | 511 | /* Read data value from SDRAM memory */ |
bcostm | 0:c9112f0c67e3 | 512 | ret = *(__IO uint16_t*) (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))); |
bcostm | 0:c9112f0c67e3 | 513 | } |
bcostm | 0:c9112f0c67e3 | 514 | else |
bcostm | 0:c9112f0c67e3 | 515 | { |
bcostm | 0:c9112f0c67e3 | 516 | /* Read data value from SDRAM memory */ |
bcostm | 0:c9112f0c67e3 | 517 | ret = *(__IO uint8_t*) (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))); |
bcostm | 0:c9112f0c67e3 | 518 | } |
bcostm | 0:c9112f0c67e3 | 519 | |
bcostm | 0:c9112f0c67e3 | 520 | return ret; |
bcostm | 0:c9112f0c67e3 | 521 | } |
bcostm | 0:c9112f0c67e3 | 522 | |
bcostm | 0:c9112f0c67e3 | 523 | /** |
bcostm | 0:c9112f0c67e3 | 524 | * @brief Clears the hole LCD. |
bcostm | 0:c9112f0c67e3 | 525 | * @param Color: Color of the background |
bcostm | 0:c9112f0c67e3 | 526 | * @retval None |
bcostm | 0:c9112f0c67e3 | 527 | */ |
bcostm | 0:c9112f0c67e3 | 528 | void BSP_LCD_Clear(uint32_t Color) |
bcostm | 0:c9112f0c67e3 | 529 | { |
bcostm | 0:c9112f0c67e3 | 530 | /* Clear the LCD */ |
bcostm | 0:c9112f0c67e3 | 531 | LL_FillBuffer(ActiveLayer, (uint32_t *)(hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress), BSP_LCD_GetXSize(), BSP_LCD_GetYSize(), 0, Color); |
bcostm | 0:c9112f0c67e3 | 532 | } |
bcostm | 0:c9112f0c67e3 | 533 | |
bcostm | 0:c9112f0c67e3 | 534 | /** |
bcostm | 0:c9112f0c67e3 | 535 | * @brief Clears the selected line. |
bcostm | 0:c9112f0c67e3 | 536 | * @param Line: Line to be cleared |
bcostm | 0:c9112f0c67e3 | 537 | * @retval None |
bcostm | 0:c9112f0c67e3 | 538 | */ |
bcostm | 0:c9112f0c67e3 | 539 | void BSP_LCD_ClearStringLine(uint32_t Line) |
bcostm | 0:c9112f0c67e3 | 540 | { |
bcostm | 0:c9112f0c67e3 | 541 | uint32_t color_backup = DrawProp[ActiveLayer].TextColor; |
bcostm | 0:c9112f0c67e3 | 542 | DrawProp[ActiveLayer].TextColor = DrawProp[ActiveLayer].BackColor; |
bcostm | 0:c9112f0c67e3 | 543 | |
bcostm | 0:c9112f0c67e3 | 544 | /* Draw rectangle with background color */ |
bcostm | 0:c9112f0c67e3 | 545 | BSP_LCD_FillRect(0, (Line * DrawProp[ActiveLayer].pFont->Height), BSP_LCD_GetXSize(), DrawProp[ActiveLayer].pFont->Height); |
bcostm | 0:c9112f0c67e3 | 546 | |
bcostm | 0:c9112f0c67e3 | 547 | DrawProp[ActiveLayer].TextColor = color_backup; |
bcostm | 0:c9112f0c67e3 | 548 | BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor); |
bcostm | 0:c9112f0c67e3 | 549 | } |
bcostm | 0:c9112f0c67e3 | 550 | |
bcostm | 0:c9112f0c67e3 | 551 | /** |
bcostm | 0:c9112f0c67e3 | 552 | * @brief Displays one character. |
bcostm | 0:c9112f0c67e3 | 553 | * @param Xpos: Start column address |
bcostm | 0:c9112f0c67e3 | 554 | * @param Ypos: Line where to display the character shape. |
bcostm | 0:c9112f0c67e3 | 555 | * @param Ascii: Character ascii code |
bcostm | 0:c9112f0c67e3 | 556 | * This parameter must be a number between Min_Data = 0x20 and Max_Data = 0x7E |
bcostm | 0:c9112f0c67e3 | 557 | * @retval None |
bcostm | 0:c9112f0c67e3 | 558 | */ |
bcostm | 0:c9112f0c67e3 | 559 | void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii) |
bcostm | 0:c9112f0c67e3 | 560 | { |
bcostm | 0:c9112f0c67e3 | 561 | DrawChar(Xpos, Ypos, &DrawProp[ActiveLayer].pFont->table[(Ascii-' ') *\ |
bcostm | 0:c9112f0c67e3 | 562 | DrawProp[ActiveLayer].pFont->Height * ((DrawProp[ActiveLayer].pFont->Width + 7) / 8)]); |
bcostm | 0:c9112f0c67e3 | 563 | } |
bcostm | 0:c9112f0c67e3 | 564 | |
bcostm | 0:c9112f0c67e3 | 565 | /** |
bcostm | 0:c9112f0c67e3 | 566 | * @brief Displays characters on the LCD. |
bcostm | 0:c9112f0c67e3 | 567 | * @param Xpos: X position (in pixel) |
bcostm | 0:c9112f0c67e3 | 568 | * @param Ypos: Y position (in pixel) |
bcostm | 0:c9112f0c67e3 | 569 | * @param Text: Pointer to string to display on LCD |
bcostm | 0:c9112f0c67e3 | 570 | * @param Mode: Display mode |
bcostm | 0:c9112f0c67e3 | 571 | * This parameter can be one of the following values: |
bcostm | 0:c9112f0c67e3 | 572 | * @arg CENTER_MODE |
bcostm | 0:c9112f0c67e3 | 573 | * @arg RIGHT_MODE |
bcostm | 0:c9112f0c67e3 | 574 | * @arg LEFT_MODE |
bcostm | 0:c9112f0c67e3 | 575 | * @retval None |
bcostm | 0:c9112f0c67e3 | 576 | */ |
bcostm | 0:c9112f0c67e3 | 577 | void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Text_AlignModeTypdef Mode) |
bcostm | 0:c9112f0c67e3 | 578 | { |
bcostm | 0:c9112f0c67e3 | 579 | uint16_t ref_column = 1, i = 0; |
bcostm | 0:c9112f0c67e3 | 580 | uint32_t size = 0, xsize = 0; |
bcostm | 0:c9112f0c67e3 | 581 | uint8_t *ptr = Text; |
bcostm | 0:c9112f0c67e3 | 582 | |
bcostm | 0:c9112f0c67e3 | 583 | /* Get the text size */ |
bcostm | 0:c9112f0c67e3 | 584 | while (*ptr++) size ++ ; |
bcostm | 0:c9112f0c67e3 | 585 | |
bcostm | 0:c9112f0c67e3 | 586 | /* Characters number per line */ |
bcostm | 0:c9112f0c67e3 | 587 | xsize = (BSP_LCD_GetXSize()/DrawProp[ActiveLayer].pFont->Width); |
bcostm | 0:c9112f0c67e3 | 588 | |
bcostm | 0:c9112f0c67e3 | 589 | switch (Mode) |
bcostm | 0:c9112f0c67e3 | 590 | { |
bcostm | 0:c9112f0c67e3 | 591 | case CENTER_MODE: |
bcostm | 0:c9112f0c67e3 | 592 | { |
bcostm | 0:c9112f0c67e3 | 593 | ref_column = Xpos + ((xsize - size)* DrawProp[ActiveLayer].pFont->Width) / 2; |
bcostm | 0:c9112f0c67e3 | 594 | break; |
bcostm | 0:c9112f0c67e3 | 595 | } |
bcostm | 0:c9112f0c67e3 | 596 | case LEFT_MODE: |
bcostm | 0:c9112f0c67e3 | 597 | { |
bcostm | 0:c9112f0c67e3 | 598 | ref_column = Xpos; |
bcostm | 0:c9112f0c67e3 | 599 | break; |
bcostm | 0:c9112f0c67e3 | 600 | } |
bcostm | 0:c9112f0c67e3 | 601 | case RIGHT_MODE: |
bcostm | 0:c9112f0c67e3 | 602 | { |
bcostm | 0:c9112f0c67e3 | 603 | ref_column = - Xpos + ((xsize - size)*DrawProp[ActiveLayer].pFont->Width); |
bcostm | 0:c9112f0c67e3 | 604 | break; |
bcostm | 0:c9112f0c67e3 | 605 | } |
bcostm | 0:c9112f0c67e3 | 606 | default: |
bcostm | 0:c9112f0c67e3 | 607 | { |
bcostm | 0:c9112f0c67e3 | 608 | ref_column = Xpos; |
bcostm | 0:c9112f0c67e3 | 609 | break; |
bcostm | 0:c9112f0c67e3 | 610 | } |
bcostm | 0:c9112f0c67e3 | 611 | } |
bcostm | 0:c9112f0c67e3 | 612 | |
bcostm | 0:c9112f0c67e3 | 613 | /* Check that the Start column is located in the screen */ |
bcostm | 0:c9112f0c67e3 | 614 | if ((ref_column < 1) || (ref_column >= 0x8000)) |
bcostm | 0:c9112f0c67e3 | 615 | { |
bcostm | 0:c9112f0c67e3 | 616 | ref_column = 1; |
bcostm | 0:c9112f0c67e3 | 617 | } |
bcostm | 0:c9112f0c67e3 | 618 | |
bcostm | 0:c9112f0c67e3 | 619 | /* Send the string character by character on LCD */ |
bcostm | 0:c9112f0c67e3 | 620 | while ((*Text != 0) & (((BSP_LCD_GetXSize() - (i*DrawProp[ActiveLayer].pFont->Width)) & 0xFFFF) >= DrawProp[ActiveLayer].pFont->Width)) |
bcostm | 0:c9112f0c67e3 | 621 | { |
bcostm | 0:c9112f0c67e3 | 622 | /* Display one character on LCD */ |
bcostm | 0:c9112f0c67e3 | 623 | BSP_LCD_DisplayChar(ref_column, Ypos, *Text); |
bcostm | 0:c9112f0c67e3 | 624 | /* Decrement the column position by 16 */ |
bcostm | 0:c9112f0c67e3 | 625 | ref_column += DrawProp[ActiveLayer].pFont->Width; |
bcostm | 0:c9112f0c67e3 | 626 | /* Point on the next character */ |
bcostm | 0:c9112f0c67e3 | 627 | Text++; |
bcostm | 0:c9112f0c67e3 | 628 | i++; |
bcostm | 0:c9112f0c67e3 | 629 | } |
bcostm | 0:c9112f0c67e3 | 630 | } |
bcostm | 0:c9112f0c67e3 | 631 | |
bcostm | 0:c9112f0c67e3 | 632 | /** |
bcostm | 0:c9112f0c67e3 | 633 | * @brief Displays a maximum of 60 characters on the LCD. |
bcostm | 0:c9112f0c67e3 | 634 | * @param Line: Line where to display the character shape |
bcostm | 0:c9112f0c67e3 | 635 | * @param ptr: Pointer to string to display on LCD |
bcostm | 0:c9112f0c67e3 | 636 | * @retval None |
bcostm | 0:c9112f0c67e3 | 637 | */ |
bcostm | 0:c9112f0c67e3 | 638 | void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *ptr) |
bcostm | 0:c9112f0c67e3 | 639 | { |
bcostm | 0:c9112f0c67e3 | 640 | BSP_LCD_DisplayStringAt(0, LINE(Line), ptr, LEFT_MODE); |
bcostm | 0:c9112f0c67e3 | 641 | } |
bcostm | 0:c9112f0c67e3 | 642 | |
bcostm | 0:c9112f0c67e3 | 643 | /** |
bcostm | 0:c9112f0c67e3 | 644 | * @brief Draws an horizontal line. |
bcostm | 0:c9112f0c67e3 | 645 | * @param Xpos: X position |
bcostm | 0:c9112f0c67e3 | 646 | * @param Ypos: Y position |
bcostm | 0:c9112f0c67e3 | 647 | * @param Length: Line length |
bcostm | 0:c9112f0c67e3 | 648 | * @retval None |
bcostm | 0:c9112f0c67e3 | 649 | */ |
bcostm | 0:c9112f0c67e3 | 650 | void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length) |
bcostm | 0:c9112f0c67e3 | 651 | { |
bcostm | 0:c9112f0c67e3 | 652 | uint32_t Xaddress = 0; |
bcostm | 0:c9112f0c67e3 | 653 | |
bcostm | 0:c9112f0c67e3 | 654 | /* Get the line address */ |
bcostm | 0:c9112f0c67e3 | 655 | if(hLtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565) |
bcostm | 0:c9112f0c67e3 | 656 | { /* RGB565 format */ |
bcostm | 0:c9112f0c67e3 | 657 | Xaddress = (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress) + 2*(BSP_LCD_GetXSize()*Ypos + Xpos); |
bcostm | 0:c9112f0c67e3 | 658 | } |
bcostm | 0:c9112f0c67e3 | 659 | else |
bcostm | 0:c9112f0c67e3 | 660 | { /* ARGB8888 format */ |
bcostm | 0:c9112f0c67e3 | 661 | Xaddress = (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos); |
bcostm | 0:c9112f0c67e3 | 662 | } |
bcostm | 0:c9112f0c67e3 | 663 | |
bcostm | 0:c9112f0c67e3 | 664 | /* Write line */ |
bcostm | 0:c9112f0c67e3 | 665 | LL_FillBuffer(ActiveLayer, (uint32_t *)Xaddress, Length, 1, 0, DrawProp[ActiveLayer].TextColor); |
bcostm | 0:c9112f0c67e3 | 666 | } |
bcostm | 0:c9112f0c67e3 | 667 | |
bcostm | 0:c9112f0c67e3 | 668 | /** |
bcostm | 0:c9112f0c67e3 | 669 | * @brief Draws a vertical line. |
bcostm | 0:c9112f0c67e3 | 670 | * @param Xpos: X position |
bcostm | 0:c9112f0c67e3 | 671 | * @param Ypos: Y position |
bcostm | 0:c9112f0c67e3 | 672 | * @param Length: Line length |
bcostm | 0:c9112f0c67e3 | 673 | * @retval None |
bcostm | 0:c9112f0c67e3 | 674 | */ |
bcostm | 0:c9112f0c67e3 | 675 | void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length) |
bcostm | 0:c9112f0c67e3 | 676 | { |
bcostm | 0:c9112f0c67e3 | 677 | uint32_t Xaddress = 0; |
bcostm | 0:c9112f0c67e3 | 678 | |
bcostm | 0:c9112f0c67e3 | 679 | /* Get the line address */ |
bcostm | 0:c9112f0c67e3 | 680 | if(hLtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565) |
bcostm | 0:c9112f0c67e3 | 681 | { /* RGB565 format */ |
bcostm | 0:c9112f0c67e3 | 682 | Xaddress = (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress) + 2*(BSP_LCD_GetXSize()*Ypos + Xpos); |
bcostm | 0:c9112f0c67e3 | 683 | } |
bcostm | 0:c9112f0c67e3 | 684 | else |
bcostm | 0:c9112f0c67e3 | 685 | { /* ARGB8888 format */ |
bcostm | 0:c9112f0c67e3 | 686 | Xaddress = (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos); |
bcostm | 0:c9112f0c67e3 | 687 | } |
bcostm | 0:c9112f0c67e3 | 688 | |
bcostm | 0:c9112f0c67e3 | 689 | /* Write line */ |
bcostm | 0:c9112f0c67e3 | 690 | LL_FillBuffer(ActiveLayer, (uint32_t *)Xaddress, 1, Length, (BSP_LCD_GetXSize() - 1), DrawProp[ActiveLayer].TextColor); |
bcostm | 0:c9112f0c67e3 | 691 | } |
bcostm | 0:c9112f0c67e3 | 692 | |
bcostm | 0:c9112f0c67e3 | 693 | /** |
bcostm | 0:c9112f0c67e3 | 694 | * @brief Draws an uni-line (between two points). |
bcostm | 0:c9112f0c67e3 | 695 | * @param x1: Point 1 X position |
bcostm | 0:c9112f0c67e3 | 696 | * @param y1: Point 1 Y position |
bcostm | 0:c9112f0c67e3 | 697 | * @param x2: Point 2 X position |
bcostm | 0:c9112f0c67e3 | 698 | * @param y2: Point 2 Y position |
bcostm | 0:c9112f0c67e3 | 699 | * @retval None |
bcostm | 0:c9112f0c67e3 | 700 | */ |
bcostm | 0:c9112f0c67e3 | 701 | void BSP_LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) |
bcostm | 0:c9112f0c67e3 | 702 | { |
bcostm | 0:c9112f0c67e3 | 703 | int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, |
bcostm | 0:c9112f0c67e3 | 704 | yinc1 = 0, yinc2 = 0, den = 0, num = 0, num_add = 0, num_pixels = 0, |
bcostm | 0:c9112f0c67e3 | 705 | curpixel = 0; |
bcostm | 0:c9112f0c67e3 | 706 | |
bcostm | 0:c9112f0c67e3 | 707 | deltax = ABS(x2 - x1); /* The difference between the x's */ |
bcostm | 0:c9112f0c67e3 | 708 | deltay = ABS(y2 - y1); /* The difference between the y's */ |
bcostm | 0:c9112f0c67e3 | 709 | x = x1; /* Start x off at the first pixel */ |
bcostm | 0:c9112f0c67e3 | 710 | y = y1; /* Start y off at the first pixel */ |
bcostm | 0:c9112f0c67e3 | 711 | |
bcostm | 0:c9112f0c67e3 | 712 | if (x2 >= x1) /* The x-values are increasing */ |
bcostm | 0:c9112f0c67e3 | 713 | { |
bcostm | 0:c9112f0c67e3 | 714 | xinc1 = 1; |
bcostm | 0:c9112f0c67e3 | 715 | xinc2 = 1; |
bcostm | 0:c9112f0c67e3 | 716 | } |
bcostm | 0:c9112f0c67e3 | 717 | else /* The x-values are decreasing */ |
bcostm | 0:c9112f0c67e3 | 718 | { |
bcostm | 0:c9112f0c67e3 | 719 | xinc1 = -1; |
bcostm | 0:c9112f0c67e3 | 720 | xinc2 = -1; |
bcostm | 0:c9112f0c67e3 | 721 | } |
bcostm | 0:c9112f0c67e3 | 722 | |
bcostm | 0:c9112f0c67e3 | 723 | if (y2 >= y1) /* The y-values are increasing */ |
bcostm | 0:c9112f0c67e3 | 724 | { |
bcostm | 0:c9112f0c67e3 | 725 | yinc1 = 1; |
bcostm | 0:c9112f0c67e3 | 726 | yinc2 = 1; |
bcostm | 0:c9112f0c67e3 | 727 | } |
bcostm | 0:c9112f0c67e3 | 728 | else /* The y-values are decreasing */ |
bcostm | 0:c9112f0c67e3 | 729 | { |
bcostm | 0:c9112f0c67e3 | 730 | yinc1 = -1; |
bcostm | 0:c9112f0c67e3 | 731 | yinc2 = -1; |
bcostm | 0:c9112f0c67e3 | 732 | } |
bcostm | 0:c9112f0c67e3 | 733 | |
bcostm | 0:c9112f0c67e3 | 734 | if (deltax >= deltay) /* There is at least one x-value for every y-value */ |
bcostm | 0:c9112f0c67e3 | 735 | { |
bcostm | 0:c9112f0c67e3 | 736 | xinc1 = 0; /* Don't change the x when numerator >= denominator */ |
bcostm | 0:c9112f0c67e3 | 737 | yinc2 = 0; /* Don't change the y for every iteration */ |
bcostm | 0:c9112f0c67e3 | 738 | den = deltax; |
bcostm | 0:c9112f0c67e3 | 739 | num = deltax / 2; |
bcostm | 0:c9112f0c67e3 | 740 | num_add = deltay; |
bcostm | 0:c9112f0c67e3 | 741 | num_pixels = deltax; /* There are more x-values than y-values */ |
bcostm | 0:c9112f0c67e3 | 742 | } |
bcostm | 0:c9112f0c67e3 | 743 | else /* There is at least one y-value for every x-value */ |
bcostm | 0:c9112f0c67e3 | 744 | { |
bcostm | 0:c9112f0c67e3 | 745 | xinc2 = 0; /* Don't change the x for every iteration */ |
bcostm | 0:c9112f0c67e3 | 746 | yinc1 = 0; /* Don't change the y when numerator >= denominator */ |
bcostm | 0:c9112f0c67e3 | 747 | den = deltay; |
bcostm | 0:c9112f0c67e3 | 748 | num = deltay / 2; |
bcostm | 0:c9112f0c67e3 | 749 | num_add = deltax; |
bcostm | 0:c9112f0c67e3 | 750 | num_pixels = deltay; /* There are more y-values than x-values */ |
bcostm | 0:c9112f0c67e3 | 751 | } |
bcostm | 0:c9112f0c67e3 | 752 | |
bcostm | 0:c9112f0c67e3 | 753 | for (curpixel = 0; curpixel <= num_pixels; curpixel++) |
bcostm | 0:c9112f0c67e3 | 754 | { |
bcostm | 0:c9112f0c67e3 | 755 | BSP_LCD_DrawPixel(x, y, DrawProp[ActiveLayer].TextColor); /* Draw the current pixel */ |
bcostm | 0:c9112f0c67e3 | 756 | num += num_add; /* Increase the numerator by the top of the fraction */ |
bcostm | 0:c9112f0c67e3 | 757 | if (num >= den) /* Check if numerator >= denominator */ |
bcostm | 0:c9112f0c67e3 | 758 | { |
bcostm | 0:c9112f0c67e3 | 759 | num -= den; /* Calculate the new numerator value */ |
bcostm | 0:c9112f0c67e3 | 760 | x += xinc1; /* Change the x as appropriate */ |
bcostm | 0:c9112f0c67e3 | 761 | y += yinc1; /* Change the y as appropriate */ |
bcostm | 0:c9112f0c67e3 | 762 | } |
bcostm | 0:c9112f0c67e3 | 763 | x += xinc2; /* Change the x as appropriate */ |
bcostm | 0:c9112f0c67e3 | 764 | y += yinc2; /* Change the y as appropriate */ |
bcostm | 0:c9112f0c67e3 | 765 | } |
bcostm | 0:c9112f0c67e3 | 766 | } |
bcostm | 0:c9112f0c67e3 | 767 | |
bcostm | 0:c9112f0c67e3 | 768 | /** |
bcostm | 0:c9112f0c67e3 | 769 | * @brief Draws a rectangle. |
bcostm | 0:c9112f0c67e3 | 770 | * @param Xpos: X position |
bcostm | 0:c9112f0c67e3 | 771 | * @param Ypos: Y position |
bcostm | 0:c9112f0c67e3 | 772 | * @param Width: Rectangle width |
bcostm | 0:c9112f0c67e3 | 773 | * @param Height: Rectangle height |
bcostm | 0:c9112f0c67e3 | 774 | * @retval None |
bcostm | 0:c9112f0c67e3 | 775 | */ |
bcostm | 0:c9112f0c67e3 | 776 | void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) |
bcostm | 0:c9112f0c67e3 | 777 | { |
bcostm | 0:c9112f0c67e3 | 778 | /* Draw horizontal lines */ |
bcostm | 0:c9112f0c67e3 | 779 | BSP_LCD_DrawHLine(Xpos, Ypos, Width); |
bcostm | 0:c9112f0c67e3 | 780 | BSP_LCD_DrawHLine(Xpos, (Ypos+ Height), Width); |
bcostm | 0:c9112f0c67e3 | 781 | |
bcostm | 0:c9112f0c67e3 | 782 | /* Draw vertical lines */ |
bcostm | 0:c9112f0c67e3 | 783 | BSP_LCD_DrawVLine(Xpos, Ypos, Height); |
bcostm | 0:c9112f0c67e3 | 784 | BSP_LCD_DrawVLine((Xpos + Width), Ypos, Height); |
bcostm | 0:c9112f0c67e3 | 785 | } |
bcostm | 0:c9112f0c67e3 | 786 | |
bcostm | 0:c9112f0c67e3 | 787 | /** |
bcostm | 0:c9112f0c67e3 | 788 | * @brief Draws a circle. |
bcostm | 0:c9112f0c67e3 | 789 | * @param Xpos: X position |
bcostm | 0:c9112f0c67e3 | 790 | * @param Ypos: Y position |
bcostm | 0:c9112f0c67e3 | 791 | * @param Radius: Circle radius |
bcostm | 0:c9112f0c67e3 | 792 | * @retval None |
bcostm | 0:c9112f0c67e3 | 793 | */ |
bcostm | 0:c9112f0c67e3 | 794 | void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) |
bcostm | 0:c9112f0c67e3 | 795 | { |
bcostm | 0:c9112f0c67e3 | 796 | int32_t decision; /* Decision Variable */ |
bcostm | 0:c9112f0c67e3 | 797 | uint32_t current_x; /* Current X Value */ |
bcostm | 0:c9112f0c67e3 | 798 | uint32_t current_y; /* Current Y Value */ |
bcostm | 0:c9112f0c67e3 | 799 | |
bcostm | 0:c9112f0c67e3 | 800 | decision = 3 - (Radius << 1); |
bcostm | 0:c9112f0c67e3 | 801 | current_x = 0; |
bcostm | 0:c9112f0c67e3 | 802 | current_y = Radius; |
bcostm | 0:c9112f0c67e3 | 803 | |
bcostm | 0:c9112f0c67e3 | 804 | while (current_x <= current_y) |
bcostm | 0:c9112f0c67e3 | 805 | { |
bcostm | 0:c9112f0c67e3 | 806 | BSP_LCD_DrawPixel((Xpos + current_x), (Ypos - current_y), DrawProp[ActiveLayer].TextColor); |
bcostm | 0:c9112f0c67e3 | 807 | |
bcostm | 0:c9112f0c67e3 | 808 | BSP_LCD_DrawPixel((Xpos - current_x), (Ypos - current_y), DrawProp[ActiveLayer].TextColor); |
bcostm | 0:c9112f0c67e3 | 809 | |
bcostm | 0:c9112f0c67e3 | 810 | BSP_LCD_DrawPixel((Xpos + current_y), (Ypos - current_x), DrawProp[ActiveLayer].TextColor); |
bcostm | 0:c9112f0c67e3 | 811 | |
bcostm | 0:c9112f0c67e3 | 812 | BSP_LCD_DrawPixel((Xpos - current_y), (Ypos - current_x), DrawProp[ActiveLayer].TextColor); |
bcostm | 0:c9112f0c67e3 | 813 | |
bcostm | 0:c9112f0c67e3 | 814 | BSP_LCD_DrawPixel((Xpos + current_x), (Ypos + current_y), DrawProp[ActiveLayer].TextColor); |
bcostm | 0:c9112f0c67e3 | 815 | |
bcostm | 0:c9112f0c67e3 | 816 | BSP_LCD_DrawPixel((Xpos - current_x), (Ypos + current_y), DrawProp[ActiveLayer].TextColor); |
bcostm | 0:c9112f0c67e3 | 817 | |
bcostm | 0:c9112f0c67e3 | 818 | BSP_LCD_DrawPixel((Xpos + current_y), (Ypos + current_x), DrawProp[ActiveLayer].TextColor); |
bcostm | 0:c9112f0c67e3 | 819 | |
bcostm | 0:c9112f0c67e3 | 820 | BSP_LCD_DrawPixel((Xpos - current_y), (Ypos + current_x), DrawProp[ActiveLayer].TextColor); |
bcostm | 0:c9112f0c67e3 | 821 | |
bcostm | 0:c9112f0c67e3 | 822 | if (decision < 0) |
bcostm | 0:c9112f0c67e3 | 823 | { |
bcostm | 0:c9112f0c67e3 | 824 | decision += (current_x << 2) + 6; |
bcostm | 0:c9112f0c67e3 | 825 | } |
bcostm | 0:c9112f0c67e3 | 826 | else |
bcostm | 0:c9112f0c67e3 | 827 | { |
bcostm | 0:c9112f0c67e3 | 828 | decision += ((current_x - current_y) << 2) + 10; |
bcostm | 0:c9112f0c67e3 | 829 | current_y--; |
bcostm | 0:c9112f0c67e3 | 830 | } |
bcostm | 0:c9112f0c67e3 | 831 | current_x++; |
bcostm | 0:c9112f0c67e3 | 832 | } |
bcostm | 0:c9112f0c67e3 | 833 | } |
bcostm | 0:c9112f0c67e3 | 834 | |
bcostm | 0:c9112f0c67e3 | 835 | /** |
bcostm | 0:c9112f0c67e3 | 836 | * @brief Draws an poly-line (between many points). |
bcostm | 0:c9112f0c67e3 | 837 | * @param Points: Pointer to the points array |
bcostm | 0:c9112f0c67e3 | 838 | * @param PointCount: Number of points |
bcostm | 0:c9112f0c67e3 | 839 | * @retval None |
bcostm | 0:c9112f0c67e3 | 840 | */ |
bcostm | 0:c9112f0c67e3 | 841 | void BSP_LCD_DrawPolygon(pPoint Points, uint16_t PointCount) |
bcostm | 0:c9112f0c67e3 | 842 | { |
bcostm | 0:c9112f0c67e3 | 843 | int16_t x = 0, y = 0; |
bcostm | 0:c9112f0c67e3 | 844 | |
bcostm | 0:c9112f0c67e3 | 845 | if(PointCount < 2) |
bcostm | 0:c9112f0c67e3 | 846 | { |
bcostm | 0:c9112f0c67e3 | 847 | return; |
bcostm | 0:c9112f0c67e3 | 848 | } |
bcostm | 0:c9112f0c67e3 | 849 | |
bcostm | 0:c9112f0c67e3 | 850 | BSP_LCD_DrawLine(Points->X, Points->Y, (Points+PointCount-1)->X, (Points+PointCount-1)->Y); |
bcostm | 0:c9112f0c67e3 | 851 | |
bcostm | 0:c9112f0c67e3 | 852 | while(--PointCount) |
bcostm | 0:c9112f0c67e3 | 853 | { |
bcostm | 0:c9112f0c67e3 | 854 | x = Points->X; |
bcostm | 0:c9112f0c67e3 | 855 | y = Points->Y; |
bcostm | 0:c9112f0c67e3 | 856 | Points++; |
bcostm | 0:c9112f0c67e3 | 857 | BSP_LCD_DrawLine(x, y, Points->X, Points->Y); |
bcostm | 0:c9112f0c67e3 | 858 | } |
bcostm | 0:c9112f0c67e3 | 859 | } |
bcostm | 0:c9112f0c67e3 | 860 | |
bcostm | 0:c9112f0c67e3 | 861 | /** |
bcostm | 0:c9112f0c67e3 | 862 | * @brief Draws an ellipse on LCD. |
bcostm | 0:c9112f0c67e3 | 863 | * @param Xpos: X position |
bcostm | 0:c9112f0c67e3 | 864 | * @param Ypos: Y position |
bcostm | 0:c9112f0c67e3 | 865 | * @param XRadius: Ellipse X radius |
bcostm | 0:c9112f0c67e3 | 866 | * @param YRadius: Ellipse Y radius |
bcostm | 0:c9112f0c67e3 | 867 | * @retval None |
bcostm | 0:c9112f0c67e3 | 868 | */ |
bcostm | 0:c9112f0c67e3 | 869 | void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius) |
bcostm | 0:c9112f0c67e3 | 870 | { |
bcostm | 0:c9112f0c67e3 | 871 | int x = 0, y = -YRadius, err = 2-2*XRadius, e2; |
bcostm | 0:c9112f0c67e3 | 872 | float k = 0, rad1 = 0, rad2 = 0; |
bcostm | 0:c9112f0c67e3 | 873 | |
bcostm | 0:c9112f0c67e3 | 874 | rad1 = XRadius; |
bcostm | 0:c9112f0c67e3 | 875 | rad2 = YRadius; |
bcostm | 0:c9112f0c67e3 | 876 | |
bcostm | 0:c9112f0c67e3 | 877 | k = (float)(rad2/rad1); |
bcostm | 0:c9112f0c67e3 | 878 | |
bcostm | 0:c9112f0c67e3 | 879 | do { |
bcostm | 0:c9112f0c67e3 | 880 | BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/k)), (Ypos+y), DrawProp[ActiveLayer].TextColor); |
bcostm | 0:c9112f0c67e3 | 881 | BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/k)), (Ypos+y), DrawProp[ActiveLayer].TextColor); |
bcostm | 0:c9112f0c67e3 | 882 | BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/k)), (Ypos-y), DrawProp[ActiveLayer].TextColor); |
bcostm | 0:c9112f0c67e3 | 883 | BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/k)), (Ypos-y), DrawProp[ActiveLayer].TextColor); |
bcostm | 0:c9112f0c67e3 | 884 | |
bcostm | 0:c9112f0c67e3 | 885 | e2 = err; |
bcostm | 0:c9112f0c67e3 | 886 | if (e2 <= x) { |
bcostm | 0:c9112f0c67e3 | 887 | err += ++x*2+1; |
bcostm | 0:c9112f0c67e3 | 888 | if (-y == x && e2 <= y) e2 = 0; |
bcostm | 0:c9112f0c67e3 | 889 | } |
bcostm | 0:c9112f0c67e3 | 890 | if (e2 > y) err += ++y*2+1; |
bcostm | 0:c9112f0c67e3 | 891 | } |
bcostm | 0:c9112f0c67e3 | 892 | while (y <= 0); |
bcostm | 0:c9112f0c67e3 | 893 | } |
bcostm | 0:c9112f0c67e3 | 894 | |
bcostm | 0:c9112f0c67e3 | 895 | /** |
bcostm | 0:c9112f0c67e3 | 896 | * @brief Draws a pixel on LCD. |
bcostm | 0:c9112f0c67e3 | 897 | * @param Xpos: X position |
bcostm | 0:c9112f0c67e3 | 898 | * @param Ypos: Y position |
bcostm | 0:c9112f0c67e3 | 899 | * @param RGB_Code: Pixel color in ARGB mode (8-8-8-8) |
bcostm | 0:c9112f0c67e3 | 900 | * @retval None |
bcostm | 0:c9112f0c67e3 | 901 | */ |
bcostm | 0:c9112f0c67e3 | 902 | void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint32_t RGB_Code) |
bcostm | 0:c9112f0c67e3 | 903 | { |
bcostm | 0:c9112f0c67e3 | 904 | /* Write data value to all SDRAM memory */ |
bcostm | 0:c9112f0c67e3 | 905 | if(hLtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565) |
bcostm | 0:c9112f0c67e3 | 906 | { /* RGB565 format */ |
bcostm | 0:c9112f0c67e3 | 907 | *(__IO uint16_t*) (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos))) = (uint16_t)RGB_Code; |
bcostm | 0:c9112f0c67e3 | 908 | } |
bcostm | 0:c9112f0c67e3 | 909 | else |
bcostm | 0:c9112f0c67e3 | 910 | { /* ARGB8888 format */ |
bcostm | 0:c9112f0c67e3 | 911 | *(__IO uint32_t*) (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (4*(Ypos*BSP_LCD_GetXSize() + Xpos))) = RGB_Code; |
bcostm | 0:c9112f0c67e3 | 912 | } |
bcostm | 0:c9112f0c67e3 | 913 | } |
bcostm | 0:c9112f0c67e3 | 914 | |
bcostm | 0:c9112f0c67e3 | 915 | /** |
bcostm | 0:c9112f0c67e3 | 916 | * @brief Draws a bitmap picture loaded in the internal Flash in ARGB888 format (32 bits per pixel). |
bcostm | 0:c9112f0c67e3 | 917 | * @param Xpos: Bmp X position in the LCD |
bcostm | 0:c9112f0c67e3 | 918 | * @param Ypos: Bmp Y position in the LCD |
bcostm | 0:c9112f0c67e3 | 919 | * @param pbmp: Pointer to Bmp picture address in the internal Flash |
bcostm | 0:c9112f0c67e3 | 920 | * @retval None |
bcostm | 0:c9112f0c67e3 | 921 | */ |
bcostm | 0:c9112f0c67e3 | 922 | void BSP_LCD_DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp) |
bcostm | 0:c9112f0c67e3 | 923 | { |
bcostm | 0:c9112f0c67e3 | 924 | uint32_t index = 0, width = 0, height = 0, bit_pixel = 0; |
bcostm | 0:c9112f0c67e3 | 925 | uint32_t address; |
bcostm | 0:c9112f0c67e3 | 926 | uint32_t input_color_mode = 0; |
bcostm | 0:c9112f0c67e3 | 927 | |
bcostm | 0:c9112f0c67e3 | 928 | /* Get bitmap data address offset */ |
bcostm | 0:c9112f0c67e3 | 929 | index = *(__IO uint16_t *) (pbmp + 10); |
bcostm | 0:c9112f0c67e3 | 930 | index |= (*(__IO uint16_t *) (pbmp + 12)) << 16; |
bcostm | 0:c9112f0c67e3 | 931 | |
bcostm | 0:c9112f0c67e3 | 932 | /* Read bitmap width */ |
bcostm | 0:c9112f0c67e3 | 933 | width = *(uint16_t *) (pbmp + 18); |
bcostm | 0:c9112f0c67e3 | 934 | width |= (*(uint16_t *) (pbmp + 20)) << 16; |
bcostm | 0:c9112f0c67e3 | 935 | |
bcostm | 0:c9112f0c67e3 | 936 | /* Read bitmap height */ |
bcostm | 0:c9112f0c67e3 | 937 | height = *(uint16_t *) (pbmp + 22); |
bcostm | 0:c9112f0c67e3 | 938 | height |= (*(uint16_t *) (pbmp + 24)) << 16; |
bcostm | 0:c9112f0c67e3 | 939 | |
bcostm | 0:c9112f0c67e3 | 940 | /* Read bit/pixel */ |
bcostm | 0:c9112f0c67e3 | 941 | bit_pixel = *(uint16_t *) (pbmp + 28); |
bcostm | 0:c9112f0c67e3 | 942 | |
bcostm | 0:c9112f0c67e3 | 943 | /* Set the address */ |
bcostm | 0:c9112f0c67e3 | 944 | address = hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (((BSP_LCD_GetXSize()*Ypos) + Xpos)*(4)); |
bcostm | 0:c9112f0c67e3 | 945 | |
bcostm | 0:c9112f0c67e3 | 946 | /* Get the layer pixel format */ |
bcostm | 0:c9112f0c67e3 | 947 | if ((bit_pixel/8) == 4) |
bcostm | 0:c9112f0c67e3 | 948 | { |
bcostm | 0:c9112f0c67e3 | 949 | input_color_mode = CM_ARGB8888; |
bcostm | 0:c9112f0c67e3 | 950 | } |
bcostm | 0:c9112f0c67e3 | 951 | else if ((bit_pixel/8) == 2) |
bcostm | 0:c9112f0c67e3 | 952 | { |
bcostm | 0:c9112f0c67e3 | 953 | input_color_mode = CM_RGB565; |
bcostm | 0:c9112f0c67e3 | 954 | } |
bcostm | 0:c9112f0c67e3 | 955 | else |
bcostm | 0:c9112f0c67e3 | 956 | { |
bcostm | 0:c9112f0c67e3 | 957 | input_color_mode = CM_RGB888; |
bcostm | 0:c9112f0c67e3 | 958 | } |
bcostm | 0:c9112f0c67e3 | 959 | |
bcostm | 0:c9112f0c67e3 | 960 | /* Bypass the bitmap header */ |
bcostm | 0:c9112f0c67e3 | 961 | pbmp += (index + (width * (height - 1) * (bit_pixel/8))); |
bcostm | 0:c9112f0c67e3 | 962 | |
bcostm | 0:c9112f0c67e3 | 963 | /* Convert picture to ARGB8888 pixel format */ |
bcostm | 0:c9112f0c67e3 | 964 | for(index=0; index < height; index++) |
bcostm | 0:c9112f0c67e3 | 965 | { |
bcostm | 0:c9112f0c67e3 | 966 | /* Pixel format conversion */ |
bcostm | 0:c9112f0c67e3 | 967 | LL_ConvertLineToARGB8888((uint32_t *)pbmp, (uint32_t *)address, width, input_color_mode); |
bcostm | 0:c9112f0c67e3 | 968 | |
bcostm | 0:c9112f0c67e3 | 969 | /* Increment the source and destination buffers */ |
bcostm | 0:c9112f0c67e3 | 970 | address+= (BSP_LCD_GetXSize()*4); |
bcostm | 0:c9112f0c67e3 | 971 | pbmp -= width*(bit_pixel/8); |
bcostm | 0:c9112f0c67e3 | 972 | } |
bcostm | 0:c9112f0c67e3 | 973 | } |
bcostm | 0:c9112f0c67e3 | 974 | |
bcostm | 0:c9112f0c67e3 | 975 | /** |
bcostm | 0:c9112f0c67e3 | 976 | * @brief Draws a full rectangle. |
bcostm | 0:c9112f0c67e3 | 977 | * @param Xpos: X position |
bcostm | 0:c9112f0c67e3 | 978 | * @param Ypos: Y position |
bcostm | 0:c9112f0c67e3 | 979 | * @param Width: Rectangle width |
bcostm | 0:c9112f0c67e3 | 980 | * @param Height: Rectangle height |
bcostm | 0:c9112f0c67e3 | 981 | * @retval None |
bcostm | 0:c9112f0c67e3 | 982 | */ |
bcostm | 0:c9112f0c67e3 | 983 | void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) |
bcostm | 0:c9112f0c67e3 | 984 | { |
bcostm | 0:c9112f0c67e3 | 985 | uint32_t x_address = 0; |
bcostm | 0:c9112f0c67e3 | 986 | |
bcostm | 0:c9112f0c67e3 | 987 | /* Set the text color */ |
bcostm | 0:c9112f0c67e3 | 988 | BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor); |
bcostm | 0:c9112f0c67e3 | 989 | |
bcostm | 0:c9112f0c67e3 | 990 | /* Get the rectangle start address */ |
bcostm | 0:c9112f0c67e3 | 991 | if(hLtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565) |
bcostm | 0:c9112f0c67e3 | 992 | { /* RGB565 format */ |
bcostm | 0:c9112f0c67e3 | 993 | x_address = (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress) + 2*(BSP_LCD_GetXSize()*Ypos + Xpos); |
bcostm | 0:c9112f0c67e3 | 994 | } |
bcostm | 0:c9112f0c67e3 | 995 | else |
bcostm | 0:c9112f0c67e3 | 996 | { /* ARGB8888 format */ |
bcostm | 0:c9112f0c67e3 | 997 | x_address = (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress) + 4*(BSP_LCD_GetXSize()*Ypos + Xpos); |
bcostm | 0:c9112f0c67e3 | 998 | } |
bcostm | 0:c9112f0c67e3 | 999 | /* Fill the rectangle */ |
bcostm | 0:c9112f0c67e3 | 1000 | LL_FillBuffer(ActiveLayer, (uint32_t *)x_address, Width, Height, (BSP_LCD_GetXSize() - Width), DrawProp[ActiveLayer].TextColor); |
bcostm | 0:c9112f0c67e3 | 1001 | } |
bcostm | 0:c9112f0c67e3 | 1002 | |
bcostm | 0:c9112f0c67e3 | 1003 | /** |
bcostm | 0:c9112f0c67e3 | 1004 | * @brief Draws a full circle. |
bcostm | 0:c9112f0c67e3 | 1005 | * @param Xpos: X position |
bcostm | 0:c9112f0c67e3 | 1006 | * @param Ypos: Y position |
bcostm | 0:c9112f0c67e3 | 1007 | * @param Radius: Circle radius |
bcostm | 0:c9112f0c67e3 | 1008 | * @retval None |
bcostm | 0:c9112f0c67e3 | 1009 | */ |
bcostm | 0:c9112f0c67e3 | 1010 | void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) |
bcostm | 0:c9112f0c67e3 | 1011 | { |
bcostm | 0:c9112f0c67e3 | 1012 | int32_t decision; /* Decision Variable */ |
bcostm | 0:c9112f0c67e3 | 1013 | uint32_t current_x; /* Current X Value */ |
bcostm | 0:c9112f0c67e3 | 1014 | uint32_t current_y; /* Current Y Value */ |
bcostm | 0:c9112f0c67e3 | 1015 | |
bcostm | 0:c9112f0c67e3 | 1016 | decision = 3 - (Radius << 1); |
bcostm | 0:c9112f0c67e3 | 1017 | |
bcostm | 0:c9112f0c67e3 | 1018 | current_x = 0; |
bcostm | 0:c9112f0c67e3 | 1019 | current_y = Radius; |
bcostm | 0:c9112f0c67e3 | 1020 | |
bcostm | 0:c9112f0c67e3 | 1021 | BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor); |
bcostm | 0:c9112f0c67e3 | 1022 | |
bcostm | 0:c9112f0c67e3 | 1023 | while (current_x <= current_y) |
bcostm | 0:c9112f0c67e3 | 1024 | { |
bcostm | 0:c9112f0c67e3 | 1025 | if(current_y > 0) |
bcostm | 0:c9112f0c67e3 | 1026 | { |
bcostm | 0:c9112f0c67e3 | 1027 | BSP_LCD_DrawHLine(Xpos - current_y, Ypos + current_x, 2*current_y); |
bcostm | 0:c9112f0c67e3 | 1028 | BSP_LCD_DrawHLine(Xpos - current_y, Ypos - current_x, 2*current_y); |
bcostm | 0:c9112f0c67e3 | 1029 | } |
bcostm | 0:c9112f0c67e3 | 1030 | |
bcostm | 0:c9112f0c67e3 | 1031 | if(current_x > 0) |
bcostm | 0:c9112f0c67e3 | 1032 | { |
bcostm | 0:c9112f0c67e3 | 1033 | BSP_LCD_DrawHLine(Xpos - current_x, Ypos - current_y, 2*current_x); |
bcostm | 0:c9112f0c67e3 | 1034 | BSP_LCD_DrawHLine(Xpos - current_x, Ypos + current_y, 2*current_x); |
bcostm | 0:c9112f0c67e3 | 1035 | } |
bcostm | 0:c9112f0c67e3 | 1036 | if (decision < 0) |
bcostm | 0:c9112f0c67e3 | 1037 | { |
bcostm | 0:c9112f0c67e3 | 1038 | decision += (current_x << 2) + 6; |
bcostm | 0:c9112f0c67e3 | 1039 | } |
bcostm | 0:c9112f0c67e3 | 1040 | else |
bcostm | 0:c9112f0c67e3 | 1041 | { |
bcostm | 0:c9112f0c67e3 | 1042 | decision += ((current_x - current_y) << 2) + 10; |
bcostm | 0:c9112f0c67e3 | 1043 | current_y--; |
bcostm | 0:c9112f0c67e3 | 1044 | } |
bcostm | 0:c9112f0c67e3 | 1045 | current_x++; |
bcostm | 0:c9112f0c67e3 | 1046 | } |
bcostm | 0:c9112f0c67e3 | 1047 | |
bcostm | 0:c9112f0c67e3 | 1048 | BSP_LCD_SetTextColor(DrawProp[ActiveLayer].TextColor); |
bcostm | 0:c9112f0c67e3 | 1049 | BSP_LCD_DrawCircle(Xpos, Ypos, Radius); |
bcostm | 0:c9112f0c67e3 | 1050 | } |
bcostm | 0:c9112f0c67e3 | 1051 | |
bcostm | 0:c9112f0c67e3 | 1052 | /** |
bcostm | 0:c9112f0c67e3 | 1053 | * @brief Draws a full poly-line (between many points). |
bcostm | 0:c9112f0c67e3 | 1054 | * @param Points: Pointer to the points array |
bcostm | 0:c9112f0c67e3 | 1055 | * @param PointCount: Number of points |
bcostm | 0:c9112f0c67e3 | 1056 | * @retval None |
bcostm | 0:c9112f0c67e3 | 1057 | */ |
bcostm | 0:c9112f0c67e3 | 1058 | void BSP_LCD_FillPolygon(pPoint Points, uint16_t PointCount) |
bcostm | 0:c9112f0c67e3 | 1059 | { |
bcostm | 0:c9112f0c67e3 | 1060 | 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; |
bcostm | 0:c9112f0c67e3 | 1061 | uint16_t image_left = 0, image_right = 0, image_top = 0, image_bottom = 0; |
bcostm | 0:c9112f0c67e3 | 1062 | |
bcostm | 0:c9112f0c67e3 | 1063 | image_left = image_right = Points->X; |
bcostm | 0:c9112f0c67e3 | 1064 | image_top= image_bottom = Points->Y; |
bcostm | 0:c9112f0c67e3 | 1065 | |
bcostm | 0:c9112f0c67e3 | 1066 | for(counter = 1; counter < PointCount; counter++) |
bcostm | 0:c9112f0c67e3 | 1067 | { |
bcostm | 0:c9112f0c67e3 | 1068 | pixelX = POLY_X(counter); |
bcostm | 0:c9112f0c67e3 | 1069 | if(pixelX < image_left) |
bcostm | 0:c9112f0c67e3 | 1070 | { |
bcostm | 0:c9112f0c67e3 | 1071 | image_left = pixelX; |
bcostm | 0:c9112f0c67e3 | 1072 | } |
bcostm | 0:c9112f0c67e3 | 1073 | if(pixelX > image_right) |
bcostm | 0:c9112f0c67e3 | 1074 | { |
bcostm | 0:c9112f0c67e3 | 1075 | image_right = pixelX; |
bcostm | 0:c9112f0c67e3 | 1076 | } |
bcostm | 0:c9112f0c67e3 | 1077 | |
bcostm | 0:c9112f0c67e3 | 1078 | pixelY = POLY_Y(counter); |
bcostm | 0:c9112f0c67e3 | 1079 | if(pixelY < image_top) |
bcostm | 0:c9112f0c67e3 | 1080 | { |
bcostm | 0:c9112f0c67e3 | 1081 | image_top = pixelY; |
bcostm | 0:c9112f0c67e3 | 1082 | } |
bcostm | 0:c9112f0c67e3 | 1083 | if(pixelY > image_bottom) |
bcostm | 0:c9112f0c67e3 | 1084 | { |
bcostm | 0:c9112f0c67e3 | 1085 | image_bottom = pixelY; |
bcostm | 0:c9112f0c67e3 | 1086 | } |
bcostm | 0:c9112f0c67e3 | 1087 | } |
bcostm | 0:c9112f0c67e3 | 1088 | |
bcostm | 0:c9112f0c67e3 | 1089 | if(PointCount < 2) |
bcostm | 0:c9112f0c67e3 | 1090 | { |
bcostm | 0:c9112f0c67e3 | 1091 | return; |
bcostm | 0:c9112f0c67e3 | 1092 | } |
bcostm | 0:c9112f0c67e3 | 1093 | |
bcostm | 0:c9112f0c67e3 | 1094 | X_center = (image_left + image_right)/2; |
bcostm | 0:c9112f0c67e3 | 1095 | Y_center = (image_bottom + image_top)/2; |
bcostm | 0:c9112f0c67e3 | 1096 | |
bcostm | 0:c9112f0c67e3 | 1097 | X_first = Points->X; |
bcostm | 0:c9112f0c67e3 | 1098 | Y_first = Points->Y; |
bcostm | 0:c9112f0c67e3 | 1099 | |
bcostm | 0:c9112f0c67e3 | 1100 | while(--PointCount) |
bcostm | 0:c9112f0c67e3 | 1101 | { |
bcostm | 0:c9112f0c67e3 | 1102 | X = Points->X; |
bcostm | 0:c9112f0c67e3 | 1103 | Y = Points->Y; |
bcostm | 0:c9112f0c67e3 | 1104 | Points++; |
bcostm | 0:c9112f0c67e3 | 1105 | X2 = Points->X; |
bcostm | 0:c9112f0c67e3 | 1106 | Y2 = Points->Y; |
bcostm | 0:c9112f0c67e3 | 1107 | |
bcostm | 0:c9112f0c67e3 | 1108 | FillTriangle(X, X2, X_center, Y, Y2, Y_center); |
bcostm | 0:c9112f0c67e3 | 1109 | FillTriangle(X, X_center, X2, Y, Y_center, Y2); |
bcostm | 0:c9112f0c67e3 | 1110 | FillTriangle(X_center, X2, X, Y_center, Y2, Y); |
bcostm | 0:c9112f0c67e3 | 1111 | } |
bcostm | 0:c9112f0c67e3 | 1112 | |
bcostm | 0:c9112f0c67e3 | 1113 | FillTriangle(X_first, X2, X_center, Y_first, Y2, Y_center); |
bcostm | 0:c9112f0c67e3 | 1114 | FillTriangle(X_first, X_center, X2, Y_first, Y_center, Y2); |
bcostm | 0:c9112f0c67e3 | 1115 | FillTriangle(X_center, X2, X_first, Y_center, Y2, Y_first); |
bcostm | 0:c9112f0c67e3 | 1116 | } |
bcostm | 0:c9112f0c67e3 | 1117 | |
bcostm | 0:c9112f0c67e3 | 1118 | /** |
bcostm | 0:c9112f0c67e3 | 1119 | * @brief Draws a full ellipse. |
bcostm | 0:c9112f0c67e3 | 1120 | * @param Xpos: X position |
bcostm | 0:c9112f0c67e3 | 1121 | * @param Ypos: Y position |
bcostm | 0:c9112f0c67e3 | 1122 | * @param XRadius: Ellipse X radius |
bcostm | 0:c9112f0c67e3 | 1123 | * @param YRadius: Ellipse Y radius |
bcostm | 0:c9112f0c67e3 | 1124 | * @retval None |
bcostm | 0:c9112f0c67e3 | 1125 | */ |
bcostm | 0:c9112f0c67e3 | 1126 | void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius) |
bcostm | 0:c9112f0c67e3 | 1127 | { |
bcostm | 0:c9112f0c67e3 | 1128 | int x = 0, y = -YRadius, err = 2-2*XRadius, e2; |
bcostm | 0:c9112f0c67e3 | 1129 | float k = 0, rad1 = 0, rad2 = 0; |
bcostm | 0:c9112f0c67e3 | 1130 | |
bcostm | 0:c9112f0c67e3 | 1131 | rad1 = XRadius; |
bcostm | 0:c9112f0c67e3 | 1132 | rad2 = YRadius; |
bcostm | 0:c9112f0c67e3 | 1133 | |
bcostm | 0:c9112f0c67e3 | 1134 | k = (float)(rad2/rad1); |
bcostm | 0:c9112f0c67e3 | 1135 | |
bcostm | 0:c9112f0c67e3 | 1136 | do |
bcostm | 0:c9112f0c67e3 | 1137 | { |
bcostm | 0:c9112f0c67e3 | 1138 | BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/k)), (Ypos+y), (2*(uint16_t)(x/k) + 1)); |
bcostm | 0:c9112f0c67e3 | 1139 | BSP_LCD_DrawHLine((Xpos-(uint16_t)(x/k)), (Ypos-y), (2*(uint16_t)(x/k) + 1)); |
bcostm | 0:c9112f0c67e3 | 1140 | |
bcostm | 0:c9112f0c67e3 | 1141 | e2 = err; |
bcostm | 0:c9112f0c67e3 | 1142 | if (e2 <= x) |
bcostm | 0:c9112f0c67e3 | 1143 | { |
bcostm | 0:c9112f0c67e3 | 1144 | err += ++x*2+1; |
bcostm | 0:c9112f0c67e3 | 1145 | if (-y == x && e2 <= y) e2 = 0; |
bcostm | 0:c9112f0c67e3 | 1146 | } |
bcostm | 0:c9112f0c67e3 | 1147 | if (e2 > y) err += ++y*2+1; |
bcostm | 0:c9112f0c67e3 | 1148 | } |
bcostm | 0:c9112f0c67e3 | 1149 | while (y <= 0); |
bcostm | 0:c9112f0c67e3 | 1150 | } |
bcostm | 0:c9112f0c67e3 | 1151 | |
bcostm | 0:c9112f0c67e3 | 1152 | /** |
bcostm | 0:c9112f0c67e3 | 1153 | * @brief Enables the display. |
bcostm | 0:c9112f0c67e3 | 1154 | * @retval None |
bcostm | 0:c9112f0c67e3 | 1155 | */ |
bcostm | 0:c9112f0c67e3 | 1156 | void BSP_LCD_DisplayOn(void) |
bcostm | 0:c9112f0c67e3 | 1157 | { |
bcostm | 0:c9112f0c67e3 | 1158 | /* Display On */ |
bcostm | 0:c9112f0c67e3 | 1159 | __HAL_LTDC_ENABLE(&hLtdcHandler); |
bcostm | 0:c9112f0c67e3 | 1160 | HAL_GPIO_WritePin(LCD_DISP_GPIO_PORT, LCD_DISP_PIN, GPIO_PIN_SET); /* Assert LCD_DISP pin */ |
bcostm | 0:c9112f0c67e3 | 1161 | HAL_GPIO_WritePin(LCD_BL_CTRL_GPIO_PORT, LCD_BL_CTRL_PIN, GPIO_PIN_SET); /* Assert LCD_BL_CTRL pin */ |
bcostm | 0:c9112f0c67e3 | 1162 | } |
bcostm | 0:c9112f0c67e3 | 1163 | |
bcostm | 0:c9112f0c67e3 | 1164 | /** |
bcostm | 0:c9112f0c67e3 | 1165 | * @brief Disables the display. |
bcostm | 0:c9112f0c67e3 | 1166 | * @retval None |
bcostm | 0:c9112f0c67e3 | 1167 | */ |
bcostm | 0:c9112f0c67e3 | 1168 | void BSP_LCD_DisplayOff(void) |
bcostm | 0:c9112f0c67e3 | 1169 | { |
bcostm | 0:c9112f0c67e3 | 1170 | /* Display Off */ |
bcostm | 0:c9112f0c67e3 | 1171 | __HAL_LTDC_DISABLE(&hLtdcHandler); |
bcostm | 0:c9112f0c67e3 | 1172 | HAL_GPIO_WritePin(LCD_DISP_GPIO_PORT, LCD_DISP_PIN, GPIO_PIN_RESET); /* De-assert LCD_DISP pin */ |
bcostm | 0:c9112f0c67e3 | 1173 | HAL_GPIO_WritePin(LCD_BL_CTRL_GPIO_PORT, LCD_BL_CTRL_PIN, GPIO_PIN_RESET);/* De-assert LCD_BL_CTRL pin */ |
bcostm | 0:c9112f0c67e3 | 1174 | } |
bcostm | 0:c9112f0c67e3 | 1175 | |
bcostm | 0:c9112f0c67e3 | 1176 | /** |
bcostm | 0:c9112f0c67e3 | 1177 | * @brief Initializes the LTDC MSP. |
bcostm | 0:c9112f0c67e3 | 1178 | * @param hltdc: LTDC handle |
bcostm | 0:c9112f0c67e3 | 1179 | * @param Params |
bcostm | 0:c9112f0c67e3 | 1180 | * @retval None |
bcostm | 0:c9112f0c67e3 | 1181 | */ |
bcostm | 0:c9112f0c67e3 | 1182 | __weak void BSP_LCD_MspInit(LTDC_HandleTypeDef *hltdc, void *Params) |
bcostm | 0:c9112f0c67e3 | 1183 | { |
bcostm | 0:c9112f0c67e3 | 1184 | GPIO_InitTypeDef gpio_init_structure; |
bcostm | 0:c9112f0c67e3 | 1185 | |
bcostm | 0:c9112f0c67e3 | 1186 | /* Enable the LTDC and DMA2D clocks */ |
bcostm | 0:c9112f0c67e3 | 1187 | __HAL_RCC_LTDC_CLK_ENABLE(); |
bcostm | 0:c9112f0c67e3 | 1188 | __HAL_RCC_DMA2D_CLK_ENABLE(); |
bcostm | 0:c9112f0c67e3 | 1189 | |
bcostm | 0:c9112f0c67e3 | 1190 | /* Enable GPIOs clock */ |
bcostm | 0:c9112f0c67e3 | 1191 | __HAL_RCC_GPIOE_CLK_ENABLE(); |
bcostm | 0:c9112f0c67e3 | 1192 | __HAL_RCC_GPIOG_CLK_ENABLE(); |
bcostm | 0:c9112f0c67e3 | 1193 | __HAL_RCC_GPIOI_CLK_ENABLE(); |
bcostm | 0:c9112f0c67e3 | 1194 | __HAL_RCC_GPIOJ_CLK_ENABLE(); |
bcostm | 0:c9112f0c67e3 | 1195 | __HAL_RCC_GPIOK_CLK_ENABLE(); |
bcostm | 0:c9112f0c67e3 | 1196 | LCD_DISP_GPIO_CLK_ENABLE(); |
bcostm | 0:c9112f0c67e3 | 1197 | LCD_BL_CTRL_GPIO_CLK_ENABLE(); |
bcostm | 0:c9112f0c67e3 | 1198 | |
bcostm | 0:c9112f0c67e3 | 1199 | /*** LTDC Pins configuration ***/ |
bcostm | 0:c9112f0c67e3 | 1200 | /* GPIOE configuration */ |
bcostm | 0:c9112f0c67e3 | 1201 | gpio_init_structure.Pin = GPIO_PIN_4; |
bcostm | 0:c9112f0c67e3 | 1202 | gpio_init_structure.Mode = GPIO_MODE_AF_PP; |
bcostm | 0:c9112f0c67e3 | 1203 | gpio_init_structure.Pull = GPIO_NOPULL; |
bcostm | 0:c9112f0c67e3 | 1204 | gpio_init_structure.Speed = GPIO_SPEED_FAST; |
bcostm | 0:c9112f0c67e3 | 1205 | gpio_init_structure.Alternate = GPIO_AF14_LTDC; |
bcostm | 0:c9112f0c67e3 | 1206 | HAL_GPIO_Init(GPIOE, &gpio_init_structure); |
bcostm | 0:c9112f0c67e3 | 1207 | |
bcostm | 0:c9112f0c67e3 | 1208 | /* GPIOG configuration */ |
bcostm | 0:c9112f0c67e3 | 1209 | gpio_init_structure.Pin = GPIO_PIN_12; |
bcostm | 0:c9112f0c67e3 | 1210 | gpio_init_structure.Mode = GPIO_MODE_AF_PP; |
bcostm | 0:c9112f0c67e3 | 1211 | gpio_init_structure.Alternate = GPIO_AF9_LTDC; |
bcostm | 0:c9112f0c67e3 | 1212 | HAL_GPIO_Init(GPIOG, &gpio_init_structure); |
bcostm | 0:c9112f0c67e3 | 1213 | |
bcostm | 0:c9112f0c67e3 | 1214 | /* GPIOI LTDC alternate configuration */ |
bcostm | 0:c9112f0c67e3 | 1215 | gpio_init_structure.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | \ |
bcostm | 0:c9112f0c67e3 | 1216 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; |
bcostm | 0:c9112f0c67e3 | 1217 | gpio_init_structure.Mode = GPIO_MODE_AF_PP; |
bcostm | 0:c9112f0c67e3 | 1218 | gpio_init_structure.Alternate = GPIO_AF14_LTDC; |
bcostm | 0:c9112f0c67e3 | 1219 | HAL_GPIO_Init(GPIOI, &gpio_init_structure); |
bcostm | 0:c9112f0c67e3 | 1220 | |
bcostm | 0:c9112f0c67e3 | 1221 | /* GPIOJ configuration */ |
bcostm | 0:c9112f0c67e3 | 1222 | gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | \ |
bcostm | 0:c9112f0c67e3 | 1223 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | \ |
bcostm | 0:c9112f0c67e3 | 1224 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | \ |
bcostm | 0:c9112f0c67e3 | 1225 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; |
bcostm | 0:c9112f0c67e3 | 1226 | gpio_init_structure.Mode = GPIO_MODE_AF_PP; |
bcostm | 0:c9112f0c67e3 | 1227 | gpio_init_structure.Alternate = GPIO_AF14_LTDC; |
bcostm | 0:c9112f0c67e3 | 1228 | HAL_GPIO_Init(GPIOJ, &gpio_init_structure); |
bcostm | 0:c9112f0c67e3 | 1229 | |
bcostm | 0:c9112f0c67e3 | 1230 | /* GPIOK configuration */ |
bcostm | 0:c9112f0c67e3 | 1231 | gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_4 | \ |
bcostm | 0:c9112f0c67e3 | 1232 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7; |
bcostm | 0:c9112f0c67e3 | 1233 | gpio_init_structure.Mode = GPIO_MODE_AF_PP; |
bcostm | 0:c9112f0c67e3 | 1234 | gpio_init_structure.Alternate = GPIO_AF14_LTDC; |
bcostm | 0:c9112f0c67e3 | 1235 | HAL_GPIO_Init(GPIOK, &gpio_init_structure); |
bcostm | 0:c9112f0c67e3 | 1236 | |
bcostm | 0:c9112f0c67e3 | 1237 | /* LCD_DISP GPIO configuration */ |
bcostm | 0:c9112f0c67e3 | 1238 | gpio_init_structure.Pin = LCD_DISP_PIN; /* LCD_DISP pin has to be manually controlled */ |
bcostm | 0:c9112f0c67e3 | 1239 | gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP; |
bcostm | 0:c9112f0c67e3 | 1240 | HAL_GPIO_Init(LCD_DISP_GPIO_PORT, &gpio_init_structure); |
bcostm | 0:c9112f0c67e3 | 1241 | |
bcostm | 0:c9112f0c67e3 | 1242 | /* LCD_BL_CTRL GPIO configuration */ |
bcostm | 0:c9112f0c67e3 | 1243 | gpio_init_structure.Pin = LCD_BL_CTRL_PIN; /* LCD_BL_CTRL pin has to be manually controlled */ |
bcostm | 0:c9112f0c67e3 | 1244 | gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP; |
bcostm | 0:c9112f0c67e3 | 1245 | HAL_GPIO_Init(LCD_BL_CTRL_GPIO_PORT, &gpio_init_structure); |
bcostm | 0:c9112f0c67e3 | 1246 | } |
bcostm | 0:c9112f0c67e3 | 1247 | |
bcostm | 0:c9112f0c67e3 | 1248 | /** |
bcostm | 0:c9112f0c67e3 | 1249 | * @brief DeInitializes BSP_LCD MSP. |
bcostm | 0:c9112f0c67e3 | 1250 | * @param hltdc: LTDC handle |
bcostm | 0:c9112f0c67e3 | 1251 | * @param Params |
bcostm | 0:c9112f0c67e3 | 1252 | * @retval None |
bcostm | 0:c9112f0c67e3 | 1253 | */ |
bcostm | 0:c9112f0c67e3 | 1254 | __weak void BSP_LCD_MspDeInit(LTDC_HandleTypeDef *hltdc, void *Params) |
bcostm | 0:c9112f0c67e3 | 1255 | { |
bcostm | 0:c9112f0c67e3 | 1256 | GPIO_InitTypeDef gpio_init_structure; |
bcostm | 0:c9112f0c67e3 | 1257 | |
bcostm | 0:c9112f0c67e3 | 1258 | /* Disable LTDC block */ |
bcostm | 0:c9112f0c67e3 | 1259 | __HAL_LTDC_DISABLE(hltdc); |
bcostm | 0:c9112f0c67e3 | 1260 | |
bcostm | 0:c9112f0c67e3 | 1261 | /* LTDC Pins deactivation */ |
bcostm | 0:c9112f0c67e3 | 1262 | |
bcostm | 0:c9112f0c67e3 | 1263 | /* GPIOE deactivation */ |
bcostm | 0:c9112f0c67e3 | 1264 | gpio_init_structure.Pin = GPIO_PIN_4; |
bcostm | 0:c9112f0c67e3 | 1265 | HAL_GPIO_DeInit(GPIOE, gpio_init_structure.Pin); |
bcostm | 0:c9112f0c67e3 | 1266 | |
bcostm | 0:c9112f0c67e3 | 1267 | /* GPIOG deactivation */ |
bcostm | 0:c9112f0c67e3 | 1268 | gpio_init_structure.Pin = GPIO_PIN_12; |
bcostm | 0:c9112f0c67e3 | 1269 | HAL_GPIO_DeInit(GPIOG, gpio_init_structure.Pin); |
bcostm | 0:c9112f0c67e3 | 1270 | |
bcostm | 0:c9112f0c67e3 | 1271 | /* GPIOI deactivation */ |
bcostm | 0:c9112f0c67e3 | 1272 | gpio_init_structure.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_12 | \ |
bcostm | 0:c9112f0c67e3 | 1273 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; |
bcostm | 0:c9112f0c67e3 | 1274 | HAL_GPIO_DeInit(GPIOI, gpio_init_structure.Pin); |
bcostm | 0:c9112f0c67e3 | 1275 | |
bcostm | 0:c9112f0c67e3 | 1276 | /* GPIOJ deactivation */ |
bcostm | 0:c9112f0c67e3 | 1277 | gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | \ |
bcostm | 0:c9112f0c67e3 | 1278 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | \ |
bcostm | 0:c9112f0c67e3 | 1279 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | \ |
bcostm | 0:c9112f0c67e3 | 1280 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; |
bcostm | 0:c9112f0c67e3 | 1281 | HAL_GPIO_DeInit(GPIOJ, gpio_init_structure.Pin); |
bcostm | 0:c9112f0c67e3 | 1282 | |
bcostm | 0:c9112f0c67e3 | 1283 | /* GPIOK deactivation */ |
bcostm | 0:c9112f0c67e3 | 1284 | gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_4 | \ |
bcostm | 0:c9112f0c67e3 | 1285 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7; |
bcostm | 0:c9112f0c67e3 | 1286 | HAL_GPIO_DeInit(GPIOK, gpio_init_structure.Pin); |
bcostm | 0:c9112f0c67e3 | 1287 | |
bcostm | 0:c9112f0c67e3 | 1288 | /* Disable LTDC clock */ |
bcostm | 0:c9112f0c67e3 | 1289 | __HAL_RCC_LTDC_CLK_DISABLE(); |
bcostm | 0:c9112f0c67e3 | 1290 | |
bcostm | 0:c9112f0c67e3 | 1291 | /* GPIO pins clock can be shut down in the application |
bcostm | 0:c9112f0c67e3 | 1292 | by surcharging this __weak function */ |
bcostm | 0:c9112f0c67e3 | 1293 | } |
bcostm | 0:c9112f0c67e3 | 1294 | |
bcostm | 0:c9112f0c67e3 | 1295 | /** |
bcostm | 0:c9112f0c67e3 | 1296 | * @brief Clock Config. |
bcostm | 0:c9112f0c67e3 | 1297 | * @param hltdc: LTDC handle |
bcostm | 0:c9112f0c67e3 | 1298 | * @param Params |
bcostm | 0:c9112f0c67e3 | 1299 | * @note This API is called by BSP_LCD_Init() |
bcostm | 0:c9112f0c67e3 | 1300 | * Being __weak it can be overwritten by the application |
bcostm | 0:c9112f0c67e3 | 1301 | * @retval None |
bcostm | 0:c9112f0c67e3 | 1302 | */ |
bcostm | 0:c9112f0c67e3 | 1303 | __weak void BSP_LCD_ClockConfig(LTDC_HandleTypeDef *hltdc, void *Params) |
bcostm | 0:c9112f0c67e3 | 1304 | { |
bcostm | 0:c9112f0c67e3 | 1305 | static RCC_PeriphCLKInitTypeDef periph_clk_init_struct; |
bcostm | 0:c9112f0c67e3 | 1306 | |
bcostm | 0:c9112f0c67e3 | 1307 | /* RK043FN48H LCD clock configuration */ |
bcostm | 0:c9112f0c67e3 | 1308 | /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ |
bcostm | 0:c9112f0c67e3 | 1309 | /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */ |
bcostm | 0:c9112f0c67e3 | 1310 | /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/5 = 38.4 Mhz */ |
bcostm | 0:c9112f0c67e3 | 1311 | /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_4 = 38.4/4 = 9.6Mhz */ |
bcostm | 0:c9112f0c67e3 | 1312 | periph_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; |
bcostm | 0:c9112f0c67e3 | 1313 | periph_clk_init_struct.PLLSAI.PLLSAIN = 192; |
bcostm | 0:c9112f0c67e3 | 1314 | periph_clk_init_struct.PLLSAI.PLLSAIR = RK043FN48H_FREQUENCY_DIVIDER; |
bcostm | 0:c9112f0c67e3 | 1315 | periph_clk_init_struct.PLLSAIDivR = RCC_PLLSAIDIVR_4; |
bcostm | 0:c9112f0c67e3 | 1316 | HAL_RCCEx_PeriphCLKConfig(&periph_clk_init_struct); |
bcostm | 0:c9112f0c67e3 | 1317 | } |
bcostm | 0:c9112f0c67e3 | 1318 | |
bcostm | 0:c9112f0c67e3 | 1319 | |
bcostm | 0:c9112f0c67e3 | 1320 | /******************************************************************************* |
bcostm | 0:c9112f0c67e3 | 1321 | Static Functions |
bcostm | 0:c9112f0c67e3 | 1322 | *******************************************************************************/ |
bcostm | 0:c9112f0c67e3 | 1323 | |
bcostm | 0:c9112f0c67e3 | 1324 | /** |
bcostm | 0:c9112f0c67e3 | 1325 | * @brief Draws a character on LCD. |
bcostm | 0:c9112f0c67e3 | 1326 | * @param Xpos: Line where to display the character shape |
bcostm | 0:c9112f0c67e3 | 1327 | * @param Ypos: Start column address |
bcostm | 0:c9112f0c67e3 | 1328 | * @param c: Pointer to the character data |
bcostm | 0:c9112f0c67e3 | 1329 | * @retval None |
bcostm | 0:c9112f0c67e3 | 1330 | */ |
bcostm | 0:c9112f0c67e3 | 1331 | static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c) |
bcostm | 0:c9112f0c67e3 | 1332 | { |
bcostm | 0:c9112f0c67e3 | 1333 | uint32_t i = 0, j = 0; |
bcostm | 0:c9112f0c67e3 | 1334 | uint16_t height, width; |
bcostm | 0:c9112f0c67e3 | 1335 | uint8_t offset; |
bcostm | 0:c9112f0c67e3 | 1336 | uint8_t *pchar; |
bcostm | 0:c9112f0c67e3 | 1337 | uint32_t line; |
bcostm | 0:c9112f0c67e3 | 1338 | |
bcostm | 0:c9112f0c67e3 | 1339 | height = DrawProp[ActiveLayer].pFont->Height; |
bcostm | 0:c9112f0c67e3 | 1340 | width = DrawProp[ActiveLayer].pFont->Width; |
bcostm | 0:c9112f0c67e3 | 1341 | |
bcostm | 0:c9112f0c67e3 | 1342 | offset = 8 *((width + 7)/8) - width ; |
bcostm | 0:c9112f0c67e3 | 1343 | |
bcostm | 0:c9112f0c67e3 | 1344 | for(i = 0; i < height; i++) |
bcostm | 0:c9112f0c67e3 | 1345 | { |
bcostm | 0:c9112f0c67e3 | 1346 | pchar = ((uint8_t *)c + (width + 7)/8 * i); |
bcostm | 0:c9112f0c67e3 | 1347 | |
bcostm | 0:c9112f0c67e3 | 1348 | switch(((width + 7)/8)) |
bcostm | 0:c9112f0c67e3 | 1349 | { |
bcostm | 0:c9112f0c67e3 | 1350 | |
bcostm | 0:c9112f0c67e3 | 1351 | case 1: |
bcostm | 0:c9112f0c67e3 | 1352 | line = pchar[0]; |
bcostm | 0:c9112f0c67e3 | 1353 | break; |
bcostm | 0:c9112f0c67e3 | 1354 | |
bcostm | 0:c9112f0c67e3 | 1355 | case 2: |
bcostm | 0:c9112f0c67e3 | 1356 | line = (pchar[0]<< 8) | pchar[1]; |
bcostm | 0:c9112f0c67e3 | 1357 | break; |
bcostm | 0:c9112f0c67e3 | 1358 | |
bcostm | 0:c9112f0c67e3 | 1359 | case 3: |
bcostm | 0:c9112f0c67e3 | 1360 | default: |
bcostm | 0:c9112f0c67e3 | 1361 | line = (pchar[0]<< 16) | (pchar[1]<< 8) | pchar[2]; |
bcostm | 0:c9112f0c67e3 | 1362 | break; |
bcostm | 0:c9112f0c67e3 | 1363 | } |
bcostm | 0:c9112f0c67e3 | 1364 | |
bcostm | 0:c9112f0c67e3 | 1365 | for (j = 0; j < width; j++) |
bcostm | 0:c9112f0c67e3 | 1366 | { |
bcostm | 0:c9112f0c67e3 | 1367 | if(line & (1 << (width- j + offset- 1))) |
bcostm | 0:c9112f0c67e3 | 1368 | { |
bcostm | 0:c9112f0c67e3 | 1369 | BSP_LCD_DrawPixel((Xpos + j), Ypos, DrawProp[ActiveLayer].TextColor); |
bcostm | 0:c9112f0c67e3 | 1370 | } |
bcostm | 0:c9112f0c67e3 | 1371 | else |
bcostm | 0:c9112f0c67e3 | 1372 | { |
bcostm | 0:c9112f0c67e3 | 1373 | BSP_LCD_DrawPixel((Xpos + j), Ypos, DrawProp[ActiveLayer].BackColor); |
bcostm | 0:c9112f0c67e3 | 1374 | } |
bcostm | 0:c9112f0c67e3 | 1375 | } |
bcostm | 0:c9112f0c67e3 | 1376 | Ypos++; |
bcostm | 0:c9112f0c67e3 | 1377 | } |
bcostm | 0:c9112f0c67e3 | 1378 | } |
bcostm | 0:c9112f0c67e3 | 1379 | |
bcostm | 0:c9112f0c67e3 | 1380 | /** |
bcostm | 0:c9112f0c67e3 | 1381 | * @brief Fills a triangle (between 3 points). |
bcostm | 0:c9112f0c67e3 | 1382 | * @param x1: Point 1 X position |
bcostm | 0:c9112f0c67e3 | 1383 | * @param y1: Point 1 Y position |
bcostm | 0:c9112f0c67e3 | 1384 | * @param x2: Point 2 X position |
bcostm | 0:c9112f0c67e3 | 1385 | * @param y2: Point 2 Y position |
bcostm | 0:c9112f0c67e3 | 1386 | * @param x3: Point 3 X position |
bcostm | 0:c9112f0c67e3 | 1387 | * @param y3: Point 3 Y position |
bcostm | 0:c9112f0c67e3 | 1388 | * @retval None |
bcostm | 0:c9112f0c67e3 | 1389 | */ |
bcostm | 0:c9112f0c67e3 | 1390 | static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3) |
bcostm | 0:c9112f0c67e3 | 1391 | { |
bcostm | 0:c9112f0c67e3 | 1392 | int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0, |
bcostm | 0:c9112f0c67e3 | 1393 | yinc1 = 0, yinc2 = 0, den = 0, num = 0, num_add = 0, num_pixels = 0, |
bcostm | 0:c9112f0c67e3 | 1394 | curpixel = 0; |
bcostm | 0:c9112f0c67e3 | 1395 | |
bcostm | 0:c9112f0c67e3 | 1396 | deltax = ABS(x2 - x1); /* The difference between the x's */ |
bcostm | 0:c9112f0c67e3 | 1397 | deltay = ABS(y2 - y1); /* The difference between the y's */ |
bcostm | 0:c9112f0c67e3 | 1398 | x = x1; /* Start x off at the first pixel */ |
bcostm | 0:c9112f0c67e3 | 1399 | y = y1; /* Start y off at the first pixel */ |
bcostm | 0:c9112f0c67e3 | 1400 | |
bcostm | 0:c9112f0c67e3 | 1401 | if (x2 >= x1) /* The x-values are increasing */ |
bcostm | 0:c9112f0c67e3 | 1402 | { |
bcostm | 0:c9112f0c67e3 | 1403 | xinc1 = 1; |
bcostm | 0:c9112f0c67e3 | 1404 | xinc2 = 1; |
bcostm | 0:c9112f0c67e3 | 1405 | } |
bcostm | 0:c9112f0c67e3 | 1406 | else /* The x-values are decreasing */ |
bcostm | 0:c9112f0c67e3 | 1407 | { |
bcostm | 0:c9112f0c67e3 | 1408 | xinc1 = -1; |
bcostm | 0:c9112f0c67e3 | 1409 | xinc2 = -1; |
bcostm | 0:c9112f0c67e3 | 1410 | } |
bcostm | 0:c9112f0c67e3 | 1411 | |
bcostm | 0:c9112f0c67e3 | 1412 | if (y2 >= y1) /* The y-values are increasing */ |
bcostm | 0:c9112f0c67e3 | 1413 | { |
bcostm | 0:c9112f0c67e3 | 1414 | yinc1 = 1; |
bcostm | 0:c9112f0c67e3 | 1415 | yinc2 = 1; |
bcostm | 0:c9112f0c67e3 | 1416 | } |
bcostm | 0:c9112f0c67e3 | 1417 | else /* The y-values are decreasing */ |
bcostm | 0:c9112f0c67e3 | 1418 | { |
bcostm | 0:c9112f0c67e3 | 1419 | yinc1 = -1; |
bcostm | 0:c9112f0c67e3 | 1420 | yinc2 = -1; |
bcostm | 0:c9112f0c67e3 | 1421 | } |
bcostm | 0:c9112f0c67e3 | 1422 | |
bcostm | 0:c9112f0c67e3 | 1423 | if (deltax >= deltay) /* There is at least one x-value for every y-value */ |
bcostm | 0:c9112f0c67e3 | 1424 | { |
bcostm | 0:c9112f0c67e3 | 1425 | xinc1 = 0; /* Don't change the x when numerator >= denominator */ |
bcostm | 0:c9112f0c67e3 | 1426 | yinc2 = 0; /* Don't change the y for every iteration */ |
bcostm | 0:c9112f0c67e3 | 1427 | den = deltax; |
bcostm | 0:c9112f0c67e3 | 1428 | num = deltax / 2; |
bcostm | 0:c9112f0c67e3 | 1429 | num_add = deltay; |
bcostm | 0:c9112f0c67e3 | 1430 | num_pixels = deltax; /* There are more x-values than y-values */ |
bcostm | 0:c9112f0c67e3 | 1431 | } |
bcostm | 0:c9112f0c67e3 | 1432 | else /* There is at least one y-value for every x-value */ |
bcostm | 0:c9112f0c67e3 | 1433 | { |
bcostm | 0:c9112f0c67e3 | 1434 | xinc2 = 0; /* Don't change the x for every iteration */ |
bcostm | 0:c9112f0c67e3 | 1435 | yinc1 = 0; /* Don't change the y when numerator >= denominator */ |
bcostm | 0:c9112f0c67e3 | 1436 | den = deltay; |
bcostm | 0:c9112f0c67e3 | 1437 | num = deltay / 2; |
bcostm | 0:c9112f0c67e3 | 1438 | num_add = deltax; |
bcostm | 0:c9112f0c67e3 | 1439 | num_pixels = deltay; /* There are more y-values than x-values */ |
bcostm | 0:c9112f0c67e3 | 1440 | } |
bcostm | 0:c9112f0c67e3 | 1441 | |
bcostm | 0:c9112f0c67e3 | 1442 | for (curpixel = 0; curpixel <= num_pixels; curpixel++) |
bcostm | 0:c9112f0c67e3 | 1443 | { |
bcostm | 0:c9112f0c67e3 | 1444 | BSP_LCD_DrawLine(x, y, x3, y3); |
bcostm | 0:c9112f0c67e3 | 1445 | |
bcostm | 0:c9112f0c67e3 | 1446 | num += num_add; /* Increase the numerator by the top of the fraction */ |
bcostm | 0:c9112f0c67e3 | 1447 | if (num >= den) /* Check if numerator >= denominator */ |
bcostm | 0:c9112f0c67e3 | 1448 | { |
bcostm | 0:c9112f0c67e3 | 1449 | num -= den; /* Calculate the new numerator value */ |
bcostm | 0:c9112f0c67e3 | 1450 | x += xinc1; /* Change the x as appropriate */ |
bcostm | 0:c9112f0c67e3 | 1451 | y += yinc1; /* Change the y as appropriate */ |
bcostm | 0:c9112f0c67e3 | 1452 | } |
bcostm | 0:c9112f0c67e3 | 1453 | x += xinc2; /* Change the x as appropriate */ |
bcostm | 0:c9112f0c67e3 | 1454 | y += yinc2; /* Change the y as appropriate */ |
bcostm | 0:c9112f0c67e3 | 1455 | } |
bcostm | 0:c9112f0c67e3 | 1456 | } |
bcostm | 0:c9112f0c67e3 | 1457 | |
bcostm | 0:c9112f0c67e3 | 1458 | /** |
bcostm | 0:c9112f0c67e3 | 1459 | * @brief Fills a buffer. |
bcostm | 0:c9112f0c67e3 | 1460 | * @param LayerIndex: Layer index |
bcostm | 0:c9112f0c67e3 | 1461 | * @param pDst: Pointer to destination buffer |
bcostm | 0:c9112f0c67e3 | 1462 | * @param xSize: Buffer width |
bcostm | 0:c9112f0c67e3 | 1463 | * @param ySize: Buffer height |
bcostm | 0:c9112f0c67e3 | 1464 | * @param OffLine: Offset |
bcostm | 0:c9112f0c67e3 | 1465 | * @param ColorIndex: Color index |
bcostm | 0:c9112f0c67e3 | 1466 | * @retval None |
bcostm | 0:c9112f0c67e3 | 1467 | */ |
bcostm | 0:c9112f0c67e3 | 1468 | static void LL_FillBuffer(uint32_t LayerIndex, void *pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLine, uint32_t ColorIndex) |
bcostm | 0:c9112f0c67e3 | 1469 | { |
bcostm | 0:c9112f0c67e3 | 1470 | /* Register to memory mode with ARGB8888 as color Mode */ |
bcostm | 0:c9112f0c67e3 | 1471 | hDma2dHandler.Init.Mode = DMA2D_R2M; |
bcostm | 0:c9112f0c67e3 | 1472 | if(hLtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565) |
bcostm | 0:c9112f0c67e3 | 1473 | { /* RGB565 format */ |
bcostm | 0:c9112f0c67e3 | 1474 | hDma2dHandler.Init.ColorMode = DMA2D_RGB565; |
bcostm | 0:c9112f0c67e3 | 1475 | } |
bcostm | 0:c9112f0c67e3 | 1476 | else |
bcostm | 0:c9112f0c67e3 | 1477 | { /* ARGB8888 format */ |
bcostm | 0:c9112f0c67e3 | 1478 | hDma2dHandler.Init.ColorMode = DMA2D_ARGB8888; |
bcostm | 0:c9112f0c67e3 | 1479 | } |
bcostm | 0:c9112f0c67e3 | 1480 | hDma2dHandler.Init.OutputOffset = OffLine; |
bcostm | 0:c9112f0c67e3 | 1481 | |
bcostm | 0:c9112f0c67e3 | 1482 | hDma2dHandler.Instance = DMA2D; |
bcostm | 0:c9112f0c67e3 | 1483 | |
bcostm | 0:c9112f0c67e3 | 1484 | /* DMA2D Initialization */ |
bcostm | 0:c9112f0c67e3 | 1485 | if(HAL_DMA2D_Init(&hDma2dHandler) == HAL_OK) |
bcostm | 0:c9112f0c67e3 | 1486 | { |
bcostm | 0:c9112f0c67e3 | 1487 | if(HAL_DMA2D_ConfigLayer(&hDma2dHandler, LayerIndex) == HAL_OK) |
bcostm | 0:c9112f0c67e3 | 1488 | { |
bcostm | 0:c9112f0c67e3 | 1489 | if (HAL_DMA2D_Start(&hDma2dHandler, ColorIndex, (uint32_t)pDst, xSize, ySize) == HAL_OK) |
bcostm | 0:c9112f0c67e3 | 1490 | { |
bcostm | 0:c9112f0c67e3 | 1491 | /* Polling For DMA transfer */ |
bcostm | 0:c9112f0c67e3 | 1492 | HAL_DMA2D_PollForTransfer(&hDma2dHandler, 10); |
bcostm | 0:c9112f0c67e3 | 1493 | } |
bcostm | 0:c9112f0c67e3 | 1494 | } |
bcostm | 0:c9112f0c67e3 | 1495 | } |
bcostm | 0:c9112f0c67e3 | 1496 | } |
bcostm | 0:c9112f0c67e3 | 1497 | |
bcostm | 0:c9112f0c67e3 | 1498 | /** |
bcostm | 0:c9112f0c67e3 | 1499 | * @brief Converts a line to an ARGB8888 pixel format. |
bcostm | 0:c9112f0c67e3 | 1500 | * @param pSrc: Pointer to source buffer |
bcostm | 0:c9112f0c67e3 | 1501 | * @param pDst: Output color |
bcostm | 0:c9112f0c67e3 | 1502 | * @param xSize: Buffer width |
bcostm | 0:c9112f0c67e3 | 1503 | * @param ColorMode: Input color mode |
bcostm | 0:c9112f0c67e3 | 1504 | * @retval None |
bcostm | 0:c9112f0c67e3 | 1505 | */ |
bcostm | 0:c9112f0c67e3 | 1506 | static void LL_ConvertLineToARGB8888(void *pSrc, void *pDst, uint32_t xSize, uint32_t ColorMode) |
bcostm | 0:c9112f0c67e3 | 1507 | { |
bcostm | 0:c9112f0c67e3 | 1508 | /* Configure the DMA2D Mode, Color Mode and output offset */ |
bcostm | 0:c9112f0c67e3 | 1509 | hDma2dHandler.Init.Mode = DMA2D_M2M_PFC; |
bcostm | 0:c9112f0c67e3 | 1510 | hDma2dHandler.Init.ColorMode = DMA2D_ARGB8888; |
bcostm | 0:c9112f0c67e3 | 1511 | hDma2dHandler.Init.OutputOffset = 0; |
bcostm | 0:c9112f0c67e3 | 1512 | |
bcostm | 0:c9112f0c67e3 | 1513 | /* Foreground Configuration */ |
bcostm | 0:c9112f0c67e3 | 1514 | hDma2dHandler.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA; |
bcostm | 0:c9112f0c67e3 | 1515 | hDma2dHandler.LayerCfg[1].InputAlpha = 0xFF; |
bcostm | 0:c9112f0c67e3 | 1516 | hDma2dHandler.LayerCfg[1].InputColorMode = ColorMode; |
bcostm | 0:c9112f0c67e3 | 1517 | hDma2dHandler.LayerCfg[1].InputOffset = 0; |
bcostm | 0:c9112f0c67e3 | 1518 | |
bcostm | 0:c9112f0c67e3 | 1519 | hDma2dHandler.Instance = DMA2D; |
bcostm | 0:c9112f0c67e3 | 1520 | |
bcostm | 0:c9112f0c67e3 | 1521 | /* DMA2D Initialization */ |
bcostm | 0:c9112f0c67e3 | 1522 | if(HAL_DMA2D_Init(&hDma2dHandler) == HAL_OK) |
bcostm | 0:c9112f0c67e3 | 1523 | { |
bcostm | 0:c9112f0c67e3 | 1524 | if(HAL_DMA2D_ConfigLayer(&hDma2dHandler, 1) == HAL_OK) |
bcostm | 0:c9112f0c67e3 | 1525 | { |
bcostm | 0:c9112f0c67e3 | 1526 | if (HAL_DMA2D_Start(&hDma2dHandler, (uint32_t)pSrc, (uint32_t)pDst, xSize, 1) == HAL_OK) |
bcostm | 0:c9112f0c67e3 | 1527 | { |
bcostm | 0:c9112f0c67e3 | 1528 | /* Polling For DMA transfer */ |
bcostm | 0:c9112f0c67e3 | 1529 | HAL_DMA2D_PollForTransfer(&hDma2dHandler, 10); |
bcostm | 0:c9112f0c67e3 | 1530 | } |
bcostm | 0:c9112f0c67e3 | 1531 | } |
bcostm | 0:c9112f0c67e3 | 1532 | } |
bcostm | 0:c9112f0c67e3 | 1533 | } |
bcostm | 0:c9112f0c67e3 | 1534 | |
bcostm | 0:c9112f0c67e3 | 1535 | /** |
bcostm | 0:c9112f0c67e3 | 1536 | * @} |
bcostm | 0:c9112f0c67e3 | 1537 | */ |
bcostm | 0:c9112f0c67e3 | 1538 | |
bcostm | 0:c9112f0c67e3 | 1539 | /** |
bcostm | 0:c9112f0c67e3 | 1540 | * @} |
bcostm | 0:c9112f0c67e3 | 1541 | */ |
bcostm | 0:c9112f0c67e3 | 1542 | |
bcostm | 0:c9112f0c67e3 | 1543 | /** |
bcostm | 0:c9112f0c67e3 | 1544 | * @} |
bcostm | 0:c9112f0c67e3 | 1545 | */ |
bcostm | 0:c9112f0c67e3 | 1546 | |
bcostm | 0:c9112f0c67e3 | 1547 | /** |
bcostm | 0:c9112f0c67e3 | 1548 | * @} |
bcostm | 0:c9112f0c67e3 | 1549 | */ |
bcostm | 0:c9112f0c67e3 | 1550 | |
bcostm | 0:c9112f0c67e3 | 1551 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |