diff --git a/companion/src/constants.h b/companion/src/constants.h index c28e7a218..322b016a1 100644 --- a/companion/src/constants.h +++ b/companion/src/constants.h @@ -30,10 +30,10 @@ #define CPN_MAX_CURVES 32 #define CPN_MAX_POINTS 17 #define CPN_MAX_GVARS 9 -#define CPN_MAX_ENCODERS 2 // rotary encoders -#define CPN_MAX_CHNOUT 32 // number of real output channels -#define CPN_MAX_CSW 64 // number of custom switches -#define CPN_MAX_CUSTOM_FUNCTIONS 64 // number of functions assigned to switches +#define CPN_MAX_ENCODERS 2 // rotary encoders +#define CPN_MAX_CHNOUT 32 // number of real output channels +#define CPN_MAX_LOGICAL_SWITCHES 64 // number of custom switches +#define CPN_MAX_SPECIAL_FUNCTIONS 64 // number of functions assigned to switches #define CPN_MAX_MODULES 2 #define CPN_MAX_STICKS Board::STICK_AXIS_COUNT #define CPN_MAX_TRIMS Board::TRIM_AXIS_COUNT diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index 15f834e12..6e62b51f5 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -1528,9 +1528,9 @@ void ModelData::clear() limitData[i].clear(); for (int i=0; i tracksSet; QSet scriptsSet; int mediaPlayerCurrent; - QComboBox * fswtchSwtch[CPN_MAX_CUSTOM_FUNCTIONS]; - QComboBox * fswtchFunc[CPN_MAX_CUSTOM_FUNCTIONS]; - QCheckBox * fswtchParamGV[CPN_MAX_CUSTOM_FUNCTIONS]; - QDoubleSpinBox * fswtchParam[CPN_MAX_CUSTOM_FUNCTIONS]; - QTimeEdit * fswtchParamTime[CPN_MAX_CUSTOM_FUNCTIONS]; - QPushButton * playBT[CPN_MAX_CUSTOM_FUNCTIONS]; - QComboBox * fswtchParamT[CPN_MAX_CUSTOM_FUNCTIONS]; - QComboBox * fswtchParamArmT[CPN_MAX_CUSTOM_FUNCTIONS]; - QCheckBox * fswtchEnable[CPN_MAX_CUSTOM_FUNCTIONS]; - RepeatComboBox * fswtchRepeat[CPN_MAX_CUSTOM_FUNCTIONS]; - QComboBox * fswtchGVmode[CPN_MAX_CUSTOM_FUNCTIONS]; - QSlider * fswtchBLcolor[CPN_MAX_CUSTOM_FUNCTIONS]; + QComboBox * fswtchSwtch[CPN_MAX_SPECIAL_FUNCTIONS]; + QComboBox * fswtchFunc[CPN_MAX_SPECIAL_FUNCTIONS]; + QCheckBox * fswtchParamGV[CPN_MAX_SPECIAL_FUNCTIONS]; + QDoubleSpinBox * fswtchParam[CPN_MAX_SPECIAL_FUNCTIONS]; + QTimeEdit * fswtchParamTime[CPN_MAX_SPECIAL_FUNCTIONS]; + QPushButton * playBT[CPN_MAX_SPECIAL_FUNCTIONS]; + QComboBox * fswtchParamT[CPN_MAX_SPECIAL_FUNCTIONS]; + QComboBox * fswtchParamArmT[CPN_MAX_SPECIAL_FUNCTIONS]; + QCheckBox * fswtchEnable[CPN_MAX_SPECIAL_FUNCTIONS]; + RepeatComboBox * fswtchRepeat[CPN_MAX_SPECIAL_FUNCTIONS]; + QComboBox * fswtchGVmode[CPN_MAX_SPECIAL_FUNCTIONS]; + QSlider * fswtchBLcolor[CPN_MAX_SPECIAL_FUNCTIONS]; QMediaPlayer * mediaPlayer; int selectedFunction; diff --git a/companion/src/modeledit/logicalswitches.h b/companion/src/modeledit/logicalswitches.h index 32464dbaf..70342898a 100644 --- a/companion/src/modeledit/logicalswitches.h +++ b/companion/src/modeledit/logicalswitches.h @@ -48,16 +48,16 @@ class LogicalSwitchesPanel : public ModelPanel void cswCut(); private: - QComboBox * csw[CPN_MAX_CSW]; - QDoubleSpinBox * cswitchValue[CPN_MAX_CSW]; - QDoubleSpinBox * cswitchOffset[CPN_MAX_CSW]; - QDoubleSpinBox * cswitchOffset2[CPN_MAX_CSW]; - QTimeEdit * cswitchTOffset[CPN_MAX_CSW]; - QComboBox * cswitchAnd[CPN_MAX_CSW]; - QDoubleSpinBox * cswitchDuration[CPN_MAX_CSW]; - QDoubleSpinBox * cswitchDelay[CPN_MAX_CSW]; - QComboBox * cswitchSource1[CPN_MAX_CSW]; - QComboBox * cswitchSource2[CPN_MAX_CSW]; + QComboBox * csw[CPN_MAX_LOGICAL_SWITCHES]; + QDoubleSpinBox * cswitchValue[CPN_MAX_LOGICAL_SWITCHES]; + QDoubleSpinBox * cswitchOffset[CPN_MAX_LOGICAL_SWITCHES]; + QDoubleSpinBox * cswitchOffset2[CPN_MAX_LOGICAL_SWITCHES]; + QTimeEdit * cswitchTOffset[CPN_MAX_LOGICAL_SWITCHES]; + QComboBox * cswitchAnd[CPN_MAX_LOGICAL_SWITCHES]; + QDoubleSpinBox * cswitchDuration[CPN_MAX_LOGICAL_SWITCHES]; + QDoubleSpinBox * cswitchDelay[CPN_MAX_LOGICAL_SWITCHES]; + QComboBox * cswitchSource1[CPN_MAX_LOGICAL_SWITCHES]; + QComboBox * cswitchSource2[CPN_MAX_LOGICAL_SWITCHES]; QStandardItemModel * rawSwitchItemModel; QStandardItemModel * rawSourceItemModel; void setSwitchWidgetVisibility(int i); diff --git a/companion/src/radiodata.cpp b/companion/src/radiodata.cpp index 4d09f71b9..6a284b5c5 100644 --- a/companion/src/radiodata.cpp +++ b/companion/src/radiodata.cpp @@ -23,7 +23,7 @@ // TODO here we will move a lot of functions from eeprominterface.cpp when no merge risk -void RawSource::convert(Board::Type before, Board::Type after) +RawSource RawSource::convert(Board::Type before, Board::Type after) { if (type == SOURCE_TYPE_STICK && index >= 4 + getBoardCapability(before, Board::Pots)) { // 1st slider alignment @@ -57,11 +57,79 @@ void RawSource::convert(Board::Type before, Board::Type after) } } } + + return *this; +} + +RawSwitch RawSwitch::convert(Board::Type before, Board::Type after) +{ + // SWI to SWR don't exist on !X9E board + if (!IS_TARANIS_X9E(after) && IS_TARANIS_X9E(before)) { + if (type == SWITCH_TYPE_SWITCH && index >= 24) { + index = index % 24; + } + } + + // No SE and SG on X7 board + if (IS_TARANIS_X7(after)) { + if (IS_TARANIS_X9(before) || IS_HORUS(before)) { + if (type == SWITCH_TYPE_SWITCH && index >= 18) { + index -= 6; + } + else if (type == SWITCH_TYPE_SWITCH && index >= 12) { + index -= 3; + } + } + } + + return *this; +} + +void ExpoData::convert(Board::Type before, Board::Type after) +{ + swtch.convert(before, after); } void MixData::convert(Board::Type before, Board::Type after) { srcRaw.convert(before, after); + swtch.convert(before, after); +} + +void LogicalSwitchData::convert(Board::Type before, Board::Type after) +{ + CSFunctionFamily family = getFunctionFamily(); + switch(family) { + case LS_FAMILY_VOFS: + val1 = RawSource(val1).convert(before, after).toValue(); + break; + case LS_FAMILY_STICKY: + case LS_FAMILY_VBOOL: + val1 = RawSwitch(val1).convert(before, after).toValue(); + val2 = RawSwitch(val2).convert(before, after).toValue(); + break; + case LS_FAMILY_EDGE: + val1 = RawSwitch(val1).convert(before, after).toValue(); + break; + case LS_FAMILY_VCOMP: + val1 = RawSource(val1).convert(before, after).toValue(); + val2 = RawSource(val2).convert(before, after).toValue(); + break; + default: + break; + } + + andsw = RawSwitch(andsw).convert(before, after).toValue(); +} + +void CustomFunctionData::convert(Board::Type before, Board::Type after) +{ + swtch.convert(before, after); +} + +void FlightModeData::convert(Board::Type before, Board::Type after) +{ + swtch.convert(before, after); } void ModelData::convert(Board::Type before, Board::Type after) @@ -70,11 +138,37 @@ void ModelData::convert(Board::Type before, Board::Type after) for (int i=0; itype != other.type) || (this->index != other.index); } + RawSwitch convert(Board::Type before, Board::Type after); + RawSwitchType type; int index; }; @@ -338,6 +340,7 @@ class ExpoData { int carryTrim; char name[10+1]; void clear() { memset(this, 0, sizeof(ExpoData)); } + void convert(Board::Type before, Board::Type after); }; class CurvePoint { @@ -468,6 +471,7 @@ class LogicalSwitchData { // Logical Switches data CSFunctionFamily getFunctionFamily() const; unsigned int getRangeFlags() const; QString funcToString() const; + void convert(Board::Type before, Board::Type after); }; enum AssignFunc { @@ -536,6 +540,8 @@ class CustomFunctionData { // Function Switches data static void populatePlaySoundParams(QStringList & qs); static void populateHapticParams(QStringList & qs); + void convert(Board::Type before, Board::Type after); + }; class FlightModeData { @@ -551,6 +557,7 @@ class FlightModeData { int rotaryEncoders[CPN_MAX_ENCODERS]; int gvars[CPN_MAX_GVARS]; void clear(const int phase); + void convert(Board::Type before, Board::Type after); }; class SwashRingData { // Swash Ring data @@ -1033,8 +1040,8 @@ class ModelData { ExpoData expoData[CPN_MAX_EXPOS]; CurveData curves[CPN_MAX_CURVES]; - LogicalSwitchData logicalSw[CPN_MAX_CSW]; - CustomFunctionData customFn[CPN_MAX_CUSTOM_FUNCTIONS]; + LogicalSwitchData logicalSw[CPN_MAX_LOGICAL_SWITCHES]; + CustomFunctionData customFn[CPN_MAX_SPECIAL_FUNCTIONS]; SwashRingData swashRingData; unsigned int thrTraceSrc; uint64_t switchWarningStates; @@ -1200,7 +1207,7 @@ class GeneralSettings { unsigned int switchUnlockStates; unsigned int hw_uartMode; unsigned int backlightColor; - CustomFunctionData customFn[CPN_MAX_CUSTOM_FUNCTIONS]; + CustomFunctionData customFn[CPN_MAX_SPECIAL_FUNCTIONS]; char switchName[CPN_MAX_SWITCHES][3+1]; unsigned int switchConfig[CPN_MAX_SWITCHES]; char stickName[CPN_MAX_STICKS][3+1]; diff --git a/companion/src/simulation/radiooutputswidget.cpp b/companion/src/simulation/radiooutputswidget.cpp index a7b06e7b9..d2cdd686d 100644 --- a/companion/src/simulation/radiooutputswidget.cpp +++ b/companion/src/simulation/radiooutputswidget.cpp @@ -321,7 +321,7 @@ void RadioOutputsWidget::setValues() if (ui->logicalSwitchesWidget->isVisible()) { QHash::const_iterator ls; for (ls = m_logicSwitchMap.constBegin(); ls != m_logicSwitchMap.constEnd(); ++ls) { - if (ls.key() >= CPN_MAX_CSW || (prevOutputs.vsw[ls.key()] == outputs.vsw[ls.key()] && m_lastFlightPhase > -1)) + if (ls.key() >= CPN_MAX_LOGICAL_SWITCHES || (prevOutputs.vsw[ls.key()] == outputs.vsw[ls.key()] && m_lastFlightPhase > -1)) continue; ls.value()->setBackgroundRole(outputs.vsw[ls.key()] ? QPalette::Dark : QPalette::Background); ls.value()->setForegroundRole(outputs.vsw[ls.key()] ? QPalette::BrightText : QPalette::WindowText); diff --git a/companion/src/simulation/simulatorinterface.h b/companion/src/simulation/simulatorinterface.h index 834d33746..deeaa687d 100644 --- a/companion/src/simulation/simulatorinterface.h +++ b/companion/src/simulation/simulatorinterface.h @@ -49,7 +49,7 @@ class TxOutputs public: TxOutputs() { memset(this, 0, sizeof(TxOutputs)); } int chans[CPN_MAX_CHNOUT]; - bool vsw[CPN_MAX_CSW]; + bool vsw[CPN_MAX_LOGICAL_SWITCHES]; int gvars[CPN_MAX_FLIGHT_MODES][CPN_MAX_GVARS]; unsigned int beep; // uint8_t phase;