fix(color): preview may not work when editing customisable switch colors in radio setup (#6714)
This commit is contained in:
@@ -136,6 +136,7 @@ class FunctionSwitch : public Window
|
|||||||
g_model.cfsOffColor(switchIndex).setColor(newValue);
|
g_model.cfsOffColor(switchIndex).setColor(newValue);
|
||||||
|
|
||||||
offValue = g_model.cfsOffColor(switchIndex);
|
offValue = g_model.cfsOffColor(switchIndex);
|
||||||
|
setFSEditOverride(-1, 0);
|
||||||
SET_DIRTY();
|
SET_DIRTY();
|
||||||
},
|
},
|
||||||
[=](int newValue) { previewColor(newValue); }, ETX_RGB888);
|
[=](int newValue) { previewColor(newValue); }, ETX_RGB888);
|
||||||
@@ -154,6 +155,7 @@ class FunctionSwitch : public Window
|
|||||||
g_model.cfsOnColor(switchIndex).setColor(newValue);
|
g_model.cfsOnColor(switchIndex).setColor(newValue);
|
||||||
|
|
||||||
onValue = g_model.cfsOnColor(switchIndex);
|
onValue = g_model.cfsOnColor(switchIndex);
|
||||||
|
setFSEditOverride(-1, 0);
|
||||||
SET_DIRTY();
|
SET_DIRTY();
|
||||||
},
|
},
|
||||||
[=](int newValue) { previewColor(newValue); }, ETX_RGB888);
|
[=](int newValue) { previewColor(newValue); }, ETX_RGB888);
|
||||||
@@ -240,11 +242,7 @@ class FunctionSwitch : public Window
|
|||||||
{
|
{
|
||||||
// Convert color index to RGB
|
// Convert color index to RGB
|
||||||
newValue = color32ToRGB(newValue);
|
newValue = color32ToRGB(newValue);
|
||||||
if (g_model.cfsState(switchIndex)) {
|
setFSEditOverride(switchIndex, newValue);
|
||||||
g_model.cfsOnColor(switchIndex).setColor(newValue);
|
|
||||||
} else {
|
|
||||||
g_model.cfsOffColor(switchIndex).setColor(newValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ class RadioFunctionSwitch : public Window
|
|||||||
g_eeGeneral.switchOffColor(switchIndex).setColor(newValue);
|
g_eeGeneral.switchOffColor(switchIndex).setColor(newValue);
|
||||||
|
|
||||||
offValue = g_eeGeneral.switchOffColor(switchIndex);
|
offValue = g_eeGeneral.switchOffColor(switchIndex);
|
||||||
|
setFSEditOverride(-1, 0);
|
||||||
SET_DIRTY();
|
SET_DIRTY();
|
||||||
},
|
},
|
||||||
[=](int newValue) { previewColor(newValue); }, ETX_RGB888);
|
[=](int newValue) { previewColor(newValue); }, ETX_RGB888);
|
||||||
@@ -124,6 +125,7 @@ class RadioFunctionSwitch : public Window
|
|||||||
g_eeGeneral.switchOnColor(switchIndex).setColor(newValue);
|
g_eeGeneral.switchOnColor(switchIndex).setColor(newValue);
|
||||||
|
|
||||||
onValue = g_eeGeneral.switchOnColor(switchIndex);
|
onValue = g_eeGeneral.switchOnColor(switchIndex);
|
||||||
|
setFSEditOverride(-1, 0);
|
||||||
SET_DIRTY();
|
SET_DIRTY();
|
||||||
},
|
},
|
||||||
[=](int newValue) { previewColor(newValue); }, ETX_RGB888);
|
[=](int newValue) { previewColor(newValue); }, ETX_RGB888);
|
||||||
@@ -209,11 +211,7 @@ class RadioFunctionSwitch : public Window
|
|||||||
{
|
{
|
||||||
// Convert color index to RGB
|
// Convert color index to RGB
|
||||||
newValue = color32ToRGB(newValue);
|
newValue = color32ToRGB(newValue);
|
||||||
if (g_model.cfsState(switchIndex)) {
|
setFSEditOverride(switchIndex, newValue);
|
||||||
g_eeGeneral.switchOnColor(switchIndex).setColor(newValue);
|
|
||||||
} else {
|
|
||||||
g_eeGeneral.switchOffColor(switchIndex).setColor(newValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
+28
-10
@@ -27,6 +27,14 @@
|
|||||||
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||||
static bool hasLedOverride[NUM_FUNCTIONS_SWITCHES] = { false };
|
static bool hasLedOverride[NUM_FUNCTIONS_SWITCHES] = { false };
|
||||||
static RGBLedColor ledOverride[NUM_FUNCTIONS_SWITCHES];
|
static RGBLedColor ledOverride[NUM_FUNCTIONS_SWITCHES];
|
||||||
|
static int cfsEditOverride = -1;
|
||||||
|
static uint32_t cfsEditColor;
|
||||||
|
|
||||||
|
void setFSEditOverride(int index, uint32_t color)
|
||||||
|
{
|
||||||
|
cfsEditOverride = index;
|
||||||
|
cfsEditColor = color;
|
||||||
|
}
|
||||||
|
|
||||||
void setFSLedOverride(uint8_t index, bool state, uint8_t r, uint8_t g, uint8_t b)
|
void setFSLedOverride(uint8_t index, bool state, uint8_t r, uint8_t g, uint8_t b)
|
||||||
{
|
{
|
||||||
@@ -38,21 +46,31 @@ void setFSLedOverride(uint8_t index, bool state, uint8_t r, uint8_t g, uint8_t b
|
|||||||
|
|
||||||
void setFSLedOFF(uint8_t index) {
|
void setFSLedOFF(uint8_t index) {
|
||||||
if (g_model.getSwitchType(index) != SWITCH_NONE) {
|
if (g_model.getSwitchType(index) != SWITCH_NONE) {
|
||||||
uint8_t cfsIdx = switchGetCustomSwitchIdx(index);
|
if (cfsEditOverride >= 0) {
|
||||||
if (hasLedOverride[cfsIdx] && g_model.getSwitchOffColorLuaOverride(index))
|
uint8_t cfsIdx = switchGetCustomSwitchIdx(cfsEditOverride);
|
||||||
fsLedRGB(cfsIdx, ledOverride[cfsIdx].getColor());
|
fsLedRGB(cfsIdx, cfsEditColor);
|
||||||
else
|
} else {
|
||||||
fsLedRGB(cfsIdx, g_model.getSwitchOffColor(index).getColor());
|
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) {
|
void setFSLedON(uint8_t index) {
|
||||||
if (g_model.getSwitchType(index) != SWITCH_NONE) {
|
if (g_model.getSwitchType(index) != SWITCH_NONE) {
|
||||||
uint8_t cfsIdx = switchGetCustomSwitchIdx(index);
|
if (cfsEditOverride >= 0) {
|
||||||
if (hasLedOverride[cfsIdx] && g_model.getSwitchOnColorLuaOverride(index))
|
uint8_t cfsIdx = switchGetCustomSwitchIdx(cfsEditOverride);
|
||||||
fsLedRGB(cfsIdx, ledOverride[cfsIdx].getColor());
|
fsLedRGB(cfsIdx, cfsEditColor);
|
||||||
else
|
} else {
|
||||||
fsLedRGB(cfsIdx, g_model.getSwitchOnColor(index).getColor());
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
// "Off", "White", "Red", "Green", "Yellow", "Orange", "Blue", "Pink"
|
// "Off", "White", "Red", "Green", "Yellow", "Orange", "Blue", "Pink"
|
||||||
constexpr uint32_t colorTable[] = {0x000000, 0xFFFFFF, 0xFF0000, 0x00FF00, 0xFFFF00, 0xFF4000, 0x0000FF, 0xFF00FF};
|
constexpr uint32_t colorTable[] = {0x000000, 0xFFFFFF, 0xFF0000, 0x00FF00, 0xFFFF00, 0xFF4000, 0x0000FF, 0xFF00FF};
|
||||||
|
|
||||||
|
void setFSEditOverride(int index, uint32_t color);
|
||||||
void setFSLedOverride(uint8_t index, bool state, uint8_t r, uint8_t g, uint8_t b);
|
void setFSLedOverride(uint8_t index, bool state, uint8_t r, uint8_t g, uint8_t b);
|
||||||
void setFSLedOFF(uint8_t index);
|
void setFSLedOFF(uint8_t index);
|
||||||
void setFSLedON(uint8_t index);
|
void setFSLedON(uint8_t index);
|
||||||
|
|||||||
Reference in New Issue
Block a user