Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bw): customisable switch LED color text sometimes incorrect on GX12 #5776

Merged
merged 2 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions radio/src/gui/128x64/model_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,13 @@ bool checkCFSSwitchAvailable(int sw)
}
#endif

#if defined(FUNCTION_SWITCHES_RGB_LEDS)
bool checkCFSColorAvailable(int col)
{
return col > 0;
}
#endif

void menuModelSetup(event_t event)
{
int8_t old_editMode = s_editMode;
Expand Down Expand Up @@ -963,18 +970,18 @@ void menuModelSetup(event_t event)
// ON
selectedColor = getRGBColorIndex(g_model.functionSwitchLedONColor[index].getColor());
selectedColor = editChoice(INDENT_WIDTH + getTextWidth(STR_FS_ON_COLOR) + 2, y, STR_FS_ON_COLOR, \
STR_FS_COLOR_LIST, selectedColor, 0, (sizeof(colorTable) / sizeof(colorTable[0])) - 1, menuHorizontalPosition == 0 ? attr : 0, event, INDENT_WIDTH);
STR_FS_COLOR_LIST, selectedColor, 0, DIM(colorTable), menuHorizontalPosition == 0 ? attr : 0, event, INDENT_WIDTH, checkCFSColorAvailable);
if (attr && menuHorizontalPosition == 0 && checkIncDec_Ret) {
g_model.functionSwitchLedONColor[index].setColor(colorTable[selectedColor]);
g_model.functionSwitchLedONColor[index].setColor(colorTable[selectedColor - 1]);
storageDirty(EE_MODEL);
}

// OFF
selectedColor = getRGBColorIndex(g_model.functionSwitchLedOFFColor[index].getColor());
selectedColor = editChoice((30 + 5*FW) + getTextWidth(STR_FS_OFF_COLOR) + 2, y, STR_FS_OFF_COLOR, \
STR_FS_COLOR_LIST, selectedColor, 0, (sizeof(colorTable) / sizeof(colorTable[0])) - 1, menuHorizontalPosition == 1 ? attr : 0, event, 30 + 5*FW);
STR_FS_COLOR_LIST, selectedColor, 0, DIM(colorTable), menuHorizontalPosition == 1 ? attr : 0, event, 30 + 5*FW, checkCFSColorAvailable);
if (attr && menuHorizontalPosition == 1 && checkIncDec_Ret) {
g_model.functionSwitchLedOFFColor[index].setColor(colorTable[selectedColor]);
g_model.functionSwitchLedOFFColor[index].setColor(colorTable[selectedColor - 1]);
storageDirty(EE_MODEL);
}

Expand Down
7 changes: 5 additions & 2 deletions radio/src/hal/rgbleds.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
#pragma once

#include <stdint.h>
// MUST match TR_FS_COLOR_LIST ( "White", "Red", "Green", "Yellow", "Orange", "Blue", "Pink", "Off", Custom gets display when none previous match
constexpr uint32_t colorTable[] = {0xF8F8F8, 0xF80000, 0x00F800, 0xF8F800, 0xF84000, 0x0000F8, 0xF800F8, 0x000000};
// MUST match TR_FS_COLOR_LIST (except 'Custom') - Custom gets display when none previous match
// "Off", "White", "Red", "Green", "Yellow", "Orange", "Blue", "Pink"
constexpr uint32_t colorTable[] = {0x000000, 0xFFFFFF, 0xFF0000, 0x00FF00, 0xFFFF00, 0xFF4000, 0x0000FF, 0xFF00FF};
// Alternate table for matching original RGB 565 converted values
constexpr uint32_t colorTabl2[] = {0x000000, 0xF8F8F8, 0xF80000, 0x00F800, 0xF8F800, 0xF84000, 0x0000F8, 0xF800F8};

void setFSLedOFF(uint8_t index);
void setFSLedON(uint8_t index);
Expand Down
11 changes: 8 additions & 3 deletions radio/src/targets/simu/led_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <stdint.h>
#include "hal/rgbleds.h"
#include "definitions.h"

bool usbChargerLed() { return true; }
void ledRed() {}
Expand All @@ -36,11 +37,15 @@ void rgbLedColorApply() {}

