fix(switches): widen fsPreviousState to 32-bit to fix toggle detection for more than 16 switches (#7560)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
norulers
2026-07-16 09:50:17 +10:00
committed by GitHub
co-authored by Claude Fable 5
parent c966bee5f2
commit 0a6d3d0f72
2 changed files with 45 additions and 3 deletions
+3 -3
View File
@@ -92,7 +92,7 @@ uint8_t potsPos[MAX_POTS];
// Non pushed : SWSRC_Sx0 = -1024 = Sx(up) = state 0
// Pushed : SWSRC_Sx2 = +1024 = Sx(down) = state 1
uint16_t fsPreviousState = 0;
uint32_t fsPreviousState = 0;
uint8_t isSwitch3Pos(uint8_t idx)
{
@@ -149,7 +149,7 @@ bool getFSPhysicalState(uint8_t index)
static bool getFSPreviousPhysicalState(uint8_t index)
{
return (uint8_t)(bfSingleBitGet(fsPreviousState, index) >> (index));
return (fsPreviousState >> index) & 1;
}
uint8_t getSwitchCountInFSGroup(uint8_t index)
@@ -206,7 +206,7 @@ void evalFunctionSwitches()
}
}
fsPreviousState ^= 1 << i; // Toggle state
fsPreviousState ^= uint32_t(1) << i; // Toggle state
storageDirty(EE_MODEL);
}