From 08a37b77e71f4f48a71f40958d8a30c04349a5e0 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Sat, 8 Feb 2014 08:38:06 +0100 Subject: [PATCH] Renaming started ... who wants to continue? --- companion/src/comparedialog.cpp | 2 +- companion/src/eeprominterface.cpp | 110 +++++------ companion/src/eeprominterface.h | 72 ++++---- companion/src/firmwares/er9x/er9xeeprom.cpp | 10 +- companion/src/firmwares/er9x/er9xeeprom.h | 10 +- .../src/firmwares/er9x/er9xinterface.cpp | 8 +- .../src/firmwares/ersky9x/ersky9xeeprom.cpp | 20 +- .../src/firmwares/ersky9x/ersky9xeeprom.h | 20 +- .../firmwares/ersky9x/ersky9xinterface.cpp | 14 +- .../src/firmwares/gruvin9x/gruvin9xeeprom.cpp | 10 +- .../src/firmwares/gruvin9x/gruvin9xeeprom.h | 16 +- .../firmwares/gruvin9x/gruvin9xinterface.cpp | 2 +- .../firmwares/opentx/open9xGruvin9xeeprom.cpp | 20 +- .../firmwares/opentx/open9xGruvin9xeeprom.h | 26 +-- .../firmwares/opentx/open9xSky9xeeprom.cpp | 30 +-- .../src/firmwares/opentx/open9xSky9xeeprom.h | 34 ++-- .../firmwares/opentx/open9xStockeeprom.cpp | 20 +- .../src/firmwares/opentx/open9xStockeeprom.h | 36 ++-- .../src/firmwares/opentx/opentxeeprom.cpp | 72 ++++---- .../src/firmwares/opentx/opentxinterface.cpp | 6 +- companion/src/firmwares/th9x/th9xeeprom.cpp | 14 +- companion/src/firmwares/th9x/th9xeeprom.h | 10 +- .../src/firmwares/th9x/th9xinterface.cpp | 2 +- companion/src/helpers.cpp | 52 +++--- companion/src/helpers.h | 2 +- companion/src/modeledit/customswitches.cpp | 84 ++++----- companion/src/modeledit/customswitches.h | 6 +- companion/src/modeledit/modeledit.cpp | 2 +- companion/src/modeledit/templates.cpp | 10 +- companion/src/printdialog.cpp | 2 +- companion/src/simulatordialog.cpp | 2 +- radio/src/eeprom_conversions.cpp | 10 +- radio/src/gtests.cpp | 8 +- radio/src/gui/menu_model.cpp | 174 +++++++++--------- radio/src/gui/menus.cpp | 29 ++- radio/src/gui/menus.h | 5 +- radio/src/myeeprom.h | 64 +++---- radio/src/opentx.cpp | 88 ++++----- radio/src/opentx.h | 30 +-- radio/src/templates.cpp | 8 +- 40 files changed, 577 insertions(+), 563 deletions(-) diff --git a/companion/src/comparedialog.cpp b/companion/src/comparedialog.cpp index 9a50f283c..1309857c4 100644 --- a/companion/src/comparedialog.cpp +++ b/companion/src/comparedialog.cpp @@ -1039,7 +1039,7 @@ void compareDialog::printSwitches() QString str = ""; str.append(""); str.append("

"+tr("Logical Switches")+"

"); - for (int i=0; igetCapability(CustomSwitches); i++) { + for (int i=0; igetCapability(LogicalSwitches); i++) { QString sw1 = g_model1->customSw[i].toString(*g_model1); QString sw2 = g_model2->customSw[i].toString(*g_model2); if (!(sw1.isEmpty() && sw2.isEmpty())) { diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index 7e838e19f..18379d773 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -335,71 +335,71 @@ QString CurveReference::toString() } } -CSFunctionFamily CustomSwData::getFunctionFamily() +CSFunctionFamily LogicalSwitchData::getFunctionFamily() { - if (func == CS_FN_STAY) - return CS_FAMILY_STAY; - else if (func == CS_FN_TIMER) - return CS_FAMILY_TIMER; - else if (func == CS_FN_STICKY) - return CS_FAMILY_STICKY; - else if (func < CS_FN_AND || func > CS_FN_ELESS) - return CS_FAMILY_VOFS; - else if (func < CS_FN_EQUAL) - return CS_FAMILY_VBOOL; + if (func == LS_FN_STAY) + return LS_FAMILY_STAY; + else if (func == LS_FN_TIMER) + return LS_FAMILY_TIMER; + else if (func == LS_FN_STICKY) + return LS_FAMILY_STICKY; + else if (func < LS_FN_AND || func > LS_FN_ELESS) + return LS_FAMILY_VOFS; + else if (func < LS_FN_EQUAL) + return LS_FAMILY_VBOOL; else - return CS_FAMILY_VCOMP; + return LS_FAMILY_VCOMP; } -QString CustomSwData::funcToString() +QString LogicalSwitchData::funcToString() { switch (func) { - case CS_FN_OFF: + case LS_FN_OFF: return QObject::tr("---"); - case CS_FN_VPOS: + case LS_FN_VPOS: return QObject::tr("a>x"); - case CS_FN_VNEG: + case LS_FN_VNEG: return QObject::tr("ax"); - case CS_FN_ANEG: + case LS_FN_ANEG: return QObject::tr("|a|b"); - case CS_FN_LESS: + case LS_FN_LESS: return QObject::tr("a=b"); - case CS_FN_ELESS: + case LS_FN_ELESS: return QObject::tr("a<=b"); - case CS_FN_DPOS: + case LS_FN_DPOS: return QObject::tr("d>=x"); - case CS_FN_DAPOS: + case LS_FN_DAPOS: return QObject::tr("|d|>=x"); - case CS_FN_VEQUAL: + case LS_FN_VEQUAL: return QObject::tr("a~x"); - case CS_FN_TIMER: + case LS_FN_TIMER: return QObject::tr("Timer"); - case CS_FN_STICKY: + case LS_FN_STICKY: return QObject::tr("Sticky"); - case CS_FN_STAY: + case LS_FN_STAY: return QObject::tr("Stay"); default: return QObject::tr("Unknown"); } } -QString CustomSwData::toString(const ModelData & model) +QString LogicalSwitchData::toString(const ModelData & model) { QString result = ""; @@ -410,16 +410,16 @@ QString CustomSwData::toString(const ModelData & model) result +="( "; } switch (getFunctionFamily()) { - case CS_FAMILY_STAY: + case LS_FAMILY_STAY: result = QObject::tr("STAY(%1, [%2:%3])").arg(RawSwitch(val1).toString()).arg(ValToTim(val2)).arg(ValToTim(val2+val3)); break; - case CS_FAMILY_STICKY: + case LS_FAMILY_STICKY: result = QObject::tr("STICKY(%1, %2)").arg(RawSwitch(val1).toString()).arg(RawSwitch(val2).toString()); break; - case CS_FAMILY_TIMER: + case LS_FAMILY_TIMER: result = QObject::tr("TIMER(%1, %2)").arg(ValToTim(val1)).arg(ValToTim(val2)); break; - case CS_FAMILY_VOFS: { + case LS_FAMILY_VOFS: { RawSource source = RawSource(val1, &model); RawSourceRange range = source.getRange(); if (val1) @@ -427,28 +427,28 @@ QString CustomSwData::toString(const ModelData & model) else result += "0"; result.remove(" "); - if (func == CS_FN_APOS || func == CS_FN_ANEG) + if (func == LS_FN_APOS || func == LS_FN_ANEG) result = "|" + result + "|"; - else if (func == CS_FN_DAPOS) + else if (func == LS_FN_DAPOS) result = "|d(" + result + ")|"; - else if (func == CS_FN_DPOS) result = "d(" + result + ")"; - if (func == CS_FN_APOS || func == CS_FN_VPOS || func == CS_FN_DAPOS || func == CS_FN_DPOS) + else if (func == LS_FN_DPOS) result = "d(" + result + ")"; + if (func == LS_FN_APOS || func == LS_FN_VPOS || func == LS_FN_DAPOS || func == LS_FN_DPOS) result += " > "; - else if (func == CS_FN_ANEG || func == CS_FN_VNEG) + else if (func == LS_FN_ANEG || func == LS_FN_VNEG) result += " < "; result += QString::number(range.step * (val2 /*TODO+ source.getRawOffset(model)*/) + range.offset); break; } - case CS_FAMILY_VBOOL: + case LS_FAMILY_VBOOL: result = RawSwitch(val1).toString(); switch (func) { - case CS_FN_AND: + case LS_FN_AND: result += " AND "; break; - case CS_FN_OR: + case LS_FN_OR: result += " OR "; break; - case CS_FN_XOR: + case LS_FN_XOR: result += " XOR "; break; default: @@ -457,28 +457,28 @@ QString CustomSwData::toString(const ModelData & model) result += RawSwitch(val2).toString(); break; - case CS_FAMILY_VCOMP: + case LS_FAMILY_VCOMP: if (val1) result += RawSource(val1).toString(); else result += "0"; switch (func) { - case CS_FN_EQUAL: + case LS_FN_EQUAL: result += " = "; break; - case CS_FN_NEQUAL: + case LS_FN_NEQUAL: result += " != "; break; - case CS_FN_GREATER: + case LS_FN_GREATER: result += " > "; break; - case CS_FN_LESS: + case LS_FN_LESS: result += " < "; break; - case CS_FN_EGREATER: + case LS_FN_EGREATER: result += " >= "; break; - case CS_FN_ELESS: + case LS_FN_ELESS: result += " <= "; break; default: @@ -496,7 +496,7 @@ QString CustomSwData::toString(const ModelData & model) result += RawSwitch(andsw).toString(); } - if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { + if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) { if (delay) result += QObject::tr(" Delay %1 sec").arg(delay/2.0); if (duration) diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index 3f650e6bd..8f78c2d71 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -577,42 +577,42 @@ class MixData { }; enum CSFunction { - CS_FN_OFF, - CS_FN_VPOS, - CS_FN_VNEG, - CS_FN_APOS, - CS_FN_ANEG, - CS_FN_AND, - CS_FN_OR, - CS_FN_XOR, - CS_FN_EQUAL, - CS_FN_NEQUAL, - CS_FN_GREATER, - CS_FN_LESS, - CS_FN_EGREATER, - CS_FN_ELESS, - CS_FN_DPOS, - CS_FN_DAPOS, - CS_FN_VEQUAL, // added at the end to avoid everything renumbered - CS_FN_TIMER, - CS_FN_STICKY, - CS_FN_STAY, - // later ... CS_FN_RANGE, - CS_FN_MAX + LS_FN_OFF, + LS_FN_VPOS, + LS_FN_VNEG, + LS_FN_APOS, + LS_FN_ANEG, + LS_FN_AND, + LS_FN_OR, + LS_FN_XOR, + LS_FN_EQUAL, + LS_FN_NEQUAL, + LS_FN_GREATER, + LS_FN_LESS, + LS_FN_EGREATER, + LS_FN_ELESS, + LS_FN_DPOS, + LS_FN_DAPOS, + LS_FN_VEQUAL, // added at the end to avoid everything renumbered + LS_FN_TIMER, + LS_FN_STICKY, + LS_FN_STAY, + // later ... LS_FN_RANGE, + LS_FN_MAX }; enum CSFunctionFamily { - CS_FAMILY_VOFS, - CS_FAMILY_VBOOL, - CS_FAMILY_VCOMP, - CS_FAMILY_TIMER, - CS_FAMILY_STICKY, - CS_FAMILY_STAY, + LS_FAMILY_VOFS, + LS_FAMILY_VBOOL, + LS_FAMILY_VCOMP, + LS_FAMILY_TIMER, + LS_FAMILY_STICKY, + LS_FAMILY_STAY, }; -class CustomSwData { // Custom Switches data +class LogicalSwitchData { // Custom Switches data public: - CustomSwData(unsigned int func=0) + LogicalSwitchData(unsigned int func=0) { clear(); this->func = func; @@ -624,7 +624,7 @@ class CustomSwData { // Custom Switches data unsigned int delay; unsigned int duration; int andsw; - void clear() { memset(this, 0, sizeof(CustomSwData)); } + void clear() { memset(this, 0, sizeof(LogicalSwitchData)); } CSFunctionFamily getFunctionFamily(); QString funcToString(); QString toString(const ModelData & model); @@ -876,7 +876,7 @@ class ModelData { ExpoData expoData[C9X_MAX_EXPOS]; CurveData curves[C9X_MAX_CURVES]; - CustomSwData customSw[C9X_NUM_CSW]; + LogicalSwitchData customSw[C9X_NUM_CSW]; FuncSwData funcSw[C9X_MAX_CUSTOM_FUNCTIONS]; SwashRingData swashRingData; unsigned int thrTraceSrc; @@ -942,10 +942,10 @@ enum Capability { Pots, Switches, SwitchesPositions, - CustomSwitches, + LogicalSwitches, CustomAndSwitches, HasNegAndSwitches, - CustomSwitchesExt, + LogicalSwitchesExt, RotaryEncoders, Outputs, ChannelsName, @@ -1161,13 +1161,13 @@ inline void applyStickModeToModel(ModelData &model, unsigned int mode) for (int i=0; i= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = er9xToSource(v1).toValue(); } - if (c9x.func >= CS_FN_EQUAL) { + if (c9x.func >= LS_FN_EQUAL) { c9x.val2 = er9xToSource(v2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = er9xToSwitch(v1).toValue(); c9x.val2 = er9xToSwitch(v2).toValue(); } diff --git a/companion/src/firmwares/er9x/er9xeeprom.h b/companion/src/firmwares/er9x/er9xeeprom.h index 863f861c8..b43dbe44e 100644 --- a/companion/src/firmwares/er9x/er9xeeprom.h +++ b/companion/src/firmwares/er9x/er9xeeprom.h @@ -154,15 +154,15 @@ PACK(typedef struct t_Er9xMixData { }) Er9xMixData; -PACK(typedef struct t_Er9xCustomSwData { // Custom Switches data +PACK(typedef struct t_Er9xLogicalSwitchData { // Custom Switches data int8_t v1; //input int8_t v2; //offset uint8_t func:4; uint8_t andsw:4; - operator CustomSwData(); - t_Er9xCustomSwData() { memset(this, 0, sizeof(t_Er9xCustomSwData)); } -}) Er9xCustomSwData; + operator LogicalSwitchData(); + t_Er9xLogicalSwitchData() { memset(this, 0, sizeof(t_Er9xLogicalSwitchData)); } +}) Er9xLogicalSwitchData; PACK(typedef struct t_Er9xSafetySwData { // Custom Switches data int8_t swtch; @@ -241,7 +241,7 @@ PACK(typedef struct t_Er9xModelData { int8_t trim[4]; int8_t curves5[ER9X_MAX_CURVE5][5]; int8_t curves9[ER9X_MAX_CURVE9][9]; - Er9xCustomSwData customSw[ER9X_NUM_CSW]; + Er9xLogicalSwitchData customSw[ER9X_NUM_CSW]; uint8_t frSkyVoltThreshold ; int8_t tmrModeB; uint8_t numVoice; diff --git a/companion/src/firmwares/er9x/er9xinterface.cpp b/companion/src/firmwares/er9x/er9xinterface.cpp index e2ea68868..d28b472b2 100644 --- a/companion/src/firmwares/er9x/er9xinterface.cpp +++ b/companion/src/firmwares/er9x/er9xinterface.cpp @@ -75,11 +75,11 @@ inline void applyStickModeToModel(Er9xModelData & model, unsigned int mode) for (int i=0; i= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = ersky9xToSource_v10(v1).toValue(); } - if (c9x.func >= CS_FN_EQUAL) { + if (c9x.func >= LS_FN_EQUAL) { c9x.val2 = ersky9xToSource_v10(v2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = er9xToSwitch(v1).toValue(); c9x.val2 = er9xToSwitch(v2).toValue(); } @@ -376,22 +376,22 @@ Ersky9xCustomSwData_v10::operator CustomSwData () return c9x; } -Ersky9xCustomSwData_v11::operator CustomSwData () +Ersky9xLogicalSwitchData_v11::operator LogicalSwitchData () { - CustomSwData c9x; + LogicalSwitchData c9x; c9x.func = func; c9x.val1 = v1; c9x.val2 = v2; - if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = ersky9xToSource_v11(v1).toValue(); } - if (c9x.func >= CS_FN_EQUAL) { + if (c9x.func >= LS_FN_EQUAL) { c9x.val2 = ersky9xToSource_v11(v2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = er9xToSwitch(v1).toValue(); c9x.val2 = er9xToSwitch(v2).toValue(); } diff --git a/companion/src/firmwares/ersky9x/ersky9xeeprom.h b/companion/src/firmwares/ersky9x/ersky9xeeprom.h index e92a48983..cf7a3d0f2 100644 --- a/companion/src/firmwares/ersky9x/ersky9xeeprom.h +++ b/companion/src/firmwares/ersky9x/ersky9xeeprom.h @@ -185,25 +185,25 @@ PACK(typedef struct t_Ersky9xMixData_v11 { t_Ersky9xMixData_v11(); }) Ersky9xMixData_v11; -PACK(typedef struct t_Ersky9xCustomSwData_v10 { // Custom Switches data +PACK(typedef struct t_Ersky9xLogicalSwitchData_v10 { // Custom Switches data int8_t v1; //input int8_t v2; //offset uint8_t func; - operator CustomSwData(); - t_Ersky9xCustomSwData_v10() { memset(this, 0, sizeof(t_Ersky9xCustomSwData_v10)); } -}) Ersky9xCustomSwData_v10; + operator LogicalSwitchData(); + t_Ersky9xLogicalSwitchData_v10() { memset(this, 0, sizeof(t_Ersky9xLogicalSwitchData_v10)); } +}) Ersky9xLogicalSwitchData_v10; -PACK(typedef struct t_Ersky9xCustomSwData_v11 { // Custom Switches data +PACK(typedef struct t_Ersky9xLogicalSwitchData_v11 { // Custom Switches data int8_t v1; //input int8_t v2; //offset uint8_t func; uint8_t andsw; uint8_t res ; - operator CustomSwData(); - t_Ersky9xCustomSwData_v11() { memset(this, 0, sizeof(t_Ersky9xCustomSwData_v11)); } -}) Ersky9xCustomSwData_v11; + operator LogicalSwitchData(); + t_Ersky9xLogicalSwitchData_v11() { memset(this, 0, sizeof(t_Ersky9xLogicalSwitchData_v11)); } +}) Ersky9xLogicalSwitchData_v11; PACK(typedef struct t_Ersky9xSafetySwData_v10 { // Custom Switches data int8_t swtch; @@ -360,7 +360,7 @@ PACK(typedef struct t_Ersky9xModelData_v10 { int8_t trim[4]; int8_t curves5[ERSKY9X_MAX_CURVE5][5]; int8_t curves9[ERSKY9X_MAX_CURVE9][9]; - Ersky9xCustomSwData_v10 customSw[ERSKY9X_NUM_CSW_V10]; + Ersky9xLogicalSwitchData_v10 customSw[ERSKY9X_NUM_CSW_V10]; uint8_t frSkyVoltThreshold ; uint8_t res3[2]; Ersky9xSafetySwData_v10 safetySw[ERSKY9X_NUM_CHNOUT_V10]; @@ -409,7 +409,7 @@ PACK(typedef struct t_Ersky9xModelData_v11 { int8_t curves5[ERSKY9X_MAX_CURVE5][5]; int8_t curves9[ERSKY9X_MAX_CURVE9][9]; int8_t curvexy[18]; - Ersky9xCustomSwData_v11 customSw[ERSKY9X_NUM_CSW_V11]; + Ersky9xLogicalSwitchData_v11 customSw[ERSKY9X_NUM_CSW_V11]; uint8_t frSkyVoltThreshold ; uint8_t bt_telemetry; uint8_t numVoice; // 0-16, rest are Safety switches diff --git a/companion/src/firmwares/ersky9x/ersky9xinterface.cpp b/companion/src/firmwares/ersky9x/ersky9xinterface.cpp index 28d97d068..dd65c0c92 100644 --- a/companion/src/firmwares/ersky9x/ersky9xinterface.cpp +++ b/companion/src/firmwares/ersky9x/ersky9xinterface.cpp @@ -74,11 +74,11 @@ inline void applyStickModeToModel(Ersky9xModelData_v10 & model, unsigned int mod for (int i=0; i= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = gruvin9xToSource(v1).toValue(); } - if (c9x.func >= CS_FN_EQUAL) { + if (c9x.func >= LS_FN_EQUAL) { c9x.val2 = gruvin9xToSource(v2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = gruvin9xToSwitch(v1).toValue(); c9x.val2 = gruvin9xToSwitch(v2).toValue(); } diff --git a/companion/src/firmwares/gruvin9x/gruvin9xeeprom.h b/companion/src/firmwares/gruvin9x/gruvin9xeeprom.h index 3fd51268e..8886c83d1 100644 --- a/companion/src/firmwares/gruvin9x/gruvin9xeeprom.h +++ b/companion/src/firmwares/gruvin9x/gruvin9xeeprom.h @@ -186,14 +186,14 @@ PACK(typedef struct t_Gruvin9xMixData { t_Gruvin9xMixData(); }) Gruvin9xMixData; -PACK(typedef struct t_Gruvin9xCustomSwData { // Custom Switches data +PACK(typedef struct t_Gruvin9xLogicalSwitchData { // Custom Switches data int8_t v1; //input int8_t v2; //offset uint8_t func; - operator CustomSwData(); - t_Gruvin9xCustomSwData() { memset(this, 0, sizeof(t_Gruvin9xCustomSwData)); } -}) Gruvin9xCustomSwData; + operator LogicalSwitchData(); + t_Gruvin9xLogicalSwitchData() { memset(this, 0, sizeof(t_Gruvin9xLogicalSwitchData)); } +}) Gruvin9xLogicalSwitchData; PACK(typedef struct t_Gruvin9xSafetySwData { // Safety Switches data int8_t swtch; @@ -309,7 +309,7 @@ PACK(typedef struct t_Gruvin9xModelData_v102 { Gruvin9xExpoData expoData[G9X_MAX_EXPOS]; int8_t curves5[G9X_MAX_CURVE5][5]; int8_t curves9[G9X_MAX_CURVE9][9]; - Gruvin9xCustomSwData customSw[G9X_NUM_CSW]; + Gruvin9xLogicalSwitchData customSw[G9X_NUM_CSW]; Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT]; Gruvin9xSwashRingData swashR; Gruvin9xPhaseData_v102 phaseData[G9X_MAX_PHASES]; @@ -341,7 +341,7 @@ PACK(typedef struct t_Gruvin9xModelData_v103 { Gruvin9xExpoData expoData[G9X_MAX_EXPOS]; int8_t curves5[G9X_MAX_CURVE5][5]; int8_t curves9[G9X_MAX_CURVE9][9]; - Gruvin9xCustomSwData customSw[G9X_NUM_CSW]; + Gruvin9xLogicalSwitchData customSw[G9X_NUM_CSW]; Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT]; Gruvin9xSwashRingData swashR; Gruvin9xPhaseData_v102 phaseData[G9X_MAX_PHASES]; @@ -373,7 +373,7 @@ PACK(typedef struct t_Gruvin9xModelData_v105 { Gruvin9xExpoData expoData[G9X_MAX_EXPOS]; int8_t curves5[G9X_MAX_CURVE5][5]; int8_t curves9[G9X_MAX_CURVE9][9]; - Gruvin9xCustomSwData customSw[G9X_NUM_CSW]; + Gruvin9xLogicalSwitchData customSw[G9X_NUM_CSW]; Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT]; Gruvin9xFuncSwData funcSw[G9X_NUM_FSW]; Gruvin9xSwashRingData swashR; @@ -405,7 +405,7 @@ PACK(typedef struct t_Gruvin9xModelData_v106 { Gruvin9xExpoData expoData[G9X_MAX_EXPOS]; int8_t curves5[G9X_MAX_CURVE5][5]; int8_t curves9[G9X_MAX_CURVE9][9]; - Gruvin9xCustomSwData customSw[G9X_NUM_CSW]; + Gruvin9xLogicalSwitchData customSw[G9X_NUM_CSW]; Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT]; Gruvin9xFuncSwData funcSw[G9X_NUM_FSW]; Gruvin9xSwashRingData swashR; diff --git a/companion/src/firmwares/gruvin9x/gruvin9xinterface.cpp b/companion/src/firmwares/gruvin9x/gruvin9xinterface.cpp index 3e60d61be..c3d52923f 100644 --- a/companion/src/firmwares/gruvin9x/gruvin9xinterface.cpp +++ b/companion/src/firmwares/gruvin9x/gruvin9xinterface.cpp @@ -237,7 +237,7 @@ int Gruvin9xInterface::getCapability(const Capability capability) return 9; case CustomFunctions: return 12; - case CustomSwitches: + case LogicalSwitches: return 12; case CSFunc: return 13; diff --git a/companion/src/firmwares/opentx/open9xGruvin9xeeprom.cpp b/companion/src/firmwares/opentx/open9xGruvin9xeeprom.cpp index 20bd50453..6ec5f402d 100644 --- a/companion/src/firmwares/opentx/open9xGruvin9xeeprom.cpp +++ b/companion/src/firmwares/opentx/open9xGruvin9xeeprom.cpp @@ -293,22 +293,22 @@ RawSource open9xV4209ToSource(int8_t value) } } -Open9xGruvin9xCustomSwData_v207::operator CustomSwData () +Open9xGruvin9xLogicalSwitchData_v207::operator LogicalSwitchData () { - CustomSwData c9x; + LogicalSwitchData c9x; c9x.func = func; c9x.val1 = v1; c9x.val2 = v2; - if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = open9xV4207ToSource(v1).toValue(); } - if (c9x.func >= CS_FN_EQUAL) { + if (c9x.func >= LS_FN_EQUAL) { c9x.val2 = open9xV4207ToSource(v2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = open9xStockToSwitch(v1).toValue(); c9x.val2 = open9xStockToSwitch(v2).toValue(); } @@ -316,22 +316,22 @@ Open9xGruvin9xCustomSwData_v207::operator CustomSwData () return c9x; } -Open9xGruvin9xCustomSwData_v209::operator CustomSwData () +Open9xGruvin9xLogicalSwitchData_v209::operator LogicalSwitchData () { - CustomSwData c9x; + LogicalSwitchData c9x; c9x.func = func; c9x.val1 = v1; c9x.val2 = v2; - if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = open9xV4209ToSource(v1).toValue(); } - if (c9x.func >= CS_FN_EQUAL && c9x.func <= CS_FN_ELESS) { + if (c9x.func >= LS_FN_EQUAL && c9x.func <= LS_FN_ELESS) { c9x.val2 = open9xV4209ToSource(v2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = open9xStockToSwitch(v1).toValue(); c9x.val2 = open9xStockToSwitch(v2).toValue(); } diff --git a/companion/src/firmwares/opentx/open9xGruvin9xeeprom.h b/companion/src/firmwares/opentx/open9xGruvin9xeeprom.h index c95dc6742..214e2ef6d 100644 --- a/companion/src/firmwares/opentx/open9xGruvin9xeeprom.h +++ b/companion/src/firmwares/opentx/open9xGruvin9xeeprom.h @@ -110,27 +110,27 @@ PACK(typedef struct t_Open9xGruvin9xMixData_v211 { t_Open9xGruvin9xMixData_v211() { memset(this, 0, sizeof(t_Open9xGruvin9xMixData_v211)); } }) Open9xGruvin9xMixData_v211; -PACK(typedef struct t_Open9xGruvin9xCustomSwData_v207 { // Custom Switches data +PACK(typedef struct t_Open9xGruvin9xLogicalSwitchData_v207 { // Custom Switches data int8_t v1; //input int8_t v2; //offset uint8_t func; - operator CustomSwData(); - t_Open9xGruvin9xCustomSwData_v207() { memset(this, 0, sizeof(t_Open9xGruvin9xCustomSwData_v207)); } + operator LogicalSwitchData(); + t_Open9xGruvin9xLogicalSwitchData_v207() { memset(this, 0, sizeof(t_Open9xGruvin9xLogicalSwitchData_v207)); } int8_t fromSource(RawSource source); RawSource toSource(int8_t value); -}) Open9xGruvin9xCustomSwData_v207; +}) Open9xGruvin9xLogicalSwitchData_v207; -PACK(typedef struct t_Open9xGruvin9xCustomSwData_v209 { // Custom Switches data +PACK(typedef struct t_Open9xGruvin9xLogicalSwitchData_v209 { // Custom Switches data int8_t v1; //input int8_t v2; //offset uint8_t func; - operator CustomSwData(); - t_Open9xGruvin9xCustomSwData_v209() { memset(this, 0, sizeof(t_Open9xGruvin9xCustomSwData_v209)); } + operator LogicalSwitchData(); + t_Open9xGruvin9xLogicalSwitchData_v209() { memset(this, 0, sizeof(t_Open9xGruvin9xLogicalSwitchData_v209)); } int8_t fromSource(RawSource source); RawSource toSource(int8_t value); -}) Open9xGruvin9xCustomSwData_v209; +}) Open9xGruvin9xLogicalSwitchData_v209; PACK(typedef struct t_Open9xGruvin9xFuncSwData_v203 { // Function Switches data int8_t swtch; // input @@ -194,7 +194,7 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v207 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xGruvin9xCustomSwData_v207 customSw[O9X_NUM_CSW]; + Open9xGruvin9xLogicalSwitchData_v207 customSw[O9X_NUM_CSW]; Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xGruvin9xSwashRingData_v208 swashR; Open9xGruvin9xPhaseData_v207 phaseData[O9X_MAX_PHASES]; @@ -228,7 +228,7 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v208 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xGruvin9xCustomSwData_v207 customSw[O9X_NUM_CSW]; + Open9xGruvin9xLogicalSwitchData_v207 customSw[O9X_NUM_CSW]; Open9xGruvin9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xGruvin9xSwashRingData_v208 swashR; Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES]; @@ -267,7 +267,7 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v209 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xGruvin9xCustomSwData_v209 customSw[O9X_NUM_CSW]; + Open9xGruvin9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW]; Open9xGruvin9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xGruvin9xSwashRingData_v209 swashR; Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES]; @@ -307,7 +307,7 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v210 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves[O9X_MAX_CURVES]; int8_t points[O9X_NUM_POINTS]; - Open9xGruvin9xCustomSwData_v209 customSw[O9X_NUM_CSW]; + Open9xGruvin9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW]; Open9xGruvin9xFuncSwData_v210 funcSw[O9X_NUM_FSW]; Open9xGruvin9xSwashRingData_v209 swashR; Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES]; @@ -345,7 +345,7 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v211 { Open9xExpoData_v211 expoData[O9X_MAX_EXPOS]; int8_t curves[O9X_MAX_CURVES]; int8_t points[O9X_NUM_POINTS]; - Open9xGruvin9xCustomSwData_v209 customSw[O9X_NUM_CSW]; + Open9xGruvin9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW]; Open9xGruvin9xFuncSwData_v210 funcSw[O9X_NUM_FSW]; Open9xGruvin9xSwashRingData_v209 swashR; Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES]; diff --git a/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp b/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp index 393833cc4..01a7a01b2 100644 --- a/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp +++ b/companion/src/firmwares/opentx/open9xSky9xeeprom.cpp @@ -501,22 +501,22 @@ t_Open9xArmMixData_v212::operator MixData () return c9x; } -t_Open9xArmCustomSwData_v208::operator CustomSwData () +t_Open9xArmLogicalSwitchData_v208::operator LogicalSwitchData () { - CustomSwData c9x; + LogicalSwitchData c9x; c9x.func = func; c9x.val1 = v1; c9x.val2 = v2; - if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = open9xArm208ToSource(v1).toValue(); } - if (c9x.func >= CS_FN_EQUAL) { + if (c9x.func >= LS_FN_EQUAL) { c9x.val2 = open9xArm208ToSource(v2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = open9xArmToSwitch(v1).toValue(); c9x.val2 = open9xArmToSwitch(v2).toValue(); } @@ -524,22 +524,22 @@ t_Open9xArmCustomSwData_v208::operator CustomSwData () return c9x; } -t_Open9xArmCustomSwData_v209::operator CustomSwData () +t_Open9xArmLogicalSwitchData_v209::operator LogicalSwitchData () { - CustomSwData c9x; + LogicalSwitchData c9x; c9x.func = func; c9x.val1 = v1; c9x.val2 = v2; - if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = open9xArm209ToSource(v1).toValue(); } - if (c9x.func >= CS_FN_EQUAL) { + if (c9x.func >= LS_FN_EQUAL) { c9x.val2 = open9xArm209ToSource(v2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = open9xArmToSwitch(v1).toValue(); c9x.val2 = open9xArmToSwitch(v2).toValue(); } @@ -547,24 +547,24 @@ t_Open9xArmCustomSwData_v209::operator CustomSwData () return c9x; } -t_Open9xArmCustomSwData_v210::operator CustomSwData () +t_Open9xArmLogicalSwitchData_v210::operator LogicalSwitchData () { - CustomSwData c9x; + LogicalSwitchData c9x; c9x.func = func; c9x.val1 = v1; c9x.val2 = v2; c9x.delay = delay; c9x.duration = duration; - if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = open9xArm210ToSource(v1).toValue(); } - if (c9x.func >= CS_FN_EQUAL && c9x.func <= CS_FN_ELESS) { + if (c9x.func >= LS_FN_EQUAL && c9x.func <= LS_FN_ELESS) { c9x.val2 = open9xArm210ToSource(v2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = open9xArmToSwitch(v1).toValue(); c9x.val2 = open9xArmToSwitch(v2).toValue(); } diff --git a/companion/src/firmwares/opentx/open9xSky9xeeprom.h b/companion/src/firmwares/opentx/open9xSky9xeeprom.h index b313169b8..fdb3974ee 100644 --- a/companion/src/firmwares/opentx/open9xSky9xeeprom.h +++ b/companion/src/firmwares/opentx/open9xSky9xeeprom.h @@ -190,34 +190,34 @@ PACK(typedef struct t_Open9xArmPhaseData_v212 { t_Open9xArmPhaseData_v212() { memset(this, 0, sizeof(t_Open9xArmPhaseData_v212)); } }) Open9xArmPhaseData_v212; -PACK(typedef struct t_Open9xArmCustomSwData_v208 { // Custom Switches data +PACK(typedef struct t_Open9xArmLogicalSwitchData_v208 { // Custom Switches data int8_t v1; //input int8_t v2; //offset uint8_t func; - operator CustomSwData(); - t_Open9xArmCustomSwData_v208() { memset(this, 0, sizeof(t_Open9xArmCustomSwData_v208)); } -}) Open9xArmCustomSwData_v208; + operator LogicalSwitchData(); + t_Open9xArmLogicalSwitchData_v208() { memset(this, 0, sizeof(t_Open9xArmLogicalSwitchData_v208)); } +}) Open9xArmLogicalSwitchData_v208; -PACK(typedef struct t_Open9xArmCustomSwData_v209 { // Custom Switches data +PACK(typedef struct t_Open9xArmLogicalSwitchData_v209 { // Custom Switches data int8_t v1; //input int8_t v2; //offset uint8_t func; - operator CustomSwData(); - t_Open9xArmCustomSwData_v209() { memset(this, 0, sizeof(t_Open9xArmCustomSwData_v209)); } -}) Open9xArmCustomSwData_v209; + operator LogicalSwitchData(); + t_Open9xArmLogicalSwitchData_v209() { memset(this, 0, sizeof(t_Open9xArmLogicalSwitchData_v209)); } +}) Open9xArmLogicalSwitchData_v209; -PACK(typedef struct t_Open9xArmCustomSwData_v210 { // Custom Switches data +PACK(typedef struct t_Open9xArmLogicalSwitchData_v210 { // Custom Switches data int8_t v1; //input int8_t v2; //offset uint8_t func; uint8_t delay; uint8_t duration; - operator CustomSwData(); - t_Open9xArmCustomSwData_v210() { memset(this, 0, sizeof(t_Open9xArmCustomSwData_v210)); } -}) Open9xArmCustomSwData_v210; + operator LogicalSwitchData(); + t_Open9xArmLogicalSwitchData_v210() { memset(this, 0, sizeof(t_Open9xArmLogicalSwitchData_v210)); } +}) Open9xArmLogicalSwitchData_v210; PACK(typedef struct t_Open9xArmFuncSwData_v208 { // Function Switches data int8_t swtch; // input @@ -343,7 +343,7 @@ PACK(typedef struct t_Open9xArmModelData_v208 { Open9xArmExpoData_v208 expoData[O9X_ARM_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xArmCustomSwData_v208 customSw[O9X_ARM_NUM_CSW]; + Open9xArmLogicalSwitchData_v208 customSw[O9X_ARM_NUM_CSW]; Open9xArmFuncSwData_v208 funcSw[O9X_ARM_NUM_FSW]; Open9xArmSwashRingData_v208 swashR; Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES]; @@ -382,7 +382,7 @@ PACK(typedef struct t_Open9xArmModelData_v209 { Open9xArmExpoData_v208 expoData[O9X_ARM_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xArmCustomSwData_v209 customSw[O9X_ARM_NUM_CSW]; + Open9xArmLogicalSwitchData_v209 customSw[O9X_ARM_NUM_CSW]; Open9xArmFuncSwData_v208 funcSw[O9X_ARM_NUM_FSW]; Open9xArmSwashRingData_v209 swashR; Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES]; @@ -422,7 +422,7 @@ PACK(typedef struct t_Open9xArmModelData_v210 { Open9xArmExpoData_v210 expoData[O9X_ARM_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xArmCustomSwData_v210 customSw[O9X_ARM_NUM_CSW]; + Open9xArmLogicalSwitchData_v210 customSw[O9X_ARM_NUM_CSW]; Open9xArmFuncSwData_v210 funcSw[O9X_ARM_NUM_FSW]; Open9xArmSwashRingData_v209 swashR; Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES]; @@ -461,7 +461,7 @@ PACK(typedef struct t_Open9xArmModelData_v211 { Open9xArmExpoData_v210 expoData[O9X_ARM_MAX_EXPOS]; int16_t curves[O9X_ARM_MAX_CURVES]; int8_t points[O9X_ARM_NUM_POINTS]; - Open9xArmCustomSwData_v210 customSw[O9X_ARM_NUM_CSW]; + Open9xArmLogicalSwitchData_v210 customSw[O9X_ARM_NUM_CSW]; Open9xArmFuncSwData_v211 funcSw[O9X_ARM_NUM_FSW]; Open9xArmSwashRingData_v209 swashR; Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES]; @@ -499,7 +499,7 @@ PACK(typedef struct t_Open9xArmModelData_v212 { Open9xArmExpoData_v212 expoData[O9X_ARM_MAX_EXPOS]; int16_t curves[O9X_ARM_MAX_CURVES]; int8_t points[O9X_ARM_NUM_POINTS]; - Open9xArmCustomSwData_v210 customSw[O9X_ARM_NUM_CSW]; + Open9xArmLogicalSwitchData_v210 customSw[O9X_ARM_NUM_CSW]; Open9xArmFuncSwData_v211 funcSw[O9X_ARM_NUM_FSW]; Open9xArmSwashRingData_v210 swashR; Open9xArmPhaseData_v212 phaseData[O9X_ARM_MAX_PHASES]; diff --git a/companion/src/firmwares/opentx/open9xStockeeprom.cpp b/companion/src/firmwares/opentx/open9xStockeeprom.cpp index 0e6e010b6..73cb22164 100644 --- a/companion/src/firmwares/opentx/open9xStockeeprom.cpp +++ b/companion/src/firmwares/opentx/open9xStockeeprom.cpp @@ -518,22 +518,22 @@ RawSource open9xStock209ToSource(int8_t value) } } -Open9xCustomSwData_v208::operator CustomSwData () +Open9xLogicalSwitchData_v208::operator LogicalSwitchData () { - CustomSwData c9x; + LogicalSwitchData c9x; c9x.func = func; c9x.val1 = v1; c9x.val2 = v2; - if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = open9x208ToSource(v1).toValue(); } - if (c9x.func >= CS_FN_EQUAL) { + if (c9x.func >= LS_FN_EQUAL) { c9x.val2 = open9x208ToSource(v2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = open9xStockToSwitch(v1).toValue(); c9x.val2 = open9xStockToSwitch(v2).toValue(); } @@ -541,22 +541,22 @@ Open9xCustomSwData_v208::operator CustomSwData () return c9x; } -Open9xCustomSwData_v209::operator CustomSwData () +Open9xLogicalSwitchData_v209::operator LogicalSwitchData () { - CustomSwData c9x; + LogicalSwitchData c9x; c9x.func = func; c9x.val1 = v1; c9x.val2 = v2; - if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = open9xStock209ToSource(v1).toValue(); } - if (c9x.func >= CS_FN_EQUAL && c9x.func <= CS_FN_ELESS) { + if (c9x.func >= LS_FN_EQUAL && c9x.func <= LS_FN_ELESS) { c9x.val2 = open9xStock209ToSource(v2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = open9xStockToSwitch(v1).toValue(); c9x.val2 = open9xStockToSwitch(v2).toValue(); } diff --git a/companion/src/firmwares/opentx/open9xStockeeprom.h b/companion/src/firmwares/opentx/open9xStockeeprom.h index 972467308..8f121441e 100644 --- a/companion/src/firmwares/opentx/open9xStockeeprom.h +++ b/companion/src/firmwares/opentx/open9xStockeeprom.h @@ -221,24 +221,24 @@ PACK(typedef struct t_Open9xMixData_v211 { t_Open9xMixData_v211() { memset(this, 0, sizeof(t_Open9xMixData_v211)); } }) Open9xMixData_v211; -PACK(typedef struct t_Open9xCustomSwData_v208 { // Custom Switches data +PACK(typedef struct t_Open9xLogicalSwitchData_v208 { // Custom Switches data int8_t v1; //input int8_t v2; //offset uint8_t func; - operator CustomSwData(); - t_Open9xCustomSwData_v208() { memset(this, 0, sizeof(t_Open9xCustomSwData_v208)); } - t_Open9xCustomSwData_v208(CustomSwData&); -}) Open9xCustomSwData_v208; + operator LogicalSwitchData(); + t_Open9xLogicalSwitchData_v208() { memset(this, 0, sizeof(t_Open9xLogicalSwitchData_v208)); } + t_Open9xLogicalSwitchData_v208(LogicalSwitchData&); +}) Open9xLogicalSwitchData_v208; -PACK(typedef struct t_Open9xCustomSwData_v209 { // Custom Switches data +PACK(typedef struct t_Open9xLogicalSwitchData_v209 { // Custom Switches data int8_t v1; //input int8_t v2; //offset uint8_t func; - operator CustomSwData(); - t_Open9xCustomSwData_v209() { memset(this, 0, sizeof(t_Open9xCustomSwData_v209)); } -}) Open9xCustomSwData_v209; + operator LogicalSwitchData(); + t_Open9xLogicalSwitchData_v209() { memset(this, 0, sizeof(t_Open9xLogicalSwitchData_v209)); } +}) Open9xLogicalSwitchData_v209; PACK(typedef struct t_Open9xSafetySwData { // Safety Switches data int8_t swtch; @@ -516,7 +516,7 @@ PACK(typedef struct t_Open9xModelData_v201 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xCustomSwData_v208 customSw[O9X_NUM_CSW]; + Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW]; Open9xSafetySwData safetySw[O9X_NUM_CHNOUT]; Open9xFuncSwData_v201 funcSw[12]; Open9xSwashRingData_v208 swashR; @@ -547,7 +547,7 @@ PACK(typedef struct t_Open9xModelData_v202 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xCustomSwData_v208 customSw[O9X_NUM_CSW]; + Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW]; Open9xSafetySwData safetySw[O9X_NUM_CHNOUT]; Open9xFuncSwData_v201 funcSw[12]; Open9xSwashRingData_v208 swashR; @@ -581,7 +581,7 @@ PACK(typedef struct t_Open9xModelData_v203 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xCustomSwData_v208 customSw[O9X_NUM_CSW]; + Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW]; Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xSwashRingData_v208 swashR; Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES]; @@ -614,7 +614,7 @@ PACK(typedef struct t_Open9xModelData_v204 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xCustomSwData_v208 customSw[O9X_NUM_CSW]; + Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW]; Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xSwashRingData_v208 swashR; Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES]; @@ -647,7 +647,7 @@ PACK(typedef struct t_Open9xModelData_v205 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xCustomSwData_v208 customSw[O9X_NUM_CSW]; + Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW]; Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xSwashRingData_v208 swashR; Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES]; @@ -682,7 +682,7 @@ PACK(typedef struct t_Open9xModelData_v208 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xCustomSwData_v208 customSw[O9X_NUM_CSW]; + Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW]; Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xSwashRingData_v208 swashR; Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES]; @@ -721,7 +721,7 @@ PACK(typedef struct t_Open9xModelData_v209 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves5[O9X_209_MAX_CURVE5][5]; int8_t curves9[O9X_209_MAX_CURVE9][9]; - Open9xCustomSwData_v209 customSw[O9X_NUM_CSW]; + Open9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW]; Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW]; Open9xSwashRingData_v209 swashR; Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES]; @@ -761,7 +761,7 @@ PACK(typedef struct t_Open9xModelData_v210 { Open9xExpoData_v201 expoData[O9X_MAX_EXPOS]; int8_t curves[O9X_MAX_CURVES]; int8_t points[O9X_NUM_POINTS]; - Open9xCustomSwData_v209 customSw[O9X_NUM_CSW]; + Open9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW]; Open9xFuncSwData_v210 funcSw[O9X_NUM_FSW]; Open9xSwashRingData_v209 swashR; Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES]; @@ -799,7 +799,7 @@ PACK(typedef struct t_Open9xModelData_v211 { Open9xExpoData_v211 expoData[O9X_MAX_EXPOS]; int8_t curves[O9X_MAX_CURVES]; int8_t points[O9X_NUM_POINTS]; - Open9xCustomSwData_v209 customSw[O9X_NUM_CSW]; + Open9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW]; Open9xFuncSwData_v210 funcSw[O9X_NUM_FSW]; Open9xSwashRingData_v209 swashR; Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES]; diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 53376a354..e0365487b 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -1045,39 +1045,39 @@ class CurvesField: public TransformedField { int _points[C9X_MAX_CURVES*C9X_MAX_POINTS*2]; }; -class CustomSwitchesFunctionsTable: public ConversionTable { +class LogicalSwitchesFunctionsTable: public ConversionTable { public: - CustomSwitchesFunctionsTable(BoardEnum board, unsigned int version) + LogicalSwitchesFunctionsTable(BoardEnum board, unsigned int version) { int val=0; bool release21March2013 = IS_RELEASE_21_MARCH_2013(board, version); - addConversion(CS_FN_OFF, val++); + addConversion(LS_FN_OFF, val++); if (release21March2013) - addConversion(CS_FN_VEQUAL, val++); - addConversion(CS_FN_VPOS, val++); - addConversion(CS_FN_VNEG, val++); + addConversion(LS_FN_VEQUAL, val++); + addConversion(LS_FN_VPOS, val++); + addConversion(LS_FN_VNEG, val++); if (IS_ARM(board) && version >= 216) val++; // later RANGE - addConversion(CS_FN_APOS, val++); - addConversion(CS_FN_ANEG, val++); - addConversion(CS_FN_AND, val++); - addConversion(CS_FN_OR, val++); - addConversion(CS_FN_XOR, val++); - if (IS_ARM(board) && version >= 216) addConversion(CS_FN_STAY, val++); - addConversion(CS_FN_EQUAL, val++); + addConversion(LS_FN_APOS, val++); + addConversion(LS_FN_ANEG, val++); + addConversion(LS_FN_AND, val++); + addConversion(LS_FN_OR, val++); + addConversion(LS_FN_XOR, val++); + if (IS_ARM(board) && version >= 216) addConversion(LS_FN_STAY, val++); + addConversion(LS_FN_EQUAL, val++); if (!release21March2013) - addConversion(CS_FN_NEQUAL, val++); - addConversion(CS_FN_GREATER, val++); - addConversion(CS_FN_LESS, val++); + addConversion(LS_FN_NEQUAL, val++); + addConversion(LS_FN_GREATER, val++); + addConversion(LS_FN_LESS, val++); if (!release21March2013) { - addConversion(CS_FN_EGREATER, val++); - addConversion(CS_FN_ELESS, val++); + addConversion(LS_FN_EGREATER, val++); + addConversion(LS_FN_ELESS, val++); } - addConversion(CS_FN_DPOS, val++); - addConversion(CS_FN_DAPOS, val++); - addConversion(CS_FN_TIMER, val++); + addConversion(LS_FN_DPOS, val++); + addConversion(LS_FN_DAPOS, val++); + addConversion(LS_FN_TIMER, val++); if (version >= 216) - addConversion(CS_FN_STICKY, val++); + addConversion(LS_FN_STICKY, val++); } }; @@ -1153,11 +1153,11 @@ class AndSwitchesConversionTable: public ConversionTable { } }; -class CustomSwitchField: public TransformedField { +class LogicalSwitchField: public TransformedField { public: - CustomSwitchField(CustomSwData & csw, BoardEnum board, unsigned int version, unsigned int variant): + LogicalSwitchField(LogicalSwitchData & csw, BoardEnum board, unsigned int version, unsigned int variant): TransformedField(internalField), - internalField("CustomSwitch"), + internalField("LogicalSwitch"), csw(csw), board(board), version(version), @@ -1202,21 +1202,21 @@ class CustomSwitchField: public TransformedField { virtual void beforeExport() { - if (csw.func == CS_FN_STAY) { + if (csw.func == LS_FN_STAY) { switchesConversionTable->exportValue(csw.val1, v1); v2 = csw.val2; v3 = csw.val3; } - else if ((csw.func >= CS_FN_AND && csw.func <= CS_FN_XOR) || csw.func == CS_FN_STICKY) { + else if ((csw.func >= LS_FN_AND && csw.func <= LS_FN_XOR) || csw.func == LS_FN_STICKY) { switchesConversionTable->exportValue(csw.val1, v1); switchesConversionTable->exportValue(csw.val2, v2); } - else if (csw.func >= CS_FN_EQUAL && csw.func <= CS_FN_ELESS) { + else if (csw.func >= LS_FN_EQUAL && csw.func <= LS_FN_ELESS) { sourcesConversionTable->exportValue(csw.val1, v1); sourcesConversionTable->exportValue(csw.val2, v2); } else { - if ((csw.func >= CS_FN_VPOS && csw.func <= CS_FN_ANEG) || (csw.func >= CS_FN_EQUAL && csw.func!=CS_FN_TIMER)) + if ((csw.func >= LS_FN_VPOS && csw.func <= LS_FN_ANEG) || (csw.func >= LS_FN_EQUAL && csw.func!=LS_FN_TIMER)) sourcesConversionTable->exportValue(csw.val1, v1); else v1 = csw.val1; @@ -1226,21 +1226,21 @@ class CustomSwitchField: public TransformedField { virtual void afterImport() { - if (csw.func == CS_FN_STAY) { + if (csw.func == LS_FN_STAY) { switchesConversionTable->importValue(v1, csw.val1); csw.val2 = v2; csw.val3 = v3; } - else if ((csw.func >= CS_FN_AND && csw.func <= CS_FN_XOR) || csw.func == CS_FN_STICKY) { + else if ((csw.func >= LS_FN_AND && csw.func <= LS_FN_XOR) || csw.func == LS_FN_STICKY) { switchesConversionTable->importValue(v1, csw.val1); switchesConversionTable->importValue(v2, csw.val2); } - else if (csw.func >= CS_FN_EQUAL && csw.func <= CS_FN_ELESS) { + else if (csw.func >= LS_FN_EQUAL && csw.func <= LS_FN_ELESS) { sourcesConversionTable->importValue(v1, csw.val1); sourcesConversionTable->importValue(v2, csw.val2); } else { - if ((csw.func >= CS_FN_VPOS && csw.func <= CS_FN_ANEG) || (csw.func >= CS_FN_EQUAL && csw.func!=CS_FN_TIMER)) + if ((csw.func >= LS_FN_VPOS && csw.func <= LS_FN_ANEG) || (csw.func >= LS_FN_EQUAL && csw.func!=LS_FN_TIMER)) sourcesConversionTable->importValue(v1, csw.val1); else csw.val1 = v1; @@ -1250,11 +1250,11 @@ class CustomSwitchField: public TransformedField { protected: StructField internalField; - CustomSwData & csw; + LogicalSwitchData & csw; BoardEnum board; unsigned int version; unsigned int variant; - CustomSwitchesFunctionsTable functionsConversionTable; + LogicalSwitchesFunctionsTable functionsConversionTable; SourcesConversionTable * sourcesConversionTable; SwitchesConversionTable * switchesConversionTable; ConversionTable * andswitchesConversionTable; @@ -2087,7 +2087,7 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u internalField.Append(new ExpoField(modelData.expoData[i], board, version)); internalField.Append(new CurvesField(modelData.curves, board, version)); for (int i=0; i= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) { + if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = toSource(val1).toValue(); } - if (c9x.func >= CS_FN_EQUAL) { + if (c9x.func >= LS_FN_EQUAL) { c9x.val2 = toSource(val2).toValue(); } - if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) { + if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = th9xToSwitch(val1).toValue(); c9x.val2 = th9xToSwitch(val2).toValue(); } @@ -192,7 +192,7 @@ t_Th9xCustomSwData::operator CustomSwData () return c9x; } -int8_t t_Th9xCustomSwData::fromSource(RawSource source) +int8_t t_Th9xLogicalSwitchData::fromSource(RawSource source) { int v1 = 0; if (source.type == SOURCE_TYPE_STICK) @@ -216,7 +216,7 @@ int8_t t_Th9xCustomSwData::fromSource(RawSource source) return v1; } -RawSource t_Th9xCustomSwData::toSource(int8_t value) +RawSource t_Th9xLogicalSwitchData::toSource(int8_t value) { if (value == 0) { return RawSource(SOURCE_TYPE_NONE); diff --git a/companion/src/firmwares/th9x/th9xeeprom.h b/companion/src/firmwares/th9x/th9xeeprom.h index 294a33a0c..467b09c68 100644 --- a/companion/src/firmwares/th9x/th9xeeprom.h +++ b/companion/src/firmwares/th9x/th9xeeprom.h @@ -138,18 +138,18 @@ PACK(typedef struct t_Th9xMixData { t_Th9xMixData(); }) Th9xMixData; -PACK(typedef struct t_Th9xCustomSwData { +PACK(typedef struct t_Th9xLogicalSwitchData { uint8_t sw:3; // 0..7 uint8_t opCmp:2; // < & | ^ uint8_t opRes:3; // 0 => 1=> 0=> !=> & | ^ int8_t val1; int8_t val2; - operator CustomSwData(); - t_Th9xCustomSwData() { memset(this, 0, sizeof(t_Th9xCustomSwData)); } + operator LogicalSwitchData(); + t_Th9xLogicalSwitchData() { memset(this, 0, sizeof(t_Th9xLogicalSwitchData)); } int8_t fromSource(RawSource source); RawSource toSource(int8_t value); -}) Th9xCustomSwData; +}) Th9xLogicalSwitchData; PACK(typedef struct t_Th9xTrimData { int8_t itrim:6; //trim index @@ -173,7 +173,7 @@ PACK(typedef struct t_Th9xModelData { int8_t curves3[TH9X_MAX_CURVES3][3]; // 9 new143 int8_t curves5[TH9X_MAX_CURVES5][5]; // 10 int8_t curves9[TH9X_MAX_CURVES9][9]; // 18 - Th9xCustomSwData switchTab[TH9X_MAX_SWITCHES];// + Th9xLogicalSwitchData switchTab[TH9X_MAX_SWITCHES];// Th9xTrimData trimData[NUM_STICKS]; // 3*4 -> 1*4 operator ModelData(); t_Th9xModelData(); diff --git a/companion/src/firmwares/th9x/th9xinterface.cpp b/companion/src/firmwares/th9x/th9xinterface.cpp index 9bd0cbc4a..8e3e36ab6 100644 --- a/companion/src/firmwares/th9x/th9xinterface.cpp +++ b/companion/src/firmwares/th9x/th9xinterface.cpp @@ -157,7 +157,7 @@ int Th9xInterface::getCapability(const Capability capability) return 9; case CustomFunctions: return 0; - case CustomSwitches: + case LogicalSwitches: return TH9X_MAX_SWITCHES; case Outputs: return 8; diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index 0a648bb0f..d12d900cf 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -407,7 +407,7 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr) if (item == value) b->setCurrentIndex(b->count()-1); } - for (int i=-GetEepromInterface()->getCapability(CustomSwitches); i<0; i++) { + for (int i=-GetEepromInterface()->getCapability(LogicalSwitches); i<0; i++) { item = RawSwitch(SWITCH_TYPE_VIRTUAL, i); b->addItem(item.toString(), item.toValue()); if (item == value) b->setCurrentIndex(b->count()-1); @@ -474,7 +474,7 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr) if (item == value) b->setCurrentIndex(b->count()-1); } - for (int i=1; i<=GetEepromInterface()->getCapability(CustomSwitches); i++) { + for (int i=1; i<=GetEepromInterface()->getCapability(LogicalSwitches); i++) { item = RawSwitch(SWITCH_TYPE_VIRTUAL, i); b->addItem(item.toString(), item.toValue()); if (item == value) b->setCurrentIndex(b->count()-1); @@ -582,7 +582,7 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData & if (item == source) b->setCurrentIndex(b->count()-1); } - for (int i=0; igetCapability(CustomSwitches); i++) { + for (int i=0; igetCapability(LogicalSwitches); i++) { item = RawSource(SOURCE_TYPE_CUSTOM_SWITCH, i); b->addItem(item.toString(), item.toValue()); if (item == source) b->setCurrentIndex(b->count()-1); @@ -656,33 +656,33 @@ int TimToVal(float value) void populateCSWCB(QComboBox *b, int value) { int order[] = { - CS_FN_OFF, - CS_FN_VEQUAL, // added at the end to avoid everything renumbered - CS_FN_VPOS, - CS_FN_VNEG, - // CS_FN_RANGE, - CS_FN_APOS, - CS_FN_ANEG, - CS_FN_AND, - CS_FN_OR, - CS_FN_XOR, - CS_FN_STAY, - CS_FN_EQUAL, - CS_FN_NEQUAL, - CS_FN_GREATER, - CS_FN_LESS, - CS_FN_EGREATER, - CS_FN_ELESS, - CS_FN_DPOS, - CS_FN_DAPOS, - CS_FN_TIMER, - CS_FN_STICKY + LS_FN_OFF, + LS_FN_VEQUAL, // added at the end to avoid everything renumbered + LS_FN_VPOS, + LS_FN_VNEG, + // LS_FN_RANGE, + LS_FN_APOS, + LS_FN_ANEG, + LS_FN_AND, + LS_FN_OR, + LS_FN_XOR, + LS_FN_STAY, + LS_FN_EQUAL, + LS_FN_NEQUAL, + LS_FN_GREATER, + LS_FN_LESS, + LS_FN_EGREATER, + LS_FN_ELESS, + LS_FN_DPOS, + LS_FN_DAPOS, + LS_FN_TIMER, + LS_FN_STICKY }; b->clear(); - for (int i=0; iaddItem(CustomSwData(func).funcToString(), func); + b->addItem(LogicalSwitchData(func).funcToString(), func); // if (i>GetEepromInterface()->getCapability(CSFunc)) { // QModelIndex index = b->model()->index(i, 0); // QVariant v(0); diff --git a/companion/src/helpers.h b/companion/src/helpers.h index 4c742faad..ad22a4e7c 100644 --- a/companion/src/helpers.h +++ b/companion/src/helpers.h @@ -4,7 +4,7 @@ #include #include "eeprominterface.h" -#define TMR_NUM_OPTION (TMR_VAROFS+2*9+2*GetEepromInterface()->getCapability(CustomSwitches)-1) +#define TMR_NUM_OPTION (TMR_VAROFS+2*9+2*GetEepromInterface()->getCapability(LogicalSwitches)-1) //convert from mode 1 to mode generalSettings.stickMode //NOTICE! => 1..4 -> 1..4 diff --git a/companion/src/modeledit/customswitches.cpp b/companion/src/modeledit/customswitches.cpp index 72c9404f0..cf02f4430 100644 --- a/companion/src/modeledit/customswitches.cpp +++ b/companion/src/modeledit/customswitches.cpp @@ -7,7 +7,7 @@ #include #include "helpers.h" -CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model): +LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model): ModelPanel(parent, model), selectedSwitch(0) { @@ -18,13 +18,13 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model): addLabel(gridLayout, tr("V1"), col++); addLabel(gridLayout, tr("V2"), col++); addLabel(gridLayout, tr("AND"), col++); - if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { + if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) { addLabel(gridLayout, tr("Duration"), col++); addLabel(gridLayout, tr("Delay"), col++); } lock = true; - for (int i=0; igetCapability(CustomSwitches); i++) { + for (int i=0; igetCapability(LogicalSwitches); i++) { // The label QLabel * label = new QLabel(this); label->setProperty("index", i); @@ -81,7 +81,7 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model): connect(cswitchAnd[i], SIGNAL(currentIndexChanged(int)), this, SLOT(andEdited(int))); gridLayout->addWidget(cswitchAnd[i], i+1, 4); - if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { + if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) { // Duration cswitchDuration[i] = new QDoubleSpinBox(this); cswitchDuration[i]->setProperty("index", i); @@ -109,19 +109,19 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model): lock = false; } -CustomSwitchesPanel::~CustomSwitchesPanel() +LogicalSwitchesPanel::~LogicalSwitchesPanel() { } -void CustomSwitchesPanel::v1Edited(int value) +void LogicalSwitchesPanel::v1Edited(int value) { if (!lock) { int i = sender()->property("index").toInt(); model.customSw[i].val1 = cswitchSource1[i]->itemData(value).toInt(); - if (model.customSw[i].getFunctionFamily() == CS_FAMILY_VOFS) { + if (model.customSw[i].getFunctionFamily() == LS_FAMILY_VOFS) { RawSource source = RawSource(model.customSw[i].val1, &model); if (source.type == SOURCE_TYPE_TELEMETRY) { - if (model.customSw[i].func > CS_FN_ELESS && model.customSw[i].func < CS_FN_VEQUAL) { + if (model.customSw[i].func > LS_FN_ELESS && model.customSw[i].func < LS_FN_VEQUAL) { model.customSw[i].val2 = 0; } else { @@ -130,7 +130,7 @@ void CustomSwitchesPanel::v1Edited(int value) } else { RawSourceRange range = source.getRange(); - if (model.customSw[i].func > CS_FN_ELESS && model.customSw[i].func < CS_FN_VEQUAL) { + if (model.customSw[i].func > LS_FN_ELESS && model.customSw[i].func < LS_FN_VEQUAL) { model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step); } else { @@ -143,7 +143,7 @@ void CustomSwitchesPanel::v1Edited(int value) } } -void CustomSwitchesPanel::v2Edited(int value) +void LogicalSwitchesPanel::v2Edited(int value) { if (!lock) { int i = sender()->property("index").toInt(); @@ -152,7 +152,7 @@ void CustomSwitchesPanel::v2Edited(int value) } } -void CustomSwitchesPanel::andEdited(int value) +void LogicalSwitchesPanel::andEdited(int value) { if (!lock) { int index = sender()->property("index").toInt(); @@ -161,34 +161,34 @@ void CustomSwitchesPanel::andEdited(int value) } } -void CustomSwitchesPanel::durationEdited(double duration) +void LogicalSwitchesPanel::durationEdited(double duration) { int index = sender()->property("index").toInt(); model.customSw[index].duration = (uint8_t)round(duration*2); emit modified(); } -void CustomSwitchesPanel::delayEdited(double delay) +void LogicalSwitchesPanel::delayEdited(double delay) { int index = sender()->property("index").toInt(); model.customSw[index].delay = (uint8_t)round(delay*2); emit modified(); } -void CustomSwitchesPanel::edited() +void LogicalSwitchesPanel::edited() { if (!lock) { lock = true; int i = sender()->property("index").toInt(); int newFunc = csw[i]->itemData(csw[i]->currentIndex()).toInt(); - bool chAr = (model.customSw[i].getFunctionFamily() != CustomSwData(newFunc).getFunctionFamily()); + bool chAr = (model.customSw[i].getFunctionFamily() != LogicalSwitchData(newFunc).getFunctionFamily()); model.customSw[i].func = newFunc; if (chAr) { - if (model.customSw[i].getFunctionFamily() == CS_FAMILY_TIMER) { + if (model.customSw[i].getFunctionFamily() == LS_FAMILY_TIMER) { model.customSw[i].val1 = -119; model.customSw[i].val2 = -119; } - else if (model.customSw[i].getFunctionFamily() == CS_FAMILY_STAY) { + else if (model.customSw[i].getFunctionFamily() == LS_FAMILY_STAY) { model.customSw[i].val1 = 0; model.customSw[i].val2 = -129; model.customSw[i].val3 = 0; @@ -204,11 +204,11 @@ void CustomSwitchesPanel::edited() RawSource source; switch (model.customSw[i].getFunctionFamily()) { - case CS_FAMILY_VOFS: + case LS_FAMILY_VOFS: { source = RawSource(model.customSw[i].val1, &model); RawSourceRange range = source.getRange(); - if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].funcLS_FN_ELESS && model.customSw[i].funcvalue() / range.step); cswitchOffset[i]->setValue(model.customSw[i].val2*range.step); } @@ -218,13 +218,13 @@ void CustomSwitchesPanel::edited() } } break; - case CS_FAMILY_TIMER: + case LS_FAMILY_TIMER: model.customSw[i].val1 = TimToVal(cswitchValue[i]->value()); model.customSw[i].val2 = TimToVal(cswitchOffset[i]->value()); updateTimerParam(cswitchValue[i], model.customSw[i].val1); updateTimerParam(cswitchOffset[i], model.customSw[i].val2); break; - case CS_FAMILY_STAY: + case LS_FAMILY_STAY: model.customSw[i].val2 = TimToVal(cswitchOffset[i]->value()); updateTimerParam(cswitchOffset[i], model.customSw[i].val2, true); break; @@ -236,7 +236,7 @@ void CustomSwitchesPanel::edited() } } -void CustomSwitchesPanel::updateTimerParam(QDoubleSpinBox *sb, int timer, bool allowZero) +void LogicalSwitchesPanel::updateTimerParam(QDoubleSpinBox *sb, int timer, bool allowZero) { sb->setVisible(true); sb->setDecimals(1); @@ -252,7 +252,7 @@ void CustomSwitchesPanel::updateTimerParam(QDoubleSpinBox *sb, int timer, bool a sb->setValue(value); } -void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) +void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i) { lock = true; @@ -261,7 +261,7 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) switch (model.customSw[i].getFunctionFamily()) { - case CS_FAMILY_VOFS: + case LS_FAMILY_VOFS: cswitchSource1[i]->setVisible(true); cswitchSource2[i]->setVisible(false); cswitchValue[i]->setVisible(false); @@ -269,7 +269,7 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) populateSourceCB(cswitchSource1[i], source, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); cswitchOffset[i]->setDecimals(range.decimals); cswitchOffset[i]->setSingleStep(range.step); - if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].funcLS_FN_ELESS && model.customSw[i].funcsetMinimum(range.step*-127); cswitchOffset[i]->setMaximum(range.step*127); cswitchOffset[i]->setValue(range.step*model.customSw[i].val2); @@ -280,8 +280,8 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) cswitchOffset[i]->setValue(range.step*(model.customSw[i].val2/* TODO+source.getRawOffset(model)*/)+range.offset); } break; - case CS_FAMILY_VBOOL: - case CS_FAMILY_STICKY: + case LS_FAMILY_VBOOL: + case LS_FAMILY_STICKY: cswitchSource1[i]->setVisible(true); cswitchSource2[i]->setVisible(true); cswitchValue[i]->setVisible(false); @@ -289,14 +289,14 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1)); populateSwitchCB(cswitchSource2[i], RawSwitch(model.customSw[i].val2)); break; - case CS_FAMILY_STAY: + case LS_FAMILY_STAY: cswitchSource1[i]->setVisible(true); cswitchSource2[i]->setVisible(false); cswitchValue[i]->setVisible(false); populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1)); updateTimerParam(cswitchOffset[i], model.customSw[i].val2, true); break; - case CS_FAMILY_VCOMP: + case LS_FAMILY_VCOMP: cswitchSource1[i]->setVisible(true); cswitchSource2[i]->setVisible(true); cswitchValue[i]->setVisible(false); @@ -304,7 +304,7 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) populateSourceCB(cswitchSource1[i], RawSource(model.customSw[i].val1), model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); populateSourceCB(cswitchSource2[i], RawSource(model.customSw[i].val2), model, POPULATE_SOURCES | POPULATE_TRIMS | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); break; - case CS_FAMILY_TIMER: + case LS_FAMILY_TIMER: cswitchSource1[i]->setVisible(false); cswitchSource2[i]->setVisible(false); updateTimerParam(cswitchValue[i], model.customSw[i].val1); @@ -315,16 +315,16 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i) lock = false; } -void CustomSwitchesPanel::update() +void LogicalSwitchesPanel::update() { - for (int i=0; igetCapability(CustomSwitches); i++) { + for (int i=0; igetCapability(LogicalSwitches); i++) { lock = true; populateCSWCB(csw[i], model.customSw[i].func); lock = false; setSwitchWidgetVisibility(i); lock = true; populateAndSwitchCB(cswitchAnd[i], RawSwitch(model.customSw[i].andsw)); - if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { + if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) { cswitchDuration[i]->setValue(model.customSw[i].duration/2.0); cswitchDelay[i]->setValue(model.customSw[i].delay/2.0); } @@ -332,37 +332,37 @@ void CustomSwitchesPanel::update() } } -void CustomSwitchesPanel::cswPaste() +void LogicalSwitchesPanel::cswPaste() { const QClipboard *clipboard = QApplication::clipboard(); const QMimeData *mimeData = clipboard->mimeData(); if (mimeData->hasFormat("application/x-companion-csw")) { QByteArray cswData = mimeData->data("application/x-companion-csw"); - CustomSwData *csw = &model.customSw[selectedSwitch]; - memcpy(csw, cswData.mid(0, sizeof(CustomSwData)).constData(), sizeof(CustomSwData)); + LogicalSwitchData *csw = &model.customSw[selectedSwitch]; + memcpy(csw, cswData.mid(0, sizeof(LogicalSwitchData)).constData(), sizeof(LogicalSwitchData)); emit modified(); updateSelectedSwitch(); } } -void CustomSwitchesPanel::cswDelete() +void LogicalSwitchesPanel::cswDelete() { model.customSw[selectedSwitch].clear(); emit modified(); updateSelectedSwitch(); } -void CustomSwitchesPanel::cswCopy() +void LogicalSwitchesPanel::cswCopy() { QByteArray cswData; - cswData.append((char*)&model.customSw[selectedSwitch],sizeof(CustomSwData)); + cswData.append((char*)&model.customSw[selectedSwitch],sizeof(LogicalSwitchData)); QMimeData *mimeData = new QMimeData; mimeData->setData("application/x-companion-csw", cswData); QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard); } -void CustomSwitchesPanel::updateSelectedSwitch() +void LogicalSwitchesPanel::updateSelectedSwitch() { lock = true; populateCSWCB(csw[selectedSwitch], model.customSw[selectedSwitch].func); @@ -370,14 +370,14 @@ void CustomSwitchesPanel::updateSelectedSwitch() lock = false; } -void CustomSwitchesPanel::cswCut() +void LogicalSwitchesPanel::cswCut() { cswCopy(); cswDelete(); } // TODO make something generic here! -void CustomSwitchesPanel::csw_customContextMenuRequested(QPoint pos) +void LogicalSwitchesPanel::csw_customContextMenuRequested(QPoint pos) { QLabel *label = (QLabel *)sender(); selectedSwitch = label->property("index").toInt(); diff --git a/companion/src/modeledit/customswitches.h b/companion/src/modeledit/customswitches.h index 0ff1973d6..ef7945afd 100644 --- a/companion/src/modeledit/customswitches.h +++ b/companion/src/modeledit/customswitches.h @@ -5,13 +5,13 @@ #include #include -class CustomSwitchesPanel : public ModelPanel +class LogicalSwitchesPanel : public ModelPanel { Q_OBJECT public: - CustomSwitchesPanel(QWidget *parent, ModelData & model); - virtual ~CustomSwitchesPanel(); + LogicalSwitchesPanel(QWidget *parent, ModelData & model); + virtual ~LogicalSwitchesPanel(); virtual void update(); diff --git a/companion/src/modeledit/modeledit.cpp b/companion/src/modeledit/modeledit.cpp index 3aed2b38f..9336f913b 100644 --- a/companion/src/modeledit/modeledit.cpp +++ b/companion/src/modeledit/modeledit.cpp @@ -30,7 +30,7 @@ ModelEdit::ModelEdit(RadioData & radioData, int modelId, bool openWizard, bool i addTab(new InputsPanel(this, model, radioData.generalSettings), tr("Inputs")); addTab(new MixesPanel(this, model, radioData.generalSettings), tr("Mixes")); addTab(new Channels(this, model), tr("Channels")); - addTab(new CustomSwitchesPanel(this, model), tr("Logical Switches")); + addTab(new LogicalSwitchesPanel(this, model), tr("Logical Switches")); if (GetEepromInterface()->getCapability(CustomFunctions)) addTab(new CustomFunctionsPanel(this, model, radioData.generalSettings), tr("Switch Assignment")); addTab(new Curves(this, model), tr("Curves")); diff --git a/companion/src/modeledit/templates.cpp b/companion/src/modeledit/templates.cpp index 6bfb52247..38bec941a 100644 --- a/companion/src/modeledit/templates.cpp +++ b/companion/src/modeledit/templates.cpp @@ -584,8 +584,8 @@ void Templates::applyTemplate(uint8_t idx) md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_CH, 13); md->weight= 100; md->swtch=RawSwitch(); md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 11); md->mltpx=MLTPX_REP; md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP; - setSwitch(0xB, CS_FN_VNEG, RawSource(SOURCE_TYPE_STICK, 2).toValue(), -99); - setSwitch(0xC, CS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 13).toValue(), 0); + setSwitch(0xB, LS_FN_VNEG, RawSource(SOURCE_TYPE_STICK, 2).toValue(), -99); + setSwitch(0xC, LS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 13).toValue(), 0); updateSwitchesTab(); } @@ -841,9 +841,9 @@ void Templates::applyTemplate(uint8_t idx) md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_CUSTOM_SWITCH, 0); md->weight= 110; md->swtch=RawSwitch(); md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-110; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 2); md->mltpx=MLTPX_REP; md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 110; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 3); md->mltpx=MLTPX_REP; - setSwitch(1, CS_FN_LESS, RawSource(SOURCE_TYPE_CH, 14).toValue(), RawSource(SOURCE_TYPE_CH, 15).toValue()); - setSwitch(2, CS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 14).toValue(), 105); - setSwitch(3, CS_FN_VNEG, RawSource(SOURCE_TYPE_CH, 14).toValue(), -105); + setSwitch(1, LS_FN_LESS, RawSource(SOURCE_TYPE_CH, 14).toValue(), RawSource(SOURCE_TYPE_CH, 15).toValue()); + setSwitch(2, LS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 14).toValue(), 105); + setSwitch(3, LS_FN_VNEG, RawSource(SOURCE_TYPE_CH, 14).toValue(), -105); // redraw switches tab updateSwitchesTab(); diff --git a/companion/src/printdialog.cpp b/companion/src/printdialog.cpp index be95c92be..aecd4c088 100644 --- a/companion/src/printdialog.cpp +++ b/companion/src/printdialog.cpp @@ -642,7 +642,7 @@ void printDialog::printSwitches() str.append(""); str.append("

"+tr("Logical Switches")+"

"); - for (int i=0; igetCapability(CustomSwitches); i++) { + for (int i=0; igetCapability(LogicalSwitches); i++) { if (g_model->customSw[i].func) { str.append(""); if (i<9) { diff --git a/companion/src/simulatordialog.cpp b/companion/src/simulatordialog.cpp index 85cc110d2..8a26c0ecb 100644 --- a/companion/src/simulatordialog.cpp +++ b/companion/src/simulatordialog.cpp @@ -356,7 +356,7 @@ void simulatorDialog::loadParams(RadioData &radioData, const int model_idx) beepVal = 0; beepShow = 0; - switches=txInterface->getCapability(CustomSwitches); + switches=txInterface->getCapability(LogicalSwitches); if ( switches < 13) { ui->cswitch_13->hide(); ui->labelCSW_13->hide(); diff --git a/radio/src/eeprom_conversions.cpp b/radio/src/eeprom_conversions.cpp index eb0ff91c7..defef59ea 100644 --- a/radio/src/eeprom_conversions.cpp +++ b/radio/src/eeprom_conversions.cpp @@ -168,7 +168,7 @@ PACK(typedef struct { int16_t curves[16]; int8_t points[NUM_POINTS]; - CustomSwData customSw[NUM_CSW]; + LogicalSwitchData customSw[NUM_CSW]; CustomFnData funcSw[NUM_CFN]; SwashRingData swashR; PhaseData_v215 phaseData[MAX_PHASES]; @@ -379,13 +379,13 @@ void ConvertModel_215_to_216(ModelData &model) for (uint8_t i=0; i<32; i++) { g_model.customSw[i] = oldModel.customSw[i]; #if defined(PCBTARANIS) - CustomSwData * cs = &g_model.customSw[i]; + LogicalSwitchData * cs = &g_model.customSw[i]; uint8_t cstate = cswFamily(cs->func); - if (cstate == CS_FAMILY_OFS || cstate == CS_FAMILY_COMP || cstate == CS_FAMILY_DIFF) { + if (cstate == LS_FAMILY_OFS || cstate == LS_FAMILY_COMP || cstate == LS_FAMILY_DIFF) { if (cs->v1 > 0) cs->v1 += MAX_INPUTS + MAX_SCRIPTS*MAX_SCRIPT_OUTPUTS; if (cs->v1 > MIXSRC_GVAR1+4) cs->v1 += 4; } - if (cstate == CS_FAMILY_OFS || cstate == CS_FAMILY_DIFF) { + if (cstate == LS_FAMILY_OFS || cstate == LS_FAMILY_DIFF) { if (cs->v1 >= MIXSRC_FIRST_TELEM) { switch ((uint8_t)cs->v1) { case MIXSRC_FIRST_TELEM + TELEM_TM1-1: @@ -429,7 +429,7 @@ void ConvertModel_215_to_216(ModelData &model) } } } - if (cstate == CS_FAMILY_COMP) { + if (cstate == LS_FAMILY_COMP) { if (cs->v2 > 0) cs->v2 += MAX_INPUTS + MAX_SCRIPTS*MAX_SCRIPT_OUTPUTS; if (cs->v2 > MIXSRC_GVAR1+4) cs->v2 += 4; } diff --git a/radio/src/gtests.cpp b/radio/src/gtests.cpp index fe6cb1a0a..5530d21a2 100644 --- a/radio/src/gtests.cpp +++ b/radio/src/gtests.cpp @@ -304,8 +304,8 @@ TEST(getSwitch, circularCSW) { MODEL_RESET(); MIXER_RESET(); - g_model.customSw[0] = { SWSRC_SW1, SWSRC_SW1, CS_OR }; - g_model.customSw[1] = { SWSRC_SW1, SWSRC_SW1, CS_AND }; + g_model.customSw[0] = { SWSRC_SW1, SWSRC_SW1, LS_FUNC_OR }; + g_model.customSw[1] = { SWSRC_SW1, SWSRC_SW1, LS_FUNC_AND }; EXPECT_EQ(getSwitch(SWSRC_SW1), false); EXPECT_EQ(getSwitch(-SWSRC_SW1), true); EXPECT_EQ(getSwitch(SWSRC_SW2), false); @@ -324,8 +324,8 @@ TEST(getSwitch, recursiveSW) MODEL_RESET(); MIXER_RESET(); - g_model.customSw[0] = { SWSRC_RUD, -SWSRC_SW2, CS_OR }; - g_model.customSw[1] = { SWSRC_ELE, -SWSRC_SW1, CS_OR }; + g_model.customSw[0] = { SWSRC_RUD, -SWSRC_SW2, LS_FUNC_OR }; + g_model.customSw[1] = { SWSRC_ELE, -SWSRC_SW1, LS_FUNC_OR }; EXPECT_EQ(getSwitch(SWSRC_SW1), false); EXPECT_EQ(getSwitch(SWSRC_SW2), true); diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index 89847da43..ba0c68abc 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -55,7 +55,7 @@ enum EnumTabModel { #if LCD_W >= 212 IF_GVARS(e_GVars) #endif - e_CustomSwitches, + e_LogicalSwitches, e_CustomFunctions, #if defined(LUA_MODEL_SCRIPTS) e_CustomScripts, @@ -74,7 +74,7 @@ void menuModelMixAll(uint8_t event); void menuModelLimits(uint8_t event); void menuModelCurvesAll(uint8_t event); void menuModelGVars(uint8_t event); -void menuModelCustomSwitches(uint8_t event); +void menuModelLogicalSwitches(uint8_t event); void menuModelCustomFunctions(uint8_t event); void menuModelCustomScripts(uint8_t event); void menuModelTelemetry(uint8_t event); @@ -93,7 +93,7 @@ const MenuFuncP_PROGMEM menuTabModel[] PROGMEM = { #if LCD_W >= 212 && defined(GVARS) && defined(FLIGHT_MODES) IF_GVARS(menuModelGVars) #endif - menuModelCustomSwitches, + menuModelLogicalSwitches, menuModelCustomFunctions, #if defined(LUA_MODEL_SCRIPTS) menuModelCustomScripts, @@ -4124,20 +4124,20 @@ void menuModelGVars(uint8_t event) #define CHECK_INCDEC_PARAM(event, var, min, max) checkIncDec(event, var, min, max, incdecFlag) #endif -enum CustomSwitchFields { - CSW_FIELD_FUNCTION, - CSW_FIELD_V1, - CSW_FIELD_V2, +enum LogicalSwitchFields { + LS_FIELD_FUNCTION, + LS_FIELD_V1, + LS_FIELD_V2, #if defined(PCBTARANIS) - CSW_FIELD_V3, + LS_FIELD_V3, #endif - CSW_FIELD_ANDSW, + LS_FIELD_ANDSW, #if defined(CPUARM) - CSW_FIELD_DURATION, - CSW_FIELD_DELAY, + LS_FIELD_DURATION, + LS_FIELD_DELAY, #endif - CSW_FIELD_COUNT, - CSW_FIELD_LAST = CSW_FIELD_COUNT-1 + LS_FIELD_COUNT, + LS_FIELD_LAST = LS_FIELD_COUNT-1 }; #if LCD_W >= 212 @@ -4158,15 +4158,15 @@ enum CustomSwitchFields { #define CSWONE_2ND_COLUMN (11*FW) -void menuModelCustomSwitchOne(uint8_t event) +void menuModelLogicalSwitchOne(uint8_t event) { TITLE(STR_MENUCUSTOMSWITCH); - CustomSwData * cs = cswAddress(s_currIdx); + LogicalSwitchData * cs = cswAddress(s_currIdx); uint8_t sw = SWSRC_SW1+s_currIdx; putsSwitches(14*FW, 0, sw, (getSwitch(sw) ? BOLD : 0)); - SUBMENU_NOTITLE(CSW_FIELD_COUNT, {0, 0, 1, 0 /*, 0...*/}); + SUBMENU_NOTITLE(LS_FIELD_COUNT, {0, 0, 1, 0 /*, 0...*/}); int8_t sub = m_posVert; @@ -4176,17 +4176,17 @@ void menuModelCustomSwitchOne(uint8_t event) uint8_t attr = (sub==i ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0); uint8_t cstate = cswFamily(cs->func); switch(i) { - case CSW_FIELD_FUNCTION: + case LS_FIELD_FUNCTION: lcd_putsLeft(y, STR_FUNC); lcd_putsiAtt(CSWONE_2ND_COLUMN, y, STR_VCSWFUNC, cs->func, attr); if (attr) { - cs->func = checkIncDec(event, cs->func, 0, CS_MAXF, EE_MODEL, isFunctionAvailable); + cs->func = checkIncDec(event, cs->func, 0, LS_FUNC_MAX, EE_MODEL, isLogicalSwitchFunctionAvailable); uint8_t new_cstate = cswFamily(cs->func); if (cstate != new_cstate) { - if (new_cstate == CS_FAMILY_TIMER) { + if (new_cstate == LS_FAMILY_TIMER) { cs->v1 = cs->v2 = -119; } - else if (new_cstate == CS_FAMILY_STAY) { + else if (new_cstate == LS_FAMILY_STAY) { cs->v1 = 0; cs->v2 = -129; cs->v3 = 0; } else { @@ -4195,15 +4195,15 @@ void menuModelCustomSwitchOne(uint8_t event) } } break; - case CSW_FIELD_V1: + case LS_FIELD_V1: { lcd_putsLeft(y, STR_V1); int8_t v1_min=0, v1_max=MIXSRC_LAST_TELEM; - if (cstate == CS_FAMILY_BOOL || cstate == CS_FAMILY_STICKY || cstate == CS_FAMILY_STAY) { + if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY || cstate == LS_FAMILY_STAY) { putsSwitches(CSWONE_2ND_COLUMN, y, cs->v1, attr); v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1; } - else if (cstate == CS_FAMILY_TIMER) { + else if (cstate == LS_FAMILY_TIMER) { lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->v1+1, LEFT|attr); v1_max = 99; } @@ -4215,19 +4215,19 @@ void menuModelCustomSwitchOne(uint8_t event) } break; } - case CSW_FIELD_V2: + case LS_FIELD_V2: { lcd_putsLeft(y, STR_V2); int16_t v2_min=0, v2_max=MIXSRC_LAST_TELEM; - if (cstate == CS_FAMILY_BOOL || cstate == CS_FAMILY_STICKY) { + if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY) { putsSwitches(CSWONE_2ND_COLUMN, y, cs->v2, attr); v2_min = SWSRC_OFF+1; v2_max = SWSRC_ON-1; } - else if (cstate == CS_FAMILY_TIMER) { + else if (cstate == LS_FAMILY_TIMER) { lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->v2+1, LEFT|attr); v2_max = 99; } - else if (cstate == CS_FAMILY_STAY) { + else if (cstate == LS_FAMILY_STAY) { lcd_putc(CSWONE_2ND_COLUMN-4, y, '['); lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cswTimerValue(cs->v2), LEFT|PREC1|(m_posHorz==0 ? attr : 0)); lcd_putc(lcdLastPos, y, ':'); @@ -4243,7 +4243,7 @@ void menuModelCustomSwitchOne(uint8_t event) } v2_min=-129; v2_max = 122; } - else if (cstate == CS_FAMILY_COMP) { + else if (cstate == LS_FAMILY_COMP) { putsMixerSource(CSWONE_2ND_COLUMN, y, cs->v2, attr); } else { @@ -4251,7 +4251,7 @@ void menuModelCustomSwitchOne(uint8_t event) if (cs->v1 >= MIXSRC_FIRST_TELEM) { putsTelemetryChannel(CSWONE_2ND_COLUMN, y, cs->v1 - MIXSRC_FIRST_TELEM, convertCswTelemValue(cs), attr|LEFT); v2_max = maxTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1); - if (cstate == CS_FAMILY_OFS) { + if (cstate == LS_FAMILY_OFS) { v2_min = -128; v2_max -= 128; } @@ -4277,34 +4277,34 @@ void menuModelCustomSwitchOne(uint8_t event) } break; } - case CSW_FIELD_ANDSW: + case LS_FIELD_ANDSW: lcd_putsLeft(y, STR_AND_SWITCH); putsSwitches(CSWONE_2ND_COLUMN, y, cs->andsw, attr); - if (attr) CHECK_INCDEC_MODELVAR(event, cs->andsw, -MAX_CSW_ANDSW, MAX_CSW_ANDSW); + if (attr) CHECK_INCDEC_MODELVAR(event, cs->andsw, -MAX_LS_ANDSW, MAX_LS_ANDSW); break; - case CSW_FIELD_DURATION: + case LS_FIELD_DURATION: lcd_putsLeft(y, STR_DURATION); if (cs->duration > 0) lcd_outdezAtt(CSWONE_2ND_COLUMN, y, 5*cs->duration, attr|PREC1|LEFT); else lcd_putsiAtt(CSWONE_2ND_COLUMN, y, STR_MMMINV, 0, attr); - if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, cs->duration, MAX_CSW_DURATION); + if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, cs->duration, MAX_LS_DURATION); break; - case CSW_FIELD_DELAY: + case LS_FIELD_DELAY: lcd_putsLeft(y, STR_DELAY); if (cs->delay > 0) lcd_outdezAtt(CSWONE_2ND_COLUMN, y, 5*cs->delay, attr|PREC1|LEFT); else lcd_putsiAtt(CSWONE_2ND_COLUMN, y, STR_MMMINV, 0, attr); - if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, cs->delay, MAX_CSW_DELAY); + if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, cs->delay, MAX_LS_DELAY); break; } } } -void menuModelCustomSwitches(uint8_t event) +void menuModelLogicalSwitches(uint8_t event) { - SIMPLE_MENU(STR_MENUCUSTOMSWITCHES, menuTabModel, e_CustomSwitches, NUM_CSW+1); + SIMPLE_MENU(STR_MENUCUSTOMSWITCHES, menuTabModel, e_LogicalSwitches, NUM_CSW+1); uint8_t y = 0; uint8_t k = 0; @@ -4318,7 +4318,7 @@ void menuModelCustomSwitches(uint8_t event) case EVT_KEY_FIRST(KEY_ENTER): if (sub >= 0) { s_currIdx = sub; - pushMenu(menuModelCustomSwitchOne); + pushMenu(menuModelLogicalSwitchOne); } break; } @@ -4326,7 +4326,7 @@ void menuModelCustomSwitches(uint8_t event) for (uint8_t i=0; ifunc); - if (cstate == CS_FAMILY_BOOL || cstate == CS_FAMILY_STICKY) { + if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY) { putsSwitches(CSW_2ND_COLUMN, y, cs->v1, 0); putsSwitches(CSW_3RD_COLUMN, y, cs->v2, 0); } - else if (cstate == CS_FAMILY_COMP) { + else if (cstate == LS_FAMILY_COMP) { putsMixerSource(CSW_2ND_COLUMN, y, cs->v1, 0); putsMixerSource(CSW_3RD_COLUMN, y, cs->v2, 0); } - else if (cstate == CS_FAMILY_STAY) { + else if (cstate == LS_FAMILY_STAY) { putsSwitches(CSW_2ND_COLUMN, y, cs->v1, 0); lcd_putc(CSW_3RD_COLUMN-4, y, '['); lcd_outdezAtt(CSW_3RD_COLUMN, y, cswTimerValue(cs->v2), LEFT|PREC1); @@ -4359,7 +4359,7 @@ void menuModelCustomSwitches(uint8_t event) lcd_outdezAtt(lcdLastPos+3, y, cswTimerValue(cs->v2+cs->v3), LEFT|PREC1); lcd_putc(lcdLastPos-1, y, ']'); } - else if (cstate == CS_FAMILY_TIMER) { + else if (cstate == LS_FAMILY_TIMER) { lcd_outdezAtt(CSW_2ND_COLUMN, y, cs->v1+1, LEFT); lcd_outdezAtt(CSW_3RD_COLUMN, y, cs->v2+1, LEFT); } @@ -4391,17 +4391,17 @@ enum ClipboardType { struct Clipboard { ClipboardType type; union { - CustomSwData csw; + LogicalSwitchData csw; CustomFnData cfn; } data; }; Clipboard clipboard; -void onCustomSwitchesMenu(const char *result) +void onLogicalSwitchesMenu(const char *result) { int8_t sub = m_posVert-1; - CustomSwData * cs = cswAddress(sub); + LogicalSwitchData * cs = cswAddress(sub); if (result == STR_COPY) { clipboard.type = CLIPBOARD_TYPE_CUSTOM_SWITCH; @@ -4412,17 +4412,17 @@ void onCustomSwitchesMenu(const char *result) eeDirty(EE_MODEL); } else if (result == STR_DELETE) { - memset(cs, 0, sizeof(CustomSwData)); + memset(cs, 0, sizeof(LogicalSwitchData)); eeDirty(EE_MODEL); } } #endif -void menuModelCustomSwitches(uint8_t event) +void menuModelLogicalSwitches(uint8_t event) { INCDEC_DECLARE_VARS(); - MENU(STR_MENUCUSTOMSWITCHES, menuTabModel, e_CustomSwitches, NUM_CSW+1, {0, NAVIGATION_LINE_BY_LINE|CSW_FIELD_LAST/*repeated...*/}); + MENU(STR_MENUCUSTOMSWITCHES, menuTabModel, e_LogicalSwitches, NUM_CSW+1, {0, NAVIGATION_LINE_BY_LINE|LS_FIELD_LAST/*repeated...*/}); uint8_t y = 0; uint8_t k = 0; @@ -4438,12 +4438,12 @@ void menuModelCustomSwitches(uint8_t event) #if defined(PCBTARANIS) if (sub>=0 && horz<0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) { killEvents(event); - CustomSwData * cs = cswAddress(sub); + LogicalSwitchData * cs = cswAddress(sub); if (cs->func) MENU_ADD_ITEM(STR_COPY); if (clipboard.type == CLIPBOARD_TYPE_CUSTOM_SWITCH) MENU_ADD_ITEM(STR_PASTE); if (cs->func || cs->v1 || cs->v2 || cs->delay || cs->duration || cs->andsw) MENU_ADD_ITEM(STR_DELETE); - menuHandler = onCustomSwitchesMenu; + menuHandler = onLogicalSwitchesMenu; } #endif @@ -4453,7 +4453,7 @@ void menuModelCustomSwitches(uint8_t event) uint8_t attr = (sub==k ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0); uint8_t attr1 = (horz==1 ? attr : 0); uint8_t attr2 = (horz==2 ? attr : 0); - CustomSwData * cs = cswAddress(k); + LogicalSwitchData * cs = cswAddress(k); // CSW name uint8_t sw = SWSRC_SW1+k; @@ -4471,24 +4471,24 @@ void menuModelCustomSwitches(uint8_t event) int8_t v1_min=0, v1_max=MIXSRC_LAST_TELEM, v2_min=0, v2_max=MIXSRC_LAST_TELEM; #endif - if (cstate == CS_FAMILY_BOOL || cstate == CS_FAMILY_STICKY) { + if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY) { putsSwitches(CSW_2ND_COLUMN, y, cs->v1, attr1); putsSwitches(CSW_3RD_COLUMN, y, cs->v2, attr2); v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1; v2_min = SWSRC_OFF+1; v2_max = SWSRC_ON-1; INCDEC_SET_FLAG(INCDEC_SWITCH); - INCDEC_ENABLE_CHECK(isSwitchAvailableInCustomSwitches); + INCDEC_ENABLE_CHECK(isSwitchAvailableInLogicalSwitches); } #if defined(CPUARM) - else if (cstate == CS_FAMILY_STAY) { + else if (cstate == LS_FAMILY_STAY) { putsSwitches(CSW_2ND_COLUMN, y, cs->v1, attr1); lcd_putc(CSW_3RD_COLUMN-4, y, '['); lcd_outdezAtt(CSW_3RD_COLUMN, y, cswTimerValue(cs->v2), LEFT|PREC1|attr2); lcd_putc(lcdLastPos, y, ':'); if (cs->v3 == 0) - lcd_putsAtt(lcdLastPos+3, y, "--", (horz==CSW_FIELD_V3 ? attr : 0)); + lcd_putsAtt(lcdLastPos+3, y, "--", (horz==LS_FIELD_V3 ? attr : 0)); else - lcd_outdezAtt(lcdLastPos+3, y, cswTimerValue(cs->v2+cs->v3), LEFT|PREC1|(horz==CSW_FIELD_V3 ? attr : 0)); + lcd_outdezAtt(lcdLastPos+3, y, cswTimerValue(cs->v2+cs->v3), LEFT|PREC1|(horz==LS_FIELD_V3 ? attr : 0)); lcd_putc(lcdLastPos, y, ']'); v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1; v2_min=-129; v2_max = 122; @@ -4503,13 +4503,13 @@ void menuModelCustomSwitches(uint8_t event) } } #endif - else if (cstate == CS_FAMILY_COMP) { + else if (cstate == LS_FAMILY_COMP) { putsMixerSource(CSW_2ND_COLUMN, y, cs->v1, attr1); putsMixerSource(CSW_3RD_COLUMN, y, cs->v2, attr2); INCDEC_SET_FLAG(INCDEC_SOURCE); INCDEC_ENABLE_CHECK(isSourceAvailable); } - else if (cstate == CS_FAMILY_TIMER) { + else if (cstate == LS_FAMILY_TIMER) { lcd_outdezAtt(CSW_2ND_COLUMN, y, cswTimerValue(cs->v1), LEFT|PREC1|attr1); lcd_outdezAtt(CSW_3RD_COLUMN, y, cswTimerValue(cs->v2), LEFT|PREC1|attr2); v1_min = v2_min = -128; @@ -4538,7 +4538,7 @@ void menuModelCustomSwitches(uint8_t event) eeDirty(EE_MODEL); } #else - if (cstate == CS_FAMILY_OFS) { + if (cstate == LS_FAMILY_OFS) { v2_min = -128; v2_max -= 128; } @@ -4570,37 +4570,37 @@ void menuModelCustomSwitches(uint8_t event) // CSW AND switch #if defined(CPUARM) - putsSwitches(CSW_4TH_COLUMN, y, cs->andsw, horz==CSW_FIELD_ANDSW ? attr : 0); + putsSwitches(CSW_4TH_COLUMN, y, cs->andsw, horz==LS_FIELD_ANDSW ? attr : 0); #else uint8_t andsw = cs->andsw; if (andsw > SWSRC_LAST_SWITCH) { andsw += SWSRC_SW1-SWSRC_LAST_SWITCH-1; } - putsSwitches(CSW_4TH_COLUMN, y, andsw, horz==CSW_FIELD_ANDSW ? attr : 0); + putsSwitches(CSW_4TH_COLUMN, y, andsw, horz==LS_FIELD_ANDSW ? attr : 0); #endif #if defined(CPUARM) // CSW duration if (cs->duration > 0) - lcd_outdezAtt(CSW_5TH_COLUMN, y, 5*cs->duration, (horz==CSW_FIELD_DURATION ? attr : 0)|PREC1|LEFT); + lcd_outdezAtt(CSW_5TH_COLUMN, y, 5*cs->duration, (horz==LS_FIELD_DURATION ? attr : 0)|PREC1|LEFT); else - lcd_putsiAtt(CSW_5TH_COLUMN, y, STR_MMMINV, 0, horz==CSW_FIELD_DURATION ? attr : 0); + lcd_putsiAtt(CSW_5TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DURATION ? attr : 0); // CSW delay - if (cstate == CS_FAMILY_STAY) { + if (cstate == LS_FAMILY_STAY) { lcd_puts(CSW_6TH_COLUMN, y, "N/A"); - if (attr && horz == CSW_FIELD_DELAY) { + if (attr && horz == LS_FIELD_DELAY) { REPEAT_LAST_CURSOR_MOVE(); } } else if (cs->delay > 0) { - lcd_outdezAtt(CSW_6TH_COLUMN, y, 5*cs->delay, (horz==CSW_FIELD_DELAY ? attr : 0)|PREC1|LEFT); + lcd_outdezAtt(CSW_6TH_COLUMN, y, 5*cs->delay, (horz==LS_FIELD_DELAY ? attr : 0)|PREC1|LEFT); } else { - lcd_putsiAtt(CSW_6TH_COLUMN, y, STR_MMMINV, 0, horz==CSW_FIELD_DELAY ? attr : 0); + lcd_putsiAtt(CSW_6TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DELAY ? attr : 0); } - if (attr && horz == CSW_FIELD_V3 && cstate != CS_FAMILY_STAY) { + if (attr && horz == LS_FIELD_V3 && cstate != LS_FAMILY_STAY) { REPEAT_LAST_CURSOR_MOVE(); } #endif @@ -4608,38 +4608,38 @@ void menuModelCustomSwitches(uint8_t event) if ((s_editMode>0 || p1valdiff) && attr) { switch (horz) { - case CSW_FIELD_FUNCTION: + case LS_FIELD_FUNCTION: { #if defined(CPUARM) - cs->func = checkIncDec(event, cs->func, 0, CS_MAXF, EE_MODEL, isFunctionAvailable); + cs->func = checkIncDec(event, cs->func, 0, LS_FUNC_MAX, EE_MODEL, isLogicalSwitchFunctionAvailable); #else - CHECK_INCDEC_MODELVAR_ZERO(event, cs->func, CS_MAXF); + CHECK_INCDEC_MODELVAR_ZERO(event, cs->func, LS_FUNC_MAX); #endif uint8_t new_cstate = cswFamily(cs->func); if (cstate != new_cstate) { #if defined(CPUARM) - if (new_cstate == CS_FAMILY_TIMER) { + if (new_cstate == LS_FAMILY_TIMER) { cs->v1 = cs->v2 = -119; } - else if (new_cstate == CS_FAMILY_STAY) { + else if (new_cstate == LS_FAMILY_STAY) { cs->v1 = 0; cs->v2 = -129; cs->v3 = 0; } else { cs->v1 = cs->v2 = 0; } #else - cs->v1 = cs->v2 = (new_cstate==CS_FAMILY_TIMER ? -119/*1.0*/ : 0); + cs->v1 = cs->v2 = (new_cstate==LS_FAMILY_TIMER ? -119/*1.0*/ : 0); #endif } break; } - case CSW_FIELD_V1: + case LS_FIELD_V1: cs->v1 = CHECK_INCDEC_PARAM(event, cs->v1, v1_min, v1_max); break; - case CSW_FIELD_V2: + case LS_FIELD_V2: cs->v2 = CHECK_INCDEC_PARAM(event, cs->v2, v2_min, v2_max); #if defined(PCBTARANIS) - if (cstate==CS_FAMILY_OFS && cs->v1!=0 && event==EVT_KEY_LONG(KEY_ENTER)) { + if (cstate==LS_FAMILY_OFS && cs->v1!=0 && event==EVT_KEY_LONG(KEY_ENTER)) { killEvents(event); getvalue_t x = getValue(cs->v1); if (cs->v1 < MIXSRC_GVAR1) @@ -4651,25 +4651,25 @@ void menuModelCustomSwitches(uint8_t event) #endif break; #if defined(CPUARM) - case CSW_FIELD_V3: + case LS_FIELD_V3: cs->v3 = CHECK_INCDEC_PARAM(event, cs->v3, v3_min, v3_max); break; #endif - case CSW_FIELD_ANDSW: + case LS_FIELD_ANDSW: #if defined(CPUARM) INCDEC_SET_FLAG(INCDEC_SWITCH); - INCDEC_ENABLE_CHECK(isSwitchAvailableInCustomSwitches); - cs->andsw = CHECK_INCDEC_PARAM(event, cs->andsw, -MAX_CSW_ANDSW, MAX_CSW_ANDSW); + INCDEC_ENABLE_CHECK(isSwitchAvailableInLogicalSwitches); + cs->andsw = CHECK_INCDEC_PARAM(event, cs->andsw, -MAX_LS_ANDSW, MAX_LS_ANDSW); #else - CHECK_INCDEC_MODELVAR_ZERO(event, cs->andsw, MAX_CSW_ANDSW); + CHECK_INCDEC_MODELVAR_ZERO(event, cs->andsw, MAX_LS_ANDSW); #endif break; #if defined(CPUARM) - case CSW_FIELD_DURATION: - CHECK_INCDEC_MODELVAR_ZERO(event, cs->duration, MAX_CSW_DURATION); + case LS_FIELD_DURATION: + CHECK_INCDEC_MODELVAR_ZERO(event, cs->duration, MAX_LS_DURATION); break; - case CSW_FIELD_DELAY: - CHECK_INCDEC_MODELVAR_ZERO(event, cs->delay, MAX_CSW_DELAY); + case LS_FIELD_DELAY: + CHECK_INCDEC_MODELVAR_ZERO(event, cs->delay, MAX_LS_DELAY); break; #endif } diff --git a/radio/src/gui/menus.cpp b/radio/src/gui/menus.cpp index e6cbfccee..3296994d4 100644 --- a/radio/src/gui/menus.cpp +++ b/radio/src/gui/menus.cpp @@ -1219,8 +1219,8 @@ bool isSourceAvailable(int16_t source) } if (source>=MIXSRC_SW1 && source<=MIXSRC_LAST_CSW) { - CustomSwData * cs = cswAddress(source-MIXSRC_SW1); - return (cs->func != CS_OFF); + LogicalSwitchData * cs = cswAddress(source-MIXSRC_SW1); + return (cs->func != LS_FUNC_NONE); } #if !defined(GVARS) @@ -1248,7 +1248,7 @@ bool isInputSourceAvailable(int16_t source) return false; } -bool isSwitchAvailableInCustomSwitches(int16_t swtch) +bool isSwitchAvailableInLogicalSwitches(int16_t swtch) { if (swtch < 0) { if (swtch <= -SWSRC_ON) @@ -1279,22 +1279,35 @@ bool isSwitchAvailableInCustomSwitches(int16_t swtch) bool isSwitchAvailable(int16_t swtch) { - if (!isSwitchAvailableInCustomSwitches(swtch)) { + if (!isSwitchAvailableInLogicalSwitches(swtch)) { return false; } if (swtch >= SWSRC_FIRST_CSW && swtch <= SWSRC_LAST_CSW) { - CustomSwData * cs = cswAddress(swtch-SWSRC_FIRST_CSW); - return (cs->func != CS_OFF); + LogicalSwitchData * cs = cswAddress(swtch-SWSRC_FIRST_CSW); + return (cs->func != LS_FUNC_NONE); } return true; } // Not available yet, will be needed if we implement the Range function later... -bool isFunctionAvailable(int16_t function) +bool isLogicalSwitchFunctionAvailable(int16_t function) { - return function != CS_RANGE; + return function != LS_FUNC_RANGE; } +bool isAssignableFunctionAvailable(int16_t function) +{ + switch (function) { + +#if !defined(HAPTIC) + case FUNC_HAPTIC: + return false; +#endif + + default: + return true; + } +} #endif diff --git a/radio/src/gui/menus.h b/radio/src/gui/menus.h index eed58fd97..c476f2e71 100644 --- a/radio/src/gui/menus.h +++ b/radio/src/gui/menus.h @@ -190,9 +190,10 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max); var = checkIncDecModelZero(event,var,max) #if defined(CPUARM) - bool isFunctionAvailable(int16_t function); + bool isLogicalSwitchFunctionAvailable(int16_t function); + bool isAssignableFunctionAvailable(int16_t function); bool isSwitchAvailable(int16_t swtch); - bool isSwitchAvailableInCustomSwitches(int16_t swtch); + bool isSwitchAvailableInLogicalSwitches(int16_t swtch); #define AUTOSWITCH_ENTER_LONG() (attr && event==EVT_KEY_LONG(KEY_ENTER)) #define CHECK_INCDEC_MODELSWITCH(event, var, min, max) \ var = checkIncDec(event,var,min,max,EE_MODEL|INCDEC_SWITCH|NO_INCDEC_MARKS, isSwitchAvailable) diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index fd1f6db60..cbcfd1389 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -668,39 +668,39 @@ PACK( union u_int8int16_t { #endif -enum CswFunctions { - CS_OFF, - CS_VEQUAL, // v==offset - CS_VPOS, // v>offset - CS_VNEG, // voffset + LS_FUNC_VNEG, // voffset - CS_ANEG, // |v|offset + LS_FUNC_ANEG, // |v|andsw; #else @@ -1432,48 +1432,48 @@ bool getSwitch(int8_t swtch) s += SWSRC_SW1-SWSRC_LAST_SWITCH-1; } #endif - if (cs->func == CS_OFF || (s && !getSwitch(s))) { + if (cs->func == LS_FUNC_NONE || (s && !getSwitch(s))) { csLastValue[cs_idx] = CS_LAST_VALUE_INIT; result = false; } - else if ((s=cswFamily(cs->func)) == CS_FAMILY_BOOL) { + else if ((s=cswFamily(cs->func)) == LS_FAMILY_BOOL) { bool res1 = getSwitch(cs->v1); bool res2 = getSwitch(cs->v2); switch (cs->func) { - case CS_AND: + case LS_FUNC_AND: result = (res1 && res2); break; - case CS_OR: + case LS_FUNC_OR: result = (res1 || res2); break; - // case CS_XOR: + // case LS_FUNC_XOR: default: result = (res1 ^ res2); break; } } - else if (s == CS_FAMILY_TIMER) { + else if (s == LS_FAMILY_TIMER) { result = (csLastValue[cs_idx] <= 0); } - else if (s == CS_FAMILY_STICKY) { + else if (s == LS_FAMILY_STICKY) { result = (csLastValue[cs_idx] & (1<<0)); } #if defined(CPUARM) - else if (s == CS_FAMILY_STAY) { + else if (s == LS_FAMILY_STAY) { result = (csLastValue[cs_idx] & (1<<0)); } #endif else { getvalue_t x = getValue(cs->v1); getvalue_t y; - if (s == CS_FAMILY_COMP) { + if (s == LS_FAMILY_COMP) { y = getValue(cs->v2); switch (cs->func) { - case CS_EQUAL: + case LS_FUNC_EQUAL: result = (x==y); break; - case CS_GREATER: + case LS_FUNC_GREATER: result = (x>y); break; default: @@ -1491,7 +1491,7 @@ bool getSwitch(int8_t swtch) y = convertCswTelemValue(cs); #if defined(FRSKY_HUB) && defined(GAUGES) - if (s == CS_FAMILY_OFS) { + if (s == LS_FAMILY_OFS) { uint8_t idx = cs->v1-MIXSRC_FIRST_TELEM+1-TELEM_ALT; if (idx < THLD_MAX) { // Fill the threshold array @@ -1519,7 +1519,7 @@ bool getSwitch(int8_t swtch) #endif switch (cs->func) { - case CS_VEQUAL: + case LS_FUNC_VEQUAL: #if defined(GVARS) if (cs->v1 >= MIXSRC_GVAR1 && cs->v1 <= MIXSRC_LAST_GVAR) result = (x==y); @@ -1527,16 +1527,16 @@ bool getSwitch(int8_t swtch) #endif result = (abs(x-y) < (1024 / STICK_TOLERANCE)); break; - case CS_VPOS: + case LS_FUNC_VPOS: result = (x>y); break; - case CS_VNEG: + case LS_FUNC_VNEG: result = (xy); break; - case CS_ANEG: + case LS_FUNC_ANEG: result = (abs(x)func == CS_DIFFEGREATER) + if (cs->func == LS_FUNC_DIFFEGREATER) result = (y >= 0 ? (diff >= y) : (diff <= y)); else result = (abs(diff) >= y); @@ -1578,7 +1578,7 @@ bool getSwitch(int8_t swtch) if (cswDurations[cs_idx] > get_tmr10ms()) { result = true; } - else if (s == CS_FAMILY_STICKY) { + else if (s == LS_FAMILY_STICKY) { csLastValue[cs_idx] &= ~(1<<0); } } @@ -1925,7 +1925,7 @@ void setGVarValue(uint8_t idx, int16_t value, int8_t phase) #endif #if defined(FRSKY) -csw_telemetry_value_t minTelemValue(uint8_t channel) +ls_telemetry_value_t minTelemValue(uint8_t channel) { switch (channel) { case TELEM_FUEL: @@ -1944,7 +1944,7 @@ csw_telemetry_value_t minTelemValue(uint8_t channel) } } -csw_telemetry_value_t maxTelemValue(uint8_t channel) +ls_telemetry_value_t maxTelemValue(uint8_t channel) { switch (channel) { case TELEM_FUEL: @@ -1965,7 +1965,7 @@ csw_telemetry_value_t maxTelemValue(uint8_t channel) #endif #if defined(CPUARM) -getvalue_t convert16bitsTelemValue(uint8_t channel, csw_telemetry_value_t value) +getvalue_t convert16bitsTelemValue(uint8_t channel, ls_telemetry_value_t value) { getvalue_t result; switch (channel) { @@ -1979,13 +1979,13 @@ getvalue_t convert16bitsTelemValue(uint8_t channel, csw_telemetry_value_t value) return result; } -csw_telemetry_value_t max8bitsTelemValue(uint8_t channel) +ls_telemetry_value_t max8bitsTelemValue(uint8_t channel) { - return min(255, maxTelemValue(channel)); + return min(255, maxTelemValue(channel)); } #endif -getvalue_t convert8bitsTelemValue(uint8_t channel, csw_telemetry_value_t value) +getvalue_t convert8bitsTelemValue(uint8_t channel, ls_telemetry_value_t value) { getvalue_t result; switch (channel) { @@ -2037,13 +2037,13 @@ getvalue_t convert8bitsTelemValue(uint8_t channel, csw_telemetry_value_t value) return result; } -getvalue_t convertCswTelemValue(CustomSwData * cs) +getvalue_t convertCswTelemValue(LogicalSwitchData * cs) { getvalue_t val; #if defined(CPUARM) val = convert16bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, cs->v2); #else - if (cswFamily(cs->func)==CS_FAMILY_OFS) + if (cswFamily(cs->func)==LS_FAMILY_OFS) val = convert8bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128+cs->v2); else val = convert8bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128+cs->v2) - convert8bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128); @@ -4051,8 +4051,8 @@ void doMixerCalculations() s_cnt_1s += 1; for (uint8_t i=0; ifunc == CS_TIMER) { + LogicalSwitchData * cs = cswAddress(i); + if (cs->func == LS_FUNC_TIMER) { int16_t *lastValue = &csLastValue[i]; if (*lastValue == 0 || *lastValue == CS_LAST_VALUE_INIT) { *lastValue = -cswTimerValue(cs->v1); @@ -4065,7 +4065,7 @@ void doMixerCalculations() *lastValue -= 1; } } - else if (cs->func == CS_STICKY) { + else if (cs->func == LS_FUNC_STICKY) { PACK(typedef struct { bool state; bool last; @@ -4092,7 +4092,7 @@ void doMixerCalculations() } } #if defined(CPUARM) - else if (cs->func == CS_STAY) { + else if (cs->func == LS_FUNC_STAY) { PACK(typedef struct { uint8_t state:1; uint16_t duration:15; diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 8da0f1d9d..f282209a0 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -1225,7 +1225,7 @@ ExpoData *expoAddress(uint8_t idx); MixData *mixAddress(uint8_t idx); LimitData *limitAddress(uint8_t idx); int8_t *curveAddress(uint8_t idx); -CustomSwData *cswAddress(uint8_t idx); +LogicalSwitchData *cswAddress(uint8_t idx); #if !defined(PCBTARANIS) struct CurveInfo { @@ -1290,14 +1290,14 @@ extern int24_t act [MAX_MIXERS]; #endif enum CswFunctionFamilies { - CS_FAMILY_OFS, - CS_FAMILY_BOOL, - CS_FAMILY_COMP, - CS_FAMILY_DIFF, - CS_FAMILY_TIMER, - CS_FAMILY_STICKY, - CS_FAMILY_RANGE, - CS_FAMILY_STAY + LS_FAMILY_OFS, + LS_FAMILY_BOOL, + LS_FAMILY_COMP, + LS_FAMILY_DIFF, + LS_FAMILY_TIMER, + LS_FAMILY_STICKY, + LS_FAMILY_RANGE, + LS_FAMILY_STAY }; uint8_t cswFamily(uint8_t func); @@ -1646,20 +1646,20 @@ extern uint8_t barsThresholds[THLD_MAX]; #endif #if defined(FRSKY) - csw_telemetry_value_t minTelemValue(uint8_t channel); - csw_telemetry_value_t maxTelemValue(uint8_t channel); + ls_telemetry_value_t minTelemValue(uint8_t channel); + ls_telemetry_value_t maxTelemValue(uint8_t channel); #else #define minTelemValue(channel) 255 #define maxTelemValue(channel) 255 #endif #if defined(CPUARM) -getvalue_t convert16bitsTelemValue(uint8_t channel, csw_telemetry_value_t value); -csw_telemetry_value_t max8bitsTelemValue(uint8_t channel); +getvalue_t convert16bitsTelemValue(uint8_t channel, ls_telemetry_value_t value); +ls_telemetry_value_t max8bitsTelemValue(uint8_t channel); #endif -getvalue_t convert8bitsTelemValue(uint8_t channel, csw_telemetry_value_t value); -getvalue_t convertCswTelemValue(CustomSwData * cs); +getvalue_t convert8bitsTelemValue(uint8_t channel, ls_telemetry_value_t value); +getvalue_t convertCswTelemValue(LogicalSwitchData * cs); #if defined(CPUARM) #define convertTelemValue(channel, value) convert16bitsTelemValue(channel, value) diff --git a/radio/src/templates.cpp b/radio/src/templates.cpp index aad22a8c1..1b2e59a10 100644 --- a/radio/src/templates.cpp +++ b/radio/src/templates.cpp @@ -146,7 +146,7 @@ void setCurve(uint8_t c, const pm_int8_t ar[]) void setSwitch(uint8_t idx, uint8_t func, int8_t v1, int8_t v2) { - CustomSwData *cs = cswAddress(idx-1); + LogicalSwitchData *cs = cswAddress(idx-1); cs->func = func; cs->v1 = v1; cs->v2 = v2; @@ -198,8 +198,8 @@ void applyTemplate(uint8_t idx) md=setDest(13, MIXSRC_CH14); // md->weight= 100; done by setDest anyway md=setDest(13, MIXSRC_MAX); mixSetWeight(md, -100); md->swtch=SWSRC_SWB; md->mltpx=MLTPX_REP; md=setDest(13, MIXSRC_MAX); /* md->weight= 100;*/ md->swtch=SWSRC_THR; md->mltpx=MLTPX_REP; - setSwitch(11, CS_VNEG, STK_THR, -99); - setSwitch(12, CS_VPOS, MIXSRC_CH14, 0); + setSwitch(11, LS_FUNC_VNEG, STK_THR, -99); + setSwitch(12, LS_FUNC_VPOS, MIXSRC_CH14, 0); break; // V-Tail @@ -283,7 +283,7 @@ void applyTemplate(uint8_t idx) // Servo Test case TMPL_SERVO_TEST: md=setDest(NUM_CHNOUT-1, MIXSRC_SW1, true); md->weight=110; md->mltpx=MLTPX_ADD; md->delayUp = 6; md->delayDown = 6; md->speedUp = 8; md->speedDown = 8; - setSwitch(1, CS_VNEG, MIXSRC_LAST_CH, 0); + setSwitch(1, LS_FUNC_VNEG, MIXSRC_LAST_CH, 0); break; default: