diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index 7fd34ceb6..c880f72b3 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -357,6 +357,8 @@ QString RawSource::toString(const ModelData & model) } return result; } + case SOURCE_TYPE_LUA_OUTPUT: + return QObject::tr("LUA%1%2").arg(index/16+1).arg(QChar('a'+index%16)); case SOURCE_TYPE_STICK: return AnalogString(index); case SOURCE_TYPE_TRIM: diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index 6d4c412bd..4a17ad5cb 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -286,7 +286,7 @@ enum TelemetrySource { enum RawSourceType { SOURCE_TYPE_NONE, SOURCE_TYPE_VIRTUAL_INPUT, - SOURCE_TYPE_LUA_INPUT, + SOURCE_TYPE_LUA_OUTPUT, SOURCE_TYPE_STICK, // and POTS SOURCE_TYPE_ROTARY_ENCODER, SOURCE_TYPE_TRIM, @@ -1055,101 +1055,103 @@ class RadioData { // TODO rename FlightPhase to FlightMode enum Capability { - FlightModes, - FlightModesName, - FlightModesHaveFades, - Imperial, - Mixes, - Timers, - TimeDivisions, - CustomFunctions, - VoicesAsNumbers, - VoicesMaxLength, - ModelVoice, - MultiLangVoice, - ModelImage, - Pots, - Switches, - SwitchesPositions, - LogicalSwitches, - CustomAndSwitches, - HasNegAndSwitches, - LogicalSwitchesExt, - RotaryEncoders, - Outputs, - ChannelsName, - ExtraInputs, - ExtendedTrims, - NumCurves, - NumCurvePoints, - OffsetWeight, - Simulation, - SoundMod, - SoundPitch, - MaxVolume, - EepromBackup, - Haptic, - HasBeeper, - ModelTrainerEnable, - Timer2ThrTrig, - HasExpoNames, - HasNoExpo, - HasMixerNames, - HasChNames, - HasCvNames, - HasPxxCountry, - HasPPMStart, - HasGeneralUnits, - HasFAIMode, - OptrexDisplay, - PPMExtCtrl, - PPMFrameLength, - DSM2Indexes, - Telemetry, - TelemetryUnits, - TelemetryBars, - Heli, - Gvars, - GvarsInCS, - GvarsAreNamed, - GvarsFlightModes, - GvarsName, - NoTelemetryProtocol, - TelemetryCustomScreens, - TelemetryCustomScreensFieldsPerLine, - TelemetryTimeshift, - TelemetryMaxMultiplier, - HasAltitudeSel, - HasVario, - HasVarioSink, - HasFailsafe, - HasSoundMixer, - NumModules, - PPMCenter, - SYMLimits, - HasCurrentCalibration, - HasVolume, - HasBrightness, - PerModelTimers, - SlowScale, - SlowRange, - PermTimers, - HasSDLogs, - CSFunc, - LCDWidth, - GetThrSwitch, - HasDisplayText, - VirtualInputs, - TrainerInputs, - LuaInputs, - LimitsPer1000, - EnhancedCurves, - HasFasOffset, - HasMahPersistent, - MultiposPots, - MultiposPotsPositions, - SimulatorVariant, - MavlinkTelemetry, + FlightModes, + FlightModesName, + FlightModesHaveFades, + Imperial, + Mixes, + Timers, + TimeDivisions, + CustomFunctions, + VoicesAsNumbers, + VoicesMaxLength, + ModelVoice, + MultiLangVoice, + ModelImage, + Pots, + Switches, + SwitchesPositions, + LogicalSwitches, + CustomAndSwitches, + HasNegAndSwitches, + LogicalSwitchesExt, + RotaryEncoders, + Outputs, + ChannelsName, + ExtraInputs, + ExtendedTrims, + NumCurves, + NumCurvePoints, + OffsetWeight, + Simulation, + SoundMod, + SoundPitch, + MaxVolume, + EepromBackup, + Haptic, + HasBeeper, + ModelTrainerEnable, + Timer2ThrTrig, + HasExpoNames, + HasNoExpo, + HasMixerNames, + HasChNames, + HasCvNames, + HasPxxCountry, + HasPPMStart, + HasGeneralUnits, + HasFAIMode, + OptrexDisplay, + PPMExtCtrl, + PPMFrameLength, + DSM2Indexes, + Telemetry, + TelemetryUnits, + TelemetryBars, + Heli, + Gvars, + GvarsInCS, + GvarsAreNamed, + GvarsFlightModes, + GvarsName, + NoTelemetryProtocol, + TelemetryCustomScreens, + TelemetryCustomScreensFieldsPerLine, + TelemetryTimeshift, + TelemetryMaxMultiplier, + HasAltitudeSel, + HasVario, + HasVarioSink, + HasFailsafe, + HasSoundMixer, + NumModules, + PPMCenter, + SYMLimits, + HasCurrentCalibration, + HasVolume, + HasBrightness, + PerModelTimers, + SlowScale, + SlowRange, + PermTimers, + HasSDLogs, + CSFunc, + LCDWidth, + GetThrSwitch, + HasDisplayText, + VirtualInputs, + TrainerInputs, + LuaScripts, + LuaInputsPerScript, + LuaOutputsPerScript, + LimitsPer1000, + EnhancedCurves, + HasFasOffset, + HasMahPersistent, + MultiposPots, + MultiposPotsPositions, + SimulatorVariant, + MavlinkTelemetry, }; class SimulatorInterface; diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index e1533636f..124323738 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -187,9 +187,9 @@ class SourcesConversionTable: public ConversionTable { if (IS_TARANIS(board) && version >= 216) { for (int i=0; i<32; i++) addConversion(RawSource(SOURCE_TYPE_VIRTUAL_INPUT, i), val++); - for (int i=0; i<7; i++) { - for (int j=0; j<6; j++) { - addConversion(RawSource(SOURCE_TYPE_LUA_INPUT, i*16+j), val++); + for (int i=0; igetCapability(LuaScripts); i++) { + for (int j=0; jgetCapability(LuaOutputsPerScript); j++) { + addConversion(RawSource(SOURCE_TYPE_LUA_OUTPUT, i*16+j), val++); } } } diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index ab630585d..5084896cb 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -678,7 +678,12 @@ int OpenTxFirmware::getCapability(const Capability capability) return IS_TARANIS(board) ? 32 : 0; case TrainerInputs: return IS_ARM(board) ? 16 : 8; - case LuaInputs: + case LuaScripts: + return IS_TARANIS(board) ? 7 : 0; + case LuaInputsPerScript: + return IS_TARANIS(board) ? 10 : 0; + case LuaOutputsPerScript: + return IS_TARANIS(board) ? 6 : 0; case LimitsPer1000: case EnhancedCurves: return IS_TARANIS(board); diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index 364c1d7b5..902bc29ab 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -519,6 +519,17 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData & if (item == source) b->setCurrentIndex(b->count()-1); } + if (flags & POPULATE_SCRIPT_OUTPUTS) { + for (int i=0; igetCapability(LuaScripts); i++) { + for (int j=0; jgetCapability(LuaOutputsPerScript); j++) { + item = RawSource(SOURCE_TYPE_LUA_OUTPUT, i*16+j); + b->addItem(item.toString(model), item.toValue()); + if (item == source) b->setCurrentIndex(b->count()-1); + } + } + } + + if (flags & POPULATE_VIRTUAL_INPUTS) { int virtualInputs = GetCurrentFirmware()->getCapability(VirtualInputs); for (int i=0; igetCapability(GvarsInCS) ? POPULATE_GVARS : 0)); + populateSourceCB(cswitchSource1[i], source, model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); cswitchOffset[i]->setDecimals(range.decimals); cswitchOffset[i]->setSingleStep(range.step); if (source.isTimeBased()) { @@ -326,8 +326,8 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i) break; case LS_FAMILY_VCOMP: mask |= SOURCE1_VISIBLE | SOURCE2_VISIBLE; - populateSourceCB(cswitchSource1[i], RawSource(model.customSw[i].val1), model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->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 | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); + populateSourceCB(cswitchSource1[i], RawSource(model.customSw[i].val1), model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); + populateSourceCB(cswitchSource2[i], RawSource(model.customSw[i].val2), model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); break; case LS_FAMILY_TIMER: mask |= VALUE1_VISIBLE | VALUE2_VISIBLE; diff --git a/companion/src/modeledit/mixerdialog.cpp b/companion/src/modeledit/mixerdialog.cpp index 1312c1255..75ea388ac 100644 --- a/companion/src/modeledit/mixerdialog.cpp +++ b/companion/src/modeledit/mixerdialog.cpp @@ -19,7 +19,7 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, G this->setWindowTitle(tr("DEST -> CH%1").arg(md->destCh)); - populateSourceCB(ui->sourceCB, md->srcRaw, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS); + populateSourceCB(ui->sourceCB, md->srcRaw, model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS); ui->sourceCB->removeItem(0); int limit = firmware->getCapability(OffsetWeight);