Skip to content

Commit

Permalink
fix(cpn): more fixes to RawSource calls (#5155)
Browse files Browse the repository at this point in the history
Arising from index shift in #4722
  • Loading branch information
philmoz committed Jun 11, 2024
1 parent 993f271 commit 0c742e2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions companion/src/modeledit/setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1941,11 +1941,11 @@ void SetupPanel::populateThrottleTrimSwitchCB()
for (int i=0; i<getBoardCapability(board, Board::NumTrims); i++, idx++) {
// here order is TERA instead of RETA
if (i == 0)
trim = RawSource(SOURCE_TYPE_TRIM, 2).toString(model, &generalSettings);
trim = RawSource(SOURCE_TYPE_TRIM, 2 + 1).toString(model, &generalSettings);
else if (i == 2)
trim = RawSource(SOURCE_TYPE_TRIM, 0).toString(model, &generalSettings);
trim = RawSource(SOURCE_TYPE_TRIM, 0 + 1).toString(model, &generalSettings);
else
trim = RawSource(SOURCE_TYPE_TRIM, i).toString(model, &generalSettings);
trim = RawSource(SOURCE_TYPE_TRIM, i + 1).toString(model, &generalSettings);
ui->throttleTrimSwitch->addItem(trim, idx);
}

Expand Down
8 changes: 6 additions & 2 deletions companion/src/modelprinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ QString ModelPrinter::printMixerLine(const MixData & mix, bool showMultiplex, in
if (mix.carryTrim > 0)
str += " " + tr("NoTrim");
else if (mix.carryTrim < 0)
str += " " + RawSource(SOURCE_TYPE_TRIM, (-(mix.carryTrim)-1)).toString(&model, &generalSettings);
str += " " + RawSource(SOURCE_TYPE_TRIM, (-(mix.carryTrim)-1) + 1).toString(&model, &generalSettings);

if (firmware->getCapability(HasNoExpo) && mix.noExpo)
str += " " + tr("No DR/Expo").toHtmlEscaped();
Expand Down Expand Up @@ -696,7 +696,7 @@ QString ModelPrinter::printOutputValueGVar(int val)
if (abs(val) > 10000) {
if (val < 0)
result = "-";
result.append(RawSource(SOURCE_TYPE_GVAR, abs(val)-10001).toString(&model));
result.append(RawSource(SOURCE_TYPE_GVAR, (abs(val)-10001) + 1).toString(&model));
}
else {
if (val >= 0)
Expand Down Expand Up @@ -932,6 +932,10 @@ QString ModelPrinter::printThrottle()
result << printLabelValue(tr("Trim idle only"), printBoolean(model.thrTrim, BOOLEAN_YESNO));
result << printLabelValue(tr("Warning"), printBoolean(!model.disableThrottleWarning, BOOLEAN_YESNO));
result << printLabelValue(tr("Reversed"), printBoolean(model.throttleReversed, BOOLEAN_YESNO));
int thrTrim = model.thrTrimSwitch;
if (thrTrim == 0) thrTrim = 2;
else if (thrTrim == 2) thrTrim = 0;
result << printLabelValue(tr("Trim source"), RawSource(SOURCE_TYPE_TRIM, thrTrim + 1).toString(&model, &generalSettings));
return result.join(" ");
}

Expand Down
6 changes: 3 additions & 3 deletions companion/src/simulation/joystickdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void joystickDialog::populateSourceCombo(QComboBox * cb)
if (radioSettings.isInputStick(i))
wname = Boards::getAxisName(i);
else
wname = RawSource(RawSourceType::SOURCE_TYPE_INPUT, i).toString(nullptr, &radioSettings);
wname = RawSource(RawSourceType::SOURCE_TYPE_INPUT, i + 1).toString(nullptr, &radioSettings);
cb->addItem(wname, i);
}
}
Expand All @@ -186,7 +186,7 @@ void joystickDialog::populateButtonCombo(QComboBox * cb)
for (i = 0; i < ttlSwitches; ++i) {
if (radioSettings.switchConfig[i].type != Board::SWITCH_NOT_AVAILABLE) {
swtype = Board::SwitchType(radioSettings.switchConfig[i].type);
wname = RawSource(RawSourceType::SOURCE_TYPE_SWITCH, i).toString(nullptr, &radioSettings);
wname = RawSource(RawSourceType::SOURCE_TYPE_SWITCH, i + 1).toString(nullptr, &radioSettings);
if (swtype == Board::SWITCH_3POS) {
cb->addItem(wname + CPN_STR_SW_INDICATOR_UP, i | JS_BUTTON_3POS_UP);
cb->addItem(wname + CPN_STR_SW_INDICATOR_DN, i | JS_BUTTON_3POS_DN);
Expand All @@ -197,7 +197,7 @@ void joystickDialog::populateButtonCombo(QComboBox * cb)
}

for (i = 0; i < ttlTrims; i += 1) {
wname = RawSource(RawSourceType::SOURCE_TYPE_TRIM, i).toString(nullptr, &radioSettings);
wname = RawSource(RawSourceType::SOURCE_TYPE_TRIM, i + 1).toString(nullptr, &radioSettings);
if ((i == 0) || (i == 3)) {
cb->addItem(wname + " Left", (i + ttlSwitches) | JS_BUTTON_3POS_DN);
cb->addItem(wname + " Right", (i + ttlSwitches) | JS_BUTTON_3POS_UP);
Expand Down

0 comments on commit 0c742e2

Please sign in to comment.