diff --git a/companion/src/modeledit/mixerdialog.cpp b/companion/src/modeledit/mixerdialog.cpp index 2e0514758..6593cee74 100644 --- a/companion/src/modeledit/mixerdialog.cpp +++ b/companion/src/modeledit/mixerdialog.cpp @@ -27,7 +27,7 @@ #include "namevalidator.h" #include "sourcenumref.h" -MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData * mixdata, GeneralSettings & generalSettings, Firmware * firmware, +MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData * mixdata, int index, GeneralSettings & generalSettings, Firmware * firmware, CompoundItemModelFactory * sharedItemModels) : QDialog(parent), ui(new Ui::MixerDialog), @@ -94,6 +94,11 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData * mixdata, ui->label_MixDR->hide(); } + if (index == 0 || model.mixData[index - 1].destCh != mixdata->destCh) { + ui->mltpxCB->hide(); + ui->mltpxLbl->hide(); + } + if (!firmware->getCapability(VirtualInputs)) { for(int i = 0; i < CPN_MAX_STICKS; i++) { ui->trimCB->addItem(Boards::getInputName(i, board)); diff --git a/companion/src/modeledit/mixerdialog.h b/companion/src/modeledit/mixerdialog.h index 7581454aa..b82177577 100644 --- a/companion/src/modeledit/mixerdialog.h +++ b/companion/src/modeledit/mixerdialog.h @@ -37,7 +37,7 @@ namespace Ui { class MixerDialog : public QDialog { Q_OBJECT public: - MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, GeneralSettings & generalSettings, Firmware * firmware, + MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, int index, GeneralSettings & generalSettings, Firmware * firmware, CompoundItemModelFactory * sharedItemModels); ~MixerDialog(); diff --git a/companion/src/modeledit/mixerdialog.ui b/companion/src/modeledit/mixerdialog.ui index e7eb67913..c8a886dfd 100644 --- a/companion/src/modeledit/mixerdialog.ui +++ b/companion/src/modeledit/mixerdialog.ui @@ -165,7 +165,7 @@ - + Multiplex diff --git a/companion/src/modeledit/mixes.cpp b/companion/src/modeledit/mixes.cpp index 2f1b404ab..409150193 100644 --- a/companion/src/modeledit/mixes.cpp +++ b/companion/src/modeledit/mixes.cpp @@ -184,7 +184,7 @@ void MixesPanel::gm_openMix(int index) MixData mixd(model->mixData[index]); - MixerDialog *dlg = new MixerDialog(this, *model, &mixd, generalSettings, firmware, sharedItemModels); + MixerDialog *dlg = new MixerDialog(this, *model, &mixd, index, generalSettings, firmware, sharedItemModels); if(dlg->exec()) { model->mixData[index] = mixd; emit modified(); diff --git a/companion/src/modelprinter.cpp b/companion/src/modelprinter.cpp index bf0835323..f17d09d49 100644 --- a/companion/src/modelprinter.cpp +++ b/companion/src/modelprinter.cpp @@ -416,10 +416,7 @@ QString ModelPrinter::printMixerLine(const MixData & mix, bool showMultiplex, in } str += " " + source; - if (mix.mltpx == MLTPX_MUL && !showMultiplex) - str += " " + tr("MULT!").toHtmlEscaped(); - else - str += " " + tr("Weight(%1)").arg(SourceNumRef(mix.weight).toString(&model, &generalSettings)).toHtmlEscaped(); + str += " " + tr("Weight(%1)").arg(SourceNumRef(mix.weight).toString(&model, &generalSettings)).toHtmlEscaped(); QString flightModesStr = printFlightModes(mix.flightModes); if (!flightModesStr.isEmpty()) diff --git a/radio/src/gui/128x64/model_mix_edit.cpp b/radio/src/gui/128x64/model_mix_edit.cpp index dfd9b36cd..0ce85c211 100644 --- a/radio/src/gui/128x64/model_mix_edit.cpp +++ b/radio/src/gui/128x64/model_mix_edit.cpp @@ -108,7 +108,10 @@ void menuModelMixOne(event_t event) uint8_t old_editMode = s_editMode; SUBMENU(STR_MIXES, MIX_FIELD_COUNT, - {0, 0, 0, 0, 0, 1, CASE_FLIGHT_MODES(FM_ROW((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE)) 0, 0 /*, ...*/}); + {0, 0, 0, 0, 0, 1, CASE_FLIGHT_MODES(FM_ROW((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE)) 0, 0, + (uint8_t)((s_currIdx > 0 && mixAddress(s_currIdx - 1)->destCh == md2->destCh) ? 0 : HIDDEN_ROW), + 0 /*, ...*/ + }); int8_t sub = menuVerticalPosition; int8_t editMode = s_editMode; diff --git a/radio/src/gui/212x64/model_mix_edit.cpp b/radio/src/gui/212x64/model_mix_edit.cpp index f124458b9..01cb08820 100644 --- a/radio/src/gui/212x64/model_mix_edit.cpp +++ b/radio/src/gui/212x64/model_mix_edit.cpp @@ -104,7 +104,10 @@ void menuModelMixOne(event_t event) uint8_t old_editMode = s_editMode; SUBMENU(STR_MIXES, MIX_FIELD_COUNT, - {0, 0, 0, 0, 0, 1, CASE_FLIGHT_MODES(FM_ROW((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE)) 0, 0 /*, ...*/}); + {0, 0, 0, 0, 0, 1, CASE_FLIGHT_MODES(FM_ROW((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE)) 0, 0, + (uint8_t)((s_currIdx > 0 && mixAddress(s_currIdx - 1)->destCh == md2->destCh) ? 0 : HIDDEN_ROW), + 0 /*, ...*/ + }); int8_t sub = menuVerticalPosition; int8_t editMode = s_editMode; diff --git a/radio/src/gui/colorlcd/model/mixer_edit_adv.cpp b/radio/src/gui/colorlcd/model/mixer_edit_adv.cpp index 37df3ce13..80e108eea 100644 --- a/radio/src/gui/colorlcd/model/mixer_edit_adv.cpp +++ b/radio/src/gui/colorlcd/model/mixer_edit_adv.cpp @@ -60,11 +60,14 @@ void MixEditAdvanced::buildBody(Window* form) MixData* mix = mixAddress(index); // Advanced... + FormLine* line; // Multiplex - auto line = form->newLine(grid); - new StaticText(line, rect_t{}, STR_MULTPX); - new Choice(line, rect_t{}, STR_VMLTPX, 0, 2, GET_SET_DEFAULT(mix->mltpx)); + if (index > 0 && mixAddress(index - 1)->destCh == channel) { + line = form->newLine(grid); + new StaticText(line, rect_t{}, STR_MULTPX); + new Choice(line, rect_t{}, STR_VMLTPX, 0, 2, GET_SET_DEFAULT(mix->mltpx)); + } // Flight modes if (modelFMEnabled()) { diff --git a/radio/src/gui/common/stdlcd/model_mixes.cpp b/radio/src/gui/common/stdlcd/model_mixes.cpp index 3998c6a1d..3a6581007 100644 --- a/radio/src/gui/common/stdlcd/model_mixes.cpp +++ b/radio/src/gui/common/stdlcd/model_mixes.cpp @@ -333,14 +333,9 @@ void menuModelMixAll(event_t event) drawSource(MIX_LINE_SRC_POS, y, md->srcRaw, 0); - if (mixCnt == 0 && md->mltpx == 1) { - lcdDrawText(MIX_LINE_WEIGHT_POS, y, "MULT!", RIGHT | ((isMixActive(i) ? BOLD : 0))); - } - else { - editSrcVarFieldValue(MIX_LINE_WEIGHT_POS, y, nullptr, md->weight, - MIX_WEIGHT_MIN, MIX_WEIGHT_MAX, RIGHT | ((isMixActive(i) ? BOLD : 0)), - 0, 0, MIXSRC_FIRST, INPUTSRC_LAST); - } + editSrcVarFieldValue(MIX_LINE_WEIGHT_POS, y, nullptr, md->weight, + MIX_WEIGHT_MIN, MIX_WEIGHT_MAX, RIGHT | ((isMixActive(i) ? BOLD : 0)), + 0, 0, MIXSRC_FIRST, INPUTSRC_LAST); #if LCD_W >= 212 displayMixLine(y, md); diff --git a/radio/src/mixer.cpp b/radio/src/mixer.cpp index cd328b43c..63ebecf48 100644 --- a/radio/src/mixer.cpp +++ b/radio/src/mixer.cpp @@ -1037,25 +1037,30 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms) int32_t * ptr = &chans[md->destCh]; // Save calculating address several times - switch (md->mltpx) { - case MLTPX_REPL: - *ptr = dv; - if (mode == e_perout_mode_normal) { - for (int8_t m = i - 1; m >= 0 && mixAddress(m)->destCh == md->destCh; m--) - activeMixes[m] = false; - } - break; - case MLTPX_MUL: - // @@@2 we have to remove the weight factor of 256 in case of 100%; now we use the new base of 256 - dv >>= 8; - dv *= *ptr; - dv >>= RESX_SHIFT; // same as dv /= RESXl; - *ptr = dv; - break; - default: // MLTPX_ADD - *ptr += dv; //Mixer output add up to the line (dv + (dv>0 ? 100/2 : -100/2))/(100); - break; - } // endswitch md->mltpx + // If first mix line for a channel - ignore Multiplex setting + if (i == 0 || mixAddress(i - 1)->destCh != md->destCh) { + *ptr = dv; + } else { + switch (md->mltpx) { + case MLTPX_REPL: + *ptr = dv; + if (mode == e_perout_mode_normal) { + for (int8_t m = i - 1; m >= 0 && mixAddress(m)->destCh == md->destCh; m--) + activeMixes[m] = false; + } + break; + case MLTPX_MUL: + // @@@2 we have to remove the weight factor of 256 in case of 100%; now we use the new base of 256 + dv >>= 8; + dv *= *ptr; + dv >>= RESX_SHIFT; // same as dv /= RESXl; + *ptr = dv; + break; + default: // MLTPX_ADD + *ptr += dv; //Mixer output add up to the line (dv + (dv>0 ? 100/2 : -100/2))/(100); + break; + } // endswitch md->mltpx + } #ifdef PREVENT_ARITHMETIC_OVERFLOW /* // a lot of assumptions must be true, for this kind of check; not really worth for only 4 bytes flash savings