From 7f8211ada59994834d0bf99286322ca605979674 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Mon, 21 Sep 2015 07:17:56 +0200 Subject: [PATCH] Fixes #2753 - Missing functions in Companion --- companion/src/eeprominterface.cpp | 12 ++++++++++ companion/src/eeprominterface.h | 9 ++++++- .../src/firmwares/opentx/opentxeeprom.cpp | 24 ++++++++++++++++--- .../src/firmwares/opentx/opentxinterface.cpp | 2 ++ companion/src/modeledit/customfunctions.cpp | 7 +++++- radio/src/gui/9X/helpers.cpp | 2 +- radio/src/gui/Taranis/helpers.cpp | 2 +- radio/src/myeeprom.h | 2 +- 8 files changed, 52 insertions(+), 8 deletions(-) diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index e0213785e..d9243255e 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -810,6 +810,18 @@ QString CustomFunctionData::funcToString() const return QObject::tr("Background Music Pause"); else if (func >= FuncAdjustGV1 && func <= FuncAdjustGVLast) return QObject::tr("Adjust GV%1").arg(func-FuncAdjustGV1+1); + else if (func == FuncSetFailsafeInternalModule) + return QObject::tr("SetFailsafe Int. Module"); + else if (func == FuncSetFailsafeExternalModule) + return QObject::tr("SetFailsafe Ext. Module"); + else if (func == FuncRangeCheckInternalModule) + return QObject::tr("RangeCheck Int. Module"); + else if (func == FuncRangeCheckExternalModule) + return QObject::tr("RangeCheck Ext. Module"); + else if (func == FuncBindInternalModule) + return QObject::tr("Bind Int. Module"); + else if (func == FuncBindExternalModule) + return QObject::tr("Bind Ext. Module"); else { return QString("???"); // Highlight unknown functions with output of question marks.(BTW should not happen that we do not know what a function is) } diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index c5a59efad..348cc7a39 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -598,6 +598,12 @@ enum AssignFunc { FuncBackgroundMusicPause, FuncAdjustGV1, FuncAdjustGVLast = FuncAdjustGV1+C9X_MAX_GVARS-1, + FuncSetFailsafeInternalModule, + FuncSetFailsafeExternalModule, + FuncRangeCheckInternalModule, + FuncRangeCheckExternalModule, + FuncBindInternalModule, + FuncBindExternalModule, FuncCount, FuncReserve = -1 }; @@ -1340,7 +1346,8 @@ enum Capability { HasInputDiff, HasMixerExpo, MixersMonitor, - HasBatMeterRange + HasBatMeterRange, + DangerousFunctions, }; class SimulatorInterface; diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 4c484bd3f..0ac1e1d48 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -1919,9 +1919,12 @@ class CustomFunctionsConversionTable: public ConversionTable { val++; if (IS_ARM(board)) { addConversion(FuncVolume, val++); - addConversion(FuncReserve, val++); - addConversion(FuncReserve, val++); - addConversion(FuncReserve, val++); + addConversion(FuncSetFailsafeInternalModule, val); + addConversion(FuncSetFailsafeExternalModule, val++); + addConversion(FuncRangeCheckInternalModule, val); + addConversion(FuncRangeCheckExternalModule, val++); + addConversion(FuncBindInternalModule, val); + addConversion(FuncBindExternalModule, val++); } addConversion(FuncPlaySound, val++); addConversion(FuncPlayPrompt, val++); @@ -2080,6 +2083,21 @@ class ArmCustomFunctionField: public TransformedField { *((uint8_t *)(_param+3)) = fn.func - FuncSetTimer1; } } + else if (fn.func >= FuncSetFailsafeInternalModule && fn.func <= FuncSetFailsafeExternalModule) { + if (version >= 216) { + *((uint16_t *)_param) = fn.func - FuncSetFailsafeInternalModule; + } + } + else if (fn.func >= FuncRangeCheckInternalModule && fn.func <= FuncRangeCheckExternalModule) { + if (version >= 216) { + *((uint16_t *)_param) = fn.func - FuncRangeCheckInternalModule; + } + } + else if (fn.func >= FuncBindInternalModule && fn.func <= FuncBindExternalModule) { + if (version >= 216) { + *((uint16_t *)_param) = fn.func - FuncBindInternalModule; + } + } else if (fn.func == FuncPlayPrompt || fn.func == FuncBackgroundMusic || fn.func == FuncPlayScript) { memcpy(_param, fn.paramarm, sizeof(_param)); } diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index 5c26b77dd..85c2f3109 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -800,6 +800,8 @@ int OpenTxFirmware::getCapability(const Capability capability) return id.contains("mixersmon") ? 1 : 0; case HasBatMeterRange: return (IS_TARANIS(board) ? true : false); + case DangerousFunctions: + return id.contains("danger") ? 1 : 0; default: return 0; } diff --git a/companion/src/modeledit/customfunctions.cpp b/companion/src/modeledit/customfunctions.cpp index ae20cac46..ef49992bb 100644 --- a/companion/src/modeledit/customfunctions.cpp +++ b/companion/src/modeledit/customfunctions.cpp @@ -383,13 +383,16 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) populateFuncParamCB(fswtchParamT[i], func, cfn.param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_ENABLE; } - else if (func>=FuncSetTimer1 && func<=FuncSetTimer2) { + else if (func>=FuncSetTimer1 && func<=FuncSetTimer3) { if (modified) cfn.param = QTimeS(fswtchParamTime[i]->time()).seconds(); fswtchParamTime[i]->setMinimumTime(QTime(0, 0, 0)); fswtchParamTime[i]->setMaximumTime(QTime(0, 59, 59)); fswtchParamTime[i]->setTime(QTimeS(cfn.param)); widgetsMask |= CUSTOM_FUNCTION_TIME_PARAM + CUSTOM_FUNCTION_ENABLE; } + else if (func>=FuncSetFailsafeInternalModule && func<=FuncBindExternalModule) { + widgetsMask |= CUSTOM_FUNCTION_ENABLE; + } else if (func==FuncVolume) { if (modified) cfn.param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); populateFuncParamCB(fswtchParamT[i], func, cfn.param); @@ -604,6 +607,8 @@ void CustomFunctionsPanel::populateFuncCB(QComboBox *b, unsigned int value) ((i==FuncPlayHaptic) && !firmware->getCapability(Haptic)) || ((i==FuncPlayBoth) && !firmware->getCapability(HasBeeper)) || ((i==FuncLogs) && !firmware->getCapability(HasSDLogs)) || + ((i==FuncSetTimer3) && firmware->getCapability(Timers) < 3) || + ((i>=FuncRangeCheckInternalModule && i<=FuncBindExternalModule) && (!model || !firmware->getCapability(DangerousFunctions))) || ((i>=FuncAdjustGV1 && i<=FuncAdjustGVLast) && !firmware->getCapability(Gvars)) ) { // skipped diff --git a/radio/src/gui/9X/helpers.cpp b/radio/src/gui/9X/helpers.cpp index 219276648..82440939e 100755 --- a/radio/src/gui/9X/helpers.cpp +++ b/radio/src/gui/9X/helpers.cpp @@ -238,7 +238,7 @@ bool isAssignableFunctionAvailable(int function) #if !defined(HAPTIC) case FUNC_HAPTIC: #endif - case FUNC_PLAY_DIFF: + case FUNC_RESERVE4: #if !defined(DANGEROUS_MODULE_FUNCTIONS) case FUNC_RANGECHECK: case FUNC_BIND: diff --git a/radio/src/gui/Taranis/helpers.cpp b/radio/src/gui/Taranis/helpers.cpp index 30fdff324..d479234f5 100755 --- a/radio/src/gui/Taranis/helpers.cpp +++ b/radio/src/gui/Taranis/helpers.cpp @@ -337,7 +337,7 @@ bool isAssignableFunctionAvailable(int function) #if !defined(HAPTIC) case FUNC_HAPTIC: #endif - case FUNC_PLAY_DIFF: + case FUNC_RESERVE4: #if !defined(DANGEROUS_MODULE_FUNCTIONS) case FUNC_RANGECHECK: case FUNC_BIND: diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index c1c5503e8..dd86250ec 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -533,7 +533,7 @@ enum Functions { #endif FUNC_PLAY_VALUE, #if defined(CPUARM) - FUNC_PLAY_DIFF, + FUNC_RESERVE4, FUNC_PLAY_SCRIPT, FUNC_RESERVE5, FUNC_BACKGND_MUSIC,