# HG changeset patch # User Ideenmodellierer # Date 1725219350 -7200 # Node ID 8d3f3a635397d7e957fe3a8c7e0ba1868fd32d60 # Parent 940f8e132638daa45e5dc963fa26a3fa73e23a64 Replaced global hardwareDisplay with unit access: The previous global hardwaredisplay, which indicated the display version, is stored in scope of ostc.c with interface function access. diff -r 940f8e132638 -r 8d3f3a635397 Discovery/Inc/ostc.h --- a/Discovery/Inc/ostc.h Sun Sep 01 20:31:01 2024 +0200 +++ b/Discovery/Inc/ostc.h Sun Sep 01 21:35:50 2024 +0200 @@ -57,6 +57,9 @@ #define SDRAM_MODEREG_WRITEBURST_MODE_PROGRAMMED ((uint16_t)0x0000) #define SDRAM_MODEREG_WRITEBURST_MODE_SINGLE ((uint16_t)0x0200) +#define DISPLAY_VERSION_LCD (0u) +#define DISPLAY_VERSION_NEW (1u) + /* Exported variables --------------------------------------------------------*/ extern SPI_HandleTypeDef hspiDisplay; @@ -98,6 +101,8 @@ void MX_TestPin_High(void); void MX_TestPin_Low(void); -uint8_t hardwareDisplay; //< either OSTC4 LCD (=0) or new Screen (=1) +void SetDisplayVersion(uint8_t version); +uint8_t isNewDisplay(void); + #endif // OSTC_H diff -r 940f8e132638 -r 8d3f3a635397 Discovery/Src/base.c --- a/Discovery/Src/base.c Sun Sep 01 20:31:01 2024 +0200 +++ b/Discovery/Src/base.c Sun Sep 01 21:35:50 2024 +0200 @@ -1258,12 +1258,12 @@ case 0: /* Cave */ levelMax = 3000;/* max 25 % (x2) */ levelMin = 1500; - if (hardwareDisplay == 1) display_1_brightness_cave(); + if( isNewDisplay()) display_1_brightness_cave(); break; case 1: /* Eco */ levelMax = 6000;/* max 50 % (x2) */ levelMin = 3000; - if (hardwareDisplay == 1) display_1_brightness_eco(); + if ( isNewDisplay()) display_1_brightness_eco(); break; case 2: /* Std */ levelAmbient += 1000; @@ -1271,7 +1271,7 @@ levelMin = 4500; levelUpStep_100ms += levelUpStep_100ms/2; // 4500 instead of 3000 levelDnStep_100ms += levelDnStep_100ms/2; - if (hardwareDisplay == 1) display_1_brightness_std(); + if ( isNewDisplay()) display_1_brightness_std(); break; case 3: /* High */ default: @@ -1280,7 +1280,7 @@ levelMin = 6000; levelUpStep_100ms += levelUpStep_100ms; // 6000 instead of 3000 levelDnStep_100ms += levelDnStep_100ms; - if (hardwareDisplay == 1) display_1_brightness_high(); + if ( isNewDisplay()) display_1_brightness_high(); break; case 4: /* New Max */ levelAmbient = 12000; @@ -1288,7 +1288,7 @@ levelMin = 12000; levelUpStep_100ms += 12000; levelDnStep_100ms += 0; - if (hardwareDisplay == 1) display_1_brightness_max(); + if ( isNewDisplay()) display_1_brightness_max(); break; } diff -r 940f8e132638 -r 8d3f3a635397 Discovery/Src/display.c --- a/Discovery/Src/display.c Sun Sep 01 20:31:01 2024 +0200 +++ b/Discovery/Src/display.c Sun Sep 01 21:35:50 2024 +0200 @@ -68,13 +68,13 @@ HAL_Delay(10); HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_SET); HAL_Delay(25); + // check for new screen - hardwareDisplay=0; // default is old screen aTxBuffer[0] = 0x71; // Read internal register if (receive_screen((uint8_t*)aTxBuffer) == 0x27) // chip Index (=0x27 for new screen) - { - hardwareDisplay=1; - } + { + SetDisplayVersion(DISPLAY_VERSION_NEW); + } else { // re-reset the screen to be sure the 0x71 command did nothing HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_RESET); @@ -82,6 +82,7 @@ HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_SET); HAL_Delay(25); + SetDisplayVersion(DISPLAY_VERSION_LCD); } /* RGB signals should be now for 2 frames or more (datasheet) */ @@ -167,7 +168,7 @@ void display_power_off(void) { - if (hardwareDisplay == 1) + if (isNewDisplay()) { uint8_t aTxBuffer[3]; @@ -196,7 +197,7 @@ void display_power_on__2_of_2__post_RGB(void) { - if (hardwareDisplay == 1) + if (isNewDisplay()) { display_power_on__2_of_2__post_RGB_display1(); } diff -r 940f8e132638 -r 8d3f3a635397 Discovery/Src/gfx_engine.c --- a/Discovery/Src/gfx_engine.c Sun Sep 01 20:31:01 2024 +0200 +++ b/Discovery/Src/gfx_engine.c Sun Sep 01 21:35:50 2024 +0200 @@ -3392,14 +3392,14 @@ void GFX_LTDC_Init(void) { - if (hardwareDisplay == 1) - { + if (isNewDisplay()) + { GFX_LTDC_Init_display1(); - } - else - { + } + else + { GFX_LTDC_Init_display0(); - } + } } void GFX_LTDC_Init_display0(void) diff -r 940f8e132638 -r 8d3f3a635397 Discovery/Src/ostc.c --- a/Discovery/Src/ostc.c Sun Sep 01 20:31:01 2024 +0200 +++ b/Discovery/Src/ostc.c Sun Sep 01 21:35:50 2024 +0200 @@ -53,7 +53,7 @@ /* Private variables ---------------------------------------------------------*/ /* Private variables with external access via get_xxx() function -------------*/ - +static uint8_t hardwareDisplay = 0; //< either OSTC4 LCD (=0) or new Screen (=1) /* Private function prototypes -----------------------------------------------*/ /* Exported functions --------------------------------------------------------*/ @@ -422,7 +422,22 @@ HAL_GPIO_Init(RESET_LOGIC_ALLES_OK_GPIO_PORT, &GPIO_InitStruct); #endif } - +void SetDisplayVersion(uint8_t version) +{ + if(version < 2) + { + hardwareDisplay = version; + } +} +uint8_t isNewDisplay() +{ + uint8_t ret = 0; + if(hardwareDisplay == DISPLAY_VERSION_NEW) + { + ret = 1; + } + return ret; +} #ifndef BOOTLOADER_STANDALONE void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)