mirror of
https://github.com/opentx/opentx.git
synced 2025-07-16 21:05:26 +03:00
Companion UI support
This commit is contained in:
parent
19ff2d6f39
commit
930fd7443e
9 changed files with 37 additions and 27 deletions
|
@ -995,14 +995,7 @@ void LimitData::clear()
|
|||
|
||||
GeneralSettings::SwitchInfo GeneralSettings::switchInfoFromSwitchPositionTaranis(unsigned int index)
|
||||
{
|
||||
if (index <= 3*5)
|
||||
return SwitchInfo((index-1)/3, (index-1)%3);
|
||||
else if (index <= 17)
|
||||
return SwitchInfo(5, index==17 ? 2 : 0);
|
||||
else if (index <= 20)
|
||||
return SwitchInfo(6, index-18);
|
||||
else
|
||||
return SwitchInfo(7+(index-21)/2, 2*((index-21)%2));
|
||||
return SwitchInfo((index-1)/3, (index-1)%3);
|
||||
}
|
||||
|
||||
bool GeneralSettings::switchPositionAllowedTaranis(int index) const
|
||||
|
@ -1015,7 +1008,12 @@ bool GeneralSettings::switchPositionAllowedTaranis(int index) const
|
|||
else if (info.position == 1)
|
||||
return switchConfig[info.index] == SWITCH_3POS;
|
||||
else
|
||||
return true;
|
||||
return switchConfig[info.index] != SWITCH_NONE;
|
||||
}
|
||||
|
||||
bool GeneralSettings::switchSourceAllowedTaranis(int index) const
|
||||
{
|
||||
return switchConfig[index] != SWITCH_NONE;
|
||||
}
|
||||
|
||||
GeneralSettings::GeneralSettings()
|
||||
|
|
|
@ -1174,6 +1174,7 @@ class GeneralSettings {
|
|||
|
||||
static SwitchInfo switchInfoFromSwitchPositionTaranis(unsigned int index);
|
||||
bool switchPositionAllowedTaranis(int index) const;
|
||||
bool switchSourceAllowedTaranis(int index) const;
|
||||
};
|
||||
|
||||
class RadioData {
|
||||
|
|
|
@ -412,10 +412,13 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin
|
|||
}
|
||||
|
||||
for (int i=-GetCurrentFirmware()->getCapability(SwitchesPositions); i<0; i++) {
|
||||
if (IS_TARANIS(GetCurrentFirmware()->getBoard()) && !generalSettings.switchPositionAllowedTaranis(i))
|
||||
continue;
|
||||
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
if (IS_TARANIS(GetCurrentFirmware()->getBoard()) && !generalSettings.switchPositionAllowedTaranis(i)){
|
||||
QModelIndex index = b->model()->index(b->count()-1, 0);
|
||||
QVariant v(0);
|
||||
b->model()->setData(index, v, Qt::UserRole - 1);
|
||||
}
|
||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||
}
|
||||
|
||||
|
@ -433,10 +436,13 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin
|
|||
}
|
||||
|
||||
for (int i=1; i<=GetCurrentFirmware()->getCapability(SwitchesPositions); i++) {
|
||||
if (IS_TARANIS(GetCurrentFirmware()->getBoard()) && !generalSettings.switchPositionAllowedTaranis(i))
|
||||
continue;
|
||||
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
if (IS_TARANIS(GetCurrentFirmware()->getBoard()) && !generalSettings.switchPositionAllowedTaranis(i)){
|
||||
QModelIndex index = b->model()->index(b->count()-1, 0);
|
||||
QVariant v(0);
|
||||
b->model()->setData(index, v, Qt::UserRole - 1);
|
||||
}
|
||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||
}
|
||||
|
||||
|
@ -525,7 +531,7 @@ void populateGVCB(QComboBox *b, int value)
|
|||
}
|
||||
}
|
||||
|
||||
void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData * model, unsigned int flags)
|
||||
void populateSourceCB(QComboBox *b, const RawSource & source, const GeneralSettings generalSettings, const ModelData * model, unsigned int flags)
|
||||
{
|
||||
BoardEnum board = GetCurrentFirmware()->getBoard();
|
||||
RawSource item;
|
||||
|
@ -590,6 +596,11 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData *
|
|||
for (int i=0; i<GetCurrentFirmware()->getCapability(Switches); i++) {
|
||||
item = RawSource(SOURCE_TYPE_SWITCH, i);
|
||||
b->addItem(item.toString(model), item.toValue());
|
||||
if (IS_TARANIS(GetCurrentFirmware()->getBoard()) && !generalSettings.switchSourceAllowedTaranis(i)) {
|
||||
QModelIndex index = b->model()->index(b->count()-1, 0);
|
||||
QVariant v(0);
|
||||
b->model()->setData(index, v, Qt::UserRole - 1);
|
||||
}
|
||||
if (item == source) b->setCurrentIndex(b->count()-1);
|
||||
}
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ QString getPhasesStr(unsigned int phases, ModelData * model);
|
|||
|
||||
// void populateGVarCB(QComboBox *b, int value, int min, int max,int pgvars=5); //TODO: Clean Up
|
||||
void populateGVCB(QComboBox *b, int value);
|
||||
void populateSourceCB(QComboBox *b, const RawSource &source, const ModelData * model, unsigned int flags);
|
||||
void populateSourceCB(QComboBox *b, const RawSource &source, const GeneralSettings generalSettings, const ModelData * model, unsigned int flags);
|
||||
QString getPhaseName(int val, const char * phasename=NULL);
|
||||
QString getInputStr(ModelData * model, int index);
|
||||
QString image2qstring(QImage image);
|
||||
|
|
|
@ -714,18 +714,18 @@ void CustomFunctionsPanel::populateFuncParamCB(QComboBox *b, uint function, unsi
|
|||
b->setCurrentIndex(value);
|
||||
}
|
||||
else if (function==FuncVolume) {
|
||||
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_TRIMS);
|
||||
populateSourceCB(b, RawSource(value), generalSettings, model, POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_TRIMS);
|
||||
}
|
||||
else if (function==FuncPlayValue) {
|
||||
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_SWITCHES|POPULATE_GVARS|POPULATE_TRIMS|POPULATE_TELEMETRYEXT);
|
||||
populateSourceCB(b, RawSource(value), generalSettings, model, POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_SWITCHES|POPULATE_GVARS|POPULATE_TRIMS|POPULATE_TELEMETRYEXT);
|
||||
}
|
||||
else if (function>=FuncAdjustGV1 && function<=FuncAdjustGVLast) {
|
||||
switch (adjustmode) {
|
||||
case 1:
|
||||
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_TRIMS|POPULATE_SWITCHES);
|
||||
populateSourceCB(b, RawSource(value), generalSettings, model, POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_TRIMS|POPULATE_SWITCHES);
|
||||
break;
|
||||
case 2:
|
||||
populateSourceCB(b, RawSource(value), model, POPULATE_GVARS);
|
||||
populateSourceCB(b, RawSource(value), generalSettings, model, POPULATE_GVARS);
|
||||
break;
|
||||
case 3:
|
||||
b->clear();
|
||||
|
|
|
@ -60,7 +60,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
|
|||
|
||||
if (firmware->getCapability(VirtualInputs)) {
|
||||
ui->inputName->setMaxLength(4);
|
||||
populateSourceCB(ui->sourceCB, ed->srcRaw, &model, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS | POPULATE_TELEMETRY);
|
||||
populateSourceCB(ui->sourceCB, ed->srcRaw, generalSettings, &model, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS | POPULATE_TELEMETRY);
|
||||
ui->sourceCB->removeItem(0);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -48,11 +48,11 @@ void HeliPanel::update()
|
|||
lock = true;
|
||||
|
||||
ui->swashType->setCurrentIndex(model->swashRingData.type);
|
||||
populateSourceCB(ui->swashCollectiveSource, model->swashRingData.collectiveSource, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS);
|
||||
populateSourceCB(ui->swashCollectiveSource, model->swashRingData.collectiveSource, generalSettings, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS);
|
||||
ui->swashRingVal->setValue(model->swashRingData.value);
|
||||
if (firmware->getCapability(VirtualInputs)) {
|
||||
populateSourceCB(ui->swashElevatorSource, model->swashRingData.elevatorSource, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS);
|
||||
populateSourceCB(ui->swashAileronSource, model->swashRingData.aileronSource, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS);
|
||||
populateSourceCB(ui->swashElevatorSource, model->swashRingData.elevatorSource, generalSettings, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS);
|
||||
populateSourceCB(ui->swashAileronSource, model->swashRingData.aileronSource, generalSettings, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS);
|
||||
ui->swashElevatorWeight->setValue(model->swashRingData.elevatorWeight);
|
||||
ui->swashAileronWeight->setValue(model->swashRingData.aileronWeight);
|
||||
ui->swashCollectiveWeight->setValue(model->swashRingData.collectiveWeight);
|
||||
|
|
|
@ -301,7 +301,7 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
|
|||
{
|
||||
case LS_FAMILY_VOFS:
|
||||
mask |= SOURCE1_VISIBLE;
|
||||
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));
|
||||
populateSourceCB(cswitchSource1[i], source, generalSettings, 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()) {
|
||||
|
@ -346,8 +346,8 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
|
|||
break;
|
||||
case LS_FAMILY_VCOMP:
|
||||
mask |= SOURCE1_VISIBLE | SOURCE2_VISIBLE;
|
||||
populateSourceCB(cswitchSource1[i], RawSource(model->logicalSw[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->logicalSw[i].val2), model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
|
||||
populateSourceCB(cswitchSource1[i], RawSource(model->logicalSw[i].val1), generalSettings, 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->logicalSw[i].val2), generalSettings, 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;
|
||||
|
|
|
@ -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_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS);
|
||||
populateSourceCB(ui->sourceCB, md->srcRaw, generalSettings, &model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS);
|
||||
ui->sourceCB->removeItem(0);
|
||||
|
||||
int limit = firmware->getCapability(OffsetWeight);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue