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:
co-authored by
philmoz
3djc
elecpower
parent
28833f42e6
commit
0c8c39b134
+24
-28
@@ -100,6 +100,26 @@ void setVendorSpecificModelDefaults(uint8_t id)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
void initCustomSwitches()
|
||||
{
|
||||
for (int i = 0; i < switchGetMaxSwitches(); i += 1) {
|
||||
if (switchIsCustomSwitch(i)) {
|
||||
uint8_t idx = switchGetCustomSwitchIdx(i);
|
||||
g_model.customSwitches[idx].type = SWITCH_GLOBAL;
|
||||
g_model.customSwitches[idx].group = 0;
|
||||
g_model.customSwitches[idx].start = FS_START_PREVIOUS;
|
||||
g_model.customSwitches[idx].state = 0;
|
||||
g_model.customSwitches[idx].name[0] = 0;
|
||||
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
g_model.customSwitches[idx].offColor.setColor(0);
|
||||
g_model.customSwitches[idx].onColor.setColor(0xFFFFFF);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void applyDefaultTemplate()
|
||||
{
|
||||
setDefaultInputs();
|
||||
@@ -110,42 +130,18 @@ void applyDefaultTemplate()
|
||||
setDefaultModelRegistrationID();
|
||||
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
g_model.functionSwitchConfig = DEFAULT_FS_CONFIG;
|
||||
g_model.functionSwitchGroup = DEFAULT_FS_GROUPS;
|
||||
g_model.functionSwitchStartConfig = DEFAULT_FS_STARTUP_CONFIG;
|
||||
g_model.functionSwitchLogicalState = 0;
|
||||
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
for (uint8_t i = 0; i < NUM_FUNCTIONS_SWITCHES; i++) {
|
||||
g_model.functionSwitchLedOFFColor[i].setColor(0);
|
||||
g_model.functionSwitchLedONColor[i].setColor(0xFFFFFF);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
for (uint8_t i = 0; i < NUM_FUNCTIONS_SWITCHES; i++) {
|
||||
g_model.functionSwitchLedOFFColor[i].setColor(0);
|
||||
g_model.functionSwitchLedONColor[i].setColor(0xFFFFFF);
|
||||
}
|
||||
initCustomSwitches();
|
||||
#endif
|
||||
|
||||
#if defined(COLORLCD)
|
||||
|
||||
LayoutFactory::loadDefaultLayout();
|
||||
#endif
|
||||
|
||||
// enable switch warnings
|
||||
for (uint64_t i = 0; i < MAX_SWITCHES; i++) {
|
||||
if (SWITCH_EXISTS(i)) {
|
||||
g_model.switchWarning |= (1ull << (3ull * i));
|
||||
}
|
||||
}
|
||||
#else
|
||||
// enable switch warnings
|
||||
for (uint64_t i = 0; i < MAX_SWITCHES; i++) {
|
||||
for (uint64_t i = 0; i < switchGetMaxAllSwitches(); i++) {
|
||||
if (SWITCH_WARNING_ALLOWED(i))
|
||||
g_model.switchWarning |= (1ull << (3ull * i));
|
||||
g_model.setSwitchWarning(i, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(USE_HATS_AS_KEYS)
|
||||
g_model.hatsMode = HATSMODE_GLOBAL;
|
||||
|
||||
Reference in New Issue
Block a user