comparison 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
comparison
equal deleted inserted replaced
872:5e027b0f7475 873:e373e90a48db
182 static void GFX_Dma2d_TransferError(DMA2D_HandleTypeDef* Dma2dHandle); 182 static void GFX_Dma2d_TransferError(DMA2D_HandleTypeDef* Dma2dHandle);
183 static void GFX_clear_frame_dma2d(uint8_t frameId); 183 static void GFX_clear_frame_dma2d(uint8_t frameId);
184 184
185 static uint32_t GFX_doubleBufferOne(void); 185 static uint32_t GFX_doubleBufferOne(void);
186 static uint32_t GFX_doubleBufferTwo(void); 186 static uint32_t GFX_doubleBufferTwo(void);
187
188 static void GFX_LTDC_Init_display0(void);
189 static void GFX_LTDC_Init_display1(void);
187 190
188 191
189 /* Exported functions --------------------------------------------------------*/ 192 /* Exported functions --------------------------------------------------------*/
190 193
191 uint8_t GFX_logoStatus(void) 194 uint8_t GFX_logoStatus(void)
2149 { 2152 {
2150 settings.dualFont = 0; 2153 settings.dualFont = 0;
2151 settings.actualFont = (tFont *)settings.font; 2154 settings.actualFont = (tFont *)settings.font;
2152 } 2155 }
2153 else 2156 else
2154 #ifndef BOOTLOADER_STANDALONE 2157 //#ifndef BOOTLOADER_STANDALONE
2155 if((*pText == '\005') && !minimal) 2158 if((*pText == '\005') && !minimal)
2156 { 2159 {
2157 newXdelta = GFX_write_char(hgfx, &settings, 'a', (tFont *)&Awe48); 2160 newXdelta = GFX_write_char(hgfx, &settings, 'a', (tFont *)&Awe48);
2158 settings.Xdelta = newXdelta; 2161 settings.Xdelta = newXdelta;
2159 } 2162 }
2162 { 2165 {
2163 newXdelta = GFX_write_char(hgfx, &settings, 'b', (tFont *)&Awe48); 2166 newXdelta = GFX_write_char(hgfx, &settings, 'b', (tFont *)&Awe48);
2164 settings.Xdelta = newXdelta; 2167 settings.Xdelta = newXdelta;
2165 } 2168 }
2166 else 2169 else
2167 #endif 2170 //#endif
2168 if((*pText >= '\020') && (*pText <= '\032') && !minimal) 2171 if((*pText >= '\020') && (*pText <= '\032') && !minimal)
2169 settings.color = *pText - '\020'; 2172 settings.color = *pText - '\020';
2170 else 2173 else
2171 if((*pText == '\034') && !minimal) 2174 if((*pText == '\034') && !minimal)
2172 settings.spaceMode = 1; 2175 settings.spaceMode = 1;
3384 return result; 3387 return result;
3385 } 3388 }
3386 3389
3387 void GFX_LTDC_Init(void) 3390 void GFX_LTDC_Init(void)
3388 { 3391 {
3389 /* 3392 if (hardwareDisplay == 1)
3390 HSYNC=10 (9+1) 3393 {
3391 HBP=10 (19-10+1) 3394 GFX_LTDC_Init_display1();
3392 ActiveW=480 (499-10-10+1) 3395 }
3393 HFP=8 (507-480-10-10+1) 3396 else
3394 3397 {
3395 VSYNC=2 (1+1) 3398 GFX_LTDC_Init_display0();
3396 VBP=2 (3-2+1) 3399 }
3397 ActiveH=800 (803-2-2+1) 3400 }
3398 VFP=2 (805-800-2-2+1) 3401
3399 */ 3402 void GFX_LTDC_Init_display0(void)
3400 3403 {
3401 /* Timing configuration */ 3404 /* Timing configuration */
3405
3406 #define ActiveH_d0 800
3407 #define ActiveW_d0 480
3408
3409 #define Hsync_d0 10
3410 #define HFP_d0 8
3411 #define HBP_d0 10
3412
3413 #define Vsync_d0 2
3414 #define VFP_d0 2
3415 #define VBP_d0 2
3416
3417
3402 /* Horizontal synchronization width = Hsync - 1 */ 3418 /* Horizontal synchronization width = Hsync - 1 */
3403 LtdcHandle.Init.HorizontalSync = 9; 3419 LtdcHandle.Init.HorizontalSync = Hsync_d0 - 1;
3404 /* Vertical synchronization height = Vsync - 1 */ 3420 /* Vertical synchronization height = Vsync - 1 */
3405 LtdcHandle.Init.VerticalSync = 1; 3421 LtdcHandle.Init.VerticalSync = Vsync_d0 - 1;
3406 /* Accumulated horizontal back porch = Hsync + HBP - 1 */ 3422 /* Accumulated horizontal back porch = Hsync + HBP - 1 */
3407 LtdcHandle.Init.AccumulatedHBP = 19; 3423 LtdcHandle.Init.AccumulatedHBP = Hsync_d0 + HBP_d0 - 1;
3408 /* Accumulated vertical back porch = Vsync + VBP - 1 */ 3424 /* Accumulated vertical back porch = Vsync + VBP - 1 */
3409 LtdcHandle.Init.AccumulatedVBP = 3; 3425 LtdcHandle.Init.AccumulatedVBP = Vsync_d0 + VBP_d0 - 1;
3410 /* Accumulated active width = Hsync + HBP + Active Width - 1 */ 3426 /* Accumulated active width = Hsync + HBP + Active Width - 1 */
3411 LtdcHandle.Init.AccumulatedActiveW = 499;//500;//499; 3427 LtdcHandle.Init.AccumulatedActiveW = Hsync_d0 + HBP_d0 + ActiveW_d0 - 1;
3412 /* Accumulated active height = Vsync + VBP + Active Heigh - 1 */ 3428 /* Accumulated active height = Vsync + VBP + Active Heigh - 1 */
3413 LtdcHandle.Init.AccumulatedActiveH = 803; 3429 LtdcHandle.Init.AccumulatedActiveH = Vsync_d0 + VBP_d0 + ActiveH_d0 - 1;
3414 /* Total width = Hsync + HBP + Active Width + HFP - 1 */ 3430 /* Total width = Hsync + HBP + Active Width + HFP - 1 */
3415 LtdcHandle.Init.TotalWidth = 507;//508;//507; 3431 LtdcHandle.Init.TotalWidth = Hsync_d0 + HBP_d0 + ActiveW_d0 + HFP_d0 - 1;
3416 /* Total height = Vsync + VBP + Active Heigh + VFP - 1 */ 3432 /* Total height = Vsync + VBP + Active Heigh + VFP - 1 */
3417 LtdcHandle.Init.TotalHeigh = 805; 3433 LtdcHandle.Init.TotalHeigh = Vsync_d0 + VBP_d0 + ActiveH_d0 + VFP_d0 - 1;
3418 3434
3419 /* Configure R,G,B component values for LCD background color */ 3435 /* Configure R,G,B component values for LCD background color */
3420 LtdcHandle.Init.Backcolor.Red= 0; 3436 LtdcHandle.Init.Backcolor.Red= 0;
3421 LtdcHandle.Init.Backcolor.Blue= 0; 3437 LtdcHandle.Init.Backcolor.Blue= 0;
3422 LtdcHandle.Init.Backcolor.Green= 0; 3438 LtdcHandle.Init.Backcolor.Green= 0;
3425 /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ 3441 /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */
3426 /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */ 3442 /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */
3427 /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/4 = 48 Mhz */ 3443 /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/4 = 48 Mhz */
3428 /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_8 = 48/4 = 6Mhz */ 3444 /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_8 = 48/4 = 6Mhz */
3429 3445
3430 /* done in main.c SystemClockConfig 3446 /* done in base.c SystemClockConfig
3431 3447
3432 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; 3448 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
3433 PeriphClkInitStruct.PLLSAI.PLLSAIN = 192; 3449 PeriphClkInitStruct.PLLSAI.PLLSAIN = 192;
3434 PeriphClkInitStruct.PLLSAI.PLLSAIR = 4; 3450 PeriphClkInitStruct.PLLSAI.PLLSAIR = 4;
3435 PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_8; 3451 PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_8;
3442 LtdcHandle.Init.PCPolarity = LTDC_PCPOLARITY_IIPC;//LTDC_PCPOLARITY_IPC; 3458 LtdcHandle.Init.PCPolarity = LTDC_PCPOLARITY_IIPC;//LTDC_PCPOLARITY_IPC;
3443 3459
3444 LtdcHandle.Instance = LTDC; 3460 LtdcHandle.Instance = LTDC;
3445 3461
3446 /* Configure the LTDC */ 3462 /* Configure the LTDC */
3447 if(HAL_LTDC_Init(&LtdcHandle) != HAL_OK) // auch init der GPIO Pins 3463 if(HAL_LTDC_Init(&LtdcHandle) != HAL_OK) // initialize GPIO Pins, too
3464 {
3465 /* Initialization Error */
3466 GFX_Error_Handler();
3467 }
3468 }
3469
3470
3471 void GFX_LTDC_Init_display1(void)
3472 {
3473 /* Timing configuration */
3474 #define ActiveH_d1 800
3475 #define ActiveW_d1 480
3476
3477 #define Hsync_d1 2
3478 #define HFP_d1 8
3479 #define HBP_d1 8
3480
3481 #define Vsync_d1 2
3482 #define VFP_d1 4 // make sure this value * VSYNC is also set in display.c for OLED_VFP_SET
3483 #define VBP_d1 4 // make sure this value * VSYNC is also set in display.c for OLED_VBP_SET
3484
3485 /* Horizontal synchronization width = Hsync - 1 */
3486 LtdcHandle.Init.HorizontalSync = Hsync_d1 - 1;
3487 /* Vertical synchronization height = Vsync - 1 */
3488 LtdcHandle.Init.VerticalSync = Vsync_d1 -1;
3489 /* Accumulated horizontal back porch = Hsync + HBP - 1 */
3490 LtdcHandle.Init.AccumulatedHBP = Hsync_d1 + HBP_d1 - 1;
3491 /* Accumulated vertical back porch = Vsync + VBP - 1 */
3492 LtdcHandle.Init.AccumulatedVBP = Vsync_d1 + VBP_d1 - 1;
3493 /* Accumulated active width = Hsync + HBP + Active Width - 1 */
3494 LtdcHandle.Init.AccumulatedActiveW = Hsync_d1 + HBP_d1 + ActiveW_d1 - 1;
3495 /* Accumulated active height = Vsync + VBP + Active Heigh - 1 */
3496 LtdcHandle.Init.AccumulatedActiveH = Vsync_d1 + VBP_d1 + ActiveH_d1 - 1;
3497 /* Total width = Hsync + HBP + Active Width + HFP - 1 */
3498 LtdcHandle.Init.TotalWidth = Hsync_d1 + HBP_d1 + ActiveW_d1 + HFP_d1 - 1;
3499 /* Total height = Vsync + VBP + Active Heigh + VFP - 1 */
3500 LtdcHandle.Init.TotalHeigh = Vsync_d1 + VBP_d1 + ActiveH_d1 + VFP_d1 - 1;
3501
3502 /* Configure R,G,B component values for LCD background color */
3503 LtdcHandle.Init.Backcolor.Red= 0;
3504 LtdcHandle.Init.Backcolor.Blue= 0;
3505 LtdcHandle.Init.Backcolor.Green= 0;
3506
3507 /* LCD clock configuration */
3508 /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */
3509 /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */
3510 /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/4 = 48 Mhz */
3511 /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_8 = 48/4 = 6Mhz */
3512
3513 /* done in base.c SystemClockConfig
3514
3515 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
3516 PeriphClkInitStruct.PLLSAI.PLLSAIN = 192;
3517 PeriphClkInitStruct.PLLSAI.PLLSAIR = 4;
3518 PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_8;
3519 HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
3520 */
3521 /* Polarity */
3522 LtdcHandle.Init.HSPolarity = LTDC_HSPOLARITY_AL;
3523 LtdcHandle.Init.VSPolarity = LTDC_VSPOLARITY_AL;
3524 LtdcHandle.Init.DEPolarity = LTDC_DEPOLARITY_AL;
3525 LtdcHandle.Init.PCPolarity = LTDC_PCPOLARITY_IIPC;//LTDC_PCPOLARITY_IPC;
3526
3527 LtdcHandle.Instance = LTDC;
3528
3529 /* Configure the LTDC */
3530 if(HAL_LTDC_Init(&LtdcHandle) != HAL_OK) // initialize GPIO Pins, too
3448 { 3531 {
3449 /* Initialization Error */ 3532 /* Initialization Error */
3450 GFX_Error_Handler(); 3533 GFX_Error_Handler();
3451 } 3534 }
3452 } 3535 }