Skip to content

Commit

Permalink
define LED Strip task rate
Browse files Browse the repository at this point in the history
  • Loading branch information
ASDosjani committed Aug 8, 2023
1 parent 505318f commit 2cdd624
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/fc/tasks.c
Expand Up @@ -409,7 +409,7 @@ task_attribute_t task_attributes[TASK_COUNT] = {
#endif

#ifdef USE_LED_STRIP
[TASK_LEDSTRIP] = DEFINE_TASK("LEDSTRIP", NULL, NULL, ledStripUpdate, TASK_PERIOD_HZ(100), TASK_PRIORITY_LOW),
[TASK_LEDSTRIP] = DEFINE_TASK("LEDSTRIP", NULL, NULL, ledStripUpdate, TASK_PERIOD_HZ(TASK_LEDSTRIP_RATE_HZ), TASK_PRIORITY_LOW),
#endif

#ifdef USE_BST
Expand Down
4 changes: 2 additions & 2 deletions src/main/io/ledstrip.c
Expand Up @@ -903,15 +903,15 @@ static void applyRainbowLayer(bool updateNow, timeUs_t *timer)

if (updateNow) {
offset += ledStripConfig()->ledstrip_rainbow_freq;
*timer += HZ_TO_US(100);
*timer += HZ_TO_US(TASK_LEDSTRIP_RATE_HZ);
}
uint8_t rainbowLedIndex = 0;

for (unsigned i = 0; i < ledCounts.count; i++) {
const ledConfig_t *ledConfig = &ledStripStatusModeConfig()->ledConfigs[i];
if (ledGetOverlayBit(ledConfig, LED_OVERLAY_RAINBOW)) {
hsvColor_t ledColor;
ledColor.h = (offset / 100 + (rainbowLedIndex * ledStripConfig()->ledstrip_rainbow_delta)) % (HSV_HUE_MAX + 1);
ledColor.h = (offset / TASK_LEDSTRIP_RATE_HZ + (rainbowLedIndex * ledStripConfig()->ledstrip_rainbow_delta)) % (HSV_HUE_MAX + 1);
ledColor.s = 0;
ledColor.v = HSV_VALUE_MAX;
setLedHsv(i, &ledColor);
Expand Down
2 changes: 2 additions & 0 deletions src/main/io/ledstrip.h
Expand Up @@ -28,6 +28,8 @@

#include "pg/pg.h"

#define TASK_LEDSTRIP_RATE_HZ 100

#define LED_CONFIGURABLE_COLOR_COUNT 16
#define LED_MODE_COUNT 6
#define LED_DIRECTION_COUNT 6
Expand Down

0 comments on commit 2cdd624

Please sign in to comment.