fix: Pot and slider warnings weren't being set properly on radio or syncing with Companion (#1981)
- fix Companion yaml model read and write - B&W radios treat bit values the same as color to avoid unnecessary complication for Companion and radio conversions - B&W radios default is therefore off for all pots and sliders - B&W radios fix runtime warnings check - all radios fix to save last pot or slider position when checked and mode AUTO on change of model or power off - all radios do not display Pots Warning in model setup if no pots or sliders supported
This commit is contained in:
@@ -140,6 +140,15 @@ struct YamlThrTrace {
|
|||||||
|
|
||||||
struct YamlPotsWarnEnabled {
|
struct YamlPotsWarnEnabled {
|
||||||
unsigned int value;
|
unsigned int value;
|
||||||
|
const int cnt = CPN_MAX_POTS + CPN_MAX_SLIDERS; // must not exceed 16 as radio stores in uint16_t
|
||||||
|
|
||||||
|
#define MAXPOTWARNINGS (CPN_MAX_POTS + CPN_MAX_SLIDERS)
|
||||||
|
|
||||||
|
#if MAXPOTWARNINGS > 16
|
||||||
|
#error Not enough space for pot and slider warnings
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef MAXPOTWARNINGS
|
||||||
|
|
||||||
YamlPotsWarnEnabled() = default;
|
YamlPotsWarnEnabled() = default;
|
||||||
|
|
||||||
@@ -147,17 +156,17 @@ struct YamlPotsWarnEnabled {
|
|||||||
{
|
{
|
||||||
value = 0;
|
value = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < cnt; i++) {
|
||||||
value |= (*(potsWarnEnabled + i) << (7 - i));
|
value |= (*(potsWarnEnabled + i)) << i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void toCpn(bool * potsWarnEnabled)
|
void toCpn(bool * potsWarnEnabled)
|
||||||
{
|
{
|
||||||
memset(potsWarnEnabled, 0, sizeof(bool) * (CPN_MAX_POTS + CPN_MAX_SLIDERS));
|
memset(potsWarnEnabled, 0, sizeof(bool) * cnt);
|
||||||
|
|
||||||
for (int i = 1; i <= 8; i++) {
|
for (int i = 0; i < cnt; i++) {
|
||||||
*(potsWarnEnabled + (i - 1)) = (bool)((value >> (8 - i)) & 1);
|
*(potsWarnEnabled + i) = (bool)((value >> i) & 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -856,7 +865,7 @@ Node convert<ModelData>::encode(const ModelData& rhs)
|
|||||||
node["potsWarnMode"] = potsWarningModeLut << rhs.potsWarningMode;
|
node["potsWarnMode"] = potsWarningModeLut << rhs.potsWarningMode;
|
||||||
node["jitterFilter"] = jitterFilterLut << rhs.jitterFilter;
|
node["jitterFilter"] = jitterFilterLut << rhs.jitterFilter;
|
||||||
|
|
||||||
YamlPotsWarnEnabled potsWarnEnabled(&rhs.potsWarnEnabled[CPN_MAX_POTS + CPN_MAX_SLIDERS]);
|
YamlPotsWarnEnabled potsWarnEnabled(&rhs.potsWarnEnabled[0]);
|
||||||
node["potsWarnEnabled"] = potsWarnEnabled.value;
|
node["potsWarnEnabled"] = potsWarnEnabled.value;
|
||||||
|
|
||||||
for (int i = 0; i < CPN_MAX_POTS + CPN_MAX_SLIDERS; i++) {
|
for (int i = 0; i < CPN_MAX_POTS + CPN_MAX_SLIDERS; i++) {
|
||||||
@@ -1048,7 +1057,7 @@ bool convert<ModelData>::decode(const Node& node, ModelData& rhs)
|
|||||||
|
|
||||||
YamlPotsWarnEnabled potsWarnEnabled;
|
YamlPotsWarnEnabled potsWarnEnabled;
|
||||||
node["potsWarnEnabled"] >> potsWarnEnabled.value;
|
node["potsWarnEnabled"] >> potsWarnEnabled.value;
|
||||||
potsWarnEnabled.toCpn(&rhs.potsWarnEnabled[CPN_MAX_POTS + CPN_MAX_SLIDERS]);
|
potsWarnEnabled.toCpn(&rhs.potsWarnEnabled[0]);
|
||||||
|
|
||||||
node["potsWarnPosition"] >> rhs.potsWarnPosition;
|
node["potsWarnPosition"] >> rhs.potsWarnPosition;
|
||||||
|
|
||||||
|
|||||||
@@ -1467,8 +1467,10 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
|||||||
|
|
||||||
// Pot warnings
|
// Pot warnings
|
||||||
prevFocus = ui->potWarningMode;
|
prevFocus = ui->potWarningMode;
|
||||||
if (IS_HORUS_OR_TARANIS(board)) {
|
int count = getBoardCapability(board, Board::Pots) + getBoardCapability(board, Board::Sliders);
|
||||||
for (int i = 0; i < getBoardCapability(board, Board::Pots) + getBoardCapability(board, Board::Sliders); i++) {
|
|
||||||
|
if (IS_HORUS_OR_TARANIS(board) && count > 0) {
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
RawSource src(SOURCE_TYPE_STICK, CPN_MAX_STICKS + i);
|
RawSource src(SOURCE_TYPE_STICK, CPN_MAX_STICKS + i);
|
||||||
QCheckBox * cb = new QCheckBox(this);
|
QCheckBox * cb = new QCheckBox(this);
|
||||||
cb->setProperty("index", i);
|
cb->setProperty("index", i);
|
||||||
@@ -1775,7 +1777,7 @@ void SetupPanel::updatePotWarnings()
|
|||||||
for (int i = 0; i < potWarningCheckboxes.size(); i++) {
|
for (int i = 0; i < potWarningCheckboxes.size(); i++) {
|
||||||
QCheckBox *checkbox = potWarningCheckboxes[i];
|
QCheckBox *checkbox = potWarningCheckboxes[i];
|
||||||
int index = checkbox->property("index").toInt();
|
int index = checkbox->property("index").toInt();
|
||||||
checkbox->setChecked(!model->potsWarnEnabled[index]);
|
checkbox->setChecked(model->potsWarnEnabled[index]);
|
||||||
checkbox->setDisabled(model->potsWarningMode == 0);
|
checkbox->setDisabled(model->potsWarningMode == 0);
|
||||||
}
|
}
|
||||||
lock = false;
|
lock = false;
|
||||||
@@ -1785,7 +1787,7 @@ void SetupPanel::potWarningToggled(bool checked)
|
|||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
int index = sender()->property("index").toInt();
|
int index = sender()->property("index").toInt();
|
||||||
model->potsWarnEnabled[index] = !checked;
|
model->potsWarnEnabled[index] = checked;
|
||||||
updatePotWarnings();
|
updatePotWarnings();
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1007</width>
|
<width>1024</width>
|
||||||
<height>435</height>
|
<height>435</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@@ -192,7 +192,7 @@
|
|||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string></string>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
@@ -378,7 +378,7 @@
|
|||||||
<item alignment="Qt::AlignTop">
|
<item alignment="Qt::AlignTop">
|
||||||
<widget class="QLabel" name="label_potWarning">
|
<widget class="QLabel" name="label_potWarning">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Pot Warnings</string>
|
<string>Pot/Slider Warnings</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -548,19 +548,19 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="1" column="3">
|
<item row="1" column="3">
|
||||||
<widget class="QSpinBox" name="customThrottleWarningPosition">
|
<widget class="QSpinBox" name="customThrottleWarningPosition">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<number>-100</number>
|
<number>-100</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>100</number>
|
<number>100</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="3">
|
<item row="2" column="3">
|
||||||
<widget class="QCheckBox" name="displayText">
|
<widget class="QCheckBox" name="displayText">
|
||||||
@@ -617,7 +617,6 @@
|
|||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item row="2" column="4">
|
<item row="2" column="4">
|
||||||
<widget class="QPushButton" name="editText">
|
<widget class="QPushButton" name="editText">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
|||||||
@@ -906,7 +906,7 @@ void menuModelSetup(event_t event)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LcdFlags flags = ((menuHorizontalPosition==i+1) && attr) ? BLINK : 0;
|
LcdFlags flags = ((menuHorizontalPosition==i+1) && attr) ? BLINK : 0;
|
||||||
if ((!attr || menuHorizontalPosition >= 0) && !(g_model.potsWarnEnabled & (1 << i))) {
|
if ((!attr || menuHorizontalPosition >= 0) && (g_model.potsWarnEnabled & (1 << i))) {
|
||||||
flags |= INVERS;
|
flags |= INVERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -822,7 +822,7 @@ void menuModelSetup(event_t event)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
LcdFlags flags = ((menuHorizontalPosition==i+1) && attr) ? BLINK : 0;
|
LcdFlags flags = ((menuHorizontalPosition==i+1) && attr) ? BLINK : 0;
|
||||||
if ((!attr || menuHorizontalPosition >= 0) && !(g_model.potsWarnEnabled & (1 << i))) {
|
if ((!attr || menuHorizontalPosition >= 0) && (g_model.potsWarnEnabled & (1 << i))) {
|
||||||
flags |= INVERS;
|
flags |= INVERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ void storageFlushCurrentModel()
|
|||||||
|
|
||||||
if (g_model.potsWarnMode == POTS_WARN_AUTO) {
|
if (g_model.potsWarnMode == POTS_WARN_AUTO) {
|
||||||
for (int i=0; i<NUM_POTS+NUM_SLIDERS; i++) {
|
for (int i=0; i<NUM_POTS+NUM_SLIDERS; i++) {
|
||||||
if (!(g_model.potsWarnEnabled & (1 << i))) {
|
if (g_model.potsWarnEnabled & (1 << i)) {
|
||||||
SAVE_POT_POSITION(i);
|
SAVE_POT_POSITION(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -796,7 +796,7 @@ void checkSwitches()
|
|||||||
if (!IS_POT_SLIDER_AVAILABLE(POT1+i)) {
|
if (!IS_POT_SLIDER_AVAILABLE(POT1+i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!(g_model.potsWarnEnabled & (1 << i))) {
|
if (g_model.potsWarnEnabled & (1 << i)) {
|
||||||
if (abs(g_model.potsWarnPosition[i] - GET_LOWRES_POT_POSITION(i)) > 1) {
|
if (abs(g_model.potsWarnPosition[i] - GET_LOWRES_POT_POSITION(i)) > 1) {
|
||||||
if (++numWarnings < 6) {
|
if (++numWarnings < 6) {
|
||||||
lcdDrawTextAtIndex(x, y, STR_VSRCRAW, NUM_STICKS + 1 + i, INVERS);
|
lcdDrawTextAtIndex(x, y, STR_VSRCRAW, NUM_STICKS + 1 + i, INVERS);
|
||||||
|
|||||||
Reference in New Issue
Block a user