diff --git a/AUTHORS b/AUTHORS index f1b20656d..2a1f2744c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -39,6 +39,7 @@ Hyon Lim Hubert Jozwiak James Harrison Jan Staal +Jeff Hendrix Jeremy Waters Joe Hermaszewski Joe Poser 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..5f40694d5 100644 --- a/src/main/io/ledstrip.c +++ b/src/main/io/ledstrip.c @@ -73,7 +73,7 @@ #include "telemetry/telemetry.h" -PG_REGISTER_WITH_RESET_FN(ledStripConfig_t, ledStripConfig, PG_LED_STRIP_CONFIG, 0); +PG_REGISTER_WITH_RESET_FN(ledStripConfig_t, ledStripConfig, PG_LED_STRIP_CONFIG, 1); static bool ledStripInitialised = false; static bool ledStripEnabled = true; @@ -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 {