feat(radio): refactor of switch handling to better support customisable switches (#6095)

Co-authored-by: philmoz <phil.a.mitchell@gmail.com>
Co-authored-by: 3djc <3djc@gh.com>
Co-authored-by: elecpower <elecpower@users.noreply.github.com>
This commit is contained in:
philmoz
2025-07-28 12:59:22 +10:00
committed by GitHub
co-authored by philmoz 3djc elecpower
parent 28833f42e6
commit 0c8c39b134
155 changed files with 4538 additions and 2306 deletions
+31 -4
View File
@@ -25,32 +25,59 @@
#include "dataconstants.h"
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
static bool hasLedOverride[NUM_FUNCTIONS_SWITCHES] = { false };
static RGBLedColor ledOverride[NUM_FUNCTIONS_SWITCHES];
void setFSLedOverride(uint8_t index, bool state, uint8_t r, uint8_t g, uint8_t b)
{
hasLedOverride[index] = state;
ledOverride[index].r = r;
ledOverride[index].g = g;
ledOverride[index].b = b;
}
void setFSLedOFF(uint8_t index) {
fsLedRGB(index, g_model.functionSwitchLedOFFColor[index].getColor());
if (g_model.getSwitchType(index) != SWITCH_NONE) {
uint8_t cfsIdx = switchGetCustomSwitchIdx(index);
if (hasLedOverride[cfsIdx] && g_model.getSwitchOffColorLuaOverride(index))
fsLedRGB(cfsIdx, ledOverride[cfsIdx].getColor());
else
fsLedRGB(cfsIdx, g_model.getSwitchOffColor(index).getColor());
}
}
void setFSLedON(uint8_t index) {
fsLedRGB(index, g_model.functionSwitchLedONColor[index].getColor());
if (g_model.getSwitchType(index) != SWITCH_NONE) {
uint8_t cfsIdx = switchGetCustomSwitchIdx(index);
if (hasLedOverride[cfsIdx] && g_model.getSwitchOnColorLuaOverride(index))
fsLedRGB(cfsIdx, ledOverride[cfsIdx].getColor());
else
fsLedRGB(cfsIdx, g_model.getSwitchOnColor(index).getColor());
}
}
bool getFSLedState(uint8_t index) {
return fsGetLedRGB(index) == g_model.functionSwitchLedONColor[index].getColor();
uint8_t cfsIdx = switchGetCustomSwitchIdx(index);
return rgbGetLedColor(cfsIdx) == g_model.getSwitchOnColor(index).getColor();
}
uint32_t getFSLedRGBColor(uint8_t index)
{
return fsGetLedRGB(index);
return fsGetLedRGB(index);
}
#else
void setFSLedOFF(uint8_t index) {
index = switchGetCustomSwitchIdx(index);
fsLedOff(index);
}
void setFSLedON(uint8_t index) {
index = switchGetCustomSwitchIdx(index);
fsLedOn(index);
}
bool getFSLedState(uint8_t index) {
index = switchGetCustomSwitchIdx(index);
return fsLedState(index);
}
#endif