Mercurial > public > ostc4
diff Discovery/Src/gfx_engine.c @ 873:e373e90a48db Evo_2_23
merge new screen stuff
author | heinrichsweikamp |
---|---|
date | Wed, 14 Aug 2024 16:44:46 +0200 |
parents | bc6c90e20d9e f7318457df4d |
children | fbb6f8f41e0a |
line wrap: on
line diff
--- a/Discovery/Src/gfx_engine.c Wed Aug 14 14:41:04 2024 +0200 +++ b/Discovery/Src/gfx_engine.c Wed Aug 14 16:44:46 2024 +0200 @@ -185,6 +185,9 @@ static uint32_t GFX_doubleBufferOne(void); static uint32_t GFX_doubleBufferTwo(void); +static void GFX_LTDC_Init_display0(void); +static void GFX_LTDC_Init_display1(void); + /* Exported functions --------------------------------------------------------*/ @@ -2151,7 +2154,7 @@ settings.actualFont = (tFont *)settings.font; } else -#ifndef BOOTLOADER_STANDALONE +//#ifndef BOOTLOADER_STANDALONE if((*pText == '\005') && !minimal) { newXdelta = GFX_write_char(hgfx, &settings, 'a', (tFont *)&Awe48); @@ -2164,7 +2167,7 @@ settings.Xdelta = newXdelta; } else -#endif +//#endif if((*pText >= '\020') && (*pText <= '\032') && !minimal) settings.color = *pText - '\020'; else @@ -3386,35 +3389,48 @@ void GFX_LTDC_Init(void) { - /* - HSYNC=10 (9+1) - HBP=10 (19-10+1) - ActiveW=480 (499-10-10+1) - HFP=8 (507-480-10-10+1) - - VSYNC=2 (1+1) - VBP=2 (3-2+1) - ActiveH=800 (803-2-2+1) - VFP=2 (805-800-2-2+1) - */ - - /* Timing configuration */ + if (hardwareDisplay == 1) + { + GFX_LTDC_Init_display1(); + } + else + { + GFX_LTDC_Init_display0(); + } +} + +void GFX_LTDC_Init_display0(void) +{ + /* Timing configuration */ + +#define ActiveH_d0 800 +#define ActiveW_d0 480 + +#define Hsync_d0 10 +#define HFP_d0 8 +#define HBP_d0 10 + +#define Vsync_d0 2 +#define VFP_d0 2 +#define VBP_d0 2 + + /* Horizontal synchronization width = Hsync - 1 */ - LtdcHandle.Init.HorizontalSync = 9; + LtdcHandle.Init.HorizontalSync = Hsync_d0 - 1; /* Vertical synchronization height = Vsync - 1 */ - LtdcHandle.Init.VerticalSync = 1; + LtdcHandle.Init.VerticalSync = Vsync_d0 - 1; /* Accumulated horizontal back porch = Hsync + HBP - 1 */ - LtdcHandle.Init.AccumulatedHBP = 19; + LtdcHandle.Init.AccumulatedHBP = Hsync_d0 + HBP_d0 - 1; /* Accumulated vertical back porch = Vsync + VBP - 1 */ - LtdcHandle.Init.AccumulatedVBP = 3; + LtdcHandle.Init.AccumulatedVBP = Vsync_d0 + VBP_d0 - 1; /* Accumulated active width = Hsync + HBP + Active Width - 1 */ - LtdcHandle.Init.AccumulatedActiveW = 499;//500;//499; + LtdcHandle.Init.AccumulatedActiveW = Hsync_d0 + HBP_d0 + ActiveW_d0 - 1; /* Accumulated active height = Vsync + VBP + Active Heigh - 1 */ - LtdcHandle.Init.AccumulatedActiveH = 803; + LtdcHandle.Init.AccumulatedActiveH = Vsync_d0 + VBP_d0 + ActiveH_d0 - 1; /* Total width = Hsync + HBP + Active Width + HFP - 1 */ - LtdcHandle.Init.TotalWidth = 507;//508;//507; + LtdcHandle.Init.TotalWidth = Hsync_d0 + HBP_d0 + ActiveW_d0 + HFP_d0 - 1; /* Total height = Vsync + VBP + Active Heigh + VFP - 1 */ - LtdcHandle.Init.TotalHeigh = 805; + LtdcHandle.Init.TotalHeigh = Vsync_d0 + VBP_d0 + ActiveH_d0 + VFP_d0 - 1; /* Configure R,G,B component values for LCD background color */ LtdcHandle.Init.Backcolor.Red= 0; @@ -3427,7 +3443,7 @@ /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/4 = 48 Mhz */ /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_8 = 48/4 = 6Mhz */ -/* done in main.c SystemClockConfig +/* done in base.c SystemClockConfig PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; PeriphClkInitStruct.PLLSAI.PLLSAIN = 192; @@ -3444,7 +3460,74 @@ LtdcHandle.Instance = LTDC; /* Configure the LTDC */ - if(HAL_LTDC_Init(&LtdcHandle) != HAL_OK) // auch init der GPIO Pins + if(HAL_LTDC_Init(&LtdcHandle) != HAL_OK) // initialize GPIO Pins, too + { + /* Initialization Error */ + GFX_Error_Handler(); + } +} + + +void GFX_LTDC_Init_display1(void) +{ + /* Timing configuration */ +#define ActiveH_d1 800 +#define ActiveW_d1 480 + +#define Hsync_d1 2 +#define HFP_d1 8 +#define HBP_d1 8 + +#define Vsync_d1 2 +#define VFP_d1 4 // make sure this value * VSYNC is also set in display.c for OLED_VFP_SET +#define VBP_d1 4 // make sure this value * VSYNC is also set in display.c for OLED_VBP_SET + + /* Horizontal synchronization width = Hsync - 1 */ + LtdcHandle.Init.HorizontalSync = Hsync_d1 - 1; + /* Vertical synchronization height = Vsync - 1 */ + LtdcHandle.Init.VerticalSync = Vsync_d1 -1; + /* Accumulated horizontal back porch = Hsync + HBP - 1 */ + LtdcHandle.Init.AccumulatedHBP = Hsync_d1 + HBP_d1 - 1; + /* Accumulated vertical back porch = Vsync + VBP - 1 */ + LtdcHandle.Init.AccumulatedVBP = Vsync_d1 + VBP_d1 - 1; + /* Accumulated active width = Hsync + HBP + Active Width - 1 */ + LtdcHandle.Init.AccumulatedActiveW = Hsync_d1 + HBP_d1 + ActiveW_d1 - 1; + /* Accumulated active height = Vsync + VBP + Active Heigh - 1 */ + LtdcHandle.Init.AccumulatedActiveH = Vsync_d1 + VBP_d1 + ActiveH_d1 - 1; + /* Total width = Hsync + HBP + Active Width + HFP - 1 */ + LtdcHandle.Init.TotalWidth = Hsync_d1 + HBP_d1 + ActiveW_d1 + HFP_d1 - 1; + /* Total height = Vsync + VBP + Active Heigh + VFP - 1 */ + LtdcHandle.Init.TotalHeigh = Vsync_d1 + VBP_d1 + ActiveH_d1 + VFP_d1 - 1; + + /* Configure R,G,B component values for LCD background color */ + LtdcHandle.Init.Backcolor.Red= 0; + LtdcHandle.Init.Backcolor.Blue= 0; + LtdcHandle.Init.Backcolor.Green= 0; + + /* LCD clock configuration */ + /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ + /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */ + /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/4 = 48 Mhz */ + /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_8 = 48/4 = 6Mhz */ + +/* done in base.c SystemClockConfig + + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; + PeriphClkInitStruct.PLLSAI.PLLSAIN = 192; + PeriphClkInitStruct.PLLSAI.PLLSAIR = 4; + PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_8; + HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); +*/ + /* Polarity */ + LtdcHandle.Init.HSPolarity = LTDC_HSPOLARITY_AL; + LtdcHandle.Init.VSPolarity = LTDC_VSPOLARITY_AL; + LtdcHandle.Init.DEPolarity = LTDC_DEPOLARITY_AL; + LtdcHandle.Init.PCPolarity = LTDC_PCPOLARITY_IIPC;//LTDC_PCPOLARITY_IPC; + + LtdcHandle.Instance = LTDC; + + /* Configure the LTDC */ + if(HAL_LTDC_Init(&LtdcHandle) != HAL_OK) // initialize GPIO Pins, too { /* Initialization Error */ GFX_Error_Handler();