From 55ee19b50a509b07305da9bcdf8ca0687968a7ac Mon Sep 17 00:00:00 2001 From: 3djc Date: Wed, 18 Jan 2017 07:34:08 +0100 Subject: [PATCH] 3djc/enhance companion get capability (#4243) * Add info on switches/sliders/pots setup when delivered from factory (other calls return user installed max possible) * Fix * getCapability() : Refine actoryInstalledSwitches, add NumTrimSwitches, remove FactoryInstalledPots & FactoryInstalledSliders; GeneralSettings() initialization : Use `FactoryInstalledSwitches` count instead of `Switches` for default setup, and also set up correct number of sliders for X9E (4) and X7 (0). * Enum order cosmetics. [ci skip] --- companion/src/eeprominterface.cpp | 25 +++++++++++-------- companion/src/eeprominterface.h | 6 +++-- .../src/firmwares/opentx/opentxinterface.cpp | 20 +++++++++------ 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index cd614280c..1a2e719ae 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -1093,31 +1093,36 @@ GeneralSettings::GeneralSettings() calibSpanPos[i] = 0x180; } - for (int i=0; igetCapability(Switches); i++) { + for (int i=0; igetCapability(FactoryInstalledSwitches); i++) { switchConfig[i] = GetCurrentFirmware()->getSwitch(i).type; } BoardEnum board = GetEepromInterface()->getBoard(); - if (board == BOARD_HORUS) { + if (IS_HORUS(board)) { potConfig[0] = POT_WITH_DETENT; potConfig[1] = POT_MULTIPOS_SWITCH; potConfig[2] = POT_WITH_DETENT; + } + else if (IS_TARANIS(board)) { + potConfig[0] = POT_WITH_DETENT; + potConfig[1] = POT_WITH_DETENT; + } + else { + potConfig[0] = POT_WITHOUT_DETENT; + potConfig[1] = POT_WITHOUT_DETENT; + potConfig[2] = POT_WITHOUT_DETENT; + } + + if (IS_HORUS(board) || IS_TARANIS_X9E(board)) { sliderConfig[0] = SLIDER_WITH_DETENT; sliderConfig[1] = SLIDER_WITH_DETENT; sliderConfig[2] = SLIDER_WITH_DETENT; sliderConfig[3] = SLIDER_WITH_DETENT; } - else if (IS_TARANIS(board)) { - potConfig[0] = POT_WITH_DETENT; - potConfig[1] = POT_WITH_DETENT; + else if (IS_TARANIS(board) && !IS_TARANIS_X7(board)) { sliderConfig[0] = SLIDER_WITH_DETENT; sliderConfig[1] = SLIDER_WITH_DETENT; } - else { - for (int i=0; i<3; i++) { - potConfig[i] = POT_WITHOUT_DETENT; - } - } if (IS_ARM(board)) { speakerVolume = 12; diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index 424cf3ad6..033bc31c1 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -80,8 +80,6 @@ enum Capability { Mixes, Timers, TimersName, - CustomFunctions, - SafetyChannelCustomFunction, VoicesAsNumbers, VoicesMaxLength, MultiLangVoice, @@ -89,7 +87,11 @@ enum Capability { Pots, Sliders, Switches, + FactoryInstalledSwitches, SwitchesPositions, + NumTrimSwitches, + CustomFunctions, + SafetyChannelCustomFunction, LogicalSwitches, CustomAndSwitches, HasNegAndSwitches, diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index 78779104a..c44e9d703 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -530,7 +530,7 @@ int OpenTxFirmware::getCapability(Capability capability) else if (IS_TARANIS_X9E(board)) return 4; else if (IS_TARANIS(board)) - return 3; // Taranis has only 2 pots but still has a placeholder in settings for 3 pots + return 3; else return 3; case Sliders: @@ -553,15 +553,21 @@ int OpenTxFirmware::getCapability(Capability capability) return 8; else return 7; - case SwitchesPositions: + case FactoryInstalledSwitches: if (IS_TARANIS_X9E(board)) - return 18 * 3; - else if (IS_TARANIS_X7(board)) - return 6 * 3; - else if (IS_HORUS_OR_TARANIS(board)) - return 8 * 3; + return 8; + else + return getCapability(Switches); + case SwitchesPositions: + if (IS_HORUS_OR_TARANIS(board)) + return getCapability(Switches) * 3; else return 9; + case NumTrimSwitches: + if (IS_HORUS(board)) + return 12; + else + return 8; case CustomFunctions: if (IS_ARM(board)) return 64;