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

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

Merged
merged 1 commit into from Feb 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/main/io/ledstrip.c
Expand Up @@ -1264,9 +1264,11 @@ void ledStripInit(void)
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 (colorIndexIsCustom)
*colorIndexIsCustom = false;
return ledStripConfig()->ledstrip_visual_beeper_color;
} else {
return colorIndex;
Expand All @@ -1279,6 +1281,7 @@ static ledProfileSequence_t applySimpleProfile(timeUs_t currentTimeUs)
uint8_t colorIndex = COLOR_BLACK;
bool blinkLed = false;
bool visualBeeperOverride = true;
bool useCustomColors = false;
unsigned flashPeriod;
unsigned onPercent;

Expand Down Expand Up @@ -1308,6 +1311,9 @@ static ledProfileSequence_t applySimpleProfile(timeUs_t currentTimeUs)
freq = vtxSettingsConfig()->freq;
}
colorIndex = getColorByVtxFrequency(freq);
// getColorByVtxFrequency always uses custom colors
// as they may be reassigned by the race director
useCustomColors = true;
}
}
#endif
Expand Down Expand Up @@ -1335,11 +1341,11 @@ static ledProfileSequence_t applySimpleProfile(timeUs_t currentTimeUs)
}

if (visualBeeperOverride) {
colorIndex = selectVisualBeeperColor(colorIndex);
colorIndex = selectVisualBeeperColor(colorIndex, &useCustomColors);
}

if ((colorIndex != previousProfileColorIndex) || (currentTimeUs >= colorUpdateTimeUs)) {
setStripColor(&ledStripStatusModeConfig()->colors[colorIndex]);
setStripColor((useCustomColors) ? &ledStripStatusModeConfig()->colors[colorIndex] : &hsv[colorIndex]);
previousProfileColorIndex = colorIndex;
colorUpdateTimeUs = currentTimeUs + PROFILE_COLOR_UPDATE_INTERVAL_US;
return LED_PROFILE_ADVANCE;
Expand Down