diff --git a/docs/LedStrip.md b/docs/LedStrip.md index 2220ce26c..b61c2ce55 100644 --- a/docs/LedStrip.md +++ b/docs/LedStrip.md @@ -115,6 +115,7 @@ Each LED has one base function: * `G` - `G`PS state. * `S` - R`S`SSI level. * `L` - Battery `L`evel. +* `H` - C`H`annel. And each LED has overlays: @@ -125,7 +126,7 @@ And each LED has overlays: * `O` - Lars`O`n Scanner (Cylon Effect). * `N` - Blink on la`N`ding (throttle < 50%). -`cc` specifies the color number (0 based index). +`cc` specifies the color number (0 based index), or Channel number to adjust Hue Example: @@ -137,6 +138,7 @@ led 3 0,15:SD:AWI:0 led 4 7,7::C:1 led 5 8,8::C:2 led 6 8,9::B:1 +led 7 8,10::H:6 ``` To erase an led, and to mark the end of the chain, use `0,0::` as the second argument, like this: diff --git a/src/main/io/ledstrip.c b/src/main/io/ledstrip.c index e7a27ec76..27a1ff775 100644 --- a/src/main/io/ledstrip.c +++ b/src/main/io/ledstrip.c @@ -220,7 +220,7 @@ static const hsvColor_t* getSC(ledSpecialColorIds_e index) } static const char directionCodes[LED_DIRECTION_COUNT] = { 'N', 'E', 'S', 'W', 'U', 'D' }; -static const char baseFunctionCodes[LED_BASEFUNCTION_COUNT] = { 'C', 'F', 'A', 'L', 'S', 'G', 'R' }; +static const char baseFunctionCodes[LED_BASEFUNCTION_COUNT] = { 'C', 'F', 'A', 'L', 'S', 'G', 'R', 'H' }; static const char overlayCodes[LED_OVERLAY_COUNT] = { 'T', 'O', 'B', 'N', 'I', 'W' }; #define CHUNK_BUFFER_SIZE 11 @@ -438,6 +438,7 @@ static void applyLedFixedLayers(void) int fn = ledGetFunction(ledConfig); int hOffset = HSV_HUE_MAX; + uint8_t channel = 0; switch (fn) { case LED_FUNCTION_COLOR: @@ -470,6 +471,18 @@ static void applyLedFixedLayers(void) hOffset += scaleRange(getRSSI() * 100, 0, 1023, -30, 120); break; + case LED_FUNCTION_CHANNEL: + channel = ledGetColor(ledConfig) - 1; + color = HSV(RED); + hOffset = scaleRange(rxGetChannelValue(channel), PWM_RANGE_MIN, PWM_RANGE_MAX, -1, 360); + // add black and white to range of colors + if (hOffset < 0) { + color = HSV(BLACK); + } else if (hOffset > HSV_HUE_MAX) { + color = HSV(WHITE); + } + break; + default: break; } diff --git a/src/main/io/ledstrip.h b/src/main/io/ledstrip.h index 07ad853f8..ebd10ad24 100644 --- a/src/main/io/ledstrip.h +++ b/src/main/io/ledstrip.h @@ -24,7 +24,7 @@ #define LED_CONFIGURABLE_COLOR_COUNT 16 #define LED_MODE_COUNT 6 #define LED_DIRECTION_COUNT 6 -#define LED_BASEFUNCTION_COUNT 7 +#define LED_BASEFUNCTION_COUNT 8 #define LED_OVERLAY_COUNT 6 #define LED_SPECIAL_COLOR_COUNT 11 @@ -124,6 +124,7 @@ typedef enum { LED_FUNCTION_RSSI, LED_FUNCTION_GPS, LED_FUNCTION_THRUST_RING, + LED_FUNCTION_CHANNEL, } ledBaseFunctionId_e; typedef enum {