fix(firmware): range for V2 value may be incorrect for some logical switches (#7158)

This commit is contained in:
philmoz
2026-03-10 15:22:22 +10:00
committed by GitHub
parent 61f89b6076
commit 48e3b2ac7b
5 changed files with 30 additions and 24 deletions
@@ -212,12 +212,12 @@ void menuModelSensor(event_t event)
}
else {
if (sensor->unit == UNIT_RPMS) {
sensor->custom.ratio = editNumberField(STR_BLADES, 0, SENSOR_2ND_COLUMN, y, sensor->custom.ratio, 1, 30000, attr, event);
sensor->custom.ratio = editNumberField(STR_BLADES, 0, SENSOR_2ND_COLUMN, y, sensor->custom.ratio, 1, MIXSRC_MAX_VALUE, attr, event);
break;
}
else {
lcdDrawTextAlignedLeft(y, STR_RATIO);
if (attr) CHECK_INCDEC_MODELVAR(event, sensor->custom.ratio, 0, 30000);
if (attr) CHECK_INCDEC_MODELVAR(event, sensor->custom.ratio, 0, MIXSRC_MAX_VALUE);
if (sensor->custom.ratio == 0) {
lcdDrawChar(SENSOR_2ND_COLUMN, y, '-', attr);
} else { // Ratio + Ratio Percent
@@ -281,13 +281,13 @@ void menuModelSensor(event_t event)
}
else if (sensor->unit == UNIT_RPMS) {
lcdDrawTextAlignedLeft(y, STR_MULTIPLIER);
if (attr) sensor->custom.offset = checkIncDec(event, sensor->custom.offset, 1, 30000, EE_MODEL|NO_INCDEC_MARKS|INCDEC_REP10);
if (attr) sensor->custom.offset = checkIncDec(event, sensor->custom.offset, 1, MIXSRC_MAX_VALUE, EE_MODEL|NO_INCDEC_MARKS|INCDEC_REP10);
lcdDrawNumber(SENSOR_2ND_COLUMN, y, sensor->custom.offset, LEFT|attr);
break;
}
else {
if (sensor->prec > 0) attr |= (sensor->prec == 2 ? PREC2 : PREC1);
sensor->custom.offset = editNumberField(STR_OFFSET, 0, SENSOR_2ND_COLUMN, y, sensor->custom.offset, -30000, 30000, attr, event);
sensor->custom.offset = editNumberField(STR_OFFSET, 0, SENSOR_2ND_COLUMN, y, sensor->custom.offset, -MIXSRC_MAX_VALUE, MIXSRC_MAX_VALUE, attr, event);
break;
}
// no break
@@ -227,13 +227,13 @@ void menuModelSensor(event_t event)
else {
if (sensor->unit == UNIT_RPMS) {
lcdDrawTextAlignedLeft(y, STR_BLADES);
if (attr) sensor->custom.ratio = checkIncDec(event, sensor->custom.ratio, 1, 30000, EE_MODEL|NO_INCDEC_MARKS|INCDEC_REP10);
if (attr) sensor->custom.ratio = checkIncDec(event, sensor->custom.ratio, 1, MIXSRC_MAX_VALUE, EE_MODEL|NO_INCDEC_MARKS|INCDEC_REP10);
lcdDrawNumber(SENSOR_2ND_COLUMN, y, sensor->custom.ratio, LEFT|attr);
break;
}
else {
lcdDrawTextAlignedLeft(y, STR_RATIO);
if (attr) sensor->custom.ratio = checkIncDec(event, sensor->custom.ratio, 0, 30000, EE_MODEL|NO_INCDEC_MARKS|INCDEC_REP10);
if (attr) sensor->custom.ratio = checkIncDec(event, sensor->custom.ratio, 0, MIXSRC_MAX_VALUE, EE_MODEL|NO_INCDEC_MARKS|INCDEC_REP10);
if (sensor->custom.ratio == 0) {
lcdDrawChar(SENSOR_2ND_COLUMN, y, '-', attr);
} else { // Ratio + Ratio Percent
@@ -265,13 +265,13 @@ void menuModelSensor(event_t event)
}
else if (sensor->unit == UNIT_RPMS) {
lcdDrawTextAlignedLeft(y, STR_MULTIPLIER);
if (attr) sensor->custom.offset = checkIncDec(event, sensor->custom.offset, 1, 30000, EE_MODEL|NO_INCDEC_MARKS|INCDEC_REP10);
if (attr) sensor->custom.offset = checkIncDec(event, sensor->custom.offset, 1, MIXSRC_MAX_VALUE, EE_MODEL|NO_INCDEC_MARKS|INCDEC_REP10);
lcdDrawNumber(SENSOR_2ND_COLUMN, y, sensor->custom.offset, LEFT|attr);
break;
}
else {
lcdDrawTextAlignedLeft(y, STR_OFFSET);
if (attr) sensor->custom.offset = checkIncDec(event, sensor->custom.offset, -30000, +30000, EE_MODEL|NO_INCDEC_MARKS|INCDEC_REP10);
if (attr) sensor->custom.offset = checkIncDec(event, sensor->custom.offset, -MIXSRC_MAX_VALUE, +MIXSRC_MAX_VALUE, EE_MODEL|NO_INCDEC_MARKS|INCDEC_REP10);
if (sensor->prec > 0) attr |= (sensor->prec == 2 ? PREC2 : PREC1);
lcdDrawNumber(SENSOR_2ND_COLUMN, y, sensor->custom.offset, LEFT|attr);
break;
@@ -649,14 +649,14 @@ class SensorEditWindow : public SubPage
});
paramLines[P_BLADES] = setupLine(STR_BLADES, [=](Window* parent, coord_t x, coord_t y) {
new NumberEdit(parent, {x, y, NUM_EDIT_W, 0}, 1, 30000,
new NumberEdit(parent, {x, y, NUM_EDIT_W, 0}, 1, MIXSRC_MAX_VALUE,
GET_SET_DEFAULT(sensor->custom.ratio));
});
paramLines[P_RATIO] = setupLine(STR_RATIO, [=](Window* parent, coord_t x, coord_t y) {
auto pct = new StaticText(parent, {x + NUM_EDIT_W + PAD_MEDIUM, y + PAD_MEDIUM, 0, 0}, "");
auto num = new NumberEdit(
parent, {x, y, NUM_EDIT_W, 0}, 0, 30000,
parent, {x, y, NUM_EDIT_W, 0}, 0, MIXSRC_MAX_VALUE,
GET_DEFAULT(sensor->custom.ratio),
[=](int32_t value) {
sensor->custom.ratio = value;
@@ -692,13 +692,13 @@ class SensorEditWindow : public SubPage
});
paramLines[P_MULT] = setupLine(STR_MULTIPLIER, [=](Window* parent, coord_t x, coord_t y) {
new NumberEdit(parent, {x, y, NUM_EDIT_W, 0}, 1, 30000,
new NumberEdit(parent, {x, y, NUM_EDIT_W, 0}, 1, MIXSRC_MAX_VALUE,
GET_SET_DEFAULT(sensor->custom.offset));
});
paramLines[P_OFFSET] = setupLine(STR_OFFSET, [=](Window* parent, coord_t x, coord_t y) {
new NumberEdit(
parent, {x, y, NUM_EDIT_W, 0}, -30000, 30000,
parent, {x, y, NUM_EDIT_W, 0}, -MIXSRC_MAX_VALUE, MIXSRC_MAX_VALUE,
GET_SET_DEFAULT(sensor->custom.offset),
(sensor->prec > 0) ? (sensor->prec == 2 ? PREC2 : PREC1) : 0);
});