1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-12 19:10:32 +03:00

Naming LED Strip overlay rates (#13363)

Add names to LED Strip overlay rates
This commit is contained in:
ASDosjani 2024-02-14 13:39:18 +01:00 committed by GitHub
parent 76e225aec9
commit a190ed98dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 8 deletions

View file

@ -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_____...

View file

@ -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