From 2e77f23da4493dc3dbe96c89099a6633e6e4528a Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sun, 16 May 2021 09:23:11 +0200 Subject: [PATCH] Use compressed splash image --- radio/src/bitmaps/480x272/CMakeLists.txt | 2 ++ .../480x272/{bmp_splash.png => splash.png} | Bin radio/src/gui/colorlcd/splash.cpp | 24 +++++++++--------- 3 files changed, 14 insertions(+), 12 deletions(-) rename radio/src/bitmaps/480x272/{bmp_splash.png => splash.png} (100%) diff --git a/radio/src/bitmaps/480x272/CMakeLists.txt b/radio/src/bitmaps/480x272/CMakeLists.txt index b24d5528e..326c6ad4a 100644 --- a/radio/src/bitmaps/480x272/CMakeLists.txt +++ b/radio/src/bitmaps/480x272/CMakeLists.txt @@ -20,6 +20,8 @@ set(BITMAP_RLE_ARGS ${BITMAP_ARGS} --rle) set(MASK_RLE_ARGS ${MASK_ARGS} --rle) add_bitmaps_target(${BITMAP_TARGET_PREFIX}_bitmaps "${RADIO_SRC_DIR}/bitmaps/480x272/bmp_*.png" "5/6/5" "${BITMAP_ARGS}") +add_png_target(${BITMAP_TARGET_PREFIX}_splash "${RADIO_SRC_DIR}/bitmaps/480x272/splash.png") + add_bitmaps_target(${BITMAP_TARGET_PREFIX}_calibration_bitmaps "${RADIO_SRC_DIR}/bitmaps/480x272/calibration/bmp_*.png" "5/6/5" "${BITMAP_ARGS}") add_bitmaps_target(${BITMAP_TARGET_PREFIX}_button_bitmaps "${RADIO_SRC_DIR}/bitmaps/480x272/button/alpha_*.png" "4/4/4/4" "${BITMAP_ARGS}") add_bitmaps_target(${BITMAP_TARGET_PREFIX}_alpha_bitmaps "${RADIO_SRC_DIR}/bitmaps/480x272/alpha_*.png" "4/4/4/4" "${BITMAP_ARGS}") diff --git a/radio/src/bitmaps/480x272/bmp_splash.png b/radio/src/bitmaps/480x272/splash.png similarity index 100% rename from radio/src/bitmaps/480x272/bmp_splash.png rename to radio/src/bitmaps/480x272/splash.png diff --git a/radio/src/gui/colorlcd/splash.cpp b/radio/src/gui/colorlcd/splash.cpp index 1ac28e8b9..6b15b8a9a 100644 --- a/radio/src/gui/colorlcd/splash.cpp +++ b/radio/src/gui/colorlcd/splash.cpp @@ -22,20 +22,25 @@ #if defined(SPLASH) -const uint8_t __bmp_splash[] __ALIGNED(4) { -#include "bmp_splash.lbm" +const uint8_t __bmp_splash[] { +#include "splash.lbm" }; -Bitmap BMP_SPLASH(BMP_RGB565, (const uint16_t *)__bmp_splash); void drawSplash() { - static bool loadImgFromSD = true; + static bool loadSplashImg = true; static BitmapBuffer * splashImg = nullptr; - if (loadImgFromSD && splashImg == nullptr) { + // try splash from SD card first + if (loadSplashImg && splashImg == nullptr) { if (!sdMounted()) sdInit(); splashImg = BitmapBuffer::loadBitmap(BITMAPS_PATH "/" SPLASH_FILE); - loadImgFromSD = false; + loadSplashImg = false; + + // otherwise load from FLASH + if (splashImg == nullptr) { + splashImg = BitmapBuffer::loadRamBitmap(__bmp_splash, sizeof(__bmp_splash)); + } } lcd->clear(); @@ -45,12 +50,7 @@ void drawSplash() (LCD_H - splashImg->height())/2, splashImg); } - else { - lcd->drawBitmap((LCD_W - BMP_SPLASH.width())/2, - (LCD_H - BMP_SPLASH.height())/2, - &BMP_SPLASH); - } - + lcdRefresh(); } #endif