uint8_t getRGBColorIndex(uint32_t color)
{
for (uint8_t i = 0; i < (sizeof(colorTable) / sizeof(colorTable[0])); i++) {
for (uint8_t i = 0; i < DIM(colorTable); i++) {
if (color == colorTable[i])
return(i);
return(i + 1);
}
return 5; // Custom value set with Companion
for (uint8_t i = 0; i < DIM(colorTabl2); i++) {
if (color == colorTabl2[i])
return(i + 1);
}
return 0; // Custom value set with Companion
}

// RGB
Expand Down
10 changes: 7 additions & 3 deletions radio/src/targets/taranis/led_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,15 @@ void fsLedRGB(uint8_t index, uint32_t color)

uint8_t getRGBColorIndex(uint32_t color)
{
for (uint8_t i = 0; i < (sizeof(colorTable) / sizeof(colorTable[0])); i++) {
for (uint8_t i = 0; i < DIM(colorTable); i++) {
if (color == colorTable[i])
return(i);
return(i + 1);
}
return 5; // Custom value set with Companion
for (uint8_t i = 0; i < DIM(colorTabl2); i++) {
if (color == colorTabl2[i])
return(i + 1);
}
return 0; // Custom value set with Companion
}
#elif defined(FUNCTION_SWITCHES)
void fsLedOff(uint8_t index)
Expand Down
2 changes: 1 addition & 1 deletion radio/src/translations/cn.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@
#define TR_MS "ms"
#define TR_SWITCH "开关"
#define TR_FUNCTION_SWITCHES "可自定义开关"
#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom"
#define TR_FS_COLOR_LIST "Custom","Off","White","Red","Green","Yellow","Orange","Blue","Pink"
#define TR_GROUP "Group"
#define TR_GROUP_ALWAYS_ON "Always on"
#define TR_GROUPS "Always on groups"
Expand Down
2 changes: 1 addition & 1 deletion radio/src/translations/cz.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@
#define TR_MS "ms"
#define TR_SWITCH "Spínač"
#define TR_FUNCTION_SWITCHES "Nastavitelné přepínače"
#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom"
#define TR_FS_COLOR_LIST "Custom","Off","White","Red","Green","Yellow","Orange","Blue","Pink"
#define TR_GROUP "Group"
#define TR_GROUP_ALWAYS_ON "Always on"
#define TR_GROUPS "Always on groups"
Expand Down
2 changes: 1 addition & 1 deletion radio/src/translations/da.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
#define TR_MS "ms"
#define TR_SWITCH "Kontakt"
#define TR_FUNCTION_SWITCHES "Kontakter der kan tilpasses"
#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom"
#define TR_FS_COLOR_LIST "Custom","Off","White","Red","Green","Yellow","Orange","Blue","Pink"
#define TR_GROUP "Group"
#define TR_GROUP_ALWAYS_ON "Always on"
#define TR_GROUPS "Always on groups"
Expand Down
2 changes: 1 addition & 1 deletion radio/src/translations/de.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
#define TR_MS "ms"
#define TR_SWITCH TR("Schalt.", "Schalter")
#define TR_FUNCTION_SWITCHES "Anpassbare Schalter"
#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom"
#define TR_FS_COLOR_LIST "Custom","Off","White","Red","Green","Yellow","Orange","Blue","Pink"
#define TR_GROUP "Group"
#define TR_GROUP_ALWAYS_ON "Always on"
#define TR_FS_ON_COLOR TR("ON:","ON Color")
Expand Down
2 changes: 1 addition & 1 deletion radio/src/translations/en.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
#define TR_MS "ms"
#define TR_SWITCH "Switch"
#define TR_FUNCTION_SWITCHES "Customizable Switches"
#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom"
#define TR_FS_COLOR_LIST "Custom","Off","White","Red","Green","Yellow","Orange","Blue","Pink"
#define TR_GROUP "Group"
#define TR_GROUP_ALWAYS_ON "Always on"
#define TR_FS_ON_COLOR TR("ON:","ON Color")
Expand Down
2 changes: 1 addition & 1 deletion radio/src/translations/es.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
#define TR_MS "ms"
#define TR_SWITCH TR("Interr.", "Interruptor")
#define TR_FUNCTION_SWITCHES "Customizable switches"
#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom"
#define TR_FS_COLOR_LIST "Custom","Off","White","Red","Green","Yellow","Orange","Blue","Pink"
#define TR_GROUP "Group"
#define TR_GROUP_ALWAYS_ON "Always on"
#define TR_GROUPS "Always on groups"
Expand Down
2 changes: 1 addition & 1 deletion radio/src/translations/fi.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@
#define TR_MS "ms"
#define TR_SWITCH "Switch"
#define TR_FUNCTION_SWITCHES "Customizable switches"
#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom"
#define TR_FS_COLOR_LIST "Custom","Off","White","Red","Green","Yellow","Orange","Blue","Pink"
#define TR_GROUP "Group"
#define TR_GROUP_ALWAYS_ON "Always on"
#define TR_GROUPS "Always on groups"
Expand Down
2 changes: 1 addition & 1 deletion radio/src/translations/fr.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
#define TR_MS "ms"
#define TR_SWITCH TR("Inter", "Interrupteur")
#define TR_FUNCTION_SWITCHES "Inters paramétrables"
#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom"
#define TR_FS_COLOR_LIST "Custom","Off","White","Red","Green","Yellow","Orange","Blue","Pink"
#define TR_GROUP "Group"
#define TR_GROUP_ALWAYS_ON "Always on"
#define TR_GROUPS "Always on groups"
Expand Down
2 changes: 1 addition & 1 deletion radio/src/translations/he.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
#define TR_MS "ms"
#define TR_SWITCH "מתג"
#define TR_FUNCTION_SWITCHES "מפסקים בהתאמה אישית"
#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom"
#define TR_FS_COLOR_LIST "Custom","Off","White","Red","Green","Yellow","Orange","Blue","Pink"
#define TR_GROUP "Group"
#define TR_GROUP_ALWAYS_ON "Always on"
#define TR_GROUPS "Always on groups"
Expand Down
2 changes: 1 addition & 1 deletion radio/src/translations/it.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
#define TR_MS "ms"
#define TR_SWITCH "Inter."
#define TR_FUNCTION_SWITCHES "Interruttori personalizzabili"
#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom"
#define TR_FS_COLOR_LIST "Custom","Off","White","Red","Green","Yellow","Orange","Blue","Pink"
#define TR_GROUP "Group"
#define TR_GROUP_ALWAYS_ON "Always on"
#define TR_GROUPS "Always on groups"
Expand Down
2 changes: 1 addition & 1 deletion radio/src/translations/jp.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@
#define TR_MS "ms"
#define TR_SWITCH "スイッチ"
#define TR_FUNCTION_SWITCHES "カスタマイズ スイッチ"
#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom"
#define TR_FS_COLOR_LIST "Custom","Off","White","Red","Green","Yellow","Orange","Blue","Pink"
#define TR_GROUP "Group"
#define TR_GROUP_ALWAYS_ON "Always on"
#define TR_GROUPS "Always on groups"
Expand Down
2 changes: 1 addition & 1 deletion radio/src/translations/nl.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
#define TR_MS "ms"
#define TR_SWITCH TR("Schak.", "Schakelaar")
#define TR_FUNCTION_SWITCHES "Customizable switches"
#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom"
#define TR_FS_COLOR_LIST "Custom","Off","White","Red","Green","Yellow","Orange","Blue","Pink"
#define TR_GROUP "Group"
#define TR_GROUP_ALWAYS_ON "Always on"
#define TR_GROUPS "Always on groups"
Expand Down
2 changes: 1 addition & 1 deletion radio/src/translations/pl.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
#define TR_MS "ms"
#define TR_SWITCH "Przełą"
#define TR_FUNCTION_SWITCHES "Ustawiane przełączniki"
#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom"
#define TR_FS_COLOR_LIST "Custom","Off","White","Red","Green","Yellow","Orange","Blue","Pink"
#define TR_GROUP_ALWAYS_ON "Always on"
#define TR_GROUPS "Always on groups"
#define TR_LAST "Last"
Expand Down
2 changes: 1 addition & 1 deletion radio/src/translations/pt.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
#define TR_MS "ms"
#define TR_SWITCH "Chave"
#define TR_FUNCTION_SWITCHES "Chaves customizáveis"
#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom"
#define TR_FS_COLOR_LIST "Custom","Off","White","Red","Green","Yellow","Orange","Blue","Pink"
#define TR_GROUP "Group"
#define TR_GROUP_ALWAYS_ON "Always on"
#define TR_GROUPS "Always on groups"
Expand Down
2 changes: 1 addition & 1 deletion radio/src/translations/ru.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
#define TR_MS "ms"
#define TR_SWITCH "Тумблер"
#define TR_FUNCTION_SWITCHES "Настр тумблеры"
#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom"
#define TR_FS_COLOR_LIST "Custom","Off","White","Red","Green","Yellow","Orange","Blue","Pink"
#define TR_GROUP "Group"
#define TR_GROUP_ALWAYS_ON "Always on"
#define TR_GROUPS "Always on groups"
Expand Down
2 changes: 1 addition & 1 deletion radio/src/translations/se.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@
#define TR_MS "ms"
#define TR_SWITCH "Brytare"
#define TR_FUNCTION_SWITCHES "Anpassningsbara brytare"
#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom"
#define TR_FS_COLOR_LIST "Custom","Off","White","Red","Green","Yellow","Orange","Blue","Pink"
#define TR_GROUP "Grupp"
#define TR_GROUP_ALWAYS_ON "Alltid på"
#define TR_GROUPS "Always on groups"
Expand Down
2 changes: 1 addition & 1 deletion radio/src/translations/tw.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
#define TR_MS "ms"
#define TR_SWITCH "開關"
#define TR_FUNCTION_SWITCHES "可自定義開關"
#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom"
#define TR_FS_COLOR_LIST "Custom","Off","White","Red","Green","Yellow","Orange","Blue","Pink"
#define TR_GROUP "Group"
#define TR_GROUP_ALWAYS_ON "Always on"
#define TR_GROUPS "Always on groups"
Expand Down
2 changes: 1 addition & 1 deletion radio/src/translations/ua.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
#define TR_MS "ms"
#define TR_SWITCH "Перемикач"
#define TR_FUNCTION_SWITCHES "Користувацькі перемикачі"
#define TR_FS_COLOR_LIST "White","Red","Green","Yellow","Orange","Blue","Pink","Off","Custom"
#define TR_FS_COLOR_LIST "Custom","Off","White","Red","Green","Yellow","Orange","Blue","Pink"
#define TR_GROUP "Group"
#define TR_GROUP_ALWAYS_ON "Always on"
#define TR_GROUPS "Always on groups"
Expand Down
Loading