chore: Companion - port of OpenTX function switches management (#1694)

* TPro - Port of OpenTX function switches management (https://github.com/opentx/opentx/pull/8847)

* cleanup

* Corrections

* Fix YAML generation and adjusted switches to match TPRO firmware

Co-authored-by: Batam <batam@macbook-pro.home>
This commit is contained in:
Batambatam
2022-03-21 10:43:27 +10:00
committed by GitHub
co-authored by Batam
parent 1d7c153979
commit ab15a5a514
22 changed files with 434 additions and 186 deletions
+19 -6
View File
@@ -184,9 +184,10 @@ class ModelData {
};
enum FunctionSwitchStart {
FUNC_SWITCH_START_INACTIVE,
FUNC_SWITCH_START_FIRST = FUNC_SWITCH_START_INACTIVE,
FUNC_SWITCH_START_ACTIVE,
FUNC_SWITCH_START_FIRST = FUNC_SWITCH_START_ACTIVE,
FUNC_SWITCH_START_INACTIVE,
//FUNC_SWITCH_START_FIRST = FUNC_SWITCH_START_INACTIVE,
FUNC_SWITCH_START_PREVIOUS,
FUNC_SWITCH_START_LAST = FUNC_SWITCH_START_PREVIOUS
};
@@ -232,6 +233,8 @@ class ModelData {
int getChannelsMax(bool forceExtendedLimits=false) const;
bool isAvailable(const RawSwitch & swtch) const;
bool isFunctionSwitchPositionAvailable(int index) const;
bool isFunctionSwitchSourceAllowed(int index) const;
enum ReferenceUpdateAction {
REF_UPD_ACT_CLEAR,
@@ -287,13 +290,23 @@ class ModelData {
static QString trainerModeToString(const int value);
static bool isTrainerModeAvailable(const GeneralSettings & generalSettings, const Firmware * firmware, const int value);
static AbstractStaticItemModel * trainerModeItemModel(const GeneralSettings & generalSettings, const Firmware * firmware);
QString funcSwitchConfigToString(const int index) const;
static QString funcSwitchConfigToString(const int index, const int value);
unsigned int getFuncSwitchConfig(unsigned int index) const;
void setFuncSwitchConfig(unsigned int index, unsigned int value);
static QString funcSwitchConfigToString(unsigned int value);
static AbstractStaticItemModel * funcSwitchConfigItemModel();
QString funcSwitchStartToString(const int index) const;
static QString funcSwitchStartToString(const int index, const int value);
unsigned int getFuncSwitchGroup(unsigned int index) const;
void setFuncSwitchGroup(unsigned int index, unsigned int value);
unsigned int getFuncSwitchAlwaysOnGroup(unsigned int index) const;
void setFuncSwitchAlwaysOnGroup(unsigned int index, unsigned int value);
unsigned int getFuncSwitchStart(unsigned int index) const;
void setFuncSwitchStart(unsigned int index, unsigned int value);
static QString funcSwitchStartToString(unsigned int value);
static AbstractStaticItemModel * funcSwitchStartItemModel();
protected:
void removeGlobalVar(int & var);