fix(radio): 2POS switch connected to 3POS socket may not behave as expected (#6067)
This commit is contained in:
+14
-7
@@ -727,15 +727,22 @@ bool getSwitch(swsrc_t swtch, uint8_t flags)
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (flags & GETSWITCH_MIDPOS_DELAY) {
|
||||
result = SWITCH_POSITION(cs_idx);
|
||||
} else {
|
||||
div_t qr = div(cs_idx, 3);
|
||||
if (SWITCH_EXISTS(qr.quot)) {
|
||||
result = switchState(cs_idx);
|
||||
div_t qr = div(cs_idx, 3);
|
||||
if (SWITCH_EXISTS(qr.quot)) {
|
||||
auto sw_cfg = (SwitchConfig)SWITCH_CONFIG(qr.quot);
|
||||
if (flags & GETSWITCH_MIDPOS_DELAY) {
|
||||
result = SWITCH_POSITION(cs_idx);
|
||||
// Handle 2POS switch installed in 3POS slot
|
||||
if (!result && qr.rem == SWITCH_HW_DOWN && (sw_cfg == SWITCH_2POS || sw_cfg == SWITCH_TOGGLE))
|
||||
result = SWITCH_POSITION(cs_idx - 1);
|
||||
} else {
|
||||
result = false;
|
||||
result = switchState(cs_idx);
|
||||
// Handle 2POS switch installed in 3POS slot
|
||||
if (!result && qr.rem == SWITCH_HW_DOWN && (sw_cfg == SWITCH_2POS || sw_cfg == SWITCH_TOGGLE))
|
||||
result = switchState(cs_idx - 1);
|
||||
}
|
||||
} else {
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user