Merge pull request #9 from Aircoookie/master

Sync with orig
This commit is contained in:
srg74 2020-01-14 16:23:08 -05:00 committed by GitHub
commit bed52d0a4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 291 additions and 275 deletions

View File

@ -45,7 +45,7 @@ lib_deps_external =
#Blynk@0.5.4(changed)
#E131@1.0.0(changed)
FastLED@3.3.2
NeoPixelBus@2.5.1
NeoPixelBus@2.5.6
ESPAsyncTCP@1.2.0
ESPAsyncUDP@697c75a025
AsyncTCP@1.0.3

View File

@ -69,7 +69,7 @@ uint16_t WS2812FX::blink(uint32_t color1, uint32_t color2, bool strobe, bool do_
uint32_t color = ((SEGENV.aux0 & 1) == 0) ? color1 : color2;
if (color == color1 && do_palette)
{
for(uint16_t i=SEGMENT.start; i < SEGMENT.stop; i++) {
for(uint16_t i = 0; i < SEGLEN; i++) {
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
}
} else fill(color);
@ -149,18 +149,18 @@ uint16_t WS2812FX::color_wipe(bool rev, bool useRandomColors) {
if (rem > 255) rem = 255;
uint32_t col1 = useRandomColors? color_wheel(SEGENV.aux1) : SEGCOLOR(1);
for (uint16_t i = SEGMENT.start; i < SEGMENT.stop; i++)
for (uint16_t i = 0; i < SEGLEN; i++)
{
uint16_t index = (rev && back)? SEGMENT.stop -1 -i +SEGMENT.start : i;
uint16_t index = (rev && back)? SEGLEN -1 -i : i;
uint32_t col0 = useRandomColors? color_wheel(SEGENV.aux0) : color_from_palette(index, true, PALETTE_SOLID_WRAP, 0);
if (i - SEGMENT.start < ledIndex)
if (i < ledIndex)
{
setPixelColor(index, back? col1 : col0);
} else
{
setPixelColor(index, back? col0 : col1);
if (i - SEGMENT.start == ledIndex) setPixelColor(index, color_blend(back? col0 : col1, back? col1 : col0, rem));
if (i == ledIndex) setPixelColor(index, color_blend(back? col0 : col1, back? col1 : col0, rem));
}
}
return FRAMETIME;
@ -253,7 +253,7 @@ uint16_t WS2812FX::mode_dynamic(void) {
}
for (uint16_t i = 0; i < SEGLEN; i++) {
setPixelColor(SEGMENT.start + i, color_wheel(SEGENV.data[i]));
setPixelColor(i, color_wheel(SEGENV.data[i]));
}
return FRAMETIME;
}
@ -272,7 +272,7 @@ uint16_t WS2812FX::mode_breath(void) {
}
uint8_t lum = 30 + var;
for(uint16_t i=SEGMENT.start; i < SEGMENT.stop; i++) {
for(uint16_t i = 0; i < SEGLEN; i++) {
setPixelColor(i, color_blend(SEGCOLOR(1), color_from_palette(i, true, PALETTE_SOLID_WRAP, 0), lum));
}
@ -287,7 +287,7 @@ uint16_t WS2812FX::mode_fade(void) {
uint16_t counter = (now * ((SEGMENT.speed >> 3) +10));
uint8_t lum = triwave16(counter) >> 8;
for(uint16_t i=SEGMENT.start; i < SEGMENT.stop; i++) {
for(uint16_t i = 0; i < SEGLEN; i++) {
setPixelColor(i, color_blend(SEGCOLOR(1), color_from_palette(i, true, PALETTE_SOLID_WRAP, 0), lum));
}
@ -303,7 +303,7 @@ uint16_t WS2812FX::scan(bool dual)
uint32_t cycleTime = 750 + (255 - SEGMENT.speed)*150;
uint32_t perc = now % cycleTime;
uint16_t prog = (perc * 65535) / cycleTime;
uint16_t size = 1 + ((SEGMENT.intensity * SEGLEN) >>9);
uint16_t size = 1 + ((SEGMENT.intensity * SEGLEN) >> 9);
uint16_t ledIndex = (prog * ((SEGLEN *2) - size *2)) >> 16;
fill(SEGCOLOR(1));
@ -313,14 +313,13 @@ uint16_t WS2812FX::scan(bool dual)
if (dual) {
for (uint16_t j = led_offset; j < led_offset + size; j++) {
uint16_t i2 = SEGMENT.stop -1 -j;
uint16_t i2 = SEGLEN -1 -j;
setPixelColor(i2, color_from_palette(i2, true, PALETTE_SOLID_WRAP, (SEGCOLOR(2))? 2:0));
}
}
for (uint16_t j = led_offset; j < led_offset + size; j++) {
uint16_t i = SEGMENT.start + j;
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
setPixelColor(j, color_from_palette(j, true, PALETTE_SOLID_WRAP, 0));
}
return FRAMETIME;
@ -367,10 +366,10 @@ uint16_t WS2812FX::mode_rainbow_cycle(void) {
uint16_t counter = (now * ((SEGMENT.speed >> 3) +2)) & 0xFFFF;
counter = counter >> 8;
for(uint16_t i=0; i < SEGLEN; i++) {
for(uint16_t i = 0; i < SEGLEN; i++) {
//intensity/29 = 0 (1/16) 1 (1/8) 2 (1/4) 3 (1/2) 4 (1) 5 (2) 6 (4) 7 (8) 8 (16)
uint8_t index = (i * (16 << (SEGMENT.intensity /29)) / SEGLEN) + counter;
setPixelColor(SEGMENT.start + i, color_wheel(index));
setPixelColor(i, color_wheel(index));
}
return FRAMETIME;
@ -390,16 +389,16 @@ uint16_t WS2812FX::theater_chase(uint32_t color1, uint32_t color2, bool dopalett
SEGENV.step = it;
}
for(uint16_t i=0; i < SEGLEN; i++) {
for(uint16_t i = 0; i < SEGLEN; i++) {
if((i % gap) == SEGENV.aux0) {
if (dopalette)
{
setPixelColor(SEGMENT.start + i, color_from_palette(SEGMENT.start + i, true, PALETTE_SOLID_WRAP, 0));
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
} else {
setPixelColor(SEGMENT.start + i, color1);
setPixelColor(i, color1);
}
} else {
setPixelColor(SEGMENT.start + i, color2);
setPixelColor(i, color2);
}
}
return FRAMETIME;
@ -431,7 +430,7 @@ uint16_t WS2812FX::running_base(bool saw) {
uint8_t x_scale = SEGMENT.intensity >> 2;
uint32_t counter = (now * SEGMENT.speed) >> 9;
for(uint16_t i=0; i < SEGLEN; i++) {
for(uint16_t i = 0; i < SEGLEN; i++) {
uint8_t s = 0;
uint8_t a = i*x_scale - counter;
if (saw) {
@ -443,7 +442,7 @@ uint16_t WS2812FX::running_base(bool saw) {
}
}
s = sin8(a);
setPixelColor(SEGMENT.start + i, color_blend(color_from_palette(SEGMENT.start + i, true, PALETTE_SOLID_WRAP, 0), SEGCOLOR(1), s));
setPixelColor(i, color_blend(color_from_palette(i, true, PALETTE_SOLID_WRAP, 0), SEGCOLOR(1), s));
}
return FRAMETIME;
}
@ -492,8 +491,7 @@ uint16_t WS2812FX::mode_twinkle(void) {
{
PRNG16 = (uint16_t)(PRNG16 * 2053) + 13849; // next 'random' number
uint32_t p = (uint32_t)SEGLEN * (uint32_t)PRNG16;
uint16_t mapped = p >> 16;
uint16_t j = SEGMENT.start + mapped;
uint16_t j = p >> 16;
setPixelColor(j, color_from_palette(j, true, PALETTE_SOLID_WRAP, 0));
}
@ -512,7 +510,7 @@ uint16_t WS2812FX::dissolve(uint32_t color) {
if (random8() <= SEGMENT.intensity) {
for (uint8_t times = 0; times < 10; times++) //attempt to spawn a new pixel 5 times
{
uint16_t i = SEGMENT.start + random16(SEGLEN);
uint16_t i = random16(SEGLEN);
if (SEGENV.aux0) { //dissolve to primary/palette
if (getPixelColor(i) == SEGCOLOR(1) || wa) {
if (color == SEGCOLOR(0))
@ -559,7 +557,7 @@ uint16_t WS2812FX::mode_dissolve_random(void) {
* Inspired by www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/
*/
uint16_t WS2812FX::mode_sparkle(void) {
for(uint16_t i=SEGMENT.start; i < SEGMENT.stop; i++) {
for(uint16_t i = 0; i < SEGLEN; i++) {
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 1));
}
uint32_t cycleTime = 10 + (255 - SEGMENT.speed)*2;
@ -570,7 +568,7 @@ uint16_t WS2812FX::mode_sparkle(void) {
SEGENV.step = it;
}
setPixelColor(SEGMENT.start + SEGENV.aux0, SEGCOLOR(0));
setPixelColor(SEGENV.aux0, SEGCOLOR(0));
return FRAMETIME;
}
@ -580,13 +578,13 @@ uint16_t WS2812FX::mode_sparkle(void) {
* Inspired by www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/
*/
uint16_t WS2812FX::mode_flash_sparkle(void) {
for(uint16_t i=SEGMENT.start; i < SEGMENT.stop; i++) {
for(uint16_t i = 0; i < SEGLEN; i++) {
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
}
if(random8(5) == 0) {
SEGENV.aux0 = random16(SEGLEN); // aux0 stores the random led index
setPixelColor(SEGMENT.start + SEGENV.aux0, SEGCOLOR(1));
setPixelColor(SEGENV.aux0, SEGCOLOR(1));
return 20;
}
return 20 + (uint16_t)(255-SEGMENT.speed);
@ -598,13 +596,13 @@ uint16_t WS2812FX::mode_flash_sparkle(void) {
* Inspired by www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/
*/
uint16_t WS2812FX::mode_hyper_sparkle(void) {
for(uint16_t i=SEGMENT.start; i < SEGMENT.stop; i++) {
for(uint16_t i = 0; i < SEGLEN; i++) {
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
}
if(random8(5) < 2) {
for(uint16_t i=0; i < max(1, SEGLEN/3); i++) {
setPixelColor(SEGMENT.start + random16(SEGLEN), SEGCOLOR(1));
for(uint16_t i = 0; i < max(1, SEGLEN/3); i++) {
setPixelColor(random16(SEGLEN), SEGCOLOR(1));
}
return 20;
}
@ -616,7 +614,7 @@ uint16_t WS2812FX::mode_hyper_sparkle(void) {
* Strobe effect with different strobe count and pause, controlled by speed.
*/
uint16_t WS2812FX::mode_multi_strobe(void) {
for(uint16_t i=SEGMENT.start; i < SEGMENT.stop; i++) {
for(uint16_t i = 0; i < SEGLEN; i++) {
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 1));
}
//blink(SEGCOLOR(0), SEGCOLOR(1), true, true);
@ -625,7 +623,7 @@ uint16_t WS2812FX::mode_multi_strobe(void) {
uint16_t count = 2 * ((SEGMENT.speed / 10) + 1);
if(SEGENV.step < count) {
if((SEGENV.step & 1) == 0) {
for(uint16_t i=SEGMENT.start; i < SEGMENT.stop; i++) {
for(uint16_t i = 0; i < SEGLEN; i++) {
setPixelColor(i, SEGCOLOR(0));
}
delay = 20;
@ -641,12 +639,8 @@ uint16_t WS2812FX::mode_multi_strobe(void) {
* Android loading circle
*/
uint16_t WS2812FX::mode_android(void) {
if (SEGENV.call == 0)
{
SEGENV.step = SEGMENT.start;
}
for(uint16_t i=SEGMENT.start; i < SEGMENT.stop; i++) {
for(uint16_t i = 0; i < SEGLEN; i++) {
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 1));
}
@ -670,19 +664,19 @@ uint16_t WS2812FX::mode_android(void) {
if (SEGENV.call %3 != 1) SEGENV.aux1--;
}
if (a >= SEGMENT.stop) a = SEGMENT.start;
if (a >= SEGLEN) a = 0;
if (a + SEGENV.aux1 < SEGMENT.stop)
if (a + SEGENV.aux1 < SEGLEN)
{
for(int i = a; i < a+SEGENV.aux1; i++) {
setPixelColor(i, SEGCOLOR(0));
}
} else
{
for(int i = a; i < SEGMENT.stop; i++) {
for(int i = a; i < SEGLEN; i++) {
setPixelColor(i, SEGCOLOR(0));
}
for(int i = SEGMENT.start; i < SEGENV.aux1 - (SEGMENT.stop -a); i++) {
for(int i = 0; i < SEGENV.aux1 - (SEGLEN -a); i++) {
setPixelColor(i, SEGCOLOR(0));
}
}
@ -703,11 +697,11 @@ uint16_t WS2812FX::chase(uint32_t color1, uint32_t color2, uint32_t color3, bool
uint16_t b = (a + 1 + (SEGMENT.intensity * SEGLEN >> 10)) % SEGLEN;
uint16_t c = (b + 1 + (SEGMENT.intensity * SEGLEN >> 10)) % SEGLEN;
if (dopalette) color1 = color_from_palette(SEGMENT.start + a, true, PALETTE_SOLID_WRAP, 1);
if (dopalette) color1 = color_from_palette(a, true, PALETTE_SOLID_WRAP, 1);
setPixelColor(SEGMENT.start + a, color1);
setPixelColor(SEGMENT.start + b, color2);
setPixelColor(SEGMENT.start + c, color3);
setPixelColor(a, color1);
setPixelColor(b, color2);
setPixelColor(c, color3);
return FRAMETIME;
}
@ -725,7 +719,7 @@ uint16_t WS2812FX::mode_chase_color(void) {
* Primary running followed by random color.
*/
uint16_t WS2812FX::mode_chase_random(void) {
if(SEGENV.step == 0) {
if (SEGENV.step == 0) {
SEGENV.aux0 = get_random_wheel_index(SEGENV.aux0);
}
return chase(color_wheel(SEGENV.aux0), SEGCOLOR(0), SEGCOLOR(0), false);
@ -768,23 +762,23 @@ uint16_t WS2812FX::mode_colorful(void) {
SEGENV.step = it;
}
uint16_t i = SEGMENT.start;
for (i; i < SEGMENT.stop -3; i+=4)
uint16_t i = 0;
for (i; i < SEGLEN -3; i+=4)
{
setPixelColor(i, cols[SEGENV.aux0]);
setPixelColor(i+1, cols[SEGENV.aux0+1]);
setPixelColor(i+2, cols[SEGENV.aux0+2]);
setPixelColor(i+3, cols[SEGENV.aux0+3]);
}
if(i < SEGMENT.stop)
if(i < SEGLEN)
{
setPixelColor(i, cols[SEGENV.aux0]);
if(i+1 < SEGMENT.stop)
if(i+1 < SEGLEN)
{
setPixelColor(i+1, cols[SEGENV.aux0+1]);
if(i+2 < SEGMENT.stop)
if(i+2 < SEGLEN)
{
setPixelColor(i+2, cols[SEGENV.aux0+2]);
}
@ -799,10 +793,10 @@ uint16_t WS2812FX::mode_colorful(void) {
* Emulates a traffic light.
*/
uint16_t WS2812FX::mode_traffic_light(void) {
for(uint16_t i=SEGMENT.start; i < SEGMENT.stop; i++)
for(uint16_t i=0; i < SEGLEN; i++)
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 1));
uint32_t mdelay = 500;
for (int i = SEGMENT.start; i < SEGMENT.stop-2 ; i+=3)
for (int i = 0; i < SEGLEN-2 ; i+=3)
{
switch (SEGENV.aux0)
{
@ -843,7 +837,7 @@ uint16_t WS2812FX::mode_chase_rainbow(void) {
uint16_t WS2812FX::mode_chase_flash(void) {
uint8_t flash_step = SEGENV.call % ((FLASH_COUNT * 2) + 1);
for(uint16_t i=SEGMENT.start; i < SEGMENT.stop; i++) {
for(uint16_t i = 0; i < SEGLEN; i++) {
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
}
@ -852,8 +846,8 @@ uint16_t WS2812FX::mode_chase_flash(void) {
if(flash_step % 2 == 0) {
uint16_t n = SEGENV.step;
uint16_t m = (SEGENV.step + 1) % SEGLEN;
setPixelColor(SEGMENT.start + n, SEGCOLOR(1));
setPixelColor(SEGMENT.start + m, SEGCOLOR(1));
setPixelColor( n, SEGCOLOR(1));
setPixelColor( m, SEGCOLOR(1));
delay = 20;
} else {
delay = 30;
@ -871,8 +865,8 @@ uint16_t WS2812FX::mode_chase_flash(void) {
uint16_t WS2812FX::mode_chase_flash_random(void) {
uint8_t flash_step = SEGENV.call % ((FLASH_COUNT * 2) + 1);
for(uint16_t i=0; i < SEGENV.step; i++) {
setPixelColor(SEGMENT.start + i, color_wheel(SEGENV.aux0));
for(uint16_t i = 0; i < SEGENV.step; i++) {
setPixelColor(i, color_wheel(SEGENV.aux0));
}
uint16_t delay = 1 + ((10 * (uint16_t)(255 - SEGMENT.speed)) / SEGLEN);
@ -880,12 +874,12 @@ uint16_t WS2812FX::mode_chase_flash_random(void) {
uint16_t n = SEGENV.step;
uint16_t m = (SEGENV.step + 1) % SEGLEN;
if(flash_step % 2 == 0) {
setPixelColor(SEGMENT.start + n, SEGCOLOR(0));
setPixelColor(SEGMENT.start + m, SEGCOLOR(0));
setPixelColor( n, SEGCOLOR(0));
setPixelColor( m, SEGCOLOR(0));
delay = 20;
} else {
setPixelColor(SEGMENT.start + n, color_wheel(SEGENV.aux0));
setPixelColor(SEGMENT.start + m, SEGCOLOR(1));
setPixelColor( n, color_wheel(SEGENV.aux0));
setPixelColor( m, SEGCOLOR(1));
delay = 30;
}
} else {
@ -908,17 +902,17 @@ uint16_t WS2812FX::running(uint32_t color1, uint32_t color2) {
uint32_t it = now / cycleTime;
if (SEGMENT.speed == 0) it = 0;
for(uint16_t i=0; i < SEGLEN; i++) {
for(uint16_t i = 0; i < SEGLEN; i++) {
if((i + SEGENV.aux0) % (pxw*2) < pxw) {
if (color1 == SEGCOLOR(0))
{
setPixelColor(SEGMENT.stop -i -1, color_from_palette(SEGMENT.stop -i -1, true, PALETTE_SOLID_WRAP, 0));
setPixelColor(SEGLEN -i -1, color_from_palette(SEGLEN -i -1, true, PALETTE_SOLID_WRAP, 0));
} else
{
setPixelColor(SEGMENT.stop -i -1, color1);
setPixelColor(SEGLEN -i -1, color1);
}
} else {
setPixelColor(SEGMENT.stop -i -1, color2);
setPixelColor(SEGLEN -i -1, color2);
}
}
@ -971,12 +965,12 @@ uint16_t WS2812FX::mode_running_random(void) {
if (SEGENV.aux1 == it) return FRAMETIME;
for(uint16_t i=SEGLEN-1; i > 0; i--) {
setPixelColor(SEGMENT.start + i, getPixelColor(SEGMENT.start + i - 1));
setPixelColor( i, getPixelColor( i - 1));
}
if(SEGENV.step == 0) {
SEGENV.aux0 = get_random_wheel_index(SEGENV.aux0);
setPixelColor(SEGMENT.start, color_wheel(SEGENV.aux0));
setPixelColor(0, color_wheel(SEGENV.aux0));
}
SEGENV.step++;
@ -1009,7 +1003,7 @@ uint16_t WS2812FX::larson_scanner(bool dual) {
for (uint16_t i = SEGENV.step; i < index; i++) {
uint16_t j = (SEGENV.aux0)?i:SEGLEN-1-i;
setPixelColor(SEGMENT.start + j, color_from_palette(j, true, PALETTE_SOLID_WRAP, 0));
setPixelColor( j, color_from_palette(j, true, PALETTE_SOLID_WRAP, 0));
}
if (dual) {
uint32_t c;
@ -1021,7 +1015,7 @@ uint16_t WS2812FX::larson_scanner(bool dual) {
for (uint16_t i = SEGENV.step; i < index; i++) {
uint16_t j = (SEGENV.aux0)?SEGLEN-1-i:i;
setPixelColor(SEGMENT.start + j, c);
setPixelColor(j, c);
}
}
@ -1039,7 +1033,7 @@ uint16_t WS2812FX::mode_comet(void) {
fade_out(SEGMENT.intensity);
setPixelColor(SEGMENT.start + index, color_from_palette(index, true, PALETTE_SOLID_WRAP, 0));
setPixelColor( index, color_from_palette(index, true, PALETTE_SOLID_WRAP, 0));
return FRAMETIME;
}
@ -1054,8 +1048,8 @@ uint16_t WS2812FX::mode_fireworks() {
SEGENV.aux0 = UINT16_MAX;
SEGENV.aux1 = UINT16_MAX;
}
bool valid1 = (SEGENV.aux0 < SEGMENT.stop && SEGENV.aux0 >= SEGMENT.start);
bool valid2 = (SEGENV.aux1 < SEGMENT.stop && SEGENV.aux1 >= SEGMENT.start);
bool valid1 = (SEGENV.aux0 < SEGLEN);
bool valid2 = (SEGENV.aux1 < SEGLEN);
uint32_t sv1 = 0, sv2 = 0;
if (valid1) sv1 = getPixelColor(SEGENV.aux0);
if (valid2) sv2 = getPixelColor(SEGENV.aux1);
@ -1065,7 +1059,7 @@ uint16_t WS2812FX::mode_fireworks() {
for(uint16_t i=0; i<max(1, SEGLEN/20); i++) {
if(random8(129 - (SEGMENT.intensity >> 1)) == 0) {
uint16_t index = SEGMENT.start + random(SEGLEN);
uint16_t index = random(SEGLEN);
setPixelColor(index, color_from_palette(random8(), false, false, 0));
SEGENV.aux1 = SEGENV.aux0;
SEGENV.aux0 = index;
@ -1082,17 +1076,17 @@ uint16_t WS2812FX::mode_rain()
if (SEGENV.step > SPEED_FORMULA_L) {
SEGENV.step = 0;
//shift all leds right
uint32_t ctemp = getPixelColor(SEGMENT.stop -1);
for(uint16_t i=SEGMENT.stop -1; i>SEGMENT.start; i--) {
uint32_t ctemp = getPixelColor(SEGLEN -1);
for(uint16_t i = SEGLEN -1; i > 0; i--) {
setPixelColor(i, getPixelColor(i-1));
}
setPixelColor(SEGMENT.start, ctemp);
setPixelColor(0, ctemp);
SEGENV.aux0++;
SEGENV.aux1++;
if (SEGENV.aux0 == 0) SEGENV.aux0 = UINT16_MAX;
if (SEGENV.aux1 == 0) SEGENV.aux0 = UINT16_MAX;
if (SEGENV.aux0 == SEGMENT.stop) SEGENV.aux0 = SEGMENT.start;
if (SEGENV.aux1 == SEGMENT.stop) SEGENV.aux1 = SEGMENT.start;
if (SEGENV.aux0 == SEGLEN) SEGENV.aux0 = 0;
if (SEGENV.aux1 == SEGLEN) SEGENV.aux1 = 0;
}
return mode_fireworks();
}
@ -1112,7 +1106,7 @@ uint16_t WS2812FX::mode_fire_flicker(void) {
byte b = (SEGCOLOR(0) & 0xFF);
byte lum = (SEGMENT.palette == 0) ? max(w, max(r, max(g, b))) : 255;
lum /= (((256-SEGMENT.intensity)/16)+1);
for(uint16_t i=SEGMENT.start; i < SEGMENT.stop; i++) {
for(uint16_t i = 0; i < SEGLEN; i++) {
byte flicker = random8(lum);
if (SEGMENT.palette == 0) {
setPixelColor(i, max(r - flicker, 0), max(g - flicker, 0), max(b - flicker, 0), max(w - flicker, 0));
@ -1132,7 +1126,7 @@ uint16_t WS2812FX::mode_fire_flicker(void) {
uint16_t WS2812FX::gradient_base(bool loading) {
uint16_t counter = now * (SEGMENT.speed >> 3) + 1;
SEGENV.step = counter * SEGLEN >> 16;
if (SEGMENT.speed == 0) SEGENV.step = SEGMENT.start + (SEGLEN >> 1);
if (SEGMENT.speed == 0) SEGENV.step = SEGLEN >> 1;
if (SEGENV.call == 0) SEGENV.step = 0;
float per,val; //0.0 = sec 1.0 = pri
float brd = SEGMENT.intensity;
@ -1142,7 +1136,7 @@ uint16_t WS2812FX::gradient_base(bool loading) {
int p1 = pp-SEGLEN;
int p2 = pp+SEGLEN;
for(uint16_t i=SEGMENT.start; i < SEGMENT.stop; i++)
for(uint16_t i = 0; i < SEGLEN; i++)
{
if (loading)
{
@ -1188,8 +1182,8 @@ uint16_t WS2812FX::police_base(uint32_t color1, uint32_t color2)
if (idexR > topindex) idexB -= SEGLEN;
if (idexB >= SEGLEN) idexB = 0; //otherwise overflow on odd number of LEDs
setPixelColor(SEGMENT.start + idexR, color1);
setPixelColor(SEGMENT.start + idexB, color2);
setPixelColor(idexR, color1);
setPixelColor(idexB, color2);
return FRAMETIME;
}
@ -1237,14 +1231,14 @@ uint16_t WS2812FX::tricolor_chase(uint32_t color1, uint32_t color2) {
uint8_t width = (1 + SEGMENT.intensity/32) * 3; //value of 1-8 for each colour
uint8_t index = it % width;
for(uint16_t i=0; i < SEGLEN; i++, index++) {
for(uint16_t i = 0; i < SEGLEN; i++, index++) {
if(index > width-1) index = 0;
uint32_t color = color1;
if(index > width*2/3-1) color = color_from_palette(i, true, PALETTE_SOLID_WRAP, 1);
else if(index > width/3-1) color = color2;
setPixelColor(SEGMENT.stop - i -1, color);
setPixelColor(SEGLEN - i -1, color);
}
return FRAMETIME;
@ -1278,13 +1272,13 @@ uint16_t WS2812FX::mode_icu(void) {
byte pindex = map(dest, 0, SEGLEN/2, 0, 255);
uint32_t col = color_from_palette(pindex, false, false, 0);
setPixelColor(SEGMENT.start + dest, col);
setPixelColor(SEGMENT.start + dest + SEGLEN/2, col);
setPixelColor( dest, col);
setPixelColor( dest + SEGLEN/2, col);
if(SEGENV.aux0 == dest) { // pause between eye movements
if(random8(6) == 0) { // blink once in a while
setPixelColor(SEGMENT.start + dest, SEGCOLOR(1));
setPixelColor(SEGMENT.start + dest + SEGLEN/2, SEGCOLOR(1));
setPixelColor( dest, SEGCOLOR(1));
setPixelColor( dest + SEGLEN/2, SEGCOLOR(1));
return 200;
}
SEGENV.aux0 = random16(SEGLEN/2);
@ -1299,8 +1293,8 @@ uint16_t WS2812FX::mode_icu(void) {
dest--;
}
setPixelColor(SEGMENT.start + dest, col);
setPixelColor(SEGMENT.start + dest + SEGLEN/2, col);
setPixelColor(dest, col);
setPixelColor(dest + SEGLEN/2, col);
return SPEED_FORMULA_L;
}
@ -1317,26 +1311,26 @@ uint16_t WS2812FX::mode_tricolor_wipe(void)
uint16_t ledIndex = (prog * SEGLEN * 3) >> 16;
uint16_t ledOffset = ledIndex;
for (uint16_t i = SEGMENT.start; i < SEGMENT.stop; i++)
for (uint16_t i = 0; i < SEGLEN; i++)
{
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 2));
}
if(ledIndex < SEGLEN) { //wipe from 0 to 1
for (uint16_t i = SEGMENT.start; i < SEGMENT.stop; i++)
for (uint16_t i = 0; i < SEGLEN; i++)
{
setPixelColor(i, (i - SEGMENT.start > ledOffset)? SEGCOLOR(0) : SEGCOLOR(1));
setPixelColor(i, (i > ledOffset)? SEGCOLOR(0) : SEGCOLOR(1));
}
} else if (ledIndex < SEGLEN*2) { //wipe from 1 to 2
ledOffset = ledIndex - SEGLEN;
for (uint16_t i = SEGMENT.start +ledOffset +1; i < SEGMENT.stop; i++)
for (uint16_t i = ledOffset +1; i < SEGLEN; i++)
{
setPixelColor(i, SEGCOLOR(1));
}
} else //wipe from 2 to 0
{
ledOffset = ledIndex - SEGLEN*2;
for (uint16_t i = SEGMENT.start; i <= SEGMENT.start +ledOffset; i++)
for (uint16_t i = 0; i <= ledOffset; i++)
{
setPixelColor(i, SEGCOLOR(0));
}
@ -1375,7 +1369,7 @@ uint16_t WS2812FX::mode_tricolor_fade(void)
byte stp = prog; // % 256
uint32_t color = 0;
for(uint16_t i=SEGMENT.start; i < SEGMENT.stop; i++) {
for(uint16_t i = 0; i < SEGLEN; i++) {
if (stage == 2) {
color = color_blend(color_from_palette(i, true, PALETTE_SOLID_WRAP, 2), color2, stp);
} else if (stage == 1) {
@ -1406,7 +1400,7 @@ uint16_t WS2812FX::mode_multi_comet(void)
for(uint8_t i=0; i < 8; i++) {
if(comets[i] < SEGLEN) {
uint16_t index = SEGMENT.start + comets[i];
uint16_t index = comets[i];
if (SEGCOLOR(2) != 0)
{
setPixelColor(index, i % 2 ? color_from_palette(index, true, PALETTE_SOLID_WRAP, 0) : SEGCOLOR(2));
@ -1446,15 +1440,15 @@ uint16_t WS2812FX::mode_random_chase(void)
uint32_t it = now / cycleTime;
if (SEGENV.step == it) return FRAMETIME;
for(uint16_t i=SEGMENT.stop -1; i>SEGMENT.start; i--) {
for(uint16_t i = SEGLEN -1; i > 0; i--) {
setPixelColor(i, getPixelColor(i-1));
}
uint32_t color = getPixelColor(SEGMENT.start);
if (SEGLEN > 1) color = getPixelColor(SEGMENT.start + 1);
uint32_t color = getPixelColor(0);
if (SEGLEN > 1) color = getPixelColor( 1);
uint8_t r = random8(6) != 0 ? (color >> 16 & 0xFF) : random8();
uint8_t g = random8(6) != 0 ? (color >> 8 & 0xFF) : random8();
uint8_t b = random8(6) != 0 ? (color & 0xFF) : random8();
setPixelColor(SEGMENT.start, r, g, b);
setPixelColor(0, r, g, b);
SEGENV.step = it;
return FRAMETIME;
@ -1490,7 +1484,7 @@ uint16_t WS2812FX::mode_oscillate(void)
uint32_t cycleTime = 20 + (2 * (uint32_t)(255 - SEGMENT.speed));
uint32_t it = now / cycleTime;
for(uint8_t i=0; i < numOscillators; i++) {
for(uint8_t i = 0; i < numOscillators; i++) {
// if the counter has increased, move the oscillator by the random step
if (it != SEGENV.step) oscillators[i].pos += oscillators[i].dir * oscillators[i].speed;
oscillators[i].size = SEGLEN/(3+SEGMENT.intensity/8);
@ -1514,7 +1508,7 @@ uint16_t WS2812FX::mode_oscillate(void)
color = (color == BLACK) ? SEGMENT.colors[j] : color_blend(color, SEGMENT.colors[j], 128);
}
}
setPixelColor(SEGMENT.start + i, color);
setPixelColor(i, color);
}
SEGENV.step = it;
@ -1524,8 +1518,8 @@ uint16_t WS2812FX::mode_oscillate(void)
uint16_t WS2812FX::mode_lightning(void)
{
uint16_t ledstart = SEGMENT.start + random16(SEGLEN); // Determine starting location of flash
uint16_t ledlen = random16(SEGMENT.stop -1 -ledstart); // Determine length of flash (not to go beyond NUM_LEDS-1)
uint16_t ledstart = random16(SEGLEN); // Determine starting location of flash
uint16_t ledlen = random16(SEGLEN -1 -ledstart); // Determine length of flash (not to go beyond NUM_LEDS-1)
uint8_t bri = 255/random8(1, 3);
if (SEGENV.step == 0)
@ -1584,7 +1578,7 @@ uint16_t WS2812FX::mode_pride_2015(void)
uint16_t brightnesstheta16 = sPseudotime;
CRGB fastled_col;
for( uint16_t i = SEGMENT.start ; i < SEGMENT.stop; i++) {
for (uint16_t i = 0 ; i < SEGLEN; i++) {
hue16 += hueinc16;
uint8_t hue8 = hue16 >> 8;
@ -1598,7 +1592,7 @@ uint16_t WS2812FX::mode_pride_2015(void)
CRGB newcolor = CHSV( hue8, sat8, bri8);
fastled_col = col_to_crgb(getPixelColor(i));
nblend( fastled_col, newcolor, 64);
nblend(fastled_col, newcolor, 64);
setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
}
SEGENV.step = sPseudotime;
@ -1613,7 +1607,7 @@ uint16_t WS2812FX::mode_juggle(void){
CRGB fastled_col;
byte dothue = 0;
for ( byte i = 0; i < 8; i++) {
uint16_t index = SEGMENT.start + beatsin88((128 + SEGMENT.speed)*(i + 7), 0, SEGLEN -1);
uint16_t index = 0 + beatsin88((128 + SEGMENT.speed)*(i + 7), 0, SEGLEN -1);
fastled_col = col_to_crgb(getPixelColor(index));
fastled_col |= (SEGMENT.palette==0)?CHSV(dothue, 220, 255):ColorFromPalette(currentPalette, dothue, 255);
setPixelColor(index, fastled_col.red, fastled_col.green, fastled_col.blue);
@ -1639,7 +1633,7 @@ uint16_t WS2812FX::mode_palette()
if (noWrap) colorIndex = map(colorIndex, 0, 255, 0, 240); //cut off blend at palette "end"
setPixelColor(SEGMENT.start + i, color_from_palette(colorIndex, false, true, 255));
setPixelColor(i, color_from_palette(colorIndex, false, true, 255));
}
return FRAMETIME;
}
@ -1706,7 +1700,7 @@ uint16_t WS2812FX::mode_fire_2012()
// Step 4. Map from heat cells to LED colors
for (uint16_t j = 0; j < SEGLEN; j++) {
CRGB color = ColorFromPalette(currentPalette, min(heat[j],240), 255, LINEARBLEND);
setPixelColor(SEGMENT.start + j, color.red, color.green, color.blue);
setPixelColor(j, color.red, color.green, color.blue);
}
return FRAMETIME;
}
@ -1721,7 +1715,7 @@ uint16_t WS2812FX::mode_colorwaves()
uint16_t sPseudotime = SEGENV.step;
uint16_t sHue16 = SEGENV.aux0;
uint8_t brightdepth = beatsin88( 341, 96, 224);
uint8_t brightdepth = beatsin88(341, 96, 224);
uint16_t brightnessthetainc16 = beatsin88( 203, (25 * 256), (40 * 256));
uint8_t msmultiplier = beatsin88(147, 23, 60);
@ -1729,11 +1723,11 @@ uint16_t WS2812FX::mode_colorwaves()
uint16_t hueinc16 = beatsin88(113, 300, 1500);
sPseudotime += duration * msmultiplier;
sHue16 += duration * beatsin88( 400, 5, 9);
sHue16 += duration * beatsin88(400, 5, 9);
uint16_t brightnesstheta16 = sPseudotime;
CRGB fastled_col;
for ( uint16_t i = SEGMENT.start ; i < SEGMENT.stop; i++) {
for ( uint16_t i = 0 ; i < SEGLEN; i++) {
hue16 += hueinc16;
uint8_t hue8 = hue16 >> 8;
uint16_t h16_128 = hue16 >> 7;
@ -1768,7 +1762,7 @@ uint16_t WS2812FX::mode_bpm()
CRGB fastled_col;
uint32_t stp = (now / 20) & 0xFF;
uint8_t beat = beatsin8(SEGMENT.speed, 64, 255);
for (uint16_t i = SEGMENT.start; i < SEGMENT.stop; i++) {
for (uint16_t i = 0; i < SEGLEN; i++) {
fastled_col = ColorFromPalette(currentPalette, stp + (i * 2), beat - stp + (i * 10));
setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
}
@ -1780,8 +1774,8 @@ uint16_t WS2812FX::mode_fillnoise8()
{
if (SEGENV.call == 0) SEGENV.step = random16(12345);
CRGB fastled_col;
for (uint16_t i = SEGMENT.start; i < SEGMENT.stop; i++) {
uint8_t index = inoise8(i * SEGLEN, SEGENV.step + i * SEGLEN) % 255;
for (uint16_t i = 0; i < SEGLEN; i++) {
uint8_t index = inoise8(i * SEGLEN, SEGENV.step + i * SEGLEN);
fastled_col = ColorFromPalette(currentPalette, index, 255, LINEARBLEND);
setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
}
@ -1796,7 +1790,7 @@ uint16_t WS2812FX::mode_noise16_1()
CRGB fastled_col;
SEGENV.step += (1 + SEGMENT.speed/16);
for (uint16_t i = SEGMENT.start; i < SEGMENT.stop; i++) {
for (uint16_t i = 0; i < SEGLEN; i++) {
uint16_t shift_x = beatsin8(11); // the x position of the noise field swings @ 17 bpm
uint16_t shift_y = SEGENV.step/42; // the y position becomes slowly incremented
@ -1824,7 +1818,7 @@ uint16_t WS2812FX::mode_noise16_2()
CRGB fastled_col;
SEGENV.step += (1 + (SEGMENT.speed >> 1));
for (uint16_t i = SEGMENT.start; i < SEGMENT.stop; i++) {
for (uint16_t i = 0; i < SEGLEN; i++) {
uint16_t shift_x = SEGENV.step >> 6; // x as a function of time
uint16_t shift_y = SEGENV.step/42;
@ -1849,7 +1843,7 @@ uint16_t WS2812FX::mode_noise16_3()
CRGB fastled_col;
SEGENV.step += (1 + SEGMENT.speed);
for (uint16_t i = SEGMENT.start; i < SEGMENT.stop; i++) {
for (uint16_t i = 0; i < SEGLEN; i++) {
uint16_t shift_x = 4223; // no movement along x and y
uint16_t shift_y = 1234;
@ -1875,8 +1869,8 @@ uint16_t WS2812FX::mode_noise16_4()
{
CRGB fastled_col;
uint32_t stp = (now * SEGMENT.speed) >> 7;
for (uint16_t i = SEGMENT.start; i < SEGMENT.stop; i++) {
int16_t index = inoise16(uint32_t(i - SEGMENT.start) << 12, stp);
for (uint16_t i = 0; i < SEGLEN; i++) {
int16_t index = inoise16(uint32_t(i) << 12, stp);
fastled_col = ColorFromPalette(currentPalette, index);
setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
}
@ -1892,11 +1886,11 @@ uint16_t WS2812FX::mode_colortwinkle()
CRGB fastled_col, prev;
fract8 fadeUpAmount = 8 + (SEGMENT.speed/4), fadeDownAmount = 5 + (SEGMENT.speed/7);
for (uint16_t i = SEGMENT.start; i < SEGMENT.stop; i++) {
for (uint16_t i = 0; i < SEGLEN; i++) {
fastled_col = col_to_crgb(getPixelColor(i));
prev = fastled_col;
uint16_t index = (i - SEGMENT.start) >> 3;
uint8_t bitNum = (i - SEGMENT.start) & 0x07;
uint16_t index = i >> 3;
uint8_t bitNum = i & 0x07;
bool fadeUp = bitRead(SEGENV.data[index], bitNum);
if (fadeUp) {
@ -1925,11 +1919,11 @@ uint16_t WS2812FX::mode_colortwinkle()
if (random8() <= SEGMENT.intensity) {
for (uint8_t times = 0; times < 5; times++) //attempt to spawn a new pixel 5 times
{
int i = SEGMENT.start + random16(SEGLEN);
int i = random16(SEGLEN);
if(getPixelColor(i) == 0) {
fastled_col = ColorFromPalette(currentPalette, random8(), 64, NOBLEND);
uint16_t index = (i - SEGMENT.start) >> 3;
uint8_t bitNum = (i - SEGMENT.start) & 0x07;
uint16_t index = i >> 3;
uint8_t bitNum = i & 0x07;
bitWrite(SEGENV.data[index], bitNum, true);
setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
break; //only spawn 1 new pixel per frame per 50 LEDs
@ -1949,7 +1943,7 @@ uint16_t WS2812FX::mode_lake() {
uint8_t wave3 = beatsin8(sp +2, 0,80);
CRGB fastled_col;
for (uint16_t i = SEGMENT.start; i < SEGMENT.stop; i++)
for (uint16_t i = 0; i < SEGLEN; i++)
{
int index = cos8((i*15)+ wave1)/2 + cubicwave8((i*23)+ wave2)/2;
uint8_t lum = (index > wave3) ? index - wave3 : 0;
@ -1978,7 +1972,7 @@ uint16_t WS2812FX::mode_meteor() {
{
byte meteorTrailDecay = 128 + random8(127);
trail[i] = scale8(trail[i], meteorTrailDecay);
setPixelColor(SEGMENT.start + i, color_from_palette(trail[i], false, true, 255));
setPixelColor(i, color_from_palette(trail[i], false, true, 255));
}
}
@ -1990,7 +1984,7 @@ uint16_t WS2812FX::mode_meteor() {
}
trail[index] = 240;
setPixelColor(SEGMENT.start + index, color_from_palette(trail[index], false, true, 255));
setPixelColor(index, color_from_palette(trail[index], false, true, 255));
}
return FRAMETIME;
@ -2016,7 +2010,7 @@ uint16_t WS2812FX::mode_meteor_smooth() {
trail[i] += change;
if (trail[i] > 245) trail[i] = 0;
if (trail[i] > 240) trail[i] = 240;
setPixelColor(SEGMENT.start + i, color_from_palette(trail[i], false, true, 255));
setPixelColor(i, color_from_palette(trail[i], false, true, 255));
}
}
@ -2026,7 +2020,7 @@ uint16_t WS2812FX::mode_meteor_smooth() {
if(in + j >= SEGLEN) {
index = (in + j - SEGLEN);
}
setPixelColor(SEGMENT.start + index, color_blend(getPixelColor(SEGMENT.start + index), color_from_palette(240, false, true, 255), 48));
setPixelColor(index, color_blend(getPixelColor(index), color_from_palette(240, false, true, 255), 48));
trail[index] = 240;
}
@ -2053,10 +2047,10 @@ uint16_t WS2812FX::mode_railway()
if (p0 < 255) pos = p0;
}
if (SEGENV.aux0) pos = 255 - pos;
for (uint16_t i = SEGMENT.start; i < SEGMENT.stop; i += 2)
for (uint16_t i = 0; i < SEGLEN; i += 2)
{
setPixelColor(i, color_from_palette(255 - pos, false, false, 255));
if (i < SEGMENT.stop -1)
if (i < SEGLEN -1)
{
setPixelColor(i + 1, color_from_palette(pos, false, false, 255));
}
@ -2107,12 +2101,12 @@ uint16_t WS2812FX::mode_ripple()
for (int16_t v = left; v < left +4; v++)
{
uint8_t mag = scale8(cubicwave8((propF>>2)+(v-left)*64), amp);
if (v < SEGMENT.stop && v >= SEGMENT.start)
if (v < SEGLEN && v >= 0)
{
setPixelColor(v, color_blend(getPixelColor(v), col, mag));
}
int16_t w = left + propI*2 + 3 -(v-left);
if (w < SEGMENT.stop && w >= SEGMENT.start)
if (w < SEGLEN && w >= 0)
{
setPixelColor(w, color_blend(getPixelColor(w), col, mag));
}
@ -2124,7 +2118,7 @@ uint16_t WS2812FX::mode_ripple()
if (random16(IBN + 10000) <= SEGMENT.intensity)
{
ripples[i].state = 1;
ripples[i].pos = SEGMENT.start + random16(SEGLEN);
ripples[i].pos = random16(SEGLEN);
ripples[i].color = random8(); //color
}
}
@ -2228,7 +2222,7 @@ uint16_t WS2812FX::twinklefox_base(bool cat)
uint8_t backgroundBrightness = bg.getAverageLight();
for (uint16_t i = SEGMENT.start; i < SEGMENT.stop; i++) {
for (uint16_t i = 0; i < SEGLEN; i++) {
PRNG16 = (uint16_t)(PRNG16 * 2053) + 1384; // next 'random' number
uint16_t myclockoffset16= PRNG16; // use that number as clock offset
@ -2289,7 +2283,7 @@ uint16_t WS2812FX::mode_halloween_eyes()
if (stateTime == 0) stateTime = 2000;
if (state == 0) { //spawn eyes
SEGENV.aux0 = random16(SEGMENT.start, SEGMENT.stop - eyeLength); //start pos
SEGENV.aux0 = random16(0, SEGLEN - eyeLength); //start pos
SEGENV.aux1 = random8(); //color
state = 1;
}
@ -2339,7 +2333,7 @@ uint16_t WS2812FX::mode_static_pattern()
bool drawingLit = true;
uint16_t cnt = 0;
for (uint16_t i = SEGMENT.start; i < SEGMENT.stop; i++) {
for (uint16_t i = 0; i < SEGLEN; i++) {
setPixelColor(i, (drawingLit) ? color_from_palette(i, true, PALETTE_SOLID_WRAP, 0) : SEGCOLOR(1));
cnt++;
if (cnt >= ((drawingLit) ? lit : unlit)) {
@ -2357,7 +2351,7 @@ uint16_t WS2812FX::mode_tri_static_pattern()
uint8_t currSeg = 0;
uint16_t currSegCount = 0;
for (uint16_t i = SEGMENT.start; i < SEGMENT.stop; i++) {
for (uint16_t i = 0; i < SEGLEN; i++) {
if ( currSeg % 3 == 0 ) {
setPixelColor(i, SEGCOLOR(0));
} else if( currSeg % 3 == 1) {
@ -2392,7 +2386,7 @@ uint16_t WS2812FX::spots_base(uint16_t threshold)
{
uint16_t wave = triwave16((i * 0xFFFF) / zoneLen);
if (wave > threshold) {
uint16_t index = SEGMENT.start + pos + i;
uint16_t index = 0 + pos + i;
uint8_t s = (wave - threshold)*255 / (0xFFFF - threshold);
setPixelColor(index, color_blend(color_from_palette(index, true, PALETTE_SOLID_WRAP, 0), SEGCOLOR(1), 255-s));
}
@ -2479,7 +2473,7 @@ uint16_t WS2812FX::mode_bouncing_balls(void) {
}
uint16_t pos = round(balls[i].height * (SEGLEN - 1));
setPixelColor(SEGMENT.start + pos, color);
setPixelColor(pos, color);
}
return FRAMETIME;
@ -2497,7 +2491,7 @@ uint16_t WS2812FX::sinelon_base(bool dual, bool rainbow=false) {
if (rainbow) {
color1 = color_wheel((pos & 0x07) * 32);
}
setPixelColor(SEGMENT.start + pos, color1);
setPixelColor(pos, color1);
if (dual) {
uint32_t color2 = SEGCOLOR(2);
@ -2505,7 +2499,7 @@ uint16_t WS2812FX::sinelon_base(bool dual, bool rainbow=false) {
if (!color2) color2 = color_from_palette(pos, true, false, 0);
if (rainbow) color2 = color1; //rainbow
setPixelColor(SEGMENT.start + SEGLEN-1-pos, color2);
setPixelColor(SEGLEN-1-pos, color2);
}
return FRAMETIME;
@ -2531,7 +2525,7 @@ uint16_t WS2812FX::mode_glitter()
if (SEGMENT.intensity > random8())
{
setPixelColor(SEGMENT.start + random16(SEGLEN), ULTRAWHITE);
setPixelColor(random16(SEGLEN), ULTRAWHITE);
}
return FRAMETIME;
@ -2572,16 +2566,16 @@ uint16_t WS2812FX::mode_popcorn(void) {
for(uint8_t i = 0; i < numPopcorn; i++) {
bool isActive = popcorn[i].pos >= 0.0f;
if(isActive) { // if kernel is active, update its position
if (isActive) { // if kernel is active, update its position
popcorn[i].pos += popcorn[i].vel;
popcorn[i].vel += gravity;
uint32_t col = color_wheel(popcorn[i].colIndex);
if (!SEGMENT.palette && popcorn[i].colIndex < NUM_COLORS) col = SEGCOLOR(popcorn[i].colIndex);
uint16_t ledIndex = SEGMENT.start + popcorn[i].pos;
if(ledIndex >= SEGMENT.start && ledIndex < SEGMENT.stop) setPixelColor(ledIndex, col);
uint16_t ledIndex = popcorn[i].pos;
if (ledIndex < SEGLEN) setPixelColor(ledIndex, col);
} else { // if kernel is inactive, randomly pop it
if(random8() < 2) { // POP!!!
if (random8() < 2) { // POP!!!
popcorn[i].pos = 0.01f;
uint16_t peakHeight = 128 + random8(128); //0-255
@ -2626,7 +2620,7 @@ uint16_t WS2812FX::mode_candle()
}
SEGENV.aux0 = s;
for (uint16_t i = SEGMENT.start; i < SEGMENT.stop; i++) {
for (uint16_t i = 0; i < SEGLEN; i++) {
setPixelColor(i, color_blend(color_from_palette(i, true, PALETTE_SOLID_WRAP, 0), SEGCOLOR(1), 255-s));
}
@ -2766,7 +2760,7 @@ uint16_t WS2812FX::mode_starburst(void) {
if (start == end) end++;
if (end > SEGLEN) end = SEGLEN;
for (int p = start; p < end; p++) {
setPixelColor(SEGMENT.start+p, c.r, c.g, c.b);
setPixelColor(p, c.r, c.g, c.b);
}
}
}
@ -2814,7 +2808,7 @@ uint16_t WS2812FX::mode_exploding_fireworks(void)
// launch
if (flare->vel > 12 * gravity) {
// flare
setPixelColor(SEGMENT.start + int(flare->pos),flare->col,flare->col,flare->col);
setPixelColor(int(flare->pos),flare->col,flare->col,flare->col);
flare->pos += flare->vel;
flare->pos = constrain(flare->pos, 0, SEGLEN-1);
@ -2868,7 +2862,7 @@ uint16_t WS2812FX::mode_exploding_fireworks(void)
c.g = qsub8(c.g, cooling);
c.b = qsub8(c.b, cooling * 2);
}
setPixelColor(SEGMENT.start + int(sparks[i].pos), c.red, c.green, c.blue);
setPixelColor(int(sparks[i].pos), c.red, c.green, c.blue);
}
}
dying_gravity *= .99; // as sparks burn out they fall slower
@ -2916,10 +2910,10 @@ uint16_t WS2812FX::mode_drip(void)
drops[j].colIndex = 1; // drop state (0 init, 1 forming, 2 falling, 5 bouncing)
}
setPixelColor(SEGMENT.start + SEGLEN-1,color_blend(BLACK,SEGCOLOR(0), sourcedrop));// water source
setPixelColor(SEGLEN-1,color_blend(BLACK,SEGCOLOR(0), sourcedrop));// water source
if (drops[j].colIndex==1) {
if (drops[j].col>255) drops[j].col=255;
setPixelColor(SEGMENT.start + int(drops[j].pos),color_blend(BLACK,SEGCOLOR(0),drops[j].col));
setPixelColor(int(drops[j].pos),color_blend(BLACK,SEGCOLOR(0),drops[j].col));
drops[j].col += map(SEGMENT.intensity, 0, 255, 1, 6); // swelling
@ -2935,11 +2929,11 @@ uint16_t WS2812FX::mode_drip(void)
drops[j].vel += gravity;
for (int i=1;i<7-drops[j].colIndex;i++) { // some minor math so we don't expand bouncing droplets
setPixelColor(SEGMENT.start + int(drops[j].pos)+i,color_blend(BLACK,SEGCOLOR(0),drops[j].col/i)); //spread pixel with fade while falling
setPixelColor(int(drops[j].pos)+i,color_blend(BLACK,SEGCOLOR(0),drops[j].col/i)); //spread pixel with fade while falling
}
if (drops[j].colIndex > 2) { // during bounce, some water is on the floor
setPixelColor(SEGMENT.start,color_blend(SEGCOLOR(0),BLACK,drops[j].col));
setPixelColor(0,color_blend(SEGCOLOR(0),BLACK,drops[j].col));
}
} else { // we hit bottom
if (drops[j].colIndex > 2) { // already hit once, so back to forming

View File

@ -59,7 +59,7 @@
#define SEGMENT _segments[_segment_index]
#define SEGCOLOR(x) gamma32(_segments[_segment_index].colors[x])
#define SEGENV _segment_runtimes[_segment_index]
#define SEGLEN SEGMENT.length()
#define SEGLEN _virtualSegmentLength
#define SEGACT SEGMENT.stop
#define SPEED_FORMULA_L 5 + (50*(255 - SEGMENT.speed))/SEGLEN
#define RESET_RUNTIME memset(_segment_runtimes, 0, sizeof(_segment_runtimes))
@ -208,7 +208,7 @@ class WS2812FX {
uint8_t palette;
uint8_t mode;
uint8_t options; //bit pattern: msb first: transitional tbd tbd tbd tbd paused reverse selected
uint8_t group, spacing;
uint8_t grouping, spacing;
uint8_t opacity;
uint32_t colors[NUM_COLORS];
void setOption(uint8_t n, bool val)
@ -236,6 +236,15 @@ class WS2812FX {
{
return stop - start;
}
uint16_t groupLength()
{
return grouping + spacing;
}
uint16_t virtualLength()
{
uint16_t groupLen = groupLength();
return (length() + groupLen -1) / groupLen;
}
} segment;
// segment runtime parameters
@ -379,7 +388,7 @@ class WS2812FX {
}
void
init(bool supportWhite, uint16_t countPixels, bool skipFirs, uint8_t disableNLeds),
init(bool supportWhite, uint16_t countPixels, bool skipFirst),
service(void),
blur(uint8_t),
fade_out(uint8_t r),
@ -394,7 +403,7 @@ class WS2812FX {
setShowCallback(show_callback cb),
setTransitionMode(bool t),
trigger(void),
setSegment(uint8_t n, uint16_t start, uint16_t stop),
setSegment(uint8_t n, uint16_t start, uint16_t stop, uint8_t grouping = 0, uint8_t spacing = 0),
resetSegments(),
setPixelColor(uint16_t n, uint32_t c),
setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0),
@ -414,7 +423,6 @@ class WS2812FX {
paletteBlend = 0,
colorOrder = 0,
milliampsPerLed = 55,
_disableNLeds = 0,
getBrightness(void),
getMode(void),
getSpeed(void),
@ -429,8 +437,7 @@ class WS2812FX {
uint16_t
ablMilliampsMax,
currentMilliamps,
triwave16(uint16_t),
getUsableCount();
triwave16(uint16_t);
uint32_t
timebase,
@ -562,7 +569,7 @@ class WS2812FX {
CRGBPalette16 targetPalette;
uint32_t now;
uint16_t _length, _lengthRaw, _usableCount;
uint16_t _length, _lengthRaw, _virtualSegmentLength;
uint16_t _rand16seed;
uint8_t _brightness;
static uint16_t _usedSegmentData;
@ -609,11 +616,13 @@ class WS2812FX {
uint8_t _segment_index = 0;
uint8_t _segment_index_palette_last = 99;
segment _segments[MAX_NUM_SEGMENTS] = { // SRAM footprint: 24 bytes per element
// start, stop, speed, intensity, palette, mode, options, 3 unused bytes (group, spacing, opacity), color[]
// start, stop, speed, intensity, palette, mode, options, grouping, spacing, opacity (unused), color[]
{ 0, 7, DEFAULT_SPEED, 128, 0, DEFAULT_MODE, NO_OPTIONS, 1, 0, 255, {DEFAULT_COLOR}}
};
segment_runtime _segment_runtimes[MAX_NUM_SEGMENTS]; // SRAM footprint: 28 bytes per element
friend class Segment_runtime;
uint16_t realPixelIndex(uint16_t i);
};

View File

@ -30,28 +30,16 @@
#define LED_SKIP_AMOUNT 1
#define MIN_SHOW_DELAY 15
void WS2812FX::init(bool supportWhite, uint16_t countPixels, bool skipFirst, uint8_t disableNLeds)
void WS2812FX::init(bool supportWhite, uint16_t countPixels, bool skipFirst)
{
if (supportWhite == _rgbwMode && countPixels == _length && disableNLeds == _disableNLeds) return;
if (supportWhite == _rgbwMode && countPixels == _length) return;
RESET_RUNTIME;
_rgbwMode = supportWhite;
_skipFirstMode = skipFirst;
_length = countPixels;
if (disableNLeds > 0) {
uint16_t groupCount = disableNLeds +1;
//since 1st led is lit, even partial group has a led lit, whereas int division truncates decimal.
bool hasExtraLight = _length % groupCount != 0;
_usableCount = _length/groupCount;
_usableCount += hasExtraLight ? 1 : 0;
} else {
_usableCount = _length;
}
_disableNLeds = disableNLeds;
uint8_t ty = 1;
if (supportWhite) ty =2;
if (supportWhite) ty = 2;
_lengthRaw = _length;
if (_skipFirstMode) {
_lengthRaw += LED_SKIP_AMOUNT;
@ -60,7 +48,7 @@ void WS2812FX::init(bool supportWhite, uint16_t countPixels, bool skipFirst, uin
bus->Begin((NeoPixelType)ty, _lengthRaw);
_segments[0].start = 0;
_segments[0].stop = _usableCount;
_segments[0].stop = _length;
setBrightness(_brightness);
}
@ -77,6 +65,7 @@ void WS2812FX::service() {
{
if(nowUp > SEGENV.next_time || _triggered || (doShow && SEGMENT.mode == 0)) //last is temporary
{
_virtualSegmentLength = SEGMENT.virtualLength();
doShow = true;
handle_palette();
uint16_t delay = (this->*_mode[SEGMENT.mode])();
@ -85,6 +74,7 @@ void WS2812FX::service() {
}
}
}
_virtualSegmentLength = 0;
if(doShow) {
yield();
show();
@ -100,67 +90,91 @@ void WS2812FX::setPixelColor(uint16_t n, uint32_t c) {
setPixelColor(n, r, g, b, w);
}
uint16_t WS2812FX::realPixelIndex(uint16_t i) {
int16_t iGroup = i * SEGMENT.groupLength();
/* reverse just an individual segment */
int16_t realIndex = iGroup;
if (IS_REVERSE) realIndex = SEGMENT.length() -iGroup -1;
realIndex += SEGMENT.start;
/* Reverse the whole string */
if (reverseMode) realIndex = _length - 1 - realIndex;
return realIndex;
}
void WS2812FX::setPixelColor(uint16_t i, byte r, byte g, byte b, byte w)
{
i = i * (_disableNLeds+1);
if (IS_REVERSE) i = SEGMENT.stop -1 -i + SEGMENT.start; //reverse just individual segment
byte tmpg = g;
switch (colorOrder) //0 = Grb, default
RgbwColor col;
switch (colorOrder)
{
case 0: break; //0 = Grb, default
case 1: g = r; r = tmpg; break; //1 = Rgb, common for WS2811
case 2: g = b; b = tmpg; break; //2 = Brg
case 3: g = b; b = r; r = tmpg; //3 = Rbg
case 0: col.G = g; col.R = r; col.B = b; break; //0 = GRB, default
case 1: col.G = r; col.R = g; col.B = b; break; //1 = RGB, common for WS2811
case 2: col.G = b; col.R = r; col.B = g; break; //2 = BRG
case 3: col.G = r; col.R = b; col.B = g; break; //3 = RBG
case 4: col.G = b; col.R = g; col.B = r; break; //4 = BGR
default: col.G = g; col.R = b; col.B = r; break; //5 = GBR
}
col.W = w;
if (!_cronixieMode)
{
if (reverseMode) i = _length -1 -i;
if (_skipFirstMode)
{
if (i < LED_SKIP_AMOUNT) bus->SetPixelColor(i, RgbwColor(0,0,0,0));
i += LED_SKIP_AMOUNT;
uint16_t skip = _skipFirstMode ? LED_SKIP_AMOUNT : 0;
if (SEGLEN) {//from segment
/* Set all the pixels in the group, ensuring _skipFirstMode is honored */
bool reversed = reverseMode ^ IS_REVERSE;
uint16_t realIndex = realPixelIndex(i);
for (uint16_t j = 0; j < SEGMENT.grouping; j++) {
int16_t indexSet = realIndex + (reversed ? -j : j);
if (indexSet >= SEGMENT.start && indexSet < SEGMENT.stop) bus->SetPixelColor(indexSet + skip, col);
}
} else { //live data, etc.
if (reverseMode) i = _length - 1 - i;
bus->SetPixelColor(i + skip, col);
}
if (i < _lengthRaw) bus->SetPixelColor(i, RgbwColor(r,g,b,w));
if (_disableNLeds > 0) {
for(uint16_t offCount=0; offCount < _disableNLeds; offCount++) {
if (i < _lengthRaw) bus->SetPixelColor((i + offCount + 1), RgbwColor(0,0,0,0));
if (skip && i == 0) {
for (uint16_t j = 0; j < skip; j++) {
bus->SetPixelColor(j, RgbwColor(0, 0, 0, 0));
}
}
} else {
if(i>6)return;
byte o = 10*i;
if (_cronixieBacklightEnabled && _cronixieDigits[i] <11)
return;
}
//CRONIXIE
if(i>6)return;
byte o = 10*i;
if (_cronixieBacklightEnabled && _cronixieDigits[i] <11)
{
byte r2 = _segments[0].colors[1] >>16;
byte g2 = _segments[0].colors[1] >> 8;
byte b2 = _segments[0].colors[1];
byte w2 = _segments[0].colors[1] >>24;
for (int j=o; j< o+19; j++)
{
byte r2 = _segments[0].colors[1] >>16;
byte g2 = _segments[0].colors[1] >> 8;
byte b2 = _segments[0].colors[1];
byte w2 = _segments[0].colors[1] >>24;
for (int j=o; j< o+19; j++)
{
bus->SetPixelColor(j, RgbwColor(r2,g2,b2,w2));
}
} else
{
for (int j=o; j< o+19; j++)
{
bus->SetPixelColor(j, RgbwColor(0,0,0,0));
}
bus->SetPixelColor(j, RgbwColor(r2,g2,b2,w2));
}
if (_skipFirstMode) o += LED_SKIP_AMOUNT;
switch(_cronixieDigits[i])
} else
{
for (int j=o; j< o+19; j++)
{
case 0: bus->SetPixelColor(o+5, RgbwColor(r,g,b,w)); break;
case 1: bus->SetPixelColor(o+0, RgbwColor(r,g,b,w)); break;
case 2: bus->SetPixelColor(o+6, RgbwColor(r,g,b,w)); break;
case 3: bus->SetPixelColor(o+1, RgbwColor(r,g,b,w)); break;
case 4: bus->SetPixelColor(o+7, RgbwColor(r,g,b,w)); break;
case 5: bus->SetPixelColor(o+2, RgbwColor(r,g,b,w)); break;
case 6: bus->SetPixelColor(o+8, RgbwColor(r,g,b,w)); break;
case 7: bus->SetPixelColor(o+3, RgbwColor(r,g,b,w)); break;
case 8: bus->SetPixelColor(o+9, RgbwColor(r,g,b,w)); break;
case 9: bus->SetPixelColor(o+4, RgbwColor(r,g,b,w)); break;
bus->SetPixelColor(j, RgbwColor(0,0,0,0));
}
}
if (_skipFirstMode) o += LED_SKIP_AMOUNT;
switch(_cronixieDigits[i])
{
case 0: bus->SetPixelColor(o+5, col); break;
case 1: bus->SetPixelColor(o+0, col); break;
case 2: bus->SetPixelColor(o+6, col); break;
case 3: bus->SetPixelColor(o+1, col); break;
case 4: bus->SetPixelColor(o+7, col); break;
case 5: bus->SetPixelColor(o+2, col); break;
case 6: bus->SetPixelColor(o+8, col); break;
case 7: bus->SetPixelColor(o+3, col); break;
case 8: bus->SetPixelColor(o+9, col); break;
case 9: bus->SetPixelColor(o+4, col); break;
}
}
void WS2812FX::driverModeCronixie(bool b)
@ -374,10 +388,8 @@ uint32_t WS2812FX::getColor(void) {
uint32_t WS2812FX::getPixelColor(uint16_t i)
{
i = i * (_disableNLeds+1);
if (reverseMode) i = _length- 1 -i;
if (IS_REVERSE) i = SEGMENT.stop -1 -i + SEGMENT.start; //reverse just individual segment
if (_skipFirstMode) i += LED_SKIP_AMOUNT;
i = realPixelIndex(i) + (_skipFirstMode ? LED_SKIP_AMOUNT : 0);
if (_cronixieMode)
{
if(i>6)return 0;
@ -398,16 +410,19 @@ uint32_t WS2812FX::getPixelColor(uint16_t i)
}
}
if (i >= _lengthRaw) return 0;
RgbwColor lColor = bus->GetPixelColorRgbw(i);
byte r = lColor.R, g = lColor.G, b = lColor.B;
RgbwColor col = bus->GetPixelColorRgbw(i);
switch (colorOrder)
{
case 0: break; //0 = Grb
case 1: r = lColor.G; g = lColor.R; break; //1 = Rgb, common for WS2811
case 2: g = lColor.B; b = lColor.G; break; //2 = Brg
case 3: r = lColor.B; g = lColor.R; b = lColor.G; //3 = Rbg
// W G R B
case 0: return ((col.W << 24) | (col.G << 8) | (col.R << 16) | (col.B)); //0 = GRB, default
case 1: return ((col.W << 24) | (col.R << 8) | (col.G << 16) | (col.B)); //1 = RGB, common for WS2811
case 2: return ((col.W << 24) | (col.B << 8) | (col.R << 16) | (col.G)); //2 = BRG
case 3: return ((col.W << 24) | (col.R << 8) | (col.B << 16) | (col.G)); //3 = RBG
case 4: return ((col.W << 24) | (col.B << 8) | (col.G << 16) | (col.R)); //4 = BGR
case 5: return ((col.W << 24) | (col.G << 8) | (col.B << 16) | (col.R)); //5 = GBR
}
return ( (lColor.W << 24) | (r << 16) | (g << 8) | (b) );
return 0;
}
WS2812FX::Segment& WS2812FX::getSegment(uint8_t id) {
@ -423,20 +438,18 @@ WS2812FX::Segment* WS2812FX::getSegments(void) {
return _segments;
}
uint16_t WS2812FX::getUsableCount(void) {
return _usableCount;
}
uint32_t WS2812FX::getLastShow(void) {
return _lastShow;
}
void WS2812FX::setSegment(uint8_t n, uint16_t i1, uint16_t i2) {
void WS2812FX::setSegment(uint8_t n, uint16_t i1, uint16_t i2, uint8_t grouping, uint8_t spacing) {
if (n >= MAX_NUM_SEGMENTS) return;
Segment& seg = _segments[n];
if (seg.start == i1 && seg.stop == i2) return;
_segment_index = n; fill(0); //turn old segment range off
//return if neither bounds nor grouping have changed
if (seg.start == i1 && seg.stop == i2 && (!grouping || (seg.grouping == grouping && seg.spacing == spacing))) return;
if (seg.stop) setRange(seg.start, seg.stop -1, 0); //turn old segment range off
if (i2 <= i1) //disable segment
{
seg.stop = 0; return;
@ -444,6 +457,10 @@ void WS2812FX::setSegment(uint8_t n, uint16_t i1, uint16_t i2) {
if (i1 < _length) seg.start = i1;
seg.stop = i2;
if (i2 > _length) seg.stop = _length;
if (grouping) {
seg.grouping = grouping;
seg.spacing = spacing;
}
_segment_runtimes[n].reset();
}
@ -456,10 +473,12 @@ void WS2812FX::resetSegments() {
_segments[0].start = 0;
_segments[0].speed = DEFAULT_SPEED;
_segments[0].stop = _length;
_segments[0].grouping = 1;
_segments[0].setOption(0, 1); //select
for (uint16_t i = 1; i < MAX_NUM_SEGMENTS; i++)
{
_segments[i].colors[0] = color_wheel(i*51);
_segments[i].grouping = 1;
_segment_runtimes[i].reset();
}
_segment_runtimes[0].reset();
@ -519,7 +538,7 @@ uint32_t WS2812FX::color_blend(uint32_t color1, uint32_t color2, uint8_t blend)
* Fills segment with color
*/
void WS2812FX::fill(uint32_t c) {
for(uint16_t i=SEGMENT.start; i < SEGMENT.stop; i++) {
for(uint16_t i = 0; i < SEGLEN; i++) {
setPixelColor(i, c);
}
}
@ -537,7 +556,7 @@ void WS2812FX::fade_out(uint8_t rate) {
int g2 = (color >> 8) & 0xff;
int b2 = color & 0xff;
for(uint16_t i=SEGMENT.start; i < SEGMENT.stop; i++) {
for(uint16_t i = 0; i < SEGLEN; i++) {
color = getPixelColor(i);
int w1 = (color >> 24) & 0xff;
int r1 = (color >> 16) & 0xff;
@ -567,14 +586,14 @@ void WS2812FX::blur(uint8_t blur_amount)
uint8_t keep = 255 - blur_amount;
uint8_t seep = blur_amount >> 1;
CRGB carryover = CRGB::Black;
for(uint16_t i = SEGMENT.start; i < SEGMENT.stop; i++)
for(uint16_t i = 0; i < SEGLEN; i++)
{
CRGB cur = col_to_crgb(getPixelColor(i));
CRGB part = cur;
part.nscale8(seep);
cur.nscale8(keep);
cur += carryover;
if(i > SEGMENT.start) {
if(i > 0) {
uint32_t c = getPixelColor(i-1);
uint8_t r = (c >> 16 & 0xFF);
uint8_t g = (c >> 8 & 0xFF);
@ -739,7 +758,7 @@ uint32_t WS2812FX::color_from_palette(uint16_t i, bool mapping, bool wrap, uint8
{
if (SEGMENT.palette == 0 && mcol < 3) return SEGCOLOR(mcol); //WS2812FX default
uint8_t paletteIndex = i;
if (mapping) paletteIndex = map(i,SEGMENT.start,SEGMENT.stop-1,0,255);
if (mapping) paletteIndex = (i*255)/(SEGLEN -1);
if (!wrap) paletteIndex = scale8(paletteIndex, 240); //cut off blend at palette "end"
CRGB fastled_col;
fastled_col = ColorFromPalette( currentPalette, paletteIndex, pbri, (paletteBlend == 3)? NOBLEND:LINEARBLEND);

View File

@ -123,6 +123,8 @@ Color order:
<option value=1>RGB</option>
<option value=2>BRG</option>
<option value=3>RBG</option>
<option value=4>BGR</option>
<option value=5>GBR</option>
</select>
<h3>Defaults</h3>
Turn LEDs on after power up/reset: <input type=checkbox name=BO><br>
@ -150,9 +152,7 @@ Palette blending:
<option value=3>None (not recommended)</option>
</select><br>
Reverse LED order (rotate 180): <input type=checkbox name=RV><br>
Skip first LED: <input type=checkbox name=SL><br>
Disable repeating N LEDs: <input type=number min=0 max=255 name=DL><br>
(Turns off N LEDs between each lit one, spacing out effects)<hr>
Skip first LED: <input type=checkbox name=SL><hr>
<button type=button onclick=B()>Back</button><button type=submit>Save</button>
</form></body></html>)=====";

View File

@ -90,7 +90,8 @@
#endif
//version code in format yymmddb (b = daily build)
#define VERSION 2001131
#define VERSION 2001142
char versionString[] = "0.9.0-b2";
@ -142,7 +143,6 @@ bool enableSecTransition = true; //also enable transition for secon
uint16_t transitionDelay = 750; //default crossfade duration in ms
bool skipFirstLed = false; //ignore first LED in strip (useful if you need the LED as signal repeater)
uint8_t disableNLeds = 0; //disables N LEDs between active nodes. (Useful for spacing out lights for more traditional christmas light look)
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)

View File

@ -230,8 +230,6 @@ void saveSettingsToEEPROM()
saveCurrPresetCycConf = false;
}
EEPROM.write(2213, disableNLeds);
writeStringToEEPROM(2220, blynkApiKey, 35);
for (int i = 0; i < 8; ++i)
@ -490,8 +488,6 @@ void loadSettingsFromEEPROM(bool first)
presetApplyFx = EEPROM.read(2212);
}
disableNLeds = EEPROM.read(2213);
bootPreset = EEPROM.read(389);
wifiLock = EEPROM.read(393);
utcOffsetSecs = EEPROM.read(394) + ((EEPROM.read(395) << 8) & 0xFF00);

View File

@ -237,7 +237,6 @@ void getSettingsJS(byte subPage, char* dest)
sappend('i',"PB",strip.paletteBlend);
sappend('c',"RV",strip.reverseMode);
sappend('c',"SL",skipFirstLed);
sappend('v',"DL",disableNLeds);
}
if (subPage == 3)

View File

@ -104,7 +104,6 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
if (t >= 0 && t < 4) strip.paletteBlend = t;
strip.reverseMode = request->hasArg("RV");
skipFirstLed = request->hasArg("SL");
disableNLeds = request->arg("DL").toInt();
t = request->arg("BF").toInt();
if (t > 0) briMultiplier = t;
}
@ -290,7 +289,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
}
if (subPage != 6 || !doReboot) saveSettingsToEEPROM(); //do not save if factory reset
if (subPage == 2) {
strip.init(useRGBW,ledCount,skipFirstLed,disableNLeds);
strip.init(useRGBW,ledCount,skipFirstLed);
}
if (subPage == 4) alexaInit();
}

View File

@ -8,10 +8,6 @@ void wledInit()
ledCount = EEPROM.read(229) + ((EEPROM.read(398) << 8) & 0xFF00);
if (ledCount > MAX_LEDS || ledCount == 0) ledCount = 30;
disableNLeds = EEPROM.read(2213);
//this was reading 255 after inital flash causing bootloop. Don't know why.
disableNLeds = disableNLeds != 255 ? disableNLeds : 0;
#ifdef ESP8266
#if LEDPIN == 3
if (ledCount > MAX_LEDS_DMA) ledCount = MAX_LEDS_DMA; //DMA method uses too much ram
@ -30,7 +26,7 @@ void wledInit()
DEBUG_PRINT("heap ");
DEBUG_PRINTLN(ESP.getFreeHeap());
strip.init(EEPROM.read(372),ledCount,EEPROM.read(2204),disableNLeds); //init LEDs quickly
strip.init(EEPROM.read(372),ledCount,EEPROM.read(2204)); //init LEDs quickly
strip.setBrightness(0);
DEBUG_PRINT("LEDs inited. heap usage ~");

View File

@ -15,7 +15,9 @@ void deserializeSegment(JsonObject elem, byte it)
uint16_t len = elem["len"];
stop = (len > 0) ? start + len : seg.stop;
}
strip.setSegment(id, start, stop);
uint16_t grp = elem["grp"] | seg.grouping;
uint16_t spc = elem["spc"] | seg.spacing;
strip.setSegment(id, start, stop, grp, spc);
JsonArray colarr = elem["col"];
if (!colarr.isNull())
@ -166,6 +168,8 @@ void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id)
root["start"] = seg.start;
root["stop"] = seg.stop;
root["len"] = seg.stop - seg.start;
root["grp"] = seg.grouping;
root["spc"] = seg.spacing;
JsonArray colarr = root.createNestedArray("col");
@ -359,7 +363,7 @@ void serveJson(AsyncWebServerRequest* request)
void serveLiveLeds(AsyncWebServerRequest* request)
{
byte used = strip.getUsableCount();
byte used = ledCount;
byte n = (used -1) /MAX_LIVE_LEDS +1; //only serve every n'th LED if count over MAX_LIVE_LEDS
char buffer[2000] = "{\"leds\":[";
olen = 9;