From 716a91fc0c1caaf868af15596524e513263858a1 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Tue, 19 Dec 2017 12:15:03 +0100 Subject: [PATCH] allow splash image to be loaded from SD on Horus (#5463) * allow splash image to be loaded from SD on Horus * added a new menu entry to assign splash screen --- radio/src/gui/480x272/radio_sdmanager.cpp | 7 +++++++ radio/src/gui/480x272/splash.cpp | 29 ++++++++++++++++++++++++++--- radio/src/sdcard.h | 1 + radio/src/translations.cpp | 3 +++ radio/src/translations.h | 3 +++ radio/src/translations/de.h.txt | 1 + radio/src/translations/en.h.txt | 1 + radio/src/translations/fr.h.txt | 1 + 8 files changed, 43 insertions(+), 3 deletions(-) diff --git a/radio/src/gui/480x272/radio_sdmanager.cpp b/radio/src/gui/480x272/radio_sdmanager.cpp index 10874a11d..f0bbe5a32 100644 --- a/radio/src/gui/480x272/radio_sdmanager.cpp +++ b/radio/src/gui/480x272/radio_sdmanager.cpp @@ -128,6 +128,10 @@ void onSdManagerMenu(const char * result) memcpy(g_model.header.bitmap, line, sizeof(g_model.header.bitmap)); storageDirty(EE_MODEL); } + else if (result == STR_ASSIGN_SPLASH) { + f_getcwd(lfn, _MAX_LFN); + sdCopyFile(line, lfn, SPLASH_FILE, BITMAPS_PATH); + } else if (result == STR_VIEW_TEXT) { getSelectionFullPath(lfn); pushMenuTextView(lfn); @@ -219,6 +223,9 @@ bool menuRadioSdManager(event_t _event) if (!READ_ONLY() && unsigned(strlen(ext)+ext-line) <= sizeof(g_model.header.bitmap) && !strcmp(lfn, BITMAPS_PATH)) { POPUP_MENU_ADD_ITEM(STR_ASSIGN_BITMAP); } + if (!strcmp(ext, PNG_EXT)) { + POPUP_MENU_ADD_ITEM(STR_ASSIGN_SPLASH); + } } else if (!strcasecmp(ext, TEXT_EXT)) { POPUP_MENU_ADD_ITEM(STR_VIEW_TEXT); diff --git a/radio/src/gui/480x272/splash.cpp b/radio/src/gui/480x272/splash.cpp index 94fddb08b..4ed8b200d 100644 --- a/radio/src/gui/480x272/splash.cpp +++ b/radio/src/gui/480x272/splash.cpp @@ -19,13 +19,36 @@ */ #include "opentx.h" -#include "bmp_splash.lbm" #if defined(SPLASH) + +#include "bmp_splash.lbm" + void drawSplash() { - lcd->clear(); - lcd->drawBitmap((LCD_W-BMP_SPLASH.getWidth())/2, (LCD_H-BMP_SPLASH.getHeight())/2, &BMP_SPLASH); + static bool loadImgFromSD = true; + static BitmapBuffer* splashImg = NULL; + + if (loadImgFromSD && splashImg == NULL) { + bool sd_mounted = sdMounted(); + if (!sd_mounted) sdInit(); + splashImg = BitmapBuffer::load(BITMAPS_PATH "/" SPLASH_FILE); + loadImgFromSD = false; + if (!sd_mounted) sdDone(); + } + + lcd->clear(); + + if (splashImg) { + lcd->drawBitmap((LCD_W - splashImg->getWidth())/2, + (LCD_H - splashImg->getHeight())/2, + splashImg); + } + else { + lcd->drawBitmap((LCD_W - BMP_SPLASH.getWidth())/2, + (LCD_H - BMP_SPLASH.getHeight())/2, + &BMP_SPLASH); + } #if MENUS_LOCK == 1 if (readonly == false) { diff --git a/radio/src/sdcard.h b/radio/src/sdcard.h index d0cce1f7d..f3e588f35 100644 --- a/radio/src/sdcard.h +++ b/radio/src/sdcard.h @@ -49,6 +49,7 @@ #if defined(COLORLCD) const char RADIO_MODELSLIST_PATH[] = RADIO_PATH "/models.txt"; const char RADIO_SETTINGS_PATH[] = RADIO_PATH "/radio.bin"; +#define SPLASH_FILE "splash.png" #endif #define MODELS_EXT ".bin" diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index d7a0420a7..34fe26048 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -556,6 +556,9 @@ const pm_char STR_SCRIPT_KILLED[] PROGMEM = TR_SCRIPT_KILLED; const pm_char STR_SCRIPT_ERROR[] PROGMEM = TR_SCRIPT_ERROR; const pm_char STR_PLAY_FILE[] PROGMEM = TR_PLAY_FILE; const pm_char STR_ASSIGN_BITMAP[] PROGMEM = TR_ASSIGN_BITMAP; +#if defined(PCBHORUS) +const pm_char STR_ASSIGN_SPLASH[] PROGMEM = TR_ASSIGN_SPLASH; +#endif const pm_char STR_EXECUTE_FILE[] PROGMEM = TR_EXECUTE_FILE; const pm_char STR_DELETE_FILE[] PROGMEM = TR_DELETE_FILE; const pm_char STR_COPY_FILE[] PROGMEM = TR_COPY_FILE; diff --git a/radio/src/translations.h b/radio/src/translations.h index 2f5815264..92db72d69 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -790,6 +790,9 @@ extern const pm_char STR_SCRIPT_KILLED[]; extern const pm_char STR_SCRIPT_ERROR[]; extern const pm_char STR_PLAY_FILE[]; extern const pm_char STR_ASSIGN_BITMAP[]; +#if defined(PCBHORUS) +extern const pm_char STR_ASSIGN_SPLASH[]; +#endif extern const pm_char STR_EXECUTE_FILE[]; extern const pm_char STR_DELETE_FILE[]; extern const pm_char STR_COPY_FILE[]; diff --git a/radio/src/translations/de.h.txt b/radio/src/translations/de.h.txt index ec17620c9..1bacc17c3 100644 --- a/radio/src/translations/de.h.txt +++ b/radio/src/translations/de.h.txt @@ -968,6 +968,7 @@ #define TR_COPY_FILE "Kopieren" #define TR_RENAME_FILE "Umbenennen" #define TR_ASSIGN_BITMAP "Bitmap zuordnen" +#define TR_ASSIGN_SPLASH "Als Startbild" #define TR_EXECUTE_FILE "Execute" #define TR_REMOVED " gelöscht" #define TR_SD_INFO "Information" diff --git a/radio/src/translations/en.h.txt b/radio/src/translations/en.h.txt index 33044c0c3..8082e11f3 100644 --- a/radio/src/translations/en.h.txt +++ b/radio/src/translations/en.h.txt @@ -951,6 +951,7 @@ #define TR_COPY_FILE "Copy" #define TR_RENAME_FILE "Rename" #define TR_ASSIGN_BITMAP "Assign bitmap" +#define TR_ASSIGN_SPLASH "Splash screen" #define TR_EXECUTE_FILE "Execute" #define TR_REMOVED " removed" #define TR_SD_INFO "Information" diff --git a/radio/src/translations/fr.h.txt b/radio/src/translations/fr.h.txt index 83da7e456..9bf5b3217 100644 --- a/radio/src/translations/fr.h.txt +++ b/radio/src/translations/fr.h.txt @@ -965,6 +965,7 @@ #define TR_COPY_FILE "Copier" #define TR_RENAME_FILE "Renommer" #define TR_ASSIGN_BITMAP "Sélectionner image" +#define TR_ASSIGN_SPLASH "Logo d'accueil" #define TR_EXECUTE_FILE "Exécuter" #define TR_REMOVED " supprimé" #define TR_SD_INFO "Information" -- 2.11.4.GIT