diff --git a/src/main/drivers/light_ws2811strip.c b/src/main/drivers/light_ws2811strip.c index 0820e33eb0..107bbeaa75 100644 --- a/src/main/drivers/light_ws2811strip.c +++ b/src/main/drivers/light_ws2811strip.c @@ -42,6 +42,11 @@ void setLedHsv(uint16_t index, const hsvColor_t *color) ledColorBuffer[index] = *color; } +void getLedHsv(uint16_t index, hsvColor_t *color) +{ + *color = ledColorBuffer[index]; +} + void setLedValue(uint16_t index, const uint8_t value) { ledColorBuffer[index].v = value; diff --git a/src/main/drivers/light_ws2811strip.h b/src/main/drivers/light_ws2811strip.h index efca5a4707..0efadbebeb 100644 --- a/src/main/drivers/light_ws2811strip.h +++ b/src/main/drivers/light_ws2811strip.h @@ -31,6 +31,8 @@ void ws2811LedStripDMAEnable(void); void ws2811UpdateStrip(void); void setLedHsv(uint16_t index, const hsvColor_t *color); +void getLedHsv(uint16_t index, hsvColor_t *color); + void scaleLedValue(uint16_t index, const uint8_t scalePercent); void setLedValue(uint16_t index, const uint8_t value); diff --git a/src/main/io/ledstrip.c b/src/main/io/ledstrip.c index c9c087a985..3ee0082f82 100644 --- a/src/main/io/ledstrip.c +++ b/src/main/io/ledstrip.c @@ -643,15 +643,21 @@ void applyLedIndicatorLayer(uint8_t indicatorFlashState) void applyLedThrottleLayer() { const ledConfig_t *ledConfig; + hsvColor_t color; uint8_t ledIndex; for (ledIndex = 0; ledIndex < ledCount; ledIndex++) { - ledConfig = &ledConfigs[ledIndex]; - if(ledConfig->flags & LED_FUNCTION_THROTTLE) { - int hue = scaleRange(rcCommand[THROTTLE], PWM_RANGE_MIN, PWM_RANGE_MAX, hsv_lightBlue.h, hsv_red.h); - hsvColor_t color = {hue , 0 , 255}; - setLedHsv(ledIndex, &color); - } + ledConfig = &ledConfigs[ledIndex]; + if(!(ledConfig->flags & LED_FUNCTION_THROTTLE)) { + continue; + } + + getLedHsv(ledIndex, &color); + + int scaled = scaleRange(rcData[THROTTLE], PWM_RANGE_MIN, PWM_RANGE_MAX, -60, +60); + scaled += HSV_HUE_MAX; + color.h = scaled % HSV_HUE_MAX; + setLedHsv(ledIndex, &color); } } diff --git a/src/main/io/ledstrip.h b/src/main/io/ledstrip.h index 139021ad63..f3a7195f54 100644 --- a/src/main/io/ledstrip.h +++ b/src/main/io/ledstrip.h @@ -65,3 +65,4 @@ void generateLedConfig(uint8_t ledIndex, char *ledConfigBuffer, size_t bufferSiz bool parseColor(uint8_t index, char *colorConfig); void applyDefaultColors(hsvColor_t *colors, uint8_t colorCount); +