Refactored WS2812FX variable names
This commit is contained in:
parent
793f919d59
commit
b224a67ea7
@ -3,8 +3,15 @@
|
|||||||
#define NpbWrapper_h
|
#define NpbWrapper_h
|
||||||
|
|
||||||
//PIN CONFIGURATION
|
//PIN CONFIGURATION
|
||||||
#define BTNPIN 0 //button pin. Needs to have pullup (gpio0 recommended)
|
#define LEDPIN 5 //strip pin. Any for ESP32, gpio2 or 3 is recommended for ESP8266 (gpio2/3 are labeled D4/RX on NodeMCU and Wemos)
|
||||||
//#define USE_APA102 // Uncomment for using APA102 LEDs.
|
//#define USE_APA102 // Uncomment for using APA102 LEDs.
|
||||||
|
#define BTNPIN 0 //button pin. Needs to have pullup (gpio0 recommended)
|
||||||
|
#define IR_PIN 4 //infrared pin (-1 to disable)
|
||||||
|
#define RLYPIN 12 //pin for relay, will be set HIGH if LEDs are on (-1 to disable). Also usable for standby leds, triggers,...
|
||||||
|
#define AUXPIN -1 //debug auxiliary output pin (-1 to disable)
|
||||||
|
|
||||||
|
#define RLYMDE 1 //mode for relay, 0: LOW if LEDs are on 1: HIGH if LEDs are on
|
||||||
|
|
||||||
#ifdef USE_APA102
|
#ifdef USE_APA102
|
||||||
#define CLKPIN 0
|
#define CLKPIN 0
|
||||||
#define DATAPIN 2
|
#define DATAPIN 2
|
||||||
@ -13,13 +20,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LEDPIN 2 //strip pin. Any for ESP32, gpio2 or 3 is recommended for ESP8266 (gpio2/3 are labeled D4/RX on NodeMCU and Wemos)
|
|
||||||
#define IR_PIN 4 //infrared pin (-1 to disable)
|
|
||||||
#define RLYPIN 12 //pin for relay, will be set HIGH if LEDs are on (-1 to disable). Also usable for standby leds, triggers,...
|
|
||||||
#define AUXPIN -1 //debug auxiliary output pin (-1 to disable)
|
|
||||||
|
|
||||||
#define RLYMDE 1 //mode for relay, 0: LOW if LEDs are on 1: HIGH if LEDs are on
|
|
||||||
|
|
||||||
|
|
||||||
//automatically uses the right driver method for each platform
|
//automatically uses the right driver method for each platform
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -42,12 +42,13 @@
|
|||||||
|
|
||||||
/* each segment uses 37 bytes of SRAM memory, so if you're application fails because of
|
/* each segment uses 37 bytes of SRAM memory, so if you're application fails because of
|
||||||
insufficient memory, decreasing MAX_NUM_SEGMENTS may help */
|
insufficient memory, decreasing MAX_NUM_SEGMENTS may help */
|
||||||
#define MAX_NUM_SEGMENTS 1
|
#define MAX_NUM_SEGMENTS 8
|
||||||
#define NUM_COLORS 3 /* number of colors per segment */
|
#define NUM_COLORS 3 /* number of colors per segment */
|
||||||
#define SEGMENT _segments[_segment_index]
|
#define SEGMENT _segments[_segment_index]
|
||||||
#define SEGMENT_RUNTIME _segment_runtimes[_segment_index]
|
#define SEGCOLOR(x) gamma32(_segments[_segment_index].colors[x])
|
||||||
#define SEGMENT_LENGTH (SEGMENT.stop - SEGMENT.start)
|
#define SEGENV _segment_runtimes[_segment_index]
|
||||||
#define SPEED_FORMULA_L 5 + (50*(255 - SEGMENT.speed))/SEGMENT_LENGTH
|
#define SEGLEN SEGMENT.length()
|
||||||
|
#define SPEED_FORMULA_L 5 + (50*(255 - SEGMENT.speed))/SEGLEN
|
||||||
#define RESET_RUNTIME memset(_segment_runtimes, 0, sizeof(_segment_runtimes))
|
#define RESET_RUNTIME memset(_segment_runtimes, 0, sizeof(_segment_runtimes))
|
||||||
|
|
||||||
// some common colors
|
// some common colors
|
||||||
@ -176,11 +177,6 @@ class WS2812FX {
|
|||||||
uint8_t mode;
|
uint8_t mode;
|
||||||
uint8_t options; //bit pattern: msb first: transitional tbd tbd tbd tbd paused reverse selected
|
uint8_t options; //bit pattern: msb first: transitional tbd tbd tbd tbd paused reverse selected
|
||||||
uint32_t colors[NUM_COLORS];
|
uint32_t colors[NUM_COLORS];
|
||||||
//member functions
|
|
||||||
uint32_t color(uint8_t n)
|
|
||||||
{
|
|
||||||
return colors[n];
|
|
||||||
}
|
|
||||||
void setOption(uint8_t n, bool val)
|
void setOption(uint8_t n, bool val)
|
||||||
{
|
{
|
||||||
if (val) {
|
if (val) {
|
||||||
@ -194,16 +190,20 @@ class WS2812FX {
|
|||||||
{
|
{
|
||||||
return ((options >> n) & 0x01);
|
return ((options >> n) & 0x01);
|
||||||
}
|
}
|
||||||
|
inline uint16_t length()
|
||||||
|
{
|
||||||
|
return stop - start;
|
||||||
|
}
|
||||||
} segment;
|
} segment;
|
||||||
|
|
||||||
// segment runtime parameters
|
// segment runtime parameters
|
||||||
typedef struct Segment_runtime { // 16 bytes
|
typedef struct Segment_runtime { // 16 bytes
|
||||||
unsigned long next_time;
|
unsigned long next_time;
|
||||||
uint32_t counter_mode_step;
|
uint32_t step;
|
||||||
uint32_t counter_mode_call;
|
uint32_t call;
|
||||||
uint16_t aux_param;
|
uint16_t aux0;
|
||||||
uint16_t aux_param2;
|
uint16_t aux1;
|
||||||
void reset(){next_time = 0; counter_mode_step = 0; counter_mode_call = 0; aux_param = 0; aux_param2 = 0;};
|
void reset(){next_time = 0; step = 0; call = 0; aux0 = 0; aux1 = 0;};
|
||||||
} segment_runtime;
|
} segment_runtime;
|
||||||
|
|
||||||
WS2812FX() {
|
WS2812FX() {
|
||||||
@ -296,11 +296,6 @@ class WS2812FX {
|
|||||||
_segments[0].speed = DEFAULT_SPEED;
|
_segments[0].speed = DEFAULT_SPEED;
|
||||||
currentPalette = CRGBPalette16(CRGB::Black);
|
currentPalette = CRGBPalette16(CRGB::Black);
|
||||||
targetPalette = CloudColors_p;
|
targetPalette = CloudColors_p;
|
||||||
_reverseMode = false;
|
|
||||||
_skipFirstMode = false;
|
|
||||||
colorOrder = 0;
|
|
||||||
paletteFade = 0;
|
|
||||||
paletteBlend = 0;
|
|
||||||
ablMilliampsMax = 850;
|
ablMilliampsMax = 850;
|
||||||
currentMilliamps = 0;
|
currentMilliamps = 0;
|
||||||
_locked = nullptr;
|
_locked = nullptr;
|
||||||
@ -310,7 +305,7 @@ class WS2812FX {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
init(bool supportWhite, uint16_t countPixels, bool skipFirst),
|
init(bool supportWhite, uint16_t countPixels, bool skipFirs),
|
||||||
service(void),
|
service(void),
|
||||||
blur(uint8_t),
|
blur(uint8_t),
|
||||||
fade_out(uint8_t r),
|
fade_out(uint8_t r),
|
||||||
@ -323,7 +318,6 @@ class WS2812FX {
|
|||||||
setColor(uint32_t c),
|
setColor(uint32_t c),
|
||||||
setSecondaryColor(uint32_t c),
|
setSecondaryColor(uint32_t c),
|
||||||
setBrightness(uint8_t b),
|
setBrightness(uint8_t b),
|
||||||
setReverseMode(bool b),
|
|
||||||
driverModeCronixie(bool b),
|
driverModeCronixie(bool b),
|
||||||
setCronixieDigits(byte* d),
|
setCronixieDigits(byte* d),
|
||||||
setCronixieBacklight(bool b),
|
setCronixieBacklight(bool b),
|
||||||
@ -343,12 +337,15 @@ class WS2812FX {
|
|||||||
show(void);
|
show(void);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
reverseMode = true,
|
||||||
|
gammaCorrectBri = false,
|
||||||
|
gammaCorrectCol = true,
|
||||||
setEffectConfig(uint8_t m, uint8_t s, uint8_t i, uint8_t p);
|
setEffectConfig(uint8_t m, uint8_t s, uint8_t i, uint8_t p);
|
||||||
|
|
||||||
uint8_t
|
uint8_t
|
||||||
paletteFade,
|
paletteFade = 0,
|
||||||
paletteBlend,
|
paletteBlend = 0,
|
||||||
colorOrder,
|
colorOrder = 0,
|
||||||
getBrightness(void),
|
getBrightness(void),
|
||||||
getMode(void),
|
getMode(void),
|
||||||
getSpeed(void),
|
getSpeed(void),
|
||||||
@ -356,12 +353,14 @@ class WS2812FX {
|
|||||||
getModeCount(void),
|
getModeCount(void),
|
||||||
getPaletteCount(void),
|
getPaletteCount(void),
|
||||||
getMaxSegments(void),
|
getMaxSegments(void),
|
||||||
|
gamma8(uint8_t),
|
||||||
get_random_wheel_index(uint8_t);
|
get_random_wheel_index(uint8_t);
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
color_wheel(uint8_t),
|
color_wheel(uint8_t),
|
||||||
color_from_palette(uint16_t, bool, bool, uint8_t, uint8_t pbri = 255),
|
color_from_palette(uint16_t, bool, bool, uint8_t, uint8_t pbri = 255),
|
||||||
color_blend(uint32_t,uint32_t,uint8_t),
|
color_blend(uint32_t,uint32_t,uint8_t),
|
||||||
|
gamma32(uint32_t),
|
||||||
getPixelColor(uint16_t),
|
getPixelColor(uint16_t),
|
||||||
getColor(void);
|
getColor(void);
|
||||||
|
|
||||||
@ -491,7 +490,6 @@ class WS2812FX {
|
|||||||
bool
|
bool
|
||||||
_modeUsesLock,
|
_modeUsesLock,
|
||||||
_rgbwMode,
|
_rgbwMode,
|
||||||
_reverseMode,
|
|
||||||
_cronixieMode,
|
_cronixieMode,
|
||||||
_cronixieBacklightEnabled,
|
_cronixieBacklightEnabled,
|
||||||
_skipFirstMode,
|
_skipFirstMode,
|
||||||
|
@ -61,13 +61,13 @@ void WS2812FX::service() {
|
|||||||
for(uint8_t i=0; i < _num_segments; i++)
|
for(uint8_t i=0; i < _num_segments; i++)
|
||||||
{
|
{
|
||||||
_segment_index = i;
|
_segment_index = i;
|
||||||
if(now > SEGMENT_RUNTIME.next_time || _triggered)
|
if(now > SEGENV.next_time || _triggered)
|
||||||
{
|
{
|
||||||
doShow = true;
|
doShow = true;
|
||||||
handle_palette();
|
handle_palette();
|
||||||
uint16_t delay = (this->*_mode[SEGMENT.mode])();
|
uint16_t delay = (this->*_mode[SEGMENT.mode])();
|
||||||
SEGMENT_RUNTIME.next_time = now + max(delay, MIN_SHOW_DELAY);
|
SEGENV.next_time = now + max(delay, MIN_SHOW_DELAY);
|
||||||
SEGMENT_RUNTIME.counter_mode_call++;
|
SEGENV.call++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(doShow) {
|
if(doShow) {
|
||||||
@ -97,7 +97,7 @@ void WS2812FX::setPixelColor(uint16_t n, uint32_t c) {
|
|||||||
void WS2812FX::setPixelColor(uint16_t i, byte r, byte g, byte b, byte w)
|
void WS2812FX::setPixelColor(uint16_t i, byte r, byte g, byte b, byte w)
|
||||||
{
|
{
|
||||||
if (_locked[i] && !_modeUsesLock) return;
|
if (_locked[i] && !_modeUsesLock) return;
|
||||||
if (_reverseMode) i = _length -1 -i;
|
if (reverseMode) i = _length -1 -i;
|
||||||
if (IS_REVERSE) i = SEGMENT.stop -1 -i - SEGMENT.start; //reverse just individual segment
|
if (IS_REVERSE) i = SEGMENT.stop -1 -i - SEGMENT.start; //reverse just individual segment
|
||||||
byte tmpg = g;
|
byte tmpg = g;
|
||||||
switch (colorOrder) //0 = Grb, default
|
switch (colorOrder) //0 = Grb, default
|
||||||
@ -153,11 +153,6 @@ void WS2812FX::setPixelColor(uint16_t i, byte r, byte g, byte b, byte w)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::setReverseMode(bool b)
|
|
||||||
{
|
|
||||||
_reverseMode = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WS2812FX::driverModeCronixie(bool b)
|
void WS2812FX::driverModeCronixie(bool b)
|
||||||
{
|
{
|
||||||
_cronixieMode = b;
|
_cronixieMode = b;
|
||||||
@ -316,8 +311,8 @@ void WS2812FX::setSecondaryColor(uint32_t c) {
|
|||||||
|
|
||||||
void WS2812FX::setBrightness(uint8_t b) {
|
void WS2812FX::setBrightness(uint8_t b) {
|
||||||
if (_brightness == b) return;
|
if (_brightness == b) return;
|
||||||
_brightness = b;
|
_brightness = gammaCorrectBri ? gamma8(b) : b;
|
||||||
if (SEGMENT_RUNTIME.next_time > millis() + 20) show(); //apply brightness change immeadiately if no refresh soon
|
if (SEGENV.next_time > millis() + 20) show(); //apply brightness change immediately if no refresh soon
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t WS2812FX::getMode(void) {
|
uint8_t WS2812FX::getMode(void) {
|
||||||
@ -346,7 +341,7 @@ uint32_t WS2812FX::getColor(void) {
|
|||||||
|
|
||||||
uint32_t WS2812FX::getPixelColor(uint16_t i)
|
uint32_t WS2812FX::getPixelColor(uint16_t i)
|
||||||
{
|
{
|
||||||
if (_reverseMode) i = _length- 1 -i;
|
if (reverseMode) i = _length- 1 -i;
|
||||||
if (IS_REVERSE) i = SEGMENT.stop -1 -i - SEGMENT.start; //reverse just individual segment
|
if (IS_REVERSE) i = SEGMENT.stop -1 -i - SEGMENT.start; //reverse just individual segment
|
||||||
if (_skipFirstMode) i += LED_SKIP_AMOUNT;
|
if (_skipFirstMode) i += LED_SKIP_AMOUNT;
|
||||||
if (_cronixieMode)
|
if (_cronixieMode)
|
||||||
@ -386,7 +381,7 @@ WS2812FX::Segment& WS2812FX::getSegment(uint8_t id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
WS2812FX::Segment_runtime WS2812FX::getSegmentRuntime(void) {
|
WS2812FX::Segment_runtime WS2812FX::getSegmentRuntime(void) {
|
||||||
return SEGMENT_RUNTIME;
|
return SEGENV;
|
||||||
}
|
}
|
||||||
|
|
||||||
WS2812FX::Segment* WS2812FX::getSegments(void) {
|
WS2812FX::Segment* WS2812FX::getSegments(void) {
|
||||||
@ -477,7 +472,7 @@ void WS2812FX::setTransitionMode(bool t)
|
|||||||
SEGMENT.setOption(7,t);
|
SEGMENT.setOption(7,t);
|
||||||
if (!t) return;
|
if (!t) return;
|
||||||
unsigned long waitMax = millis() + 20; //refresh after 20 ms if transition enabled
|
unsigned long waitMax = millis() + 20; //refresh after 20 ms if transition enabled
|
||||||
if (SEGMENT.mode == FX_MODE_STATIC && SEGMENT_RUNTIME.next_time > waitMax) SEGMENT_RUNTIME.next_time = waitMax;
|
if (SEGMENT.mode == FX_MODE_STATIC && SEGENV.next_time > waitMax) SEGENV.next_time = waitMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -521,7 +516,7 @@ void WS2812FX::fade_out(uint8_t rate) {
|
|||||||
rate = (255-rate) >> 1;
|
rate = (255-rate) >> 1;
|
||||||
float mappedRate = float(rate) +1.1;
|
float mappedRate = float(rate) +1.1;
|
||||||
|
|
||||||
uint32_t color = SEGMENT.colors[1]; // target color
|
uint32_t color = SEGCOLOR(1); // target color
|
||||||
int w2 = (color >> 24) & 0xff;
|
int w2 = (color >> 24) & 0xff;
|
||||||
int r2 = (color >> 16) & 0xff;
|
int r2 = (color >> 16) & 0xff;
|
||||||
int g2 = (color >> 8) & 0xff;
|
int g2 = (color >> 8) & 0xff;
|
||||||
@ -663,11 +658,11 @@ void WS2812FX::handle_palette(void)
|
|||||||
_lastPaletteChange = millis();
|
_lastPaletteChange = millis();
|
||||||
} break;}
|
} break;}
|
||||||
case 2: {//primary color only
|
case 2: {//primary color only
|
||||||
CRGB prim = fastled_from_col(SEGMENT.colors[0]);
|
CRGB prim = fastled_from_col(SEGCOLOR(0));
|
||||||
targetPalette = CRGBPalette16(prim); break;}
|
targetPalette = CRGBPalette16(prim); break;}
|
||||||
case 3: {//based on primary
|
case 3: {//based on primary
|
||||||
//considering performance implications
|
//considering performance implications
|
||||||
CRGB prim = fastled_from_col(SEGMENT.colors[0]);
|
CRGB prim = fastled_from_col(SEGCOLOR(0));
|
||||||
CHSV prim_hsv = rgb2hsv_approximate(prim);
|
CHSV prim_hsv = rgb2hsv_approximate(prim);
|
||||||
targetPalette = CRGBPalette16(
|
targetPalette = CRGBPalette16(
|
||||||
CHSV(prim_hsv.h, prim_hsv.s, prim_hsv.v), //color itself
|
CHSV(prim_hsv.h, prim_hsv.s, prim_hsv.v), //color itself
|
||||||
@ -676,12 +671,12 @@ void WS2812FX::handle_palette(void)
|
|||||||
CHSV(prim_hsv.h, prim_hsv.s, prim_hsv.v)); //color itself
|
CHSV(prim_hsv.h, prim_hsv.s, prim_hsv.v)); //color itself
|
||||||
break;}
|
break;}
|
||||||
case 4: {//primary + secondary
|
case 4: {//primary + secondary
|
||||||
CRGB prim = fastled_from_col(SEGMENT.colors[0]);
|
CRGB prim = fastled_from_col(SEGCOLOR(0));
|
||||||
CRGB sec = fastled_from_col(SEGMENT.colors[1]);
|
CRGB sec = fastled_from_col(SEGCOLOR(1));
|
||||||
targetPalette = CRGBPalette16(sec,prim); break;}
|
targetPalette = CRGBPalette16(sec,prim); break;}
|
||||||
case 5: {//based on primary + secondary
|
case 5: {//based on primary + secondary
|
||||||
CRGB prim = fastled_from_col(SEGMENT.colors[0]);
|
CRGB prim = fastled_from_col(SEGCOLOR(0));
|
||||||
CRGB sec = fastled_from_col(SEGMENT.colors[1]);
|
CRGB sec = fastled_from_col(SEGCOLOR(1));
|
||||||
targetPalette = CRGBPalette16(sec,prim,CRGB::White); break;}
|
targetPalette = CRGBPalette16(sec,prim,CRGB::White); break;}
|
||||||
case 6: //Party colors
|
case 6: //Party colors
|
||||||
targetPalette = PartyColors_p; break;
|
targetPalette = PartyColors_p; break;
|
||||||
@ -720,3 +715,41 @@ uint32_t WS2812FX::color_from_palette(uint16_t i, bool mapping, bool wrap, uint8
|
|||||||
fastled_col = ColorFromPalette( currentPalette, paletteIndex, pbri, (paletteBlend == 3)? NOBLEND:LINEARBLEND);
|
fastled_col = ColorFromPalette( currentPalette, paletteIndex, pbri, (paletteBlend == 3)? NOBLEND:LINEARBLEND);
|
||||||
return fastled_col.r*65536 + fastled_col.g*256 + fastled_col.b;
|
return fastled_col.r*65536 + fastled_col.g*256 + fastled_col.b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//gamma 2.4 lookup table used for color correction
|
||||||
|
const byte gammaT[] = {
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
|
||||||
|
2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5,
|
||||||
|
5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10,
|
||||||
|
10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16,
|
||||||
|
17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25,
|
||||||
|
25, 26, 27, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36,
|
||||||
|
37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50,
|
||||||
|
51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68,
|
||||||
|
69, 70, 72, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89,
|
||||||
|
90, 92, 93, 95, 96, 98, 99,101,102,104,105,107,109,110,112,114,
|
||||||
|
115,117,119,120,122,124,126,127,129,131,133,135,137,138,140,142,
|
||||||
|
144,146,148,150,152,154,156,158,160,162,164,167,169,171,173,175,
|
||||||
|
177,180,182,184,186,189,191,193,196,198,200,203,205,208,210,213,
|
||||||
|
215,218,220,223,225,228,231,233,236,239,241,244,247,249,252,255 };
|
||||||
|
|
||||||
|
uint8_t WS2812FX::gamma8(uint8_t b)
|
||||||
|
{
|
||||||
|
return gammaT[b];
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t WS2812FX::gamma32(uint32_t color)
|
||||||
|
{
|
||||||
|
if (!gammaCorrectCol) return color;
|
||||||
|
uint8_t w = (color >> 24) & 0xFF;
|
||||||
|
uint8_t r = (color >> 16) & 0xFF;
|
||||||
|
uint8_t g = (color >> 8) & 0xFF;
|
||||||
|
uint8_t b = color & 0xFF;
|
||||||
|
w = gammaT[w];
|
||||||
|
r = gammaT[r];
|
||||||
|
g = gammaT[g];
|
||||||
|
b = gammaT[b];
|
||||||
|
return ((w << 24) | (r << 16) | (g << 8) | (b));
|
||||||
|
}
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
//#define WLED_ENABLE_FS_EDITOR //enable /edit page for editing SPIFFS content. Will also be disabled with OTA lock
|
//#define WLED_ENABLE_FS_EDITOR //enable /edit page for editing SPIFFS content. Will also be disabled with OTA lock
|
||||||
|
|
||||||
//to toggle usb serial debug (un)comment the following line
|
//to toggle usb serial debug (un)comment the following line
|
||||||
#define WLED_DEBUG
|
//#define WLED_DEBUG
|
||||||
|
|
||||||
|
|
||||||
//library inclusions
|
//library inclusions
|
||||||
@ -98,7 +98,7 @@
|
|||||||
|
|
||||||
|
|
||||||
//version code in format yymmddb (b = daily build)
|
//version code in format yymmddb (b = daily build)
|
||||||
#define VERSION 1905091
|
#define VERSION 1905222
|
||||||
char versionString[] = "0.8.4";
|
char versionString[] = "0.8.4";
|
||||||
|
|
||||||
|
|
||||||
@ -144,17 +144,17 @@ byte effectSpeedDefault = 75;
|
|||||||
byte effectIntensityDefault = 128; //intensity is supported on some effects as an additional parameter (e.g. for blink you can change the duty cycle)
|
byte effectIntensityDefault = 128; //intensity is supported on some effects as an additional parameter (e.g. for blink you can change the duty cycle)
|
||||||
byte effectPaletteDefault = 0; //palette is supported on the FastLED effects, otherwise it has no effect
|
byte effectPaletteDefault = 0; //palette is supported on the FastLED effects, otherwise it has no effect
|
||||||
|
|
||||||
bool useGammaCorrectionBri = false; //gamma correct brightness (not recommended)
|
//bool strip.gammaCorrectBri = false; //gamma correct brightness (not recommended) --> edit in WS2812FX.h
|
||||||
bool useGammaCorrectionRGB = true; //gamma correct colors (strongly recommended)
|
//bool strip.gammaCorrectCol = true; //gamma correct colors (strongly recommended)
|
||||||
|
|
||||||
byte nightlightTargetBri = 0; //brightness after nightlight is over
|
byte nightlightTargetBri = 0; //brightness after nightlight is over
|
||||||
byte nightlightDelayMins = 60;
|
byte nightlightDelayMins = 60;
|
||||||
bool nightlightFade = true; //if enabled, light will gradually dim towards the target bri. Otherwise, it will instantly set after delay over
|
bool nightlightFade = true; //if enabled, light will gradually dim towards the target bri. Otherwise, it will instantly set after delay over
|
||||||
bool fadeTransition = true; //enable crossfading color transition
|
bool fadeTransition = true; //enable crossfading color transition
|
||||||
bool enableSecTransition = true; //also enable transition for secondary color
|
bool enableSecTransition = true; //also enable transition for secondary color
|
||||||
uint16_t transitionDelay = 750; //default crossfade duration in ms
|
uint16_t transitionDelay = 750; //default crossfade duration in ms
|
||||||
|
|
||||||
bool reverseMode = false; //flip entire LED strip (reverses all effect directions)
|
//bool strip.reverseMode = false; //flip entire LED strip (reverses all effect directions) --> edit in WS2812FX.h
|
||||||
bool skipFirstLed = false; //ignore first LED in strip (useful if you need the LED as signal repeater)
|
bool skipFirstLed = false; //ignore first LED in strip (useful if you need the LED as signal repeater)
|
||||||
byte briMultiplier = 100; //% of brightness to set (to limit power, if you set it to 50 and set bri to 255, actual brightness will be 127)
|
byte briMultiplier = 100; //% of brightness to set (to limit power, if you set it to 50 and set bri to 255, actual brightness will be 127)
|
||||||
|
|
||||||
@ -450,25 +450,6 @@ WS2812FX strip = WS2812FX();
|
|||||||
#include "SPIFFSEditor.h"
|
#include "SPIFFSEditor.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//gamma 2.4 lookup table used for color correction
|
|
||||||
const byte gamma8[] = {
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
|
|
||||||
2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5,
|
|
||||||
5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10,
|
|
||||||
10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16,
|
|
||||||
17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25,
|
|
||||||
25, 26, 27, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36,
|
|
||||||
37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50,
|
|
||||||
51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68,
|
|
||||||
69, 70, 72, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89,
|
|
||||||
90, 92, 93, 95, 96, 98, 99,101,102,104,105,107,109,110,112,114,
|
|
||||||
115,117,119,120,122,124,126,127,129,131,133,135,137,138,140,142,
|
|
||||||
144,146,148,150,152,154,156,158,160,162,164,167,169,171,173,175,
|
|
||||||
177,180,182,184,186,189,191,193,196,198,200,203,205,208,210,213,
|
|
||||||
215,218,220,223,225,228,231,233,236,239,241,244,247,249,252,255 };
|
|
||||||
|
|
||||||
//function prototypes
|
//function prototypes
|
||||||
void serveMessage(AsyncWebServerRequest*,uint16_t,String,String,byte);
|
void serveMessage(AsyncWebServerRequest*,uint16_t,String,String,byte);
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ void saveSettingsToEEPROM()
|
|||||||
|
|
||||||
EEPROM.write(250, receiveNotificationBrightness);
|
EEPROM.write(250, receiveNotificationBrightness);
|
||||||
EEPROM.write(251, fadeTransition);
|
EEPROM.write(251, fadeTransition);
|
||||||
EEPROM.write(252, reverseMode);
|
EEPROM.write(252, strip.reverseMode);
|
||||||
EEPROM.write(253, transitionDelayDefault & 0xFF);
|
EEPROM.write(253, transitionDelayDefault & 0xFF);
|
||||||
EEPROM.write(254, (transitionDelayDefault >> 8) & 0xFF);
|
EEPROM.write(254, (transitionDelayDefault >> 8) & 0xFF);
|
||||||
EEPROM.write(255, briMultiplier);
|
EEPROM.write(255, briMultiplier);
|
||||||
@ -117,8 +117,8 @@ void saveSettingsToEEPROM()
|
|||||||
EEPROM.write(327, ntpEnabled);
|
EEPROM.write(327, ntpEnabled);
|
||||||
EEPROM.write(328, currentTimezone);
|
EEPROM.write(328, currentTimezone);
|
||||||
EEPROM.write(329, useAMPM);
|
EEPROM.write(329, useAMPM);
|
||||||
EEPROM.write(330, useGammaCorrectionBri);
|
EEPROM.write(330, strip.gammaCorrectBri);
|
||||||
EEPROM.write(331, useGammaCorrectionRGB);
|
EEPROM.write(331, strip.gammaCorrectCol);
|
||||||
EEPROM.write(332, overlayDefault);
|
EEPROM.write(332, overlayDefault);
|
||||||
|
|
||||||
EEPROM.write(333, alexaEnabled);
|
EEPROM.write(333, alexaEnabled);
|
||||||
@ -321,7 +321,7 @@ void loadSettingsFromEEPROM(bool first)
|
|||||||
}
|
}
|
||||||
receiveNotificationBrightness = EEPROM.read(250);
|
receiveNotificationBrightness = EEPROM.read(250);
|
||||||
fadeTransition = EEPROM.read(251);
|
fadeTransition = EEPROM.read(251);
|
||||||
reverseMode = EEPROM.read(252);
|
strip.reverseMode = EEPROM.read(252);
|
||||||
transitionDelayDefault = EEPROM.read(253) + ((EEPROM.read(254) << 8) & 0xFF00);
|
transitionDelayDefault = EEPROM.read(253) + ((EEPROM.read(254) << 8) & 0xFF00);
|
||||||
transitionDelay = transitionDelayDefault;
|
transitionDelay = transitionDelayDefault;
|
||||||
briMultiplier = EEPROM.read(255);
|
briMultiplier = EEPROM.read(255);
|
||||||
@ -339,8 +339,8 @@ void loadSettingsFromEEPROM(bool first)
|
|||||||
ntpEnabled = EEPROM.read(327);
|
ntpEnabled = EEPROM.read(327);
|
||||||
currentTimezone = EEPROM.read(328);
|
currentTimezone = EEPROM.read(328);
|
||||||
useAMPM = EEPROM.read(329);
|
useAMPM = EEPROM.read(329);
|
||||||
useGammaCorrectionBri = EEPROM.read(330);
|
strip.gammaCorrectBri = EEPROM.read(330);
|
||||||
useGammaCorrectionRGB = EEPROM.read(331);
|
strip.gammaCorrectCol = EEPROM.read(331);
|
||||||
overlayDefault = EEPROM.read(332);
|
overlayDefault = EEPROM.read(332);
|
||||||
if (lastEEPROMversion < 8 && overlayDefault > 0) overlayDefault--; //overlay mode 1 (solid) was removed
|
if (lastEEPROMversion < 8 && overlayDefault > 0) overlayDefault--; //overlay mode 1 (solid) was removed
|
||||||
|
|
||||||
|
@ -253,8 +253,8 @@ void getSettingsJS(byte subPage, char* dest)
|
|||||||
oappend(";");
|
oappend(";");
|
||||||
sappend('v',"SX",effectSpeedDefault);
|
sappend('v',"SX",effectSpeedDefault);
|
||||||
sappend('v',"IX",effectIntensityDefault);
|
sappend('v',"IX",effectIntensityDefault);
|
||||||
sappend('c',"GB",useGammaCorrectionBri);
|
sappend('c',"GB",strip.gammaCorrectBri);
|
||||||
sappend('c',"GC",useGammaCorrectionRGB);
|
sappend('c',"GC",strip.gammaCorrectCol);
|
||||||
sappend('c',"TF",fadeTransition);
|
sappend('c',"TF",fadeTransition);
|
||||||
sappend('v',"TD",transitionDelay);
|
sappend('v',"TD",transitionDelay);
|
||||||
sappend('c',"PF",strip.paletteFade);
|
sappend('c',"PF",strip.paletteFade);
|
||||||
@ -264,7 +264,7 @@ void getSettingsJS(byte subPage, char* dest)
|
|||||||
sappend('v',"TL",nightlightDelayMinsDefault);
|
sappend('v',"TL",nightlightDelayMinsDefault);
|
||||||
sappend('c',"TW",nightlightFade);
|
sappend('c',"TW",nightlightFade);
|
||||||
sappend('i',"PB",strip.paletteBlend);
|
sappend('i',"PB",strip.paletteBlend);
|
||||||
sappend('c',"RV",reverseMode);
|
sappend('c',"RV",strip.reverseMode);
|
||||||
sappend('c',"SL",skipFirstLed);
|
sappend('c',"SL",skipFirstLed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,8 +98,8 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
turnOnAtBoot = request->hasArg("BO");
|
turnOnAtBoot = request->hasArg("BO");
|
||||||
t = request->arg("BP").toInt();
|
t = request->arg("BP").toInt();
|
||||||
if (t <= 25) bootPreset = t;
|
if (t <= 25) bootPreset = t;
|
||||||
useGammaCorrectionBri = request->hasArg("GB");
|
strip.gammaCorrectBri = request->hasArg("GB");
|
||||||
useGammaCorrectionRGB = request->hasArg("GC");
|
strip.gammaCorrectCol = request->hasArg("GC");
|
||||||
|
|
||||||
fadeTransition = request->hasArg("TF");
|
fadeTransition = request->hasArg("TF");
|
||||||
t = request->arg("TD").toInt();
|
t = request->arg("TD").toInt();
|
||||||
@ -115,8 +115,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
|
|
||||||
t = request->arg("PB").toInt();
|
t = request->arg("PB").toInt();
|
||||||
if (t >= 0 && t < 4) strip.paletteBlend = t;
|
if (t >= 0 && t < 4) strip.paletteBlend = t;
|
||||||
reverseMode = request->hasArg("RV");
|
strip.reverseMode = request->hasArg("RV");
|
||||||
strip.setReverseMode(reverseMode);
|
|
||||||
skipFirstLed = request->hasArg("SL");
|
skipFirstLed = request->hasArg("SL");
|
||||||
t = request->arg("BF").toInt();
|
t = request->arg("BF").toInt();
|
||||||
if (t > 0) briMultiplier = t;
|
if (t > 0) briMultiplier = t;
|
||||||
|
@ -143,7 +143,6 @@ void wledInit()
|
|||||||
void beginStrip()
|
void beginStrip()
|
||||||
{
|
{
|
||||||
// Initialize NeoPixel Strip and button
|
// Initialize NeoPixel Strip and button
|
||||||
strip.setReverseMode(reverseMode);
|
|
||||||
strip.setColor(0);
|
strip.setColor(0);
|
||||||
strip.setBrightness(255);
|
strip.setBrightness(255);
|
||||||
|
|
||||||
|
@ -258,9 +258,9 @@ void setRealtimePixel(uint16_t i, byte r, byte g, byte b, byte w)
|
|||||||
uint16_t pix = i + arlsOffset;
|
uint16_t pix = i + arlsOffset;
|
||||||
if (pix < ledCount)
|
if (pix < ledCount)
|
||||||
{
|
{
|
||||||
if (!arlsDisableGammaCorrection && useGammaCorrectionRGB)
|
if (!arlsDisableGammaCorrection && strip.gammaCorrectCol)
|
||||||
{
|
{
|
||||||
strip.setPixelColor(pix, gamma8[r], gamma8[g], gamma8[b], gamma8[w]);
|
strip.setPixelColor(pix, strip.gamma8(r), strip.gamma8(g), strip.gamma8(b), strip.gamma8(w));
|
||||||
} else {
|
} else {
|
||||||
strip.setPixelColor(pix, r, g, b, w);
|
strip.setPixelColor(pix, r, g, b, w);
|
||||||
}
|
}
|
||||||
|
@ -21,12 +21,7 @@ void setAllLeds() {
|
|||||||
double d = briT*briMultiplier;
|
double d = briT*briMultiplier;
|
||||||
int val = d/100;
|
int val = d/100;
|
||||||
if (val > 255) val = 255;
|
if (val > 255) val = 255;
|
||||||
if (useGammaCorrectionBri)
|
strip.setBrightness(val);
|
||||||
{
|
|
||||||
strip.setBrightness(gamma8[val]);
|
|
||||||
} else {
|
|
||||||
strip.setBrightness(val);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!enableSecTransition)
|
if (!enableSecTransition)
|
||||||
{
|
{
|
||||||
@ -40,14 +35,8 @@ void setAllLeds() {
|
|||||||
colorRGBtoRGBW(colT);
|
colorRGBtoRGBW(colT);
|
||||||
colorRGBtoRGBW(colSecT);
|
colorRGBtoRGBW(colSecT);
|
||||||
}
|
}
|
||||||
if (useGammaCorrectionRGB)
|
strip.setColor(colT[0], colT[1], colT[2], colT[3]);
|
||||||
{
|
strip.setSecondaryColor(colSecT[0], colSecT[1], colSecT[2], colSecT[3]);
|
||||||
strip.setColor(gamma8[colT[0]], gamma8[colT[1]], gamma8[colT[2]], gamma8[colT[3]]);
|
|
||||||
strip.setSecondaryColor(gamma8[colSecT[0]], gamma8[colSecT[1]], gamma8[colSecT[2]], gamma8[colSecT[3]]);
|
|
||||||
} else {
|
|
||||||
strip.setColor(colT[0], colT[1], colT[2], colT[3]);
|
|
||||||
strip.setSecondaryColor(colSecT[0], colSecT[1], colSecT[2], colSecT[3]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,13 +125,7 @@ void serializeSegment(JsonObject& root)
|
|||||||
|
|
||||||
JsonArray& colarr = root.createNestedArray("col");
|
JsonArray& colarr = root.createNestedArray("col");
|
||||||
|
|
||||||
//temporary
|
for (uint8_t i = 0; i < 3; i++)
|
||||||
JsonArray& c0 = colarr.createNestedArray();
|
|
||||||
c0.add(col[0]); c0.add(col[1]); c0.add(col[2]); if (useRGBW) c0.add(col[3]);
|
|
||||||
JsonArray& c1 = colarr.createNestedArray();
|
|
||||||
c1.add(colSec[0]); c1.add(colSec[1]); c1.add(colSec[2]); if (useRGBW) c1.add(colSec[3]);
|
|
||||||
//set i back to 0 once temporary is removed!
|
|
||||||
for (uint8_t i = 2; i < 3; i++)
|
|
||||||
{
|
{
|
||||||
JsonArray& colX = colarr.createNestedArray();
|
JsonArray& colX = colarr.createNestedArray();
|
||||||
colX.add((seg.colors[i] >> 16) & 0xFF);
|
colX.add((seg.colors[i] >> 16) & 0xFF);
|
||||||
@ -211,7 +205,7 @@ void serializeInfo(JsonObject& root)
|
|||||||
|
|
||||||
root["brand"] = "WLED";
|
root["brand"] = "WLED";
|
||||||
root["product"] = "DIY light";
|
root["product"] = "DIY light";
|
||||||
root["btype"] = "src";
|
root["btype"] = "dev";
|
||||||
root["mac"] = escapedMac;
|
root["mac"] = escapedMac;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user