From 21a6f96e2e5010b4cb6f29985255b307684e6452 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Tue, 27 Oct 2026 16:55:41 +0100 Subject: [PATCH] No white flash at power-on on the tinySA ULTRA (ZS405) Report: switching an Ultra (ZS405) on showed a momentary all white screen, an Ultra+ (ZS406, ZS407) did not. - The backlight came on before ili9341_init(), so the panel was lit in reset and during its init; the ZS405 panel shows white then (the ZS406/ZS407 panels, the ones with display inversion, stay black). It now comes on at DEFAULT_BRIGHTNESS once the screen is cleared. - That left a very brief flash: the backlight came on before the panel had settled. The init now waits the 120 ms the controller needs after SLEEP_OUT before DISPLAY_ON (LCD_WAKE_UP_MS). Only with __LCD_BRIGHTNESS__: without backlight control a longer wait would only show the uninitialised panel longer, so the BASIC is unchanged. Tested on a ZS405 (HW V0.4.5.1) with the ST-Link: DAC2 at 0 darkens the backlight, the backlight is dark with the CPU held in reset, the backlight switched on 2 s after the init shows no flash, and with this build power-ons show no flash. Start-up 120 ms longer; ULTRA +12 bytes, BASIC binary unchanged in size. Co-Authored-By: Claude Opus 5.5 (1M context) --- ili9341.c | 8 +++++++- main.c | 8 +++++--- 2 files changed, 12 insertions(+), 4 deletions(-) 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);