From b5f66182387c7e0e9aa2d8c828db0b91008f05c6 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Tue, 1 Mar 2016 23:47:11 +0100 Subject: [PATCH] [Horus] UI continued --- radio/sdcard/horus/THEMES/TBS/thumb.bmp | Bin 0 -> 6462 bytes radio/src/CMakeLists.txt | 78 +++++++++++++++-------- radio/src/cli.cpp | 14 ++-- radio/src/gui/horus/bitmapbuffer.h | 12 ++++ radio/src/gui/horus/curves.cpp | 2 +- radio/src/gui/horus/gui.h | 17 +++-- radio/src/gui/horus/lcd.cpp | 9 --- radio/src/gui/horus/lcd.h | 57 +++++++++-------- radio/src/gui/horus/menu_model_setup.cpp | 4 +- radio/src/gui/horus/popups.cpp | 7 +- radio/src/gui/horus/theme.cpp | 40 +++++++----- radio/src/gui/horus/theme.h | 10 ++- radio/src/gui/horus/themes/default.cpp | 16 ++++- radio/src/gui/horus/topbar.cpp | 20 +++++- radio/src/gui/horus/widgets.cpp | 23 +------ radio/src/gui/horus/widgets/outputs.cpp | 61 ++++++++++++++++++ radio/src/opentx.cpp | 2 + radio/src/translations/en.h.txt | 7 -- 18 files changed, 241 insertions(+), 138 deletions(-) create mode 100644 radio/sdcard/horus/THEMES/TBS/thumb.bmp create mode 100644 radio/src/gui/horus/widgets/outputs.cpp diff --git a/radio/sdcard/horus/THEMES/TBS/thumb.bmp b/radio/sdcard/horus/THEMES/TBS/thumb.bmp new file mode 100644 index 0000000000000000000000000000000000000000..89a1bc66454e19c12fa5c042eefd1889911e7bce GIT binary patch literal 6462 zcmeHJzpo)t6dqP6C?rIvb~_}Z5h5fTd5!8NBB4;}P;Vg-e}HVG6qQmT5)z4$Qt^TW z4MIdTI>c|u*_pe0WoFC_JNve~H}0Hq&UeoD&7CuM=I#Bvg+k*eeazC+MbEGFR8Zfj zFSKo#DaxSzJ?X!A07cz@)LSt80|#EUN*<7|##AJetO4l((gUOiNDq)6AUz=51Mp`^ ztq;avd%a#^wOT=?QUQ<0!}->5xm=LX=b_*4!+yVq^Z5+RFvN_urh0>15a7WB5ImNF)UHDV0jF+wG7_rC>Ij zp)!R+K@iL4lY7qBDO3kz_;xy-LOdRS&=v>;pkA-TZnxv4bh}+J7z_`1Ax=3yOeU3! zF>K2`BgJA7^m;uR)_ulGPmFJI@Y7-p|!#%8nOT+8uzM1GUW#PJK&{cIm1rVmne`55NDWHK4# zUa!}j+`(Xg{LN+)oK7b&`-IVGgh(U;tyYVJmEwFB!_hFYx#%)5knH_qpCD3wa!^Z6dIn1fj1 U?`5(sWL-!PkRBjC@TooU3zN1v7ytkO literal 0 HcmV?d00001 diff --git a/radio/src/CMakeLists.txt b/radio/src/CMakeLists.txt index 7678c30cc..969256fcf 100644 --- a/radio/src/CMakeLists.txt +++ b/radio/src/CMakeLists.txt @@ -48,6 +48,12 @@ set(9X_GUI_SRC menu_general_diaganas.cpp ) +set(FATFS_SRC + ${FATFS_DIR}/ff.c + ${FATFS_DIR}/fattime.c + ${FATFS_DIR}/option/ccsbcs.c +) + if(PCB STREQUAL HORUS) set(CPU_TYPE STM32F4) set(HSE_VALUE 12000000) @@ -240,7 +246,6 @@ elseif(PCB STREQUAL SKY9X OR PCB STREQUAL 9XRPRO OR PCB STREQUAL AR9X) set(FIRMWARE_SRC ${FIRMWARE_SRC} loadboot.cpp) elseif(PCB STREQUAL 9X OR PCB STREQUAL 9XR OR PCB STREQUAL 9X128 OR PCB STREQUAL 9XR128) option(SP22 "SmartieParts 2.2 Backlight support" OFF) - option(HAPTIC "Haptic support" OFF) option(PWM_BACKLIGHT "PWM Backlight" OFF) set(ARCH AVR) set(MCU atmega64) @@ -253,16 +258,13 @@ elseif(PCB STREQUAL 9X OR PCB STREQUAL 9XR OR PCB STREQUAL 9X128 OR PCB STREQUAL add_definitions(-DPCBSTD -DPCB${PCB} -DCPUM64) set(TARGET_SRC ${TARGET_SRC} board_stock.cpp) set(GUI_SRC ${GUI_SRC} ${9X_GUI_SRC}) - if(HAPTIC) - add_definitions(-DHAPTIC) - set(SRC ${SRC} haptic.cpp) - endif() if(SP22) add_definitions(-DSP22) endif() if(PWM_BACKLIGHT) add_definitions(-DPWM_BACKLIGHT) endif() + set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} lcd_driver.cpp) elseif(PCB STREQUAL 9X2561) set(ARCH AVR) set(MCU atmega2561) @@ -275,29 +277,44 @@ elseif(PCB STREQUAL 9X2561) add_definitions(-DPCBSTD -DPCB${PCB} -DCPUM2561) set(TARGET_SRC ${TARGET_SRC} board_stock.cpp) set(GUI_SRC ${GUI_SRC} ${9X_GUI_SRC}) - if(HAPTIC) - add_definitions(-DHAPTIC) - set(SRC ${SRC} haptic.cpp) - endif() if(SP22) add_definitions(-DSP22) endif() if(PWM_BACKLIGHT) add_definitions(-DPWM_BACKLIGHT) endif() + set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} lcd_driver.cpp) elseif(PCB STREQUAL GRUVIN9X) - set(ARCH AVR) - set(MCU atmega2560) - string(TOLOWER ${PCB} FLAVOUR) - set(EEPROM EEPROM_RLC) - add_definitions(-DEEPROM_VARIANT=0) - set(GUI_DIR 9x) - set(TARGET_DIR gruvin9x) - set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} 9x_bitmaps) - add_definitions(-DPCB${PCB} -DCPUM2560) - set(TARGET_SRC ${TARGET_SRC} board_gruvin9x.cpp) - set(GUI_SRC ${GUI_SRC} ${9X_GUI_SRC}) -elseif(PCB STREQUAL MEGA2560) + set(ARCH AVR) + set(MCU atmega2560) + string(TOLOWER ${PCB} FLAVOUR) + set(EEPROM EEPROM_RLC) + add_definitions(-DEEPROM_VARIANT=0) + set(GUI_DIR 9x) + set(TARGET_DIR gruvin9x) + set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} 9x_bitmaps) + add_definitions(-DPCB${PCB} -DCPUM2560 -DROTARY_ENCODERS=2) + set(TARGET_SRC ${TARGET_SRC} board_gruvin9x.cpp) + set(GUI_SRC ${GUI_SRC} ${9X_GUI_SRC}) + set(FIRMWARE_SRC ${FIRMWARE_SRC} targets/9x/lcd_driver.cpp) +elseif(PCB STREQUAL MEGA2560) + option(PWRMANAGE "Pwr Manage" OFF) + option(SDCARD "SD card support" ON) + set(ARCH AVR) + set(MCU atmega2560) + string(TOLOWER ${PCB} FLAVOUR) + set(EEPROM EEPROM_RLC) + add_definitions(-DEEPROM_VARIANT=0) + set(GUI_DIR 9x) + set(TARGET_DIR mega2560) + set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} 9x_bitmaps) + add_definitions(-DPCB${PCB} -DCPUM2560 -DROTARY_ENCODERS=2) + set(TARGET_SRC ${TARGET_SRC} board_mega2560.cpp) + set(GUI_SRC ${GUI_SRC} ${9X_GUI_SRC}) + set(FIRMWARE_SRC ${FIRMWARE_SRC} targets/9x/lcd_driver.cpp) + if(PWRMANAGE) + add_definitions(-DPWRMANAGE) + endif() else() message(FATAL_ERROR "Unknown PCB '${PCB}'") endif() @@ -501,9 +518,6 @@ if(ARCH STREQUAL ARM) ) set(FIRMWARE_SRC ${FIRMWARE_SRC} - ${FATFS_DIR}/ff.c - ${FATFS_DIR}/fattime.c - ${FATFS_DIR}/option/ccsbcs.c ${COOS_DIR}/kernel/core.c ${COOS_DIR}/kernel/hook.c ${COOS_DIR}/kernel/task.c @@ -530,10 +544,15 @@ else() option(GRAPHICS "Additional graphics" ON) option(BOLD "Bold font" ON) option(BATTGRAPH "Battery graph" OFF) + option(HAPTIC "Haptic support" OFF) + set(LCD "DEFAULT" CACHE STRING "LCD type (DEFAULT/ST7565P/ST7565R/ERC12864FSF/ST7920)") set(PULSES_SRC pulses_avr.cpp) set(SRC ${SRC} main_avr.cpp) - set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} lcd_driver.cpp) set(FIRMWARE_SRC ${FIRMWARE_SRC} targets/common_avr/adc_driver.cpp) + add_definitions(-DLCD_${LCD}) + if(SDCARD) + set(FIRMWARE_SRC ${FIRMWARE_SRC} targets/gruvin9x/diskio.cpp) + endif() if(AUDIO) add_definitions(-DAUDIO) set(SRC ${SRC} audio_avr.cpp) @@ -558,6 +577,10 @@ else() if(BATTGRAPH) add_definitions(-DBATTGRAPH) endif() + if(HAPTIC) + add_definitions(-DHAPTIC) + set(SRC ${SRC} haptic.cpp) + endif() if(${EXT} STREQUAL OFF) add_definitions(-DEXTSTD) elseif(EXT STREQUAL ARDUPILOT) @@ -670,6 +693,7 @@ set(GUI_SRC if(VIRTUAL_INPUTS) add_definitions(-DVIRTUALINPUTS) + set(TEMPLATES OFF) else() option(TEMPLATES "Model Templates Menu" ON) endif() @@ -718,6 +742,10 @@ if(GVARS) math(EXPR EEPROM_VARIANT ${EEPROM_VARIANT}+${GVARS_VARIANT}) endif() +if(SDCARD) + set(FIRMWARE_SRC ${FIRMWARE_SRC} ${FATFS_SRC}) +endif() + if(FAI STREQUAL YES) add_definitions(-DFAI) elseif(FAI STREQUAL CHOICE) diff --git a/radio/src/cli.cpp b/radio/src/cli.cpp index af83258cd..cbbf43aa1 100644 --- a/radio/src/cli.cpp +++ b/radio/src/cli.cpp @@ -138,9 +138,9 @@ int cliRead(const char ** argv) { FIL file; uint32_t bytesRead = 0; - int bufferSize; + int bufferSize; if (toInt(argv, 2, &bufferSize) == 0 || bufferSize < 0 ) { - serialPrint("%s: Invalid buffer size \"%s\"", argv[0], argv[2]); + serialPrint("%s: Invalid buffer size \"%s\"", argv[0], argv[2]); return 0; } @@ -180,16 +180,16 @@ int cliReadSD(const char ** argv) int numberOfSectors; int bufferSectors; if (toInt(argv, 1, &startSector) == 0 || startSector < 0 ) { - serialPrint("%s: Invalid start sector \"%s\"", argv[0], argv[1]); + serialPrint("%s: Invalid start sector \"%s\"", argv[0], argv[1]); return 0; } if (toInt(argv, 2, &numberOfSectors) == 0 || numberOfSectors < 0 ) { - serialPrint("%s: Invalid number of sectors \"%s\"", argv[0], argv[2]); + serialPrint("%s: Invalid number of sectors \"%s\"", argv[0], argv[2]); return 0; } if (toInt(argv, 3, &bufferSectors) == 0 || bufferSectors < 0 ) { - serialPrint("%s: Invalid number of buffrer sectors \"%s\"", argv[0], argv[3]); + serialPrint("%s: Invalid number of buffrer sectors \"%s\"", argv[0], argv[3]); return 0; } @@ -271,7 +271,9 @@ int cliMemoryInfo(const char ** argv) int cliReboot(const char ** argv) { +#if !defined(SIMU) NVIC_SystemReset(); +#endif return 0; } @@ -453,7 +455,7 @@ int cliDisplay(const char ** argv) int cliDebugVars(const char ** argv) { -#if defined(PCBHORUS) +#if defined(PCBHORUS) && !defined(SIMU) extern uint32_t ioMutexReq, ioMutexRel; extern uint32_t sdReadRetries; diff --git a/radio/src/gui/horus/bitmapbuffer.h b/radio/src/gui/horus/bitmapbuffer.h index b18b980eb..a24d839a7 100644 --- a/radio/src/gui/horus/bitmapbuffer.h +++ b/radio/src/gui/horus/bitmapbuffer.h @@ -143,8 +143,20 @@ class BitmapBuffer: public BitmapBufferBase void drawVerticalLine(coord_t x, coord_t y, coord_t h, uint8_t pat, LcdFlags att); + inline void drawSolidHorizontalLine(coord_t x, coord_t y, coord_t w, LcdFlags att) + { + drawSolidFilledRect(x, y, w, 1, att); + } + + inline void drawSolidVerticalLine(coord_t x, coord_t y, coord_t h, LcdFlags att) + { + drawSolidFilledRect(x, y, 1, h, att); + } + inline void drawSolidFilledRect(coord_t x, coord_t y, coord_t w, coord_t h, LcdFlags flags) { + if (h==0 || w==0) return; + if (h<0) { y+=h; h=-h; } DMAFillRect(data, width, x, y, w, h, lcdColorTable[COLOR_IDX(flags)]); } diff --git a/radio/src/gui/horus/curves.cpp b/radio/src/gui/horus/curves.cpp index 2be86be34..7e77fde34 100644 --- a/radio/src/gui/horus/curves.cpp +++ b/radio/src/gui/horus/curves.cpp @@ -82,7 +82,7 @@ void drawCurveHorizontalScale() void drawCurveCoord(int x, int y, const char * text, bool active) { - lcdDrawSolidFilledRect(x, y, CURVE_COORD_WIDTH, CURVE_COORD_HEIGHT, CURVE_CURSOR_COLOR); + lcd->drawSolidFilledRect(x, y, CURVE_COORD_WIDTH, CURVE_COORD_HEIGHT, CURVE_CURSOR_COLOR); lcdDrawText(x+3+(CURVE_COORD_WIDTH-1-getTextWidth(text, SMLSIZE))/2, y+1, text, LEFT|SMLSIZE|TEXT_BGCOLOR); if (active) { lcdDrawBitmapPattern(x, y, LBM_CURVE_COORD_SHADOW, TEXT_COLOR); diff --git a/radio/src/gui/horus/gui.h b/radio/src/gui/horus/gui.h index 828c78fa7..49893fbbf 100644 --- a/radio/src/gui/horus/gui.h +++ b/radio/src/gui/horus/gui.h @@ -27,20 +27,19 @@ #define MENU_HEADER_HEIGHT 45 #define MENU_TITLE_TOP 48 #define MENU_TITLE_HEIGHT 21 -#define MENU_BODY_TOP 69 // MENU_TITLE_TOP + MENU_TITLE_HEIGHT -#define MENU_CONTENT_TOP 72 -#define MENU_BODY_HEIGHT 182 -#define MENU_FOOTER_TOP 251 // MENU_BODY_TOP + MENU_BODY_HEIGHT +#define MENU_BODY_TOP (MENU_TITLE_TOP+MENU_TITLE_HEIGHT) +#define MENU_CONTENT_TOP (MENU_BODY_TOP+3) #define MENU_FOOTER_HEIGHT 21 - +#define MENU_FOOTER_TOP (LCD_H-MENU_FOOTER_HEIGHT) +#define MENU_BODY_HEIGHT (MENU_FOOTER_TOP-MENU_BODY_TOP) #define MENUS_MARGIN_LEFT 6 #define DEFAULT_SCROLLBAR_X LCD_W-10 #define DEFAULT_SCROLLBAR_Y MENU_CONTENT_TOP #define DEFAULT_SCROLLBAR_H (MENU_FOOTER_TOP - DEFAULT_SCROLLBAR_Y - 6) -#define NUM_BODY_LINES 9 #define FH 20 +#define NUM_BODY_LINES (MENU_BODY_HEIGHT / FH) #define INVERT_HORZ_MARGIN 3 #define INVERT_VERT_MARGIN 1 @@ -52,13 +51,17 @@ #define CURVE_COORD_WIDTH 36 #define CURVE_COORD_HEIGHT 17 +#define DATETIME_SEPARATOR_X (LCD_W-55) +#define DATETIME_LINE1 9 +#define DATETIME_LINE2 23 +#define DATETIME_MIDDLE (LCD_W+DATETIME_SEPARATOR_X+8)/2 + #define MENU_TITLE_NEXT_POS (lcdNextPos + 10) #define MENU_INIT_VPOS -1 #define MENU_ICONS_SPACING 31 #define SUBMENU_LINE_WIDTH 230 -#define BITMAP_BUFFER_SIZE(w, h) (4 + (w)*(h)*3) #define LOAD_MODEL_BITMAP() #if defined(FLIGHT_MODES) diff --git a/radio/src/gui/horus/lcd.cpp b/radio/src/gui/horus/lcd.cpp index 8ecfb62d4..0f641e18f 100644 --- a/radio/src/gui/horus/lcd.cpp +++ b/radio/src/gui/horus/lcd.cpp @@ -234,15 +234,6 @@ void lcdDrawRect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t thickness, } } -#if defined(SIMU) -void lcdDrawSolidFilledRect(coord_t x, coord_t y, coord_t w, coord_t h, LcdFlags att) -{ - for (coord_t i=y; idrawSolidHorizontalLine(x, y, w, att); +} + +inline void lcdDrawSolidVerticalLine(coord_t x, coord_t y, coord_t h, LcdFlags att) +{ + lcd->drawSolidVerticalLine(x, y, h, att); +} + +inline void lcdDrawSolidFilledRect(coord_t x, coord_t y, coord_t w, coord_t h, LcdFlags flags) +{ + lcd->drawSolidFilledRect(x, y, w, h, flags); +} + inline void lcdDrawHorizontalLine(coord_t x, coord_t y, coord_t w, uint8_t pat, LcdFlags att=0) { lcd->drawHorizontalLine(x, y, w, pat, att); @@ -154,37 +175,17 @@ inline void lcdDrawAlphaPixel(coord_t x, coord_t y, uint8_t opacity, uint16_t co lcdDrawAlphaPixel(p, opacity, color); } -#if !defined(SIMU) -inline void lcdDrawSolidFilledRect(coord_t x, coord_t y, coord_t w, coord_t h, LcdFlags flags) -{ - DMAFillRect(lcd->getData(), LCD_W, x, y, w, h, lcdColorTable[COLOR_IDX(flags)]); -} -#else -void lcdDrawSolidFilledRect(coord_t x, coord_t y, coord_t w, coord_t h, LcdFlags flags); -#endif - inline void lcdSetColor(uint16_t color) { lcdColorTable[CUSTOM_COLOR_INDEX] = color; } -inline void lcdDrawSolidHorizontalLine(coord_t x, coord_t y, coord_t w, LcdFlags att) -{ - lcdDrawSolidFilledRect(x, y, w, 1, att); -} - -inline void lcdDrawSolidVerticalLine(coord_t x, coord_t y, coord_t h, LcdFlags att) -{ - if (h<0) { y+=h; h=-h; } - lcdDrawSolidFilledRect(x, y, 1, h, att); -} - inline void lcdDrawSolidRect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t thickness=1, LcdFlags att=0) { - lcdDrawSolidFilledRect(x, y, thickness, h, att); - lcdDrawSolidFilledRect(x+w-thickness, y, thickness, h, att); - lcdDrawSolidFilledRect(x, y, w, thickness, att); - lcdDrawSolidFilledRect(x, y+h-thickness, w, thickness, att); + lcd->drawSolidFilledRect(x, y, thickness, h, att); + lcd->drawSolidFilledRect(x+w-thickness, y, thickness, h, att); + lcd->drawSolidFilledRect(x, y, w, thickness, att); + lcd->drawSolidFilledRect(x, y+h-thickness, w, thickness, att); } inline void lcdDrawFilledRect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t pat, LcdFlags att=0) diff --git a/radio/src/gui/horus/menu_model_setup.cpp b/radio/src/gui/horus/menu_model_setup.cpp index c6b9a773c..a79a0e1bb 100644 --- a/radio/src/gui/horus/menu_model_setup.cpp +++ b/radio/src/gui/horus/menu_model_setup.cpp @@ -18,7 +18,7 @@ * GNU General Public License for more details. */ -#include "../../opentx.h" +#include "opentx.h" uint8_t g_moduleIdx; bool menuModelFailsafe(evt_t event); @@ -699,7 +699,7 @@ bool menuModelSetup(evt_t event) } if (IS_RANGECHECK_ENABLE()) { - theme->drawMessageBox("RSSI :", NULL, NULL, 0); + theme->drawMessageBox("RSSI :", NULL, NULL, WARNING_TYPE_INFO); lcdDrawNumber(WARNING_LINE_X, WARNING_INFOLINE_Y, TELEMETRY_RSSI(), DBLSIZE|LEFT); } diff --git a/radio/src/gui/horus/popups.cpp b/radio/src/gui/horus/popups.cpp index 4b0a4d664..67982f246 100644 --- a/radio/src/gui/horus/popups.cpp +++ b/radio/src/gui/horus/popups.cpp @@ -55,7 +55,7 @@ void displayMessageBox() void drawAlertBox(const char * title, const char * text, const char * action) { - theme->drawMessageBox(title, text, action, MESSAGEBOX_TYPE_ALERT); + theme->drawMessageBox(title, text, action, WARNING_TYPE_ALERT); } void message(const pm_char * title, const pm_char * text, const char * action, uint8_t sound) @@ -78,10 +78,7 @@ void displayWarning(evt_t event) { warningResult = false; - if (warningType == WARNING_TYPE_INPUT) - theme->drawMessageBox(warningText, "", "", MESSAGEBOX_TYPE_INFO); - else - theme->drawMessageBox(warningText, "", "", MESSAGEBOX_TYPE_WARNING); + theme->drawMessageBox(warningText, "", "", warningType); if (warningInfoText) { lcdDrawSizedText(WARNING_LINE_X, WARNING_INFOLINE_Y, warningInfoText, warningInfoLength, WARNING_INFO_FLAGS); diff --git a/radio/src/gui/horus/theme.cpp b/radio/src/gui/horus/theme.cpp index 8cc97fa6f..f3ca54970 100644 --- a/radio/src/gui/horus/theme.cpp +++ b/radio/src/gui/horus/theme.cpp @@ -20,6 +20,10 @@ #include "opentx.h" +const BitmapBuffer * Theme::asterisk = NULL; +const BitmapBuffer * Theme::question = NULL; +const BitmapBuffer * Theme::busy = NULL; + void Theme::init() const { memset(&g_eeGeneral.themeData, 0, sizeof(Theme::PersistentData)); @@ -32,6 +36,13 @@ void Theme::init() const } } +void Theme::load() const +{ + if (!asterisk) asterisk = BitmapBuffer::load(getThemePath("asterisk.bmp")); + if (!question) question = BitmapBuffer::load(getThemePath("question.bmp")); + if (!busy) busy = BitmapBuffer::load(getThemePath("busy.bmp")); +} + ZoneOptionValue * Theme::getOptionValue(unsigned int index) const { return &g_eeGeneral.themeData.options[index]; @@ -70,40 +81,39 @@ void Theme::drawAboutBackground() const drawBackground(); } -void Theme::drawMessageBox(const char * title, const char * text, const char * action, uint32_t flags) const +void Theme::drawMessageBox(const char * title, const char * text, const char * action, uint32_t type) const { - static const BitmapBuffer * asterisk = BitmapBuffer::load(getThemePath("asterisk.bmp")); - //if (flags & MESSAGEBOX_TYPE_ALERT) { drawBackground(); lcdDrawFilledRect(0, POPUP_Y, LCD_W, POPUP_H, SOLID, TEXT_INVERTED_COLOR | OPACITY(8)); //} - if ((flags & MESSAGEBOX_TYPE_ALERT) || (flags & MESSAGEBOX_TYPE_WARNING)) { + if (type == WARNING_TYPE_ALERT || type == WARNING_TYPE_ASTERISK) lcd->drawBitmap(POPUP_X-80, POPUP_Y+12, asterisk); - } - else { - lcd->drawBitmap(POPUP_X-80, POPUP_Y+12, asterisk); - } + else if (type == WARNING_TYPE_INFO) + lcd->drawBitmap(POPUP_X-80, POPUP_Y+12, busy); + else + lcd->drawBitmap(POPUP_X-80, POPUP_Y+12, question); + if (type == WARNING_TYPE_ALERT) { #if defined(TRANSLATIONS_FR) || defined(TRANSLATIONS_IT) || defined(TRANSLATIONS_CZ) - if ((flags & MESSAGEBOX_TYPE_ALERT) || (flags & MESSAGEBOX_TYPE_WARNING)) { lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y, STR_WARNING, ALARM_COLOR|DBLSIZE); - } - lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+28, title, 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); - if ((flags & MESSAGEBOX_TYPE_ALERT) || (flags & MESSAGEBOX_TYPE_WARNING)) { + 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 + } + else if (title) { + lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y, title, ALARM_COLOR|DBLSIZE); + } if (text) { lcdDrawText(WARNING_LINE_X, WARNING_INFOLINE_Y, text); } if (action) { - lcdDrawText(WARNING_LINE_X, WARNING_INFOLINE_Y+16, action); + lcdDrawText(WARNING_LINE_X, WARNING_INFOLINE_Y+20, action); } } diff --git a/radio/src/gui/horus/theme.h b/radio/src/gui/horus/theme.h index f80ea8960..78e82c763 100644 --- a/radio/src/gui/horus/theme.h +++ b/radio/src/gui/horus/theme.h @@ -28,11 +28,6 @@ class Theme; void registerTheme(Theme * theme); -#define MESSAGEBOX_TYPE_INFO 0 -#define MESSAGEBOX_TYPE_QUESTION 1 -#define MESSAGEBOX_TYPE_WARNING 2 -#define MESSAGEBOX_TYPE_ALERT 4 - class Theme { public: @@ -66,7 +61,7 @@ class Theme ZoneOptionValue * getOptionValue(unsigned int index) const; - virtual void load() const = 0; + virtual void load() const; virtual void drawBackground() const; @@ -80,6 +75,9 @@ class Theme const char * name; const ZoneOption * options; BitmapBuffer * thumb; + static const BitmapBuffer * asterisk; + static const BitmapBuffer * question; + static const BitmapBuffer * busy; }; extern Theme * theme; diff --git a/radio/src/gui/horus/themes/default.cpp b/radio/src/gui/horus/themes/default.cpp index 01b353f68..5667e8887 100644 --- a/radio/src/gui/horus/themes/default.cpp +++ b/radio/src/gui/horus/themes/default.cpp @@ -64,11 +64,15 @@ class DefaultTheme: public Theme lcdColorTable[HEADER_ICON_BGCOLOR_INDEX] = RED; lcdColorTable[HEADER_CURRENT_BGCOLOR_INDEX] = RED; lcdColorTable[OVERLAY_COLOR_INDEX] = BLACK; + + Theme::load(); + + if (!backgroundBitmap) backgroundBitmap = BitmapBuffer::load(getThemePath("mainbg.bmp")); + if (!aboutBackgroundBitmap) aboutBackgroundBitmap = BitmapBuffer::load(getThemePath("aboutbg.bmp")); } virtual void drawBackground() const { - static BitmapBuffer * backgroundBitmap = BitmapBuffer::load(getThemePath("mainbg.bmp")); if (backgroundBitmap) { lcd->drawBitmap(0, 0, backgroundBitmap); } @@ -80,8 +84,7 @@ class DefaultTheme: public Theme virtual void drawAboutBackground() const { - static BitmapBuffer * backgroundBitmap = BitmapBuffer::load(getThemePath("aboutbg.bmp")); - lcd->drawBitmap(0, 0, backgroundBitmap); + lcd->drawBitmap(0, 0, aboutBackgroundBitmap); } virtual void drawTopbarBackground(const uint8_t * icon) const @@ -98,7 +101,14 @@ class DefaultTheme: public Theme drawTopbarDatetime(); } + + protected: + static const BitmapBuffer * backgroundBitmap; + static const BitmapBuffer * aboutBackgroundBitmap; }; +const BitmapBuffer * DefaultTheme::backgroundBitmap = NULL; +const BitmapBuffer * DefaultTheme::aboutBackgroundBitmap = NULL; + DefaultTheme defaultTheme; Theme * theme = &defaultTheme; diff --git a/radio/src/gui/horus/topbar.cpp b/radio/src/gui/horus/topbar.cpp index 4a4519106..073c8479e 100644 --- a/radio/src/gui/horus/topbar.cpp +++ b/radio/src/gui/horus/topbar.cpp @@ -35,13 +35,29 @@ Zone Topbar::getZone(unsigned int index) const return zone; } +const char * const STR_MONTHS[] = { "Jan", "Fev", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; + +void drawTopbarDatetime() +{ + lcd->drawSolidVerticalLine(DATETIME_SEPARATOR_X, 7, 31, TEXT_INVERTED_COLOR); + + struct gtm t; + gettime(&t); + char str[10]; + sprintf(str, "%d %s", t.tm_mday, STR_MONTHS[t.tm_mon]); + lcdDrawText(DATETIME_MIDDLE, DATETIME_LINE1, str, SMLSIZE|TEXT_INVERTED_COLOR|CENTERED); + + getTimerString(str, getValue(MIXSRC_TX_TIME)); + lcdDrawText(DATETIME_MIDDLE, DATETIME_LINE2, str, SMLSIZE|TEXT_INVERTED_COLOR|CENTERED); +} + void drawTopBar() { theme->drawTopbarBackground(NULL); // USB icon if (usbPlugged()) { - lcdDrawBitmapPattern(378, 8, LBM_TOPMENU_USB, MENU_TITLE_COLOR); + lcdDrawBitmapPattern(LCD_W-102, 8, LBM_TOPMENU_USB, MENU_TITLE_COLOR); } // RSSI @@ -49,7 +65,7 @@ void drawTopBar() const uint8_t rssiBarsHeight[] = {5, 10, 15, 21, 31}; for (unsigned int i = 0; i < DIM(rssiBarsHeight); i++) { uint8_t height = rssiBarsHeight[i]; - lcdDrawSolidFilledRect(390 + i * 6, 38 - height, 4, height, TELEMETRY_RSSI() >= rssiBarsValue[i] ? MENU_TITLE_COLOR : MENU_TITLE_DISABLE_COLOR); + lcdDrawSolidFilledRect(LCD_W-90 + i * 6, 38 - height, 4, height, TELEMETRY_RSSI() >= rssiBarsValue[i] ? MENU_TITLE_COLOR : MENU_TITLE_DISABLE_COLOR); } topbar->refresh(); diff --git a/radio/src/gui/horus/widgets.cpp b/radio/src/gui/horus/widgets.cpp index be6b251b4..5724feb9a 100644 --- a/radio/src/gui/horus/widgets.cpp +++ b/radio/src/gui/horus/widgets.cpp @@ -26,27 +26,6 @@ void drawColumnHeader(const char * const * headers, uint8_t index) // TODO ? displayHeader(headers[index]); } -const char * const STR_MONTHS[] = { "Jan", "Fev", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; - -#define DATETIME_SEPARATOR_X 425 -#define DATETIME_LINE1 9 -#define DATETIME_LINE2 23 -#define DATETIME_MIDDLE (LCD_W+DATETIME_SEPARATOR_X+8)/2 - -void drawTopbarDatetime() -{ - lcdDrawSolidVerticalLine(DATETIME_SEPARATOR_X, 7, 31, TEXT_INVERTED_COLOR); - - struct gtm t; - gettime(&t); - char str[10]; - sprintf(str, "%d %s", t.tm_mday, STR_MONTHS[t.tm_mon]); - lcdDrawText(DATETIME_MIDDLE, DATETIME_LINE1, str, SMLSIZE|TEXT_INVERTED_COLOR|CENTERED); - - getTimerString(str, getValue(MIXSRC_TX_TIME)); - lcdDrawText(DATETIME_MIDDLE, DATETIME_LINE2, str, SMLSIZE|TEXT_INVERTED_COLOR|CENTERED); -} - #include "alpha_stick_background.lbm" #include "alpha_stick_pointer.lbm" #define STICK_PANEL_WIDTH 68 @@ -61,7 +40,7 @@ void drawStick(coord_t x, coord_t y, int16_t xval, int16_t yval) void drawButton(coord_t x, coord_t y, const char * label, LcdFlags attr) { - int width = getTextWidth(label, 0, attr); + int width = getTextWidth(label, 0, 0); int padding = 0; if (attr & (BUTTON_OFF|BUTTON_ON)) { padding = 5; diff --git a/radio/src/gui/horus/widgets/outputs.cpp b/radio/src/gui/horus/widgets/outputs.cpp new file mode 100644 index 000000000..6ba6e53f5 --- /dev/null +++ b/radio/src/gui/horus/widgets/outputs.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include "opentx.h" + +class OutputsWidget: public Widget +{ + public: + OutputsWidget(const WidgetFactory * factory, const Zone & zone, Widget::PersistentData * persistentData): + Widget(factory, zone, persistentData) + { + } + + virtual void refresh(); + + static const ZoneOption options[]; +}; + +const ZoneOption OutputsWidget::options[] = { + { "Min", ZoneOption::Integer, OPTION_DEFAULT_VALUE({ .unsignedValue = 0 }) }, + { "Max", ZoneOption::Integer, OPTION_DEFAULT_VALUE({ .unsignedValue = 7 }) }, + { "Color", ZoneOption::Color, OPTION_DEFAULT_VALUE({ .unsignedValue = RED }) }, + { NULL, ZoneOption::Bool } +}; + +void OutputsWidget::refresh() +{ + int firstChannel = MIXSRC_CH1 + persistentData->options[0].unsignedValue; + int lastChannel = MIXSRC_CH1 + persistentData->options[1].unsignedValue; + uint16_t color = persistentData->options[2].unsignedValue; + + lcdSetColor(color); + lcd->drawSolidHorizontalLine(zone.x, zone.y+zone.h/2, zone.w, CUSTOM_COLOR); + + int count = lastChannel - firstChannel + 1; + + for (int ch=firstChannel, i=0; ch<=lastChannel; ch++, i++) { + int32_t value = limit(-RESX, getValue(ch), RESX); + int h = divRoundClosest((zone.h-1)/2 * value, RESX); + lcdDrawSolidFilledRect(zone.x+(zone.w*i)/count, zone.y + zone.h/2, zone.w/count-1, -h, CUSTOM_COLOR); + } +} + +BaseWidgetFactory outputsWidget("Outputs", OutputsWidget::options); diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index a9b440902..09c66d141 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1045,7 +1045,9 @@ void doSplash() #endif if (SPLASH_NEEDED()) { +#if !defined(PCBTARANIS) && !defined(PCBHORUS) drawSplash(); +#endif #if !defined(CPUARM) AUDIO_TADA(); diff --git a/radio/src/translations/en.h.txt b/radio/src/translations/en.h.txt index e08298acb..d069b009e 100644 --- a/radio/src/translations/en.h.txt +++ b/radio/src/translations/en.h.txt @@ -873,17 +873,10 @@ #define TR_DELAY "Delay" #define TR_SD_CARD "SD CARD" #define TR_SDHC_CARD "SD-HC CARD" -#if defined(COLORLCD) -#define TR_NO_SOUNDS_ON_SD "No Sounds" -#define TR_NO_MODELS_ON_SD "No Models" -#define TR_NO_BITMAPS_ON_SD "No Bitmaps" -#define TR_NO_SCRIPTS_ON_SD "No Scripts" -#else #define TR_NO_SOUNDS_ON_SD "No Sounds" BREAKSPACE "on SD" #define TR_NO_MODELS_ON_SD "No Models" BREAKSPACE "on SD" #define TR_NO_BITMAPS_ON_SD "No Bitmaps" BREAKSPACE "on SD" #define TR_NO_SCRIPTS_ON_SD "No Scripts" BREAKSPACE "on SD" -#endif #define TR_SCRIPT_SYNTAX_ERROR "Script syntax error" #define TR_SCRIPT_PANIC "Script panic" #define TR_SCRIPT_KILLED "Script killed"