From b9ce8df5b6811c57c71f600a9eb9cb3970929800 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Wed, 16 Sep 2015 21:47:47 +0200 Subject: [PATCH] Fixes #2850 --- companion/src/eeprominterface.h | 3 + .../src/firmwares/opentx/opentxeeprom.cpp | 4 + .../src/firmwares/opentx/opentxinterface.cpp | 4 +- companion/src/modeledit/setup.cpp | 13 + companion/src/modeledit/setup.ui | 610 +++++++++--------- radio/src/gui/Taranis/menu_model_setup.cpp | 19 +- .../src/gui/Taranis/menu_model_telemetry.cpp | 21 +- 7 files changed, 359 insertions(+), 315 deletions(-) diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index 69cd2d61f..934569ea5 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -1041,6 +1041,8 @@ class ModelData { SensorData sensorData[C9X_MAX_SENSORS]; + unsigned int toplcdTimer; + void clear(); bool isEmpty() const; void setDefaultInputs(const GeneralSettings & settings); @@ -1317,6 +1319,7 @@ enum Capability { LCDWidth, GetThrSwitch, HasDisplayText, + HasTopLcd, GlobalFunctions, VirtualInputs, TrainerInputs, diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 36f008c2d..4c484bd3f 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -3177,6 +3177,10 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne internalField.Append(new SensorField(modelData.sensorData[i], board, version)); } } + + if (IS_TARANIS_X9E(board)) { + internalField.Append(new UnsignedField<8>(modelData.toplcdTimer)); + } } void OpenTxModelData::beforeExport() diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index b1915eb5a..42523a489 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -574,7 +574,7 @@ int OpenTxFirmware::getCapability(const Capability capability) case OffsetWeight: return (IS_ARM(board) ? 500 : 245); case Timers: - return (IS_ARM(board) ? 3 : 2); + return ((IS_ARM(board) && id.contains("timer3")) ? 3 : 2); case TimersName: return (IS_TARANIS(board) ? 8 : (IS_ARM(board) ? 3 : 0)); case PermTimers: @@ -736,6 +736,8 @@ int OpenTxFirmware::getCapability(const Capability capability) return (IS_TARANIS(board) ? SWITCH_SF1 : SWITCH_THR) ; case HasDisplayText: return IS_ARM(board) ? 1 : 0; + case HasTopLcd: + return IS_TARANIS_X9E(board) ? 1 : 0; case GlobalFunctions: return IS_ARM(board) ? 64 : 0; case VirtualInputs: diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 20e85f6af..44dde3f44 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -516,6 +516,19 @@ SetupPanel::SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & gen } } + if (firmware->getCapability(HasTopLcd)) { + ui->toplcdTimer->setField(model.toplcdTimer, this); + for (int i=0; igetCapability(Timers)) { + ui->toplcdTimer->addItem(tr("Timer %1").arg(i+1), i); + } + } + } + else { + ui->toplcdTimerLabel->hide(); + ui->toplcdTimer->hide(); + } + if (!firmware->getCapability(HasDisplayText)) { ui->displayText->hide(); } diff --git a/companion/src/modeledit/setup.ui b/companion/src/modeledit/setup.ui index 825579534..b0bff997f 100644 --- a/companion/src/modeledit/setup.ui +++ b/companion/src/modeledit/setup.ui @@ -16,22 +16,6 @@ - - - - - 50 - false - - - - Timer 3 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - @@ -48,8 +32,8 @@ - - + + 50 @@ -57,14 +41,307 @@ - Timer 2 + Top LCD Timer Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + + + + + + + + + 0 + 0 + + + + 10 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + Model Image + + + + + + + + 0 + 0 + + + + + 64 + 32 + + + + + 64 + 32 + + + + QFrame::Panel + + + QFrame::Raised + + + + + + true + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Horizontal + + + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Warnings + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + Switch Warnings + + + + + + + QLayout::SetMinimumSize + + + 0 + + + 6 + + + 6 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Pot Warnings + + + + + + + + + + OFF + + + + + Manual + + + + + Auto + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 75 + true + + + + Model + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Horizontal + + + + + + + + 50 + false + + + + Center beep + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + + @@ -224,7 +501,7 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi - + @@ -276,42 +553,15 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi - + Qt::Horizontal - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Horizontal - - - - - + + 50 @@ -319,261 +569,37 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi - Center beep + Timer 2 Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - Qt::Horizontal + + + + + 50 + false + + + + Timer 3 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - 0 - 0 - - - - 10 - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - Model Image - - - - - - - - 0 - 0 - - - - - 64 - 32 - - - - - 64 - 32 - - - - QFrame::Panel - - - QFrame::Raised - - - - - - true - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Horizontal - - - - - - - + + - + 0 0 - - - 75 - true - - - - Warnings - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - Switch Warnings - - - - - - - QLayout::SetMinimumSize - - - 0 - - - 6 - - - 6 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Pot Warnings - - - - - - - - - - OFF - - - - - Manual - - - - - Auto - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - 75 - true - - - - Model - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - diff --git a/radio/src/gui/Taranis/menu_model_setup.cpp b/radio/src/gui/Taranis/menu_model_setup.cpp index 8b6428936..2d1970c09 100644 --- a/radio/src/gui/Taranis/menu_model_setup.cpp +++ b/radio/src/gui/Taranis/menu_model_setup.cpp @@ -59,6 +59,9 @@ enum menuModelSetupItems { ITEM_MODEL_TIMER3_PERSISTENT, ITEM_MODEL_TIMER3_MINUTE_BEEP, ITEM_MODEL_TIMER3_COUNTDOWN_BEEP, +#endif +#if defined(REV9E) + ITEM_MODEL_TOP_LCD_TIMER, #endif ITEM_MODEL_EXTENDED_LIMITS, ITEM_MODEL_EXTENDED_TRIMS, @@ -224,9 +227,11 @@ int getSwitchWarningsCount() #if defined(REV9E) #define SW_WARN_ITEMS() uint8_t(NAVIGATION_LINE_BY_LINE|(getSwitchWarningsCount()-1)), uint8_t(getSwitchWarningsCount() > 8 ? TITLE_ROW : HIDDEN_ROW), uint8_t(getSwitchWarningsCount() > 16 ? TITLE_ROW : HIDDEN_ROW) #define POT_WARN_ITEMS() uint8_t(g_model.potsWarnMode ? NAVIGATION_LINE_BY_LINE|NUM_POTS : 0), uint8_t(g_model.potsWarnMode ? TITLE_ROW : HIDDEN_ROW) + #define TOPLCD_ROWS 0, #else #define SW_WARN_ITEMS() uint8_t(NAVIGATION_LINE_BY_LINE|getSwitchWarningsCount()) #define POT_WARN_ITEMS() uint8_t(g_model.potsWarnMode ? NAVIGATION_LINE_BY_LINE|NUM_POTS : 0) + #define TOPLCD_ROWS #endif void menuModelSetup(uint8_t event) @@ -234,7 +239,7 @@ void menuModelSetup(uint8_t event) horzpos_t l_posHorz = m_posHorz; bool CURSOR_ON_CELL = (m_posHorz >= 0); #if defined(TARANIS_INTERNAL_PPM) - MENU_TAB({ 0, 0, TIMERS_ROWS, 0, 1, 0, 0, LABEL(Throttle), 0, 0, 0, LABEL(PreflightCheck), 0, 0, SW_WARN_ITEMS(), POT_WARN_ITEMS(), + MENU_TAB({ 0, 0, TIMERS_ROWS, TOPLCD_ROWS 0, 1, 0, 0, LABEL(Throttle), 0, 0, 0, LABEL(PreflightCheck), 0, 0, SW_WARN_ITEMS(), POT_WARN_ITEMS(), NAVIGATION_LINE_BY_LINE|(NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1), 0, LABEL(InternalModule), INTERNAL_MODULE_MODE_ROWS, @@ -248,7 +253,7 @@ void menuModelSetup(uint8_t event) IF_EXTERNAL_MODULE_XJT(FAILSAFE_ROWS(EXTERNAL_MODULE)), LABEL(Trainer), 0, TRAINER_CHANNELS_ROWS(), IF_TRAINER_ON(2)}); #else - MENU_TAB({ 0, 0, TIMERS_ROWS, 0, 1, 0, 0, LABEL(Throttle), 0, 0, 0, LABEL(PreflightCheck), 0, 0, SW_WARN_ITEMS(), POT_WARN_ITEMS(), + MENU_TAB({ 0, 0, TIMERS_ROWS, TOPLCD_ROWS 0, 1, 0, 0, LABEL(Throttle), 0, 0, 0, LABEL(PreflightCheck), 0, 0, SW_WARN_ITEMS(), POT_WARN_ITEMS(), NAVIGATION_LINE_BY_LINE|(NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1), 0, LABEL(InternalModule), INTERNAL_MODULE_MODE_ROWS, @@ -372,6 +377,16 @@ void menuModelSetup(uint8_t event) break; #endif +#if defined(REV9E) + case ITEM_MODEL_TOP_LCD_TIMER: + lcd_putsLeft(y, STR_TOPLCDTIMER); + putsStrIdx(MODEL_SETUP_2ND_COLUMN, y, STR_TIMER, g_model.topLcdTimer+1, attr); + if (attr) { + g_model.topLcdTimer = checkIncDec(event, g_model.topLcdTimer, 0, TIMERS-1, EE_MODEL); + } + break; +#endif + case ITEM_MODEL_EXTENDED_LIMITS: ON_OFF_MENU_ITEM(g_model.extendedLimits, MODEL_SETUP_2ND_COLUMN, y, STR_ELIMITS, attr, event); break; diff --git a/radio/src/gui/Taranis/menu_model_telemetry.cpp b/radio/src/gui/Taranis/menu_model_telemetry.cpp index 8eea1b51f..454426c03 100644 --- a/radio/src/gui/Taranis/menu_model_telemetry.cpp +++ b/radio/src/gui/Taranis/menu_model_telemetry.cpp @@ -86,9 +86,6 @@ enum menuModelTelemetryItems { ITEM_TELEMETRY_TOP_BAR_LABEL, ITEM_TELEMETRY_TOP_BAR_VOLTAGE, ITEM_TELEMETRY_TOP_BAR_ALTITUDE, -#if defined(REV9E) - ITEM_TELEMETRY_TOP_LCD_TIMER, -#endif ITEM_TELEMETRY_SCREEN_LABEL1, ITEM_TELEMETRY_SCREEN_LINE1, ITEM_TELEMETRY_SCREEN_LINE2, @@ -511,12 +508,6 @@ void onTelemetryScriptFileSelectionMenu(const char *result) } #endif -#if defined(REV9E) - #define TOPLCD_ROWS 0, -#else - #define TOPLCD_ROWS -#endif - void menuModelTelemetry(uint8_t event) { if (s_warning_result) { @@ -526,7 +517,7 @@ void menuModelTelemetry(uint8_t event) } } - MENU(STR_MENUTELEMETRY, menuTabModel, e_Telemetry, ITEM_TELEMETRY_MAX, { TELEMETRY_TYPE_ROWS RSSI_ROWS SENSORS_ROWS VARIO_ROWS LABEL(TopBar), 0, 0, TOPLCD_ROWS TELEMETRY_SCREEN_ROWS(0), TELEMETRY_SCREEN_ROWS(1), CASE_CPUARM(TELEMETRY_SCREEN_ROWS(2)) CASE_CPUARM(TELEMETRY_SCREEN_ROWS(3)) }); + MENU(STR_MENUTELEMETRY, menuTabModel, e_Telemetry, ITEM_TELEMETRY_MAX, { TELEMETRY_TYPE_ROWS RSSI_ROWS SENSORS_ROWS VARIO_ROWS LABEL(TopBar), 0, 0, TELEMETRY_SCREEN_ROWS(0), TELEMETRY_SCREEN_ROWS(1), CASE_CPUARM(TELEMETRY_SCREEN_ROWS(2)) CASE_CPUARM(TELEMETRY_SCREEN_ROWS(3)) }); int sub = m_posVert; @@ -716,16 +707,6 @@ void menuModelTelemetry(uint8_t event) } break; -#if defined(REV9E) - case ITEM_TELEMETRY_TOP_LCD_TIMER: - lcd_putsLeft(y, STR_TOPLCDTIMER); - putsStrIdx(TELEM_COL2, y, STR_TIMER, g_model.topLcdTimer+1, attr); - if (attr) { - g_model.topLcdTimer = checkIncDec(event, g_model.topLcdTimer, 0, MAX_TIMERS-1, EE_MODEL); - } - break; -#endif - case ITEM_TELEMETRY_SCREEN_LABEL1: case ITEM_TELEMETRY_SCREEN_LABEL2: case ITEM_TELEMETRY_SCREEN_LABEL3: