feat: Add trainer virtual switch (#3937)

Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
3djc
2023-10-16 08:41:40 +10:00
committed by GitHub
co-authored by Peter Feerick
parent ee9d50dca4
commit d396b38e8b
20 changed files with 33 additions and 2 deletions
@@ -167,6 +167,7 @@ RawSwitchItemModel::RawSwitchItemModel(const GeneralSettings * const generalSett
setUpdateMask(IMUE_FlightModes | IMUE_LogicalSwitches | IMUE_TeleSensors | IMUE_FunctionSwitches);
// Descending switch direction: NOT (!) switches
addItems(SWITCH_TYPE_TRAINER, -1);
addItems(SWITCH_TYPE_ACT, -1);
addItems(SWITCH_TYPE_SENSOR, -firmware->getCapability(Sensors));
addItems(SWITCH_TYPE_TELEMETRY, -1);
@@ -190,6 +191,7 @@ RawSwitchItemModel::RawSwitchItemModel(const GeneralSettings * const generalSett
addItems(SWITCH_TYPE_ON, 1);
addItems(SWITCH_TYPE_ONE, 1);
addItems(SWITCH_TYPE_ACT, 1);
addItems(SWITCH_TYPE_TRAINER, 1);
}
void RawSwitchItemModel::setDynamicItemData(QStandardItem * item, const RawSwitch & rsw) const
@@ -166,7 +166,7 @@ RawSwitch YamlRawSwitchDecode(const std::string& sw_str)
int sw_type = getCurrentFirmware()->getRawSwitchTypesIndex(sw_str_tmp.c_str());
if (sw_type >= 0) {
rhs.type = (RawSwitchType)sw_type;
if (rhs.type == SWITCH_TYPE_TELEMETRY || rhs.type == SWITCH_TYPE_ACT || rhs.type == SWITCH_TYPE_ONE)
if (rhs.type == SWITCH_TYPE_TELEMETRY || rhs.type == SWITCH_TYPE_TRAINER || rhs.type == SWITCH_TYPE_ACT || rhs.type == SWITCH_TYPE_ONE)
// these types use index = 1
rhs.index = 1;
else
+4
View File
@@ -149,6 +149,9 @@ QString RawSwitch::toString(Board::Type board, const GeneralSettings * const gen
case SWITCH_TYPE_TELEMETRY:
return tr("Telemetry");
case SWITCH_TYPE_TRAINER:
return tr("Trn");
default:
return CPN_STR_UNKNOWN_ITEM;
}
@@ -280,6 +283,7 @@ StringTagMappingTable RawSwitch::getRawSwitchTypesLookupTable()
{std::to_string(SWITCH_TYPE_TELEMETRY), "TELEMETRY_STREAMING"},
{std::to_string(SWITCH_TYPE_SENSOR), "Tnn"},
{std::to_string(SWITCH_TYPE_ACT), "RADIO_ACTIVITY"},
{std::to_string(SWITCH_TYPE_TRAINER), "TRAINER_CONNECTED"},
});
return tbl;
+1
View File
@@ -47,6 +47,7 @@ enum RawSwitchType {
SWITCH_TYPE_TELEMETRY,
SWITCH_TYPE_SENSOR,
SWITCH_TYPE_ACT,
SWITCH_TYPE_TRAINER,
MAX_SWITCH_TYPE
};