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