Browse Source

Merge pull request #7618 from jeffhendrix/led_channel

Add ability to adjust LED Strip color with RC channel
master
Paweł Spychalski 3 years ago
committed by GitHub
parent
commit
acf5e54694
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      AUTHORS
  2. 4
      docs/LedStrip.md
  3. 17
      src/main/io/ledstrip.c
  4. 3
      src/main/io/ledstrip.h

1
AUTHORS

@ -39,6 +39,7 @@ Hyon Lim
Hubert Jozwiak
James Harrison
Jan Staal
Jeff Hendrix
Jeremy Waters
Joe Hermaszewski
Joe Poser

4
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:

17
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;
}

3
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 {

Loading…
Cancel
Save