diff --git a/radio/src/bitmaps/horus/alpha_asterisk.png b/radio/src/bitmaps/horus/alpha_asterisk.png new file mode 100644 index 000000000..6923736be Binary files /dev/null and b/radio/src/bitmaps/horus/alpha_asterisk.png differ diff --git a/radio/src/bitmaps/horus/bmp_asterisk.png b/radio/src/bitmaps/horus/bmp_asterisk.png deleted file mode 100644 index 1e12a2492..000000000 Binary files a/radio/src/bitmaps/horus/bmp_asterisk.png and /dev/null differ diff --git a/radio/src/gui/horus/bitmaps.cpp b/radio/src/gui/horus/bitmaps.cpp index 1c83cc7a3..d352fc915 100644 --- a/radio/src/gui/horus/bitmaps.cpp +++ b/radio/src/gui/horus/bitmaps.cpp @@ -275,7 +275,7 @@ const uint8_t LBM_STICK_POINTER[] __DMA = { */ const uint8_t LBM_ASTERISK[] __DMA = { -#include "bmp_asterisk.lbm" +#include "alpha_asterisk.lbm" }; const uint8_t LBM_POINT[] __DMA = { diff --git a/radio/src/gui/horus/popups.cpp b/radio/src/gui/horus/popups.cpp index a3f11db3e..08bf862a8 100644 --- a/radio/src/gui/horus/popups.cpp +++ b/radio/src/gui/horus/popups.cpp @@ -37,14 +37,6 @@ uint16_t popupMenuOffset = 0; uint8_t popupMenuOffsetType = MENU_OFFSET_INTERNAL; void (*popupMenuHandler)(const char * result); -void displayAlertBox() -{ - lcdClear(); - lcdDrawSolidFilledRect(POPUP_X, POPUP_Y, POPUP_W, POPUP_H, TEXT_BGCOLOR); - lcdDrawSolidRect(POPUP_X, POPUP_Y, POPUP_W, POPUP_H, 2, ALARM_COLOR); - lcdDrawBitmap(POPUP_X-80, POPUP_Y-30, LBM_ASTERISK); -} - void displayWarningBox() { lcdDrawSolidFilledRect(POPUP_X, POPUP_Y, POPUP_W, POPUP_H, TEXT_BGCOLOR); @@ -59,28 +51,15 @@ void displayMessageBox() // lcdDrawBitmap(POPUP_X+15, POPUP_Y+20, LBM_MESSAGE); } -void drawMessageBox(const char * title, const char * t, const char * last, uint8_t sound) +void drawAlertBox(const char * title, const char * text, const char * action) { - displayAlertBox(); - -#if defined(TRANSLATIONS_FR) || defined(TRANSLATIONS_IT) || defined(TRANSLATIONS_CZ) - lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y, STR_WARNING, ALARM_COLOR|DBLSIZE); - lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+25, title, ALARM_COLOR|DBLSIZE); -#else - lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y, title, ALARM_COLOR|DBLSIZE); - lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+25, STR_WARNING, ALARM_COLOR|DBLSIZE); -#endif - - if (t) lcdDrawText(WARNING_LINE_X, WARNING_INFOLINE_Y, t); - if (last) { - lcdDrawText(WARNING_LINE_X, WARNING_INFOLINE_Y+16, last); - AUDIO_ERROR_MESSAGE(sound); - } + theme->drawAlertBox(title, text, action); } -void message(const pm_char * title, const pm_char * t, const char * last, uint8_t sound) +void message(const pm_char * title, const pm_char * text, const char * action, uint8_t sound) { - drawMessageBox(title, t, last, sound); + drawAlertBox(title, text, action); + AUDIO_ERROR_MESSAGE(sound); lcdRefresh(); lcdSetContrast(); clearKeyEvents(); diff --git a/radio/src/gui/horus/theme.cpp b/radio/src/gui/horus/theme.cpp index 9d3cb7763..c3f5542bf 100644 --- a/radio/src/gui/horus/theme.cpp +++ b/radio/src/gui/horus/theme.cpp @@ -20,6 +20,34 @@ #include "opentx.h" +void Theme::drawBackground() const +{ + lcdDrawSolidFilledRect(0, 0, LCD_W, LCD_H, TEXT_BGCOLOR); +} + +void Theme::drawAlertBox(const char * title, const char * text, const char * action) const +{ + drawBackground(); + lcdDrawSolidFilledRect(0, POPUP_Y, LCD_W, POPUP_H, TEXT_INVERTED_COLOR | OPACITY(8)); + lcdDrawAlphaBitmap(POPUP_X-80, POPUP_Y+12, LBM_ASTERISK); + +#if defined(TRANSLATIONS_FR) || defined(TRANSLATIONS_IT) || defined(TRANSLATIONS_CZ) + lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y, STR_WARNING, ALARM_COLOR|DBLSIZE); + lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+28, title, ALARM_COLOR|DBLSIZE); +#else + lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y, title, ALARM_COLOR|DBLSIZE); + lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+28, STR_WARNING, ALARM_COLOR|DBLSIZE); +#endif + + if (text) { + lcdDrawText(WARNING_LINE_X, WARNING_INFOLINE_Y, text); + } + + if (action) { + lcdDrawText(WARNING_LINE_X, WARNING_INFOLINE_Y+16, action); + } +} + const Theme * registeredThemes[MAX_REGISTERED_THEMES]; // TODO dynamic unsigned int countRegisteredThemes = 0; void registerTheme(const Theme * theme) diff --git a/radio/src/gui/horus/theme.h b/radio/src/gui/horus/theme.h index ca8421bca..3af0f2c5a 100644 --- a/radio/src/gui/horus/theme.h +++ b/radio/src/gui/horus/theme.h @@ -48,10 +48,12 @@ class Theme virtual void load() const = 0; - virtual void drawBackground() const = 0; + virtual void drawBackground() const; virtual void drawTopbarBackground(const uint8_t * icon) const = 0; + virtual void drawAlertBox(const char * title, const char * text, const char * action) const; + protected: const char * name; const uint8_t * bitmap; diff --git a/radio/src/gui/horus/themes/darkblue.cpp b/radio/src/gui/horus/themes/darkblue.cpp index 583510c47..59a1ac679 100644 --- a/radio/src/gui/horus/themes/darkblue.cpp +++ b/radio/src/gui/horus/themes/darkblue.cpp @@ -61,11 +61,6 @@ class DarkblueTheme: public Theme lcdColorTable[OVERLAY_COLOR_INDEX] = BLACK; } - virtual void drawBackground() const - { - lcdDrawSolidFilledRect(0, 0, LCD_W, LCD_H, TEXT_BGCOLOR); - } - void drawTopbarBackground(const uint8_t * icon) const { lcdDrawSolidFilledRect(0, 0, LCD_W, MENU_HEADER_HEIGHT, HEADER_BGCOLOR); diff --git a/radio/src/gui/taranis/popups.cpp b/radio/src/gui/taranis/popups.cpp index 914a369a7..92893aa09 100644 --- a/radio/src/gui/taranis/popups.cpp +++ b/radio/src/gui/taranis/popups.cpp @@ -55,7 +55,7 @@ const pm_uchar asterisk_lbm[] PROGMEM = { #include "asterisk.lbm" }; -void drawMessageBox(const pm_char * title, const pm_char * t, const char * last, uint8_t sound) +void drawAlertBox(const char * title, const char * text, const char * action) { lcdClear(); lcdDrawBitmap(0, 0, asterisk_lbm); @@ -71,18 +71,22 @@ void drawMessageBox(const pm_char * title, const pm_char * t, const char * last, #endif lcdDrawFilledRect(MESSAGE_LCD_OFFSET, 0, LCD_W-MESSAGE_LCD_OFFSET, 32); - if (t) lcdDrawText(MESSAGE_LCD_OFFSET, 5*FH, t); - if (last) { - lcdDrawText(MESSAGE_LCD_OFFSET, 7*FH, last); - AUDIO_ERROR_MESSAGE(sound); + + if (text) { + lcdDrawText(MESSAGE_LCD_OFFSET, 5*FH, text); + } + + if (action) { + lcdDrawText(MESSAGE_LCD_OFFSET, 7*FH, action); } #undef MESSAGE_LCD_OFFSET } -void message(const pm_char * title, const pm_char * t, const char * last, uint8_t sound) +void message(const pm_char * title, const pm_char * text, const char * action, uint8_t sound) { - drawMessageBox(title, t, last, sound); + drawAlertBox(title, text, action); + AUDIO_ERROR_MESSAGE(sound); lcdRefresh(); lcdSetContrast(); clearKeyEvents(); diff --git a/radio/src/lua/interface.cpp b/radio/src/lua/interface.cpp index 2cf8a8c42..bb7537627 100644 --- a/radio/src/lua/interface.cpp +++ b/radio/src/lua/interface.cpp @@ -814,7 +814,8 @@ class LuaTheme: public Theme Theme(name, bitmap), loadFunction(0), drawBackgroundFunction(0), - drawTopbarBackgroundFunction(0) + drawTopbarBackgroundFunction(0), + drawAlertBoxFunction(0) { } @@ -845,10 +846,18 @@ class LuaTheme: public Theme exec(drawTopbarBackgroundFunction); } +#if 0 + virtual void drawAlertBox(const char * title, const char * text, const char * action) const + { + exec(drawAlertBoxFunction); + } +#endif + protected: int loadFunction; int drawBackgroundFunction; int drawTopbarBackgroundFunction; + int drawAlertBoxFunction; }; int luaLoadTheme(const char * filename) diff --git a/radio/src/opentx.h b/radio/src/opentx.h index f16a3a1a8..15185ada8 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -674,9 +674,9 @@ uint16_t evalChkSum(); // TODO these functions in gui directories #if defined(COLORLCD) || defined(PCBTARANIS) -void drawMessageBox(const pm_char * title, const pm_char * t, const char * last, uint8_t sound); +void drawAlertBox(const char * title, const char * text, const char * action); #endif -void message(const pm_char * title, const pm_char * s, const char * last MESSAGE_SOUND_ARG); +void message(const pm_char * title, const pm_char * text, const char * action MESSAGE_SOUND_ARG); void alert(const pm_char * t, const pm_char * s MESSAGE_SOUND_ARG); enum PerOutMode { diff --git a/radio/src/switches.cpp b/radio/src/switches.cpp index ca8fcc647..b33b3fe78 100644 --- a/radio/src/switches.cpp +++ b/radio/src/switches.cpp @@ -831,7 +831,10 @@ void checkSwitches() // first - display warning #if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) if ((last_bad_switches != switches_states) || (last_bad_pots != bad_pots)) { - drawMessageBox(STR_SWITCHWARN, NULL, STR_PRESSANYKEYTOSKIP, ((last_bad_switches == 0xff) || (last_bad_pots == 0xff)) ? AU_SWITCH_ALERT : AU_NONE); + drawAlertBox(STR_SWITCHWARN, NULL, STR_PRESSANYKEYTOSKIP); + if (last_bad_switches == 0xff || last_bad_pots == 0xff) { + AUDIO_ERROR_MESSAGE(AU_SWITCH_ALERT); + } int x = SWITCH_WARNING_LIST_X, y = SWITCH_WARNING_LIST_Y; int numWarnings = 0; for (int i=0; i