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:
@@ -196,6 +196,13 @@ QString RawSource::toString(const ModelData * model, const GeneralSettings * con
|
||||
result = Boards::getSwitchInfo(board, index).name;
|
||||
return result;
|
||||
|
||||
case SOURCE_TYPE_FUNCTIONSWITCH:
|
||||
if (model)
|
||||
result = QString(model->functionSwitchNames[index]).trimmed();
|
||||
if (result.isEmpty())
|
||||
result = tr("SW%1").arg(index + 1);
|
||||
return result;
|
||||
|
||||
case SOURCE_TYPE_CUSTOM_SWITCH:
|
||||
return RawSwitch(SWITCH_TYPE_VIRTUAL, index + 1).toString();
|
||||
|
||||
@@ -309,10 +316,17 @@ 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_FUNCTIONSWITCH)
|
||||
if (!model || index >= b.getCapability(Board::FunctionSwitches))
|
||||
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_FUNCTIONSWITCH && !model->isFunctionSwitchSourceAllowed(index))
|
||||
return false;
|
||||
|
||||
if (type == SOURCE_TYPE_VIRTUAL_INPUT && !model->isInputValid(index))
|
||||
return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user