Clean up splash preprocessor structure and add include warning

Consolidate #ifndef/#ifdef into single #ifdef/#else/#endif block.
Add warning comment to generated header about static linkage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
torlando-tech
2026-03-04 18:19:49 -05:00
parent bae59ff424
commit ff00c1d783
2 changed files with 6 additions and 7 deletions

View File

@@ -85,6 +85,7 @@ else:
f.write(f"#define SPLASH_HEIGHT {SPLASH_HEIGHT}\n")
f.write(f"#define HAS_SPLASH_IMAGE 1\n\n")
f.write(f"// {SPLASH_WIDTH}x{SPLASH_HEIGHT} RGB565 big-endian ({len(rgb565_bytes)} bytes)\n")
f.write("// WARNING: static linkage — include from exactly ONE translation unit\n")
f.write("static const uint8_t PROGMEM splash_image[] = {\n")
# Write bytes, 16 per line

View File

@@ -174,15 +174,10 @@ void Display::set_power(bool on) {
}
void Display::show_splash() {
#ifndef HAS_SPLASH_IMAGE
// No splash image — fill with background color (#1D1A1E -> RGB565 0x18C3)
fill_screen(0x18C3);
#endif
#ifdef HAS_SPLASH_IMAGE
// Splash image is full-screen (320x240), so offsets are 0
static const uint16_t X_OFFSET = (Disp::WIDTH - SPLASH_WIDTH) / 2; // 0
static const uint16_t Y_OFFSET = (Disp::HEIGHT - SPLASH_HEIGHT) / 2; // 0
static const uint16_t X_OFFSET = (Disp::WIDTH - SPLASH_WIDTH) / 2;
static const uint16_t Y_OFFSET = (Disp::HEIGHT - SPLASH_HEIGHT) / 2;
set_addr_window(X_OFFSET, Y_OFFSET,
X_OFFSET + SPLASH_WIDTH - 1,
@@ -204,6 +199,9 @@ void Display::show_splash() {
end_write();
INFO(" Splash image rendered");
#else
// No splash image — fill with background color (#1D1A1E -> RGB565 0x18C3)
fill_screen(0x18C3);
#endif
// Backlight on now that screen content is ready