1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 16:25:16 +03:00

re #1334 - added Lua script outputs to: mixer soruces list, logical switches V1 and V2 list

This commit is contained in:
Damjan Adamic 2014-06-21 22:04:55 +02:00
parent 5fcba6e193
commit d0edbacf37
8 changed files with 132 additions and 111 deletions

View file

@ -357,6 +357,8 @@ QString RawSource::toString(const ModelData & model)
} }
return result; return result;
} }
case SOURCE_TYPE_LUA_OUTPUT:
return QObject::tr("[S%1]%2").arg(index/16+1).arg(index%16+1);
case SOURCE_TYPE_STICK: case SOURCE_TYPE_STICK:
return AnalogString(index); return AnalogString(index);
case SOURCE_TYPE_TRIM: case SOURCE_TYPE_TRIM:

View file

@ -286,7 +286,7 @@ enum TelemetrySource {
enum RawSourceType { enum RawSourceType {
SOURCE_TYPE_NONE, SOURCE_TYPE_NONE,
SOURCE_TYPE_VIRTUAL_INPUT, SOURCE_TYPE_VIRTUAL_INPUT,
SOURCE_TYPE_LUA_INPUT, SOURCE_TYPE_LUA_OUTPUT,
SOURCE_TYPE_STICK, // and POTS SOURCE_TYPE_STICK, // and POTS
SOURCE_TYPE_ROTARY_ENCODER, SOURCE_TYPE_ROTARY_ENCODER,
SOURCE_TYPE_TRIM, SOURCE_TYPE_TRIM,
@ -1141,7 +1141,9 @@ enum Capability {
HasDisplayText, HasDisplayText,
VirtualInputs, VirtualInputs,
TrainerInputs, TrainerInputs,
LuaInputs, LuaScripts,
LuaInputsPerScript,
LuaOutputsPerScript,
LimitsPer1000, LimitsPer1000,
EnhancedCurves, EnhancedCurves,
HasFasOffset, HasFasOffset,

View file

@ -187,9 +187,9 @@ class SourcesConversionTable: public ConversionTable {
if (IS_TARANIS(board) && version >= 216) { if (IS_TARANIS(board) && version >= 216) {
for (int i=0; i<32; i++) for (int i=0; i<32; i++)
addConversion(RawSource(SOURCE_TYPE_VIRTUAL_INPUT, i), val++); addConversion(RawSource(SOURCE_TYPE_VIRTUAL_INPUT, i), val++);
for (int i=0; i<7; i++) { for (int i=0; i<GetCurrentFirmware()->getCapability(LuaScripts); i++) {
for (int j=0; j<6; j++) { for (int j=0; j<GetCurrentFirmware()->getCapability(LuaOutputsPerScript); j++) {
addConversion(RawSource(SOURCE_TYPE_LUA_INPUT, i*16+j), val++); addConversion(RawSource(SOURCE_TYPE_LUA_OUTPUT, i*16+j), val++);
} }
} }
} }

View file

@ -678,7 +678,12 @@ int OpenTxFirmware::getCapability(const Capability capability)
return IS_TARANIS(board) ? 32 : 0; return IS_TARANIS(board) ? 32 : 0;
case TrainerInputs: case TrainerInputs:
return IS_ARM(board) ? 16 : 8; 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 LimitsPer1000:
case EnhancedCurves: case EnhancedCurves:
return IS_TARANIS(board); return IS_TARANIS(board);

View file

@ -519,6 +519,17 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData &
if (item == source) b->setCurrentIndex(b->count()-1); if (item == source) b->setCurrentIndex(b->count()-1);
} }
if (flags & POPULATE_SCRIPT_OUTPUTS) {
for (int i=0; i<GetCurrentFirmware()->getCapability(LuaScripts); i++) {
for (int j=0; j<GetCurrentFirmware()->getCapability(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) { if (flags & POPULATE_VIRTUAL_INPUTS) {
int virtualInputs = GetCurrentFirmware()->getCapability(VirtualInputs); int virtualInputs = GetCurrentFirmware()->getCapability(VirtualInputs);
for (int i=0; i<virtualInputs; i++) { for (int i=0; i<virtualInputs; i++) {

View file

@ -89,13 +89,14 @@ void populateGvarUseCB(QComboBox *b, unsigned int phase);
QString getProtocolStr(const int proto); QString getProtocolStr(const int proto);
QString getPhasesStr(unsigned int phases, ModelData & model); QString getPhasesStr(unsigned int phases, ModelData & model);
#define POPULATE_SOURCES 1 #define POPULATE_SOURCES (1<<0)
#define POPULATE_TRIMS 2 #define POPULATE_TRIMS (1<<1)
#define POPULATE_SWITCHES 4 #define POPULATE_SWITCHES (1<<2)
#define POPULATE_GVARS 8 #define POPULATE_GVARS (1<<3)
#define POPULATE_TELEMETRY 16 #define POPULATE_TELEMETRY (1<<4)
#define POPULATE_TELEMETRYEXT 32 #define POPULATE_TELEMETRYEXT (1<<5)
#define POPULATE_VIRTUAL_INPUTS 64 #define POPULATE_VIRTUAL_INPUTS (1<<6)
#define POPULATE_SCRIPT_OUTPUTS (1<<7)
#define GVARS_VARIANT 0x0001 #define GVARS_VARIANT 0x0001
#define FRSKY_VARIANT 0x0002 #define FRSKY_VARIANT 0x0002

View file

@ -286,7 +286,7 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
{ {
case LS_FAMILY_VOFS: case LS_FAMILY_VOFS:
mask |= SOURCE1_VISIBLE; mask |= SOURCE1_VISIBLE;
populateSourceCB(cswitchSource1[i], source, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(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]->setDecimals(range.decimals);
cswitchOffset[i]->setSingleStep(range.step); cswitchOffset[i]->setSingleStep(range.step);
if (source.isTimeBased()) { if (source.isTimeBased()) {
@ -326,8 +326,8 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
break; break;
case LS_FAMILY_VCOMP: case LS_FAMILY_VCOMP:
mask |= SOURCE1_VISIBLE | SOURCE2_VISIBLE; 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(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_TRIMS | POPULATE_VIRTUAL_INPUTS | 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; break;
case LS_FAMILY_TIMER: case LS_FAMILY_TIMER:
mask |= VALUE1_VISIBLE | VALUE2_VISIBLE; mask |= VALUE1_VISIBLE | VALUE2_VISIBLE;

View file

@ -19,7 +19,7 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, G
this->setWindowTitle(tr("DEST -> CH%1").arg(md->destCh)); 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); ui->sourceCB->removeItem(0);
int limit = firmware->getCapability(OffsetWeight); int limit = firmware->getCapability(OffsetWeight);