From 870fe7eca3e96f97c6a744087a109fa9556eb080 Mon Sep 17 00:00:00 2001 From: Risto Date: Sat, 23 Sep 2023 10:46:50 +0200 Subject: [PATCH] feat(color): Show custom image during shutdown if present If `IMAGES\shutdown.png` is present, a custom shutdown image will be displayed while powering off the radio --- radio/src/gui/colorlcd/draw_functions.cpp | 21 ++++++++++++++++----- radio/src/sdcard.h | 1 + 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/radio/src/gui/colorlcd/draw_functions.cpp b/radio/src/gui/colorlcd/draw_functions.cpp index dd68c0d23..cf0ffeb9f 100644 --- a/radio/src/gui/colorlcd/draw_functions.cpp +++ b/radio/src/gui/colorlcd/draw_functions.cpp @@ -129,6 +129,7 @@ const int8_t bmp_shutdown_yo[] = { void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration, const char* message) { + static BitmapBuffer* shutdownSplashImg = nullptr; if (totalDuration == 0) return; LcdFlags fgColor; @@ -150,12 +151,22 @@ void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration, int quarter = duration / (totalDuration / 5); if (shutdown) { - lcd->drawMask((LCD_W - shutdown->width()) / 2, - (LCD_H - shutdown->height()) / 2, shutdown, fgColor); + if (!sdMounted()) sdInit(); + shutdownSplashImg = BitmapBuffer::loadBitmap( + BITMAPS_PATH "/" SHUTDOWN_SPLASH_FILE, BMP_RGB565); - for (int i = 0; i <= 3 - quarter; i += 1) { - lcd->drawBitmapPattern(LCD_W / 2 + bmp_shutdown_xo[i], LCD_H / 2 + bmp_shutdown_yo[i], - LBM_SHUTDOWN_CIRCLE, fgColor, i * SHUTDOWN_CIRCLE_RADIUS, SHUTDOWN_CIRCLE_RADIUS); + if (shutdownSplashImg) { + lcd->drawBitmap(0, 0, shutdownSplashImg); + } else { + lcd->drawMask((LCD_W - shutdown->width()) / 2, + (LCD_H - shutdown->height()) / 2, shutdown, fgColor); + + for (int i = 0; i <= 3 - quarter; i += 1) { + lcd->drawBitmapPattern( + LCD_W / 2 + bmp_shutdown_xo[i], LCD_H / 2 + bmp_shutdown_yo[i], + LBM_SHUTDOWN_CIRCLE, fgColor, i * SHUTDOWN_CIRCLE_RADIUS, + SHUTDOWN_CIRCLE_RADIUS); + } } } else { for (int i = 1; i <= 4; i++) { diff --git a/radio/src/sdcard.h b/radio/src/sdcard.h index 4a83cfe79..ab18bc7ab 100644 --- a/radio/src/sdcard.h +++ b/radio/src/sdcard.h @@ -78,6 +78,7 @@ const char RADIO_SETTINGS_ERRORFILE_YAML_PATH[] = RADIO_PATH PATH_SEPARATOR "rad const char YAMLFILE_CHECKSUM_TAG_NAME[] = "checksum"; #endif #define SPLASH_FILE "splash.png" +#define SHUTDOWN_SPLASH_FILE "shutdown.png" #endif #define MODELS_EXT ".bin"