feat(bw): preview color on customisable switch LED when editing the color (#6716)
This commit is contained in:
@@ -590,7 +590,7 @@ uint8_t viewOptChoice(coord_t y, const char* title, uint8_t value, uint8_t attr,
|
||||
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
const char* _fct_sw_start[] = { STR_CHAR_UP, STR_CHAR_DOWN, "=" };
|
||||
static int swIndex;
|
||||
int swIndex;
|
||||
static uint8_t cfsGroup;
|
||||
|
||||
bool checkCFSTypeAvailable(int val)
|
||||
@@ -614,13 +614,6 @@ static bool checkCFSSwitchAvailable(int sw)
|
||||
return (sw == -1) || (sw == switchGetMaxSwitches()) || (switchIsCustomSwitch(sw) && (g_model.cfsGroup(sw) == cfsGroup));
|
||||
}
|
||||
|
||||
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
static bool checkCFSColorAvailable(int col)
|
||||
{
|
||||
return col > 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
enum CFSFields {
|
||||
CFS_FIELD_TYPE,
|
||||
CFS_FIELD_NAME,
|
||||
@@ -637,6 +630,13 @@ enum CFSFields {
|
||||
};
|
||||
|
||||
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
bool menuCFSpreview;
|
||||
|
||||
static bool checkCFSColorAvailable(int col)
|
||||
{
|
||||
return col > 0;
|
||||
}
|
||||
|
||||
void menuCFSColor(coord_t y, RGBLedColor& color, const char* title, LcdFlags attr, event_t event)
|
||||
{
|
||||
uint8_t selectedColor = getRGBColorIndex(color.getColor());
|
||||
@@ -658,6 +658,11 @@ void menuCFSColor(coord_t y, RGBLedColor& color, const char* title, LcdFlags att
|
||||
lcdDrawNumber(LCD_W, y, color.b, (menuHorizontalPosition == 3 ? attr : 0) | RIGHT);
|
||||
if (attr && menuHorizontalPosition == 3)
|
||||
color.b = checkIncDec(event, color.b, 0, 255, (isModelMenuDisplayed()) ? EE_MODEL : EE_GENERAL);
|
||||
|
||||
if ((attr & BLINK) && !menuCFSpreview) {
|
||||
menuCFSpreview = true;
|
||||
setFSEditOverride(swIndex, color.getColor());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -690,6 +695,10 @@ static void menuModelCFSOne(event_t event)
|
||||
|
||||
coord_t y = MENU_HEADER_HEIGHT + 1;
|
||||
|
||||
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
menuCFSpreview = false;
|
||||
#endif
|
||||
|
||||
for (int k = 0; k < NUM_BODY_LINES; k += 1) {
|
||||
int i = k + menuVerticalOffset;
|
||||
for (int j = 0; j <= i; j += 1) {
|
||||
@@ -776,6 +785,11 @@ static void menuModelCFSOne(event_t event)
|
||||
|
||||
y += FH;
|
||||
}
|
||||
|
||||
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
if (!menuCFSpreview)
|
||||
setFSEditOverride(-1, 0);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ static void onHardwareAntennaSwitchConfirm(const char * result)
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
#define RADIO_SETUP_2ND_COLUMN (LCD_W-11*FW)
|
||||
extern const char* _fct_sw_start[];
|
||||
static int swIndex;
|
||||
extern int swIndex;
|
||||
|
||||
extern bool checkCFSTypeAvailable(int val);
|
||||
|
||||
@@ -142,6 +142,7 @@ enum CFSFields {
|
||||
};
|
||||
|
||||
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
extern bool menuCFSpreview;
|
||||
extern void menuCFSColor(coord_t y, RGBLedColor& color, const char* title, LcdFlags attr, event_t event);
|
||||
#endif
|
||||
|
||||
@@ -173,6 +174,10 @@ static void menuRadioCFSOne(event_t event)
|
||||
|
||||
coord_t y = MENU_HEADER_HEIGHT + 1;
|
||||
|
||||
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
menuCFSpreview = false;
|
||||
#endif
|
||||
|
||||
for (int k = 0; k < NUM_BODY_LINES; k += 1) {
|
||||
int i = k + menuVerticalOffset;
|
||||
for (int j = 0; j <= i; j += 1) {
|
||||
@@ -241,6 +246,11 @@ static void menuRadioCFSOne(event_t event)
|
||||
|
||||
y += FH;
|
||||
}
|
||||
|
||||
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
if (!menuCFSpreview)
|
||||
setFSEditOverride(-1, 0);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user