From 4f614850c43adc6ace89b492fc04e1670bbfb135 Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Mon, 30 Sep 2019 17:56:12 +0200 Subject: [PATCH] Add "Act" switch to companion (fix #6851) (#6854) --- companion/src/datamodels/rawitemdatamodels.cpp | 2 ++ companion/src/firmwares/opentx/opentxeeprom.cpp | 4 ++++ companion/src/firmwares/rawswitch.cpp | 3 +++ companion/src/firmwares/rawswitch.h | 1 + 4 files changed, 10 insertions(+) diff --git a/companion/src/datamodels/rawitemdatamodels.cpp b/companion/src/datamodels/rawitemdatamodels.cpp index f1e613d4a..1cba1c180 100644 --- a/companion/src/datamodels/rawitemdatamodels.cpp +++ b/companion/src/datamodels/rawitemdatamodels.cpp @@ -85,6 +85,7 @@ RawSwitchItemModel::RawSwitchItemModel(const GeneralSettings * const generalSett Firmware * fw = getCurrentFirmware(); // Descending switch direction: NOT (!) switches + addItems(SWITCH_TYPE_ACT, -1); addItems(SWITCH_TYPE_SENSOR, -CPN_MAX_SENSORS); addItems(SWITCH_TYPE_TELEMETRY, -1); addItems(SWITCH_TYPE_FLIGHT_MODE, -fw->getCapability(FlightModes)); @@ -107,6 +108,7 @@ RawSwitchItemModel::RawSwitchItemModel(const GeneralSettings * const generalSett addItems(SWITCH_TYPE_SENSOR, CPN_MAX_SENSORS); addItems(SWITCH_TYPE_ON, 1); addItems(SWITCH_TYPE_ONE, 1); + addItems(SWITCH_TYPE_ACT, 1); } void RawSwitchItemModel::setDynamicItemData(QStandardItem * item, const RawSwitch & rsw) const diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 8332a7ff0..8e0c408db 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -217,6 +217,10 @@ class SwitchesConversionTable: public ConversionTable { addConversion(RawSwitch(SWITCH_TYPE_SENSOR, i), val++); } } + if (version >= 219) { + addConversion(RawSwitch(SWITCH_TYPE_ACT, -1), -val+offset); + addConversion(RawSwitch(SWITCH_TYPE_ACT, 1), val++); + } } diff --git a/companion/src/firmwares/rawswitch.cpp b/companion/src/firmwares/rawswitch.cpp index 6438d335e..1d91f242a 100644 --- a/companion/src/firmwares/rawswitch.cpp +++ b/companion/src/firmwares/rawswitch.cpp @@ -115,6 +115,9 @@ QString RawSwitch::toString(Board::Type board, const GeneralSettings * const gen case SWITCH_TYPE_ONE: return tr("One"); + case SWITCH_TYPE_ACT: + return tr("Act"); + case SWITCH_TYPE_FLIGHT_MODE: if (modelData) return modelData->flightModeData[index-1].nameToString(index - 1); diff --git a/companion/src/firmwares/rawswitch.h b/companion/src/firmwares/rawswitch.h index 6d0c93700..af49156c0 100644 --- a/companion/src/firmwares/rawswitch.h +++ b/companion/src/firmwares/rawswitch.h @@ -45,6 +45,7 @@ enum RawSwitchType { SWITCH_TYPE_TIMER_MODE, SWITCH_TYPE_TELEMETRY, SWITCH_TYPE_SENSOR, + SWITCH_TYPE_ACT, MAX_SWITCH_TYPE };