[Companion] Sensor switches support added

+ some refactoring to hide irrelevant switches in the combobox

More refactoring to come:
 - have only one SwitchModel per model instead of one per tab
 - only do the update work if something has changed
This commit is contained in:
Bertrand Songis
2017-07-30 12:12:27 +02:00
parent b814f997f8
commit b55070f939
18 changed files with 290 additions and 111 deletions
@@ -133,6 +133,7 @@ class SwitchesConversionTable: public ConversionTable {
addConversion(RawSwitch(SWITCH_TYPE_OFF), -val+offset);
addConversion(RawSwitch(SWITCH_TYPE_ON), val++);
if (version >= 216) {
addConversion(RawSwitch(SWITCH_TYPE_ONE, -1), -val+offset);
addConversion(RawSwitch(SWITCH_TYPE_ONE, 1), val++);
@@ -144,6 +145,15 @@ class SwitchesConversionTable: public ConversionTable {
}
}
if (IS_ARM(board) && version >= 218) {
addConversion(RawSwitch(SWITCH_TYPE_TELEMETRY, -1), -val+offset);
addConversion(RawSwitch(SWITCH_TYPE_TELEMETRY, 1), val++);
for (int i=1; i<=CPN_MAX_SENSORS; i++) {
addConversion(RawSwitch(SWITCH_TYPE_SENSOR, -i), -val+offset);
addConversion(RawSwitch(SWITCH_TYPE_SENSOR, i), val++);
}
}
if (version < 216) {
// previous "moment" switches
for (int i=1; i<=MAX_SWITCHES_POSITION(board, version); i++) {