diff --git a/companion/src/datamodels/compounditemmodels.cpp b/companion/src/datamodels/compounditemmodels.cpp index 29dc9b8f5..7ee049d1f 100644 --- a/companion/src/datamodels/compounditemmodels.cpp +++ b/companion/src/datamodels/compounditemmodels.cpp @@ -118,7 +118,7 @@ RawSourceItemModel::RawSourceItemModel(const GeneralSettings * const generalSett addItems(SOURCE_TYPE_CYC, RawSource::SourcesGroup, CPN_MAX_CYC); addItems(SOURCE_TYPE_PPM, RawSource::SourcesGroup, firmware->getCapability(TrainerInputs)); addItems(SOURCE_TYPE_CH, RawSource::SourcesGroup, firmware->getCapability(Outputs)); - addItems(SOURCE_TYPE_SPECIAL, RawSource::TelemGroup, 6); + addItems(SOURCE_TYPE_SPECIAL, RawSource::TelemGroup, SOURCE_TYPE_SPECIAL_COUNT); addItems(SOURCE_TYPE_TELEMETRY, RawSource::TelemGroup, firmware->getCapability(Sensors) * 3); addItems(SOURCE_TYPE_GVAR, RawSource::GVarsGroup, firmware->getCapability(Gvars)); } diff --git a/companion/src/firmwares/customfunctiondata.cpp b/companion/src/firmwares/customfunctiondata.cpp index f60f1c74a..293bdd6db 100644 --- a/companion/src/firmwares/customfunctiondata.cpp +++ b/companion/src/firmwares/customfunctiondata.cpp @@ -84,7 +84,7 @@ QString CustomFunctionData::funcToString(const AssignFunc func, const ModelData else if (func == FuncReset) return tr("Reset"); else if (func >= FuncSetTimer1 && func <= FuncSetTimerLast) - return tr("Set %1").arg(RawSource(SOURCE_TYPE_SPECIAL, SOURCE_TYPE_SPECIAL_TIMER1_IDX + func - FuncSetTimer1).toString(model)); + return tr("Set %1").arg(RawSource(SOURCE_TYPE_SPECIAL, SOURCE_TYPE_SPECIAL_FIRST_TIMER + func - FuncSetTimer1).toString(model)); else if (func == FuncVario) return tr("Vario"); else if (func == FuncPlayPrompt) @@ -249,7 +249,7 @@ QString CustomFunctionData::resetToString(const int value, const ModelData * mod if (value < step) { if (value < firmware->getCapability(Timers)) - return RawSource(SOURCE_TYPE_SPECIAL, value + SOURCE_TYPE_SPECIAL_TIMER1_IDX).toString(model); + return RawSource(SOURCE_TYPE_SPECIAL, value + SOURCE_TYPE_SPECIAL_FIRST_TIMER).toString(model); else return QString(CPN_STR_UNKNOWN_ITEM); } diff --git a/companion/src/firmwares/edgetx/yaml_rawsource.cpp b/companion/src/firmwares/edgetx/yaml_rawsource.cpp index 868ab4776..df72ec4fd 100644 --- a/companion/src/firmwares/edgetx/yaml_rawsource.cpp +++ b/companion/src/firmwares/edgetx/yaml_rawsource.cpp @@ -45,9 +45,13 @@ const YamlLookupTable specialSourceLut = { { 0, "TX_VOLTAGE" }, { 1, "TX_TIME" }, { 2, "TX_GPS" }, - { 3, "TIMER1" }, - { 4, "TIMER2" }, - { 5, "TIMER3" }, + { 3, "RESERVED1" }, + { 4, "RESERVED2" }, + { 5, "RESERVED3" }, + { 6, "RESERVED4" }, + { 7, "TIMER1" }, + { 8, "TIMER2" }, + { 9, "TIMER3" }, }; std::string YamlRawSourceEncode(const RawSource& rhs) diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 51402e931..d07c0887c 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -184,6 +184,7 @@ inline int MAX_MOUSE_ANALOG_SOURCES(Board::Type board, int version) #define NUM_PPM_INPUTS(board, version) 16 #define ROTENC_COUNT(board, version) ((IS_STM32(board) && version >= 218) ? 0 : 1) #define MAX_AUX_TRIMS(board) ((IS_FAMILY_HORUS_OR_T16(board) && !IS_FLYSKY_NV14(board)) ? 2 : 0) +#define MAX_SOURCE_TYPE_SPECIAL(board, version) SOURCE_TYPE_SPECIAL_COUNT inline int switchIndex(int i, Board::Type board, unsigned int version) { @@ -382,13 +383,8 @@ class SourcesConversionTable: public ConversionTable { if (!(flags & FLAG_NOTELEMETRY)) { for (int i=0; i= SOURCE_TYPE_SPECIAL_TIMER1_IDX && index <= SOURCE_TYPE_SPECIAL_TIMER1_IDX + CPN_MAX_TIMERS - 1) { + if (index >= SOURCE_TYPE_SPECIAL_FIRST_TIMER && index <= SOURCE_TYPE_SPECIAL_LAST_TIMER) { if (model) - result = model->timers[index - SOURCE_TYPE_SPECIAL_TIMER1_IDX].nameToString(index - SOURCE_TYPE_SPECIAL_TIMER1_IDX); + result = model->timers[index - SOURCE_TYPE_SPECIAL_FIRST_TIMER].nameToString(index - SOURCE_TYPE_SPECIAL_FIRST_TIMER); else - result = TimerData().nameToString(index - SOURCE_TYPE_SPECIAL_TIMER1_IDX); + result = TimerData().nameToString(index - SOURCE_TYPE_SPECIAL_FIRST_TIMER); } else result = CHECK_IN_ARRAY(special, index); @@ -293,7 +293,7 @@ bool RawSource::isSlider(int * sliderIndex, Board::Type board) const bool RawSource::isTimeBased(Board::Type board) const { - return (type == SOURCE_TYPE_SPECIAL && index >= SOURCE_TYPE_SPECIAL_TIMER1_IDX); + return (type == SOURCE_TYPE_SPECIAL && index >= SOURCE_TYPE_SPECIAL_FIRST_TIMER && index <= SOURCE_TYPE_SPECIAL_LAST_TIMER); } bool RawSource::isAvailable(const ModelData * const model, const GeneralSettings * const gs, Board::Type board) const @@ -309,6 +309,9 @@ bool RawSource::isAvailable(const ModelData * const model, const GeneralSettings if (type == SOURCE_TYPE_SWITCH && index >= b.getCapability(Board::Switches)) return false; + if (type == SOURCE_TYPE_SPECIAL && index >= SOURCE_TYPE_SPECIAL_FIRST_RESERVED && index <= SOURCE_TYPE_SPECIAL_LAST_RESERVED) + return false; + if (model) { if (type == SOURCE_TYPE_VIRTUAL_INPUT && !model->isInputValid(index)) return false; diff --git a/companion/src/firmwares/rawsource.h b/companion/src/firmwares/rawsource.h index 25779ccd4..f5fbfbcd5 100644 --- a/companion/src/firmwares/rawsource.h +++ b/companion/src/firmwares/rawsource.h @@ -178,8 +178,25 @@ enum RawSourceType { MAX_SOURCE_TYPE }; +enum RawSourceTypeSpecial { + SOURCE_TYPE_SPECIAL_TX_BATT, + SOURCE_TYPE_SPECIAL_TX_TIME, + SOURCE_TYPE_SPECIAL_TX_GPS, + SOURCE_TYPE_SPECIAL_FIRST_RESERVED, + SOURCE_TYPE_SPECIAL_RESERVED1 = SOURCE_TYPE_SPECIAL_FIRST_RESERVED, + SOURCE_TYPE_SPECIAL_RESERVED2, + SOURCE_TYPE_SPECIAL_RESERVED3, + SOURCE_TYPE_SPECIAL_RESERVED4, + SOURCE_TYPE_SPECIAL_LAST_RESERVED = SOURCE_TYPE_SPECIAL_RESERVED4, + SOURCE_TYPE_SPECIAL_FIRST_TIMER, + SOURCE_TYPE_SPECIAL_TIMER1 = SOURCE_TYPE_SPECIAL_FIRST_TIMER, + SOURCE_TYPE_SPECIAL_TIMER2, + SOURCE_TYPE_SPECIAL_TIMER3, + SOURCE_TYPE_SPECIAL_LAST_TIMER = SOURCE_TYPE_SPECIAL_TIMER3, + SOURCE_TYPE_SPECIAL_COUNT +}; + constexpr int SOURCE_TYPE_STICK_THR_IDX { 3 }; // TODO is there a function to determine index? -constexpr int SOURCE_TYPE_SPECIAL_TIMER1_IDX { 3 }; // TODO temp const until Timers own source type class RawSourceRange {