diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index abd9d9cf4..3c2e260c3 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -113,6 +113,15 @@ enum TimerModes { TMRMODE_FIRST_SWITCH }; +enum FailsafeModes { + FAILSAFE_NOT_SET, + FAILSAFE_HOLD, + FAILSAFE_CUSTOM, + FAILSAFE_NOPULSES, + FAILSAFE_RECEIVER, + FAILSAFE_LAST = FAILSAFE_RECEIVER +}; + #define TRIM_LH_L 0 #define TRIM_LH_R 1 #define TRIM_LV_DN 2 diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 915acc187..d06684e4f 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -2978,9 +2978,13 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne internalField.Append(new SignedField<8>(subprotocols[module])); internalField.Append(new UnsignedField<8>(modelData.moduleData[module].channelsStart)); internalField.Append(new ConversionField< SignedField<8> >(modelData.moduleData[module].channelsCount, -8)); - internalField.Append(new UnsignedField<8>(modelData.moduleData[module].failsafeMode)); - for (int i=0; i<32; i++) + if (version >= 217) + internalField.Append(new UnsignedField<8>(modelData.moduleData[module].failsafeMode)); + else + internalField.Append(new ConversionField< UnsignedField<8> >(modelData.moduleData[module].failsafeMode, 1)); + for (int i=0; i<32; i++) { internalField.Append(new SignedField<16>(modelData.moduleData[module].failsafeChannels[i])); + } internalField.Append(new ConversionField< SignedField<8> >(modelData.moduleData[module].ppmDelay, exportPpmDelay, importPpmDelay)); internalField.Append(new SignedField<8>(modelData.moduleData[module].ppmFrameLength)); if (IS_9XRPRO(board)) { diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 9d37b1af8..59e0a757c 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -279,7 +279,7 @@ void ModulePanel::update() ui->label_failsafeMode->setVisible(mask & MASK_FAILSAFES); ui->failsafeMode->setVisible(mask & MASK_FAILSAFES); ui->failsafeMode->setCurrentIndex(module.failsafeMode); - ui->failsafesFrame->setEnabled(module.failsafeMode == 1); + ui->failsafesFrame->setEnabled(module.failsafeMode == FAILSAFE_CUSTOM); } else { mask = 0; diff --git a/companion/src/modeledit/setup_module.ui b/companion/src/modeledit/setup_module.ui index d764103d8..df8e420e0 100644 --- a/companion/src/modeledit/setup_module.ui +++ b/companion/src/modeledit/setup_module.ui @@ -6,7 +6,7 @@ 0 0 - 737 + 757 300 @@ -67,12 +67,12 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - 0 - 6 + + 0 + @@ -418,6 +418,11 @@ 16777215 + + + Not set + + Hold diff --git a/radio/src/gui/Taranis/menu_model_setup.cpp b/radio/src/gui/Taranis/menu_model_setup.cpp index 296f3f165..4c9e3eeab 100644 --- a/radio/src/gui/Taranis/menu_model_setup.cpp +++ b/radio/src/gui/Taranis/menu_model_setup.cpp @@ -738,15 +738,16 @@ void menuModelSetup(uint8_t event) lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, STR_VFAILSAFE, moduleData.failsafeMode, m_posHorz==0 ? attr : 0); if (moduleData.failsafeMode == FAILSAFE_CUSTOM) lcd_putsAtt(MODEL_SETUP_2ND_COLUMN + MODEL_SETUP_SET_FAILSAFE_OFS, y, STR_SET, m_posHorz==1 ? attr : 0); if (attr) { - if (moduleData.failsafeMode != FAILSAFE_CUSTOM) + if (moduleData.failsafeMode != FAILSAFE_CUSTOM) { m_posHorz = 0; - if (m_posHorz==0) { - if (s_editMode>0) { + } + if (m_posHorz == 0) { + if (s_editMode > 0) { CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.failsafeMode, FAILSAFE_LAST); if (checkIncDec_Ret) SEND_FAILSAFE_NOW(moduleIdx); } } - else if (m_posHorz==1) { + else if (m_posHorz == 1) { s_editMode = 0; if (moduleData.failsafeMode==FAILSAFE_CUSTOM && event==EVT_KEY_FIRST(KEY_ENTER)) { g_moduleIdx = moduleIdx; diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index b75b1af4a..652398953 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -2044,6 +2044,7 @@ enum ModuleTypes { #define IS_PULSES_EXTERNAL_MODULE() (g_model.externalModule != MODULE_TYPE_NONE) enum FailsafeModes { + FAILSAFE_NOT_SET, FAILSAFE_HOLD, FAILSAFE_CUSTOM, FAILSAFE_NOPULSES, diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 025509c9b..538d26493 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1018,6 +1018,23 @@ void doSplash() #define doSplash() #endif +#if defined(PCBTARANIS) +void checkFailsafe() +{ + for (int i=0; i