From a190ed98dc674495b8096d369f2e7aa667d754e3 Mon Sep 17 00:00:00 2001 From: ASDosjani <62965528+ASDosjani@users.noreply.github.com> Date: Wed, 14 Feb 2024 13:39:18 +0100 Subject: [PATCH] Naming LED Strip overlay rates (#13363) Add names to LED Strip overlay rates --- src/main/io/ledstrip.c | 21 ++++++++++++++------- src/main/io/ledstrip.h | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/io/ledstrip.c b/src/main/io/ledstrip.c index 3a1fea4851..4a6401172f 100644 --- a/src/main/io/ledstrip.c +++ b/src/main/io/ledstrip.c @@ -92,6 +92,13 @@ static uint8_t previousProfileColorIndex = COLOR_UNDEFINED; #define TASK_LEDSTRIP_RATE_WAIT_HZ 500 // Scheduling rate waiting for a timer to fire #define TASK_LEDSTRIP_RATE_FAST_HZ 100000 // Reschedule as fast as possible +#define LED_OVERLAY_RAINBOW_RATE_HZ 60 +#define LED_OVERLAY_LARSON_RATE_HZ 60 +#define LED_OVERLAY_BLINK_RATE_HZ 10 +#define LED_OVERLAY_VTX_RATE_HZ 5 +#define LED_OVERLAY_INDICATOR_RATE_HZ 5 +#define LED_OVERLAY_WARNING_RATE_HZ 10 + #define LED_TASK_MARGIN 1 // Decay the estimated max task duration by 1/(1 << LED_EXEC_TIME_SHIFT) on every invocation #define LED_EXEC_TIME_SHIFT 7 @@ -600,7 +607,7 @@ static void applyLedWarningLayer(bool updateNow, timeUs_t *timer) warningFlags |= 1 << WARNING_CRASH_FLIP_ACTIVE; } } - *timer += HZ_TO_US(10); + *timer += HZ_TO_US(LED_OVERLAY_WARNING_RATE_HZ); } const hsvColor_t *warningColor = NULL; @@ -700,7 +707,7 @@ static void applyLedVtxLayer(bool updateNow, timeUs_t *timer) showSettings--; } blink = !blink; - *timer += HZ_TO_US(5); // check 5 times a second + *timer += HZ_TO_US(LED_OVERLAY_VTX_RATE_HZ); } hsvColor_t color = {0, 0, 0}; @@ -856,7 +863,7 @@ static void applyLedIndicatorLayer(bool updateNow, timeUs_t *timer) flash = !flash; } else { - *timer += HZ_TO_US(5); + *timer += HZ_TO_US(LED_OVERLAY_INDICATOR_RATE_HZ); } } @@ -926,7 +933,7 @@ static void applyRainbowLayer(bool updateNow, timeUs_t *timer) if (updateNow) { offset += ledStripConfig()->ledstrip_rainbow_freq; - *timer += HZ_TO_US(TASK_LEDSTRIP_RATE_HZ); + *timer += HZ_TO_US(LED_OVERLAY_RAINBOW_RATE_HZ); } uint8_t rainbowLedIndex = 0; @@ -934,7 +941,7 @@ static void applyRainbowLayer(bool updateNow, timeUs_t *timer) const ledConfig_t *ledConfig = &ledStripStatusModeConfig()->ledConfigs[i]; if (ledGetOverlayBit(ledConfig, LED_OVERLAY_RAINBOW)) { hsvColor_t ledColor; - ledColor.h = (offset / TASK_LEDSTRIP_RATE_HZ + rainbowLedIndex * ledStripConfig()->ledstrip_rainbow_delta) % (HSV_HUE_MAX + 1); + ledColor.h = (offset / LED_OVERLAY_RAINBOW_RATE_HZ + rainbowLedIndex * ledStripConfig()->ledstrip_rainbow_delta) % (HSV_HUE_MAX + 1); ledColor.s = 0; ledColor.v = HSV_VALUE_MAX; setLedHsv(i, &ledColor); @@ -987,7 +994,7 @@ static void applyLarsonScannerLayer(bool updateNow, timeUs_t *timer) if (updateNow) { larsonScannerNextStep(&larsonParameters, 15); - *timer += HZ_TO_US(60); + *timer += HZ_TO_US(LED_OVERLAY_LARSON_RATE_HZ); } int scannerLedIndex = 0; @@ -1016,7 +1023,7 @@ static void applyLedBlinkLayer(bool updateNow, timeUs_t *timer) if (blinkMask <= 1) blinkMask = blinkPattern; - *timer += HZ_TO_US(10); + *timer += HZ_TO_US(LED_OVERLAY_BLINK_RATE_HZ); } bool ledOn = (blinkMask & 1); // b_b_____... diff --git a/src/main/io/ledstrip.h b/src/main/io/ledstrip.h index b0c0ec821c..308475132f 100644 --- a/src/main/io/ledstrip.h +++ b/src/main/io/ledstrip.h @@ -28,7 +28,7 @@ #include "pg/pg.h" -#define TASK_LEDSTRIP_RATE_HZ 50 +#define TASK_LEDSTRIP_RATE_HZ 60 #define LED_CONFIGURABLE_COLOR_COUNT 16 #define LED_MODE_COUNT 6