diff --git a/ili9341.c b/ili9341.c index 6986649..a2ef567 100644 --- a/ili9341.c +++ b/ili9341.c @@ -504,6 +504,12 @@ void lcd_setBrightness(uint16_t b){ } #endif +#ifdef __LCD_BRIGHTNESS__ +#define LCD_WAKE_UP_MS 120 // after sleep out the panel supplies settle, the backlight comes on after the init +#else +#define LCD_WAKE_UP_MS 2 // backlight not controlled: a longer wait only shows the uninitialised panel longer +#endif + void ili9341_init(void) { LCD_DC_DATA; @@ -513,8 +519,8 @@ void ili9341_init(void) const uint8_t *p; for (p = LCD_INIT; *p; ) { send_command(p[0], p[1], &p[2]); + chThdSleepMilliseconds(p[0] == ILI9341_SLEEP_OUT ? LCD_WAKE_UP_MS : 2); p += 2 + p[1]; - chThdSleepMilliseconds(2); } #ifdef TINYSA4 if ((hwid % 100) >= 2) { diff --git a/main.c b/main.c index 0411551..fe79846 100644 --- a/main.c +++ b/main.c @@ -3550,9 +3550,6 @@ int main(void) adc_init(); PULSE DAC->CR|= DAC_CR_EN1 | DAC_CR_EN2; // Use DAC: CH1 and CH2 - #ifdef __LCD_BRIGHTNESS__ - lcd_setBrightness(DEFAULT_BRIGHTNESS); - #endif DAC->DHR12R1 = 0; // Setup DAC: CH1 value /* @@ -3563,6 +3560,11 @@ int main(void) #endif ili9341_init(); PULSE + #ifdef __LCD_BRIGHTNESS__ + // Backlight on only now the screen is cleared: a panel in reset or before its init + // shows white (the ZS405 panel, ZS406/ZS407 stay black) + lcd_setBrightness(DEFAULT_BRIGHTNESS); + #endif #ifdef TINYSA4 ili9341_set_foreground(LCD_FG_COLOR);