From 2778040497219d91d7a0756c935edbf012ac707d Mon Sep 17 00:00:00 2001 From: Max Paperno Date: Sat, 4 Mar 2017 14:49:57 -0500 Subject: [PATCH] [Simulator] Fix 6-position switch operation (only last 3 pos. were usable and were reported incorrectly). NOTE that for these switches calibration IS important (either from actual radio settings or done in standalone Simulator/simu). --- companion/src/simulation/widgets/radioknobwidget.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/companion/src/simulation/widgets/radioknobwidget.h b/companion/src/simulation/widgets/radioknobwidget.h index 9f0c4e19c..be74a9ee9 100644 --- a/companion/src/simulation/widgets/radioknobwidget.h +++ b/companion/src/simulation/widgets/radioknobwidget.h @@ -75,11 +75,11 @@ class RadioKnobWidget : public RadioWidget { setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); setFixedSize(QSize(42, 42)); - setMinimum(-1024); - setMaximum(1024); setNotchesVisible(true); if (type == Board::POT_MULTIPOS_SWITCH) { m_stepSize = 2048 / 5; + setMinimum(0); + setMaximum(2048); // this is a bit of a hack to get the notch markers to display correctly // the actual notches/value are constrained in setValue() setSingleStep(m_stepSize / 10); @@ -89,6 +89,8 @@ class RadioKnobWidget : public RadioWidget else { m_stepSize = 1; setToolTip(tr("Right-double-click to reset to center.")); + setMinimum(-1024); + setMaximum(1024); setPageStep(128); setNotchTarget(64); } @@ -97,7 +99,7 @@ class RadioKnobWidget : public RadioWidget void setValue(int value) { if (m_stepSize > 1) { - value = (value + 1024) / m_stepSize * m_stepSize - 1024; + value = value / m_stepSize * m_stepSize; } QDial::setValue(value); }