77 #include "../Fonts/fonts.h" 78 #include "../Fonts/font24.c" 79 #include "../Fonts/font20.c" 80 #include "../Fonts/font16.c" 81 #include "../Fonts/font12.c" 82 #include "../Fonts/font8.c" 114 #define ABS(X) ((X) > 0 ? (X) : -(X)) 116 #define POLY_X(Z) ((int32_t)((Points + (Z))->X)) 117 #define POLY_Y(Z) ((int32_t)((Points + (Z))->Y)) 155 static void DrawChar(uint16_t Xpos, uint16_t Ypos,
const uint8_t *c);
156 static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3);
157 static void LL_FillBuffer(uint32_t LayerIndex,
void *pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLine, uint32_t ColorIndex);
158 static void LL_ConvertLineToARGB8888(
void * pSrc,
void *pDst, uint32_t xSize, uint32_t ColorMode);
191 uint32_t LcdClock = 27429;
193 uint32_t laneByteClk_kHz = 0;
222 dsiPllInit.PLLNDIV = 100;
223 dsiPllInit.PLLIDF = DSI_PLL_IN_DIV5;
224 dsiPllInit.PLLODF = DSI_PLL_OUT_DIV1;
225 laneByteClk_kHz = 62500;
346 #if !defined(DATA_IN_ExtSDRAM) 384 gpio_init_structure.
Speed = GPIO_SPEED_HIGH;
449 Layercfg.WindowX0 = 0;
451 Layercfg.WindowY0 = 0;
453 Layercfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888;
454 Layercfg.FBStartAdress = FB_Address;
455 Layercfg.Alpha = 255;
457 Layercfg.Backcolor.Blue = 0;
458 Layercfg.Backcolor.Green = 0;
459 Layercfg.Backcolor.Red = 0;
460 Layercfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA;
461 Layercfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA;
479 ActiveLayer = LayerIndex;
543 HAL_LTDC_SetWindowPosition(&(
hltdc_discovery), Xpos, Ypos, LayerIndex);
611 DrawProp[ActiveLayer].
pFont = fonts;
620 return DrawProp[ActiveLayer].
pFont;
633 if(
hltdc_discovery.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
638 else if(
hltdc_discovery.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB888)
643 else if((
hltdc_discovery.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \
644 (
hltdc_discovery.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \
645 (
hltdc_discovery.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_AL88))
675 uint32_t color_backup = DrawProp[ActiveLayer].
TextColor;
681 DrawProp[ActiveLayer].
TextColor = color_backup;
694 DrawChar(Xpos, Ypos, &DrawProp[ActiveLayer].pFont->table[(Ascii-
' ') *\
711 uint16_t refcolumn = 1, i = 0;
712 uint32_t size = 0, xsize = 0;
716 while (*ptr++) size ++ ;
725 refcolumn = Xpos + ((xsize - size)* DrawProp[ActiveLayer].pFont->Width) / 2;
735 refcolumn = - Xpos + ((xsize - size)*DrawProp[ActiveLayer].pFont->Width);
746 if ((refcolumn < 1) || (refcolumn >= 0x8000))
752 while ((*Text != 0) & (((
BSP_LCD_GetXSize() - (i*DrawProp[ActiveLayer].pFont->Width)) & 0xFFFF) >= DrawProp[ActiveLayer].
pFont->
Width))
757 refcolumn += DrawProp[ActiveLayer].
pFont->
Width;
784 uint32_t Xaddress = 0;
790 LL_FillBuffer(ActiveLayer, (uint32_t *)Xaddress, Length, 1, 0, DrawProp[ActiveLayer].TextColor);
801 uint32_t Xaddress = 0;
807 LL_FillBuffer(ActiveLayer, (uint32_t *)Xaddress, 1, Length, (
BSP_LCD_GetXSize() - 1), DrawProp[ActiveLayer].TextColor);
819 int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0,
820 yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0,
823 deltax =
ABS(x2 - x1);
824 deltay =
ABS(y2 - y1);
850 if (deltax >= deltay)
869 for (curpixel = 0; curpixel <= numpixels; curpixel++)
914 D = 3 - (Radius << 1);
920 BSP_LCD_DrawPixel((Xpos + CurX), (Ypos - CurY), DrawProp[ActiveLayer].TextColor);
922 BSP_LCD_DrawPixel((Xpos - CurX), (Ypos - CurY), DrawProp[ActiveLayer].TextColor);
924 BSP_LCD_DrawPixel((Xpos + CurY), (Ypos - CurX), DrawProp[ActiveLayer].TextColor);
926 BSP_LCD_DrawPixel((Xpos - CurY), (Ypos - CurX), DrawProp[ActiveLayer].TextColor);
928 BSP_LCD_DrawPixel((Xpos + CurX), (Ypos + CurY), DrawProp[ActiveLayer].TextColor);
930 BSP_LCD_DrawPixel((Xpos - CurX), (Ypos + CurY), DrawProp[ActiveLayer].TextColor);
932 BSP_LCD_DrawPixel((Xpos + CurY), (Ypos + CurX), DrawProp[ActiveLayer].TextColor);
934 BSP_LCD_DrawPixel((Xpos - CurY), (Ypos + CurX), DrawProp[ActiveLayer].TextColor);
938 D += (CurX << 2) + 6;
942 D += ((CurX - CurY) << 2) + 10;
956 int16_t X = 0, Y = 0;
963 BSP_LCD_DrawLine(Points->
X, Points->
Y, (Points+PointCount-1)->X, (Points+PointCount-1)->Y);
983 int x = 0, y = -YRadius, err = 2-2*XRadius, e2;
984 float K = 0, rad1 = 0, rad2 = 0;
989 K = (float)(rad2/rad1);
992 BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/K)), (Ypos+y), DrawProp[ActiveLayer].TextColor);
993 BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/K)), (Ypos+y), DrawProp[ActiveLayer].TextColor);
994 BSP_LCD_DrawPixel((Xpos+(uint16_t)(x/K)), (Ypos-y), DrawProp[ActiveLayer].TextColor);
995 BSP_LCD_DrawPixel((Xpos-(uint16_t)(x/K)), (Ypos-y), DrawProp[ActiveLayer].TextColor);
1000 if (-y == x && e2 <= y) e2 = 0;
1002 if (e2 > y) err += ++y*2+1;
1015 uint32_t index = 0, width = 0, height = 0, bit_pixel = 0;
1017 uint32_t InputColorMode = 0;
1020 index = *(
__IO uint16_t *) (pbmp + 10);
1021 index |= (*(
__IO uint16_t *) (pbmp + 12)) << 16;
1024 width = *(uint16_t *) (pbmp + 18);
1025 width |= (*(uint16_t *) (pbmp + 20)) << 16;
1028 height = *(uint16_t *) (pbmp + 22);
1029 height |= (*(uint16_t *) (pbmp + 24)) << 16;
1032 bit_pixel = *(uint16_t *) (pbmp + 28);
1038 if ((bit_pixel/8) == 4)
1042 else if ((bit_pixel/8) == 2)
1052 pbmp += (index + (width * (height - 1) * (bit_pixel/8)));
1055 for(index=0; index < height; index++)
1058 LL_ConvertLineToARGB8888((uint32_t *)pbmp, (uint32_t *)Address, width, InputColorMode);
1062 pbmp -= width*(bit_pixel/8);
1075 uint32_t Xaddress = 0;
1084 LL_FillBuffer(ActiveLayer, (uint32_t *)Xaddress, Width, Height, (
BSP_LCD_GetXSize() - Width), DrawProp[ActiveLayer].TextColor);
1099 D = 3 - (Radius << 1);
1106 while (CurX <= CurY)
1121 D += (CurX << 2) + 6;
1125 D += ((CurX - CurY) << 2) + 10;
1142 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;
1143 uint16_t IMAGE_LEFT = 0, IMAGE_RIGHT = 0, IMAGE_TOP = 0, IMAGE_BOTTOM = 0;
1145 IMAGE_LEFT = IMAGE_RIGHT = Points->
X;
1146 IMAGE_TOP= IMAGE_BOTTOM = Points->
Y;
1148 for(counter = 1; counter < PointCount; counter++)
1150 pixelX =
POLY_X(counter);
1151 if(pixelX < IMAGE_LEFT)
1153 IMAGE_LEFT = pixelX;
1155 if(pixelX > IMAGE_RIGHT)
1157 IMAGE_RIGHT = pixelX;
1160 pixelY =
POLY_Y(counter);
1161 if(pixelY < IMAGE_TOP)
1165 if(pixelY > IMAGE_BOTTOM)
1167 IMAGE_BOTTOM = pixelY;
1176 X_center = (IMAGE_LEFT + IMAGE_RIGHT)/2;
1177 Y_center = (IMAGE_BOTTOM + IMAGE_TOP)/2;
1179 X_first = Points->
X;
1180 Y_first = Points->
Y;
1190 FillTriangle(X, X2, X_center, Y, Y2, Y_center);
1191 FillTriangle(X, X_center, X2, Y, Y_center, Y2);
1192 FillTriangle(X_center, X2, X, Y_center, Y2, Y);
1195 FillTriangle(X_first, X2, X_center, Y_first, Y2, Y_center);
1196 FillTriangle(X_first, X_center, X2, Y_first, Y_center, Y2);
1197 FillTriangle(X_center, X2, X_first, Y_center, Y2, Y_first);
1209 int x = 0, y = -YRadius, err = 2-2*XRadius, e2;
1210 float K = 0, rad1 = 0, rad2 = 0;
1215 K = (float)(rad2/rad1);
1226 if (-y == x && e2 <= y) e2 = 0;
1228 if (e2 > y) err += ++y*2+1;
1242 DSI_DCS_SHORT_PKT_WRITE_P1,
1257 DSI_DCS_SHORT_PKT_WRITE_P1,
1272 DSI_DCS_SHORT_PKT_WRITE_P1,
1315 __HAL_RCC_LTDC_FORCE_RESET();
1317 __HAL_RCC_DSI_FORCE_RESET();
1320 __HAL_RCC_LTDC_CLK_DISABLE();
1322 __HAL_RCC_DSI_CLK_DISABLE();
1332 __HAL_RCC_LTDC_CLK_ENABLE();
1335 __HAL_RCC_LTDC_FORCE_RESET();
1336 __HAL_RCC_LTDC_RELEASE_RESET();
1346 __HAL_RCC_DSI_CLK_ENABLE();
1349 __HAL_RCC_DSI_FORCE_RESET();
1350 __HAL_RCC_DSI_RELEASE_RESET();
1384 static void DrawChar(uint16_t Xpos, uint16_t Ypos,
const uint8_t *c)
1386 uint32_t i = 0, j = 0;
1387 uint16_t height, width;
1395 offset = 8 *((width + 7)/8) - width ;
1397 for(i = 0; i < height; i++)
1399 pchar = ((uint8_t *)c + (width + 7)/8 * i);
1401 switch(((width + 7)/8))
1409 line = (pchar[0]<< 8) | pchar[1];
1414 line = (pchar[0]<< 16) | (pchar[1]<< 8) | pchar[2];
1418 for (j = 0; j < width; j++)
1420 if(line & (1 << (width- j + offset- 1)))
1442 static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3)
1444 int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0,
1445 yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0,
1448 deltax =
ABS(x2 - x1);
1449 deltay =
ABS(y2 - y1);
1475 if (deltax >= deltay)
1494 for (curpixel = 0; curpixel <= numpixels; curpixel++)
1519 static void LL_FillBuffer(uint32_t LayerIndex,
void *pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLine, uint32_t ColorIndex)
1549 static void LL_ConvertLineToARGB8888(
void *pSrc,
void *pDst, uint32_t xSize, uint32_t ColorMode)
#define LCD_OTM8009A_ID
LCD Display OTM8009A ID.
#define OTM8009A_CMD_DISPOFF
LCD_OrientationTypeDef
LCD_OrientationTypeDef Possible values of Display Orientation.
uint32_t PeriphClockSelection
#define OTM8009A_CMD_DISPON
void BSP_LCD_LayerDefaultInit(uint16_t LayerIndex, uint32_t FB_Address)
Initializes the LCD layers.
void BSP_LCD_SelectLayer(uint32_t LayerIndex)
Selects the LCD Layer.
void BSP_LCD_DrawPolygon(pPoint Points, uint16_t PointCount)
Draws an poly-line (between many points) in currently active layer.
void BSP_LCD_SetFont(sFONT *fonts)
Sets the LCD text font.
HAL_StatusTypeDef HAL_DMA2D_Start(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width, uint32_t Height)
void HAL_Delay(__IO uint32_t Delay)
This function provides accurate delay (in milliseconds) based on variable incremented.
#define OTM8009A_480X800_VSYNC
void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length)
Draws a vertical line in currently active layer.
void BSP_LCD_Reset(void)
BSP LCD Reset Hw reset the LCD DSI activating its XRES signal (active low for some time) and desactiv...
#define LTDC_MAX_LAYER_NUMBER
Maximum number of LTDC layers.
uint8_t BSP_LCD_InitEx(LCD_OrientationTypeDef orientation)
Initializes the DSI LCD. The initialization is done as below:
HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit)
#define LCD_OK
LCD status structure definition.
void BSP_LCD_SetYSize(uint32_t imageHeightPixels)
Set the LCD Y size.
DSI_HandleTypeDef hdsi_discovery
void BSP_LCD_SetLayerWindow(uint16_t LayerIndex, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
Sets display window.
uint8_t BSP_LCD_Init(void)
Initializes the DSI LCD.
#define LCD_COLOR_WHITE
White value in ARGB8888 format.
void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius)
Draws a circle in currently active layer.
#define OTM8009A_800X480_WIDTH
__weak void BSP_LCD_MspDeInit(void)
De-Initializes the BSP LCD Msp Application can surcharge if needed this function implementation.
void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius)
Draws a full circle in currently active layer.
void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
Draws a full rectangle in currently active layer.
LCD Drawing point (pixel) geometric definition.
void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *ptr)
Displays a maximum of 60 characters on the LCD.
sFONT * BSP_LCD_GetFont(void)
Gets the LCD text font.
void BSP_LCD_SetColorKeying(uint32_t LayerIndex, uint32_t RGBValue)
Configures and sets the color keying.
#define LCD_DEFAULT_FONT
LCD default font.
#define OTM8009A_800X480_HFP
Text_AlignModeTypdef
LCD drawing Line alignment mode definitions.
uint32_t BSP_LCD_GetXSize(void)
Gets the LCD X size.
#define OTM8009A_480X800_HSYNC
OTM8009A_480X800 Timing parameters for Portrait orientation mode.
void BSP_LCD_ResetColorKeying(uint32_t LayerIndex)
Disables the color keying.
LCD Drawing main properties.
void BSP_LCD_SetBackColor(uint32_t Color)
Sets the LCD background color.
void BSP_LCD_FillPolygon(pPoint Points, uint16_t PointCount)
Draws a full poly-line (between many points) in currently active layer.
#define __HAL_RCC_DMA2D_FORCE_RESET()
void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Text_AlignModeTypdef Mode)
Displays characters in currently active layer.
#define __HAL_RCC_DMA2D_CLK_DISABLE()
HAL_StatusTypeDef HAL_DMA2D_ConfigLayer(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
#define OTM8009A_480X800_HEIGHT
#define OTM8009A_480X800_WIDTH
otm8009a_480x800 Size
#define OTM8009A_480X800_VFP
#define OTM8009A_800X480_HEIGHT
This file contains the common defines and functions prototypes for the stm32469i_discovery_lcd.c driver.
HAL_StatusTypeDef HAL_DMA2D_Init(DMA2D_HandleTypeDef *hdma2d)
#define __HAL_RCC_GPIOJ_CLK_ENABLE()
void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius)
Draws a full ellipse in currently active layer.
#define LCD_LayerCfgTypeDef
void BSP_LCD_Clear(uint32_t Color)
Clears the whole currently active layer of LTDC.
#define OTM8009A_800X480_HSYNC
OTM8009A_800X480 Timing parameters for Landscape orientation mode Same values as for Portrait mode in...
DMA2D_HandleTypeDef hdma2d_discovery
void BSP_LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
Draws an uni-line (between two points) in currently active layer.
RCC extended clocks structure definition.
#define DMA2D_OUTPUT_ARGB8888
void BSP_LCD_DisplayOff(void)
Switch Off the display. Enter DSI ULPM mode if was allowed and configured in Dsi Configuration.
void BSP_LCD_SetLayerVisible(uint32_t LayerIndex, FunctionalState State)
Sets an LCD Layer visible.
void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority)
uint32_t BSP_LCD_GetTextColor(void)
Gets the LCD text color.
void HAL_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState)
void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius)
Draws an ellipse on LCD in currently active layer.
#define __HAL_RCC_DMA2D_CLK_ENABLE()
#define OTM8009A_800X480_VSYNC
void BSP_LCD_DisplayOn(void)
Switch back on the display if was switched off by previous call of BSP_LCD_DisplayOff(). Exit DSI ULPM mode if was allowed and configured in Dsi Configuration.
#define LCD_COLOR_BLACK
Black value in ARGB8888 format.
void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii)
Displays one character in currently active layer.
void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
Draws a rectangle in currently active layer.
#define __HAL_RCC_DMA2D_RELEASE_RESET()
void HAL_NVIC_EnableIRQ(IRQn_Type IRQn)
void BSP_LCD_ClearStringLine(uint32_t Line)
Clears the selected line in currently active layer.
void BSP_LCD_SetLayerAddress(uint32_t LayerIndex, uint32_t Address)
Sets an LCD layer frame buffer address.
LTDC_HandleTypeDef hltdc_discovery
void BSP_LCD_SetTextColor(uint32_t Color)
Sets the LCD text color.
GPIO Init structure definition.
#define OTM8009A_480X800_VBP
DSI_PLLInitTypeDef dsiPllInit
void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init)
void BSP_LCD_SetBrightness(uint8_t BrightnessValue)
Set the brightness value.
uint32_t BSP_LCD_GetBackColor(void)
Gets the LCD background color.
void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length)
Draws an horizontal line in currently active layer.
uint8_t BSP_SDRAM_Init(void)
Initializes the SDRAM device.
__weak void BSP_LCD_MspInit(void)
Initialize the BSP LCD Msp. Application can surcharge if needed this function implementation.
void BSP_LCD_SetTransparency(uint32_t LayerIndex, uint8_t Transparency)
Configures the transparency.
uint32_t BSP_LCD_GetYSize(void)
Gets the LCD Y size.
#define OTM8009A_800X480_HBP
HAL_StatusTypeDef HAL_DMA2D_PollForTransfer(DMA2D_HandleTypeDef *hdma2d, uint32_t Timeout)
DSI_VidCfgTypeDef hdsivideo_handle
#define OTM8009A_480X800_HFP
#define OTM8009A_800X480_VBP
void DSI_IO_WriteCmd(uint32_t NbrParams, uint8_t *pParams)
DCS or Generic short/long write command.
void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint32_t RGB_Code)
Draws a pixel on LCD.
#define LTDC_ACTIVE_LAYER_BACKGROUND
LTDC Background layer index.
uint32_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos)
Reads an LCD pixel.
void HAL_NVIC_DisableIRQ(IRQn_Type IRQn)
void BSP_LCD_SetXSize(uint32_t imageWidthPixels)
Set the LCD X size.
void BSP_LCD_DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp)
Draws a bitmap picture loaded in the internal Flash (32 bpp) in currently active layer.
uint8_t OTM8009A_Init(uint32_t ColorCoding, uint32_t orientation)
Initializes the LCD KoD display part by communication in DSI mode in Video Mode with IC Display Drive...
#define GPIO_MODE_OUTPUT_PP
#define OTM8009A_800X480_VFP
#define OTM8009A_480X800_HBP
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct
DMA2D_LayerCfgTypeDef LayerCfg[MAX_DMA2D_LAYER]
DMA2D handle Structure definition.
#define DMA2D_NO_MODIF_ALPHA
#define OTM8009A_CMD_WRDISBV
RCC_PLLSAIInitTypeDef PLLSAI