1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-13 03:20:00 +03:00

Use fixed LED color table in RACE / BEACON LED profiles (#13339)

Use the non-custom color table when requiring fixed colors
This commit is contained in:
Bryan Mayland 2024-02-13 18:01:09 -05:00 committed by GitHub
parent b8d99d7542
commit 3ef7a188d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1264,9 +1264,11 @@ void ledStripInit(void)
ws2811LedStripInit(ledStripConfig()->ioTag); ws2811LedStripInit(ledStripConfig()->ioTag);
} }
static uint8_t selectVisualBeeperColor(uint8_t colorIndex) static uint8_t selectVisualBeeperColor(uint8_t colorIndex, bool *colorIndexIsCustom)
{ {
if (ledStripConfig()->ledstrip_visual_beeper && isBeeperOn()) { if (ledStripConfig()->ledstrip_visual_beeper && isBeeperOn()) {
if (colorIndexIsCustom)
*colorIndexIsCustom = false;
return ledStripConfig()->ledstrip_visual_beeper_color; return ledStripConfig()->ledstrip_visual_beeper_color;
} else { } else {
return colorIndex; return colorIndex;
@ -1279,6 +1281,7 @@ static ledProfileSequence_t applySimpleProfile(timeUs_t currentTimeUs)
uint8_t colorIndex = COLOR_BLACK; uint8_t colorIndex = COLOR_BLACK;
bool blinkLed = false; bool blinkLed = false;
bool visualBeeperOverride = true; bool visualBeeperOverride = true;
bool useCustomColors = false;
unsigned flashPeriod; unsigned flashPeriod;
unsigned onPercent; unsigned onPercent;
@ -1308,6 +1311,9 @@ static ledProfileSequence_t applySimpleProfile(timeUs_t currentTimeUs)
freq = vtxSettingsConfig()->freq; freq = vtxSettingsConfig()->freq;
} }
colorIndex = getColorByVtxFrequency(freq); colorIndex = getColorByVtxFrequency(freq);
// getColorByVtxFrequency always uses custom colors
// as they may be reassigned by the race director
useCustomColors = true;
} }
} }
#endif #endif
@ -1335,11 +1341,11 @@ static ledProfileSequence_t applySimpleProfile(timeUs_t currentTimeUs)
} }
if (visualBeeperOverride) { if (visualBeeperOverride) {
colorIndex = selectVisualBeeperColor(colorIndex); colorIndex = selectVisualBeeperColor(colorIndex, &useCustomColors);
} }
if ((colorIndex != previousProfileColorIndex) || (currentTimeUs >= colorUpdateTimeUs)) { if ((colorIndex != previousProfileColorIndex) || (currentTimeUs >= colorUpdateTimeUs)) {
setStripColor(&ledStripStatusModeConfig()->colors[colorIndex]); setStripColor((useCustomColors) ? &ledStripStatusModeConfig()->colors[colorIndex] : &hsv[colorIndex]);
previousProfileColorIndex = colorIndex; previousProfileColorIndex = colorIndex;
colorUpdateTimeUs = currentTimeUs + PROFILE_COLOR_UPDATE_INTERVAL_US; colorUpdateTimeUs = currentTimeUs + PROFILE_COLOR_UPDATE_INTERVAL_US;
return LED_PROFILE_ADVANCE; return LED_PROFILE_ADVANCE;