Rewritten police_base effect.
Optimisation in 4LD.
This commit is contained in:
parent
c436b586d2
commit
3a83753611
@ -347,7 +347,6 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
(knownMode != strip.getMode()) ||
|
(knownMode != strip.getMode()) ||
|
||||||
(knownPalette != strip.getSegment(0).palette)) {
|
(knownPalette != strip.getSegment(0).palette)) {
|
||||||
knownHour = 99; // force time update
|
knownHour = 99; // force time update
|
||||||
clear();
|
|
||||||
} else if (sleepMode && !displayTurnedOff && ((now - lastRedraw)/1000)%5 == 0) {
|
} else if (sleepMode && !displayTurnedOff && ((now - lastRedraw)/1000)%5 == 0) {
|
||||||
// change line every 5s
|
// change line every 5s
|
||||||
showName = !showName;
|
showName = !showName;
|
||||||
@ -528,7 +527,6 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Print the overlay
|
// Print the overlay
|
||||||
clear();
|
|
||||||
if (line1) drawString(0, 1*lineHeight, line1);
|
if (line1) drawString(0, 1*lineHeight, line1);
|
||||||
if (line2) drawString(0, 2*lineHeight, line2);
|
if (line2) drawString(0, 2*lineHeight, line2);
|
||||||
overlayUntil = millis() + showHowLong;
|
overlayUntil = millis() + showHowLong;
|
||||||
@ -562,6 +560,7 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
else setPowerSave(1);
|
else setPowerSave(1);
|
||||||
displayTurnedOff = true;
|
displayTurnedOff = true;
|
||||||
} else {
|
} else {
|
||||||
|
clear();
|
||||||
setPowerSave(0);
|
setPowerSave(0);
|
||||||
displayTurnedOff = false;
|
displayTurnedOff = false;
|
||||||
}
|
}
|
||||||
@ -582,8 +581,6 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
if (knownMinute == minuteCurrent && knownHour == hourCurrent) {
|
if (knownMinute == minuteCurrent && knownHour == hourCurrent) {
|
||||||
// Time hasn't changed.
|
// Time hasn't changed.
|
||||||
if (!fullScreen) return;
|
if (!fullScreen) return;
|
||||||
} else {
|
|
||||||
//if (fullScreen) clear();
|
|
||||||
}
|
}
|
||||||
knownMinute = minuteCurrent;
|
knownMinute = minuteCurrent;
|
||||||
knownHour = hourCurrent;
|
knownHour = hourCurrent;
|
||||||
|
@ -1216,44 +1216,17 @@ uint16_t WS2812FX::mode_loading(void) {
|
|||||||
|
|
||||||
|
|
||||||
//American Police Light with all LEDs Red and Blue
|
//American Police Light with all LEDs Red and Blue
|
||||||
uint16_t WS2812FX::police_base(uint32_t color1, uint32_t color2, bool all)
|
uint16_t WS2812FX::police_base(uint32_t color1, uint32_t color2, uint16_t width)
|
||||||
{
|
{
|
||||||
uint16_t counter = now * ((SEGMENT.speed >> 2) +1);
|
uint32_t it = now / map(SEGMENT.speed, 0, 255, 96, 12);
|
||||||
uint16_t idexR = (counter * SEGLEN) >> 16;
|
uint16_t offset = it % SEGLEN;
|
||||||
if (idexR >= SEGLEN) idexR = 0;
|
|
||||||
|
|
||||||
uint16_t topindex = SEGLEN >> 1;
|
|
||||||
uint16_t idexB = (idexR > topindex) ? idexR - topindex : idexR + topindex;
|
|
||||||
if (SEGENV.call == 0) SEGENV.aux0 = idexR;
|
|
||||||
if (idexB >= SEGLEN) idexB = 0; //otherwise overflow on odd number of LEDs
|
|
||||||
|
|
||||||
if (all) { //different algo, ensuring immediate fill
|
|
||||||
if (idexB > idexR) {
|
|
||||||
fill(color2);
|
|
||||||
for (uint16_t i = idexR; i < idexB; i++) setPixelColor(i, color1);
|
|
||||||
} else {
|
|
||||||
fill(color1);
|
|
||||||
for (uint16_t i = idexB; i < idexR; i++) setPixelColor(i, color2);
|
|
||||||
}
|
|
||||||
} else { //regular dot-only mode
|
|
||||||
uint8_t size = 1 + (SEGMENT.intensity >> 3);
|
|
||||||
if (size > SEGLEN/2) size = 1+ SEGLEN/2;
|
|
||||||
for (uint8_t i=0; i <= size; i++) {
|
|
||||||
setPixelColor(idexR+i, color1);
|
|
||||||
setPixelColor(idexB+i, color2);
|
|
||||||
}
|
|
||||||
if (SEGENV.aux0 != idexR) {
|
|
||||||
uint8_t gap = (SEGENV.aux0 < idexR)? idexR - SEGENV.aux0:SEGLEN - SEGENV.aux0 + idexR;
|
|
||||||
for (uint8_t i = 0; i <= gap ; i++) {
|
|
||||||
if ((idexR - i) < 0) idexR = SEGLEN-1 + i;
|
|
||||||
if ((idexB - i) < 0) idexB = SEGLEN-1 + i;
|
|
||||||
setPixelColor(idexR-i, color1);
|
|
||||||
setPixelColor(idexB-i, color2);
|
|
||||||
}
|
|
||||||
SEGENV.aux0 = idexR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
for (uint16_t i = 0; i < width; i++) {
|
||||||
|
uint16_t indexR = (offset + i) % SEGLEN;
|
||||||
|
uint16_t indexB = (offset + i + (SEGLEN>>1)) % SEGLEN;
|
||||||
|
setPixelColor(indexR, color1);
|
||||||
|
setPixelColor(indexB, color2);
|
||||||
|
}
|
||||||
return FRAMETIME;
|
return FRAMETIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1261,23 +1234,22 @@ uint16_t WS2812FX::police_base(uint32_t color1, uint32_t color2, bool all)
|
|||||||
//American Police Light with all LEDs Red and Blue
|
//American Police Light with all LEDs Red and Blue
|
||||||
uint16_t WS2812FX::mode_police_all()
|
uint16_t WS2812FX::mode_police_all()
|
||||||
{
|
{
|
||||||
return police_base(RED, BLUE, true);
|
return police_base(RED, BLUE, (SEGLEN>>1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Police Lights Red and Blue
|
//Police Lights Red and Blue
|
||||||
uint16_t WS2812FX::mode_police()
|
uint16_t WS2812FX::mode_police()
|
||||||
{
|
{
|
||||||
fill(SEGCOLOR(1));
|
fill(BLACK);
|
||||||
|
return police_base(RED, BLUE, (1 + ((SEGLEN*SEGMENT.intensity)>>9)));
|
||||||
return police_base(RED, BLUE, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Police All with custom colors
|
//Police All with custom colors
|
||||||
uint16_t WS2812FX::mode_two_areas()
|
uint16_t WS2812FX::mode_two_areas()
|
||||||
{
|
{
|
||||||
return police_base(SEGCOLOR(0), SEGCOLOR(1), true);
|
return police_base(SEGCOLOR(0), SEGCOLOR(1), (SEGLEN>>1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1287,7 +1259,7 @@ uint16_t WS2812FX::mode_two_dots()
|
|||||||
fill(SEGCOLOR(2));
|
fill(SEGCOLOR(2));
|
||||||
uint32_t color2 = (SEGCOLOR(1) == SEGCOLOR(2)) ? SEGCOLOR(0) : SEGCOLOR(1);
|
uint32_t color2 = (SEGCOLOR(1) == SEGCOLOR(2)) ? SEGCOLOR(0) : SEGCOLOR(1);
|
||||||
|
|
||||||
return police_base(SEGCOLOR(0), color2, false);
|
return police_base(SEGCOLOR(0), color2, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1295,21 +1267,20 @@ uint16_t WS2812FX::mode_two_dots()
|
|||||||
* Tricolor chase function
|
* Tricolor chase function
|
||||||
*/
|
*/
|
||||||
uint16_t WS2812FX::tricolor_chase(uint32_t color1, uint32_t color2) {
|
uint16_t WS2812FX::tricolor_chase(uint32_t color1, uint32_t color2) {
|
||||||
uint32_t cycleTime = 50 + (255 - SEGMENT.speed)*2;
|
uint32_t cycleTime = 50 + ((255 - SEGMENT.speed)<<1);
|
||||||
uint32_t it = now / cycleTime;
|
uint32_t it = now / cycleTime; // iterator
|
||||||
uint8_t width = (1 + SEGMENT.intensity/32) * 3; //value of 1-8 for each colour
|
uint8_t width = (1 + (SEGMENT.intensity>>4)); // value of 1-16 for each colour
|
||||||
uint8_t index = it % width;
|
uint8_t index = it % (width*3);
|
||||||
|
|
||||||
for(uint16_t i = 0; i < SEGLEN; i++, index++) {
|
for (uint16_t i = 0; i < SEGLEN; i++, index++) {
|
||||||
if(index > width-1) index = 0;
|
if (index > (width*3)-1) index = 0;
|
||||||
|
|
||||||
uint32_t color = color1;
|
uint32_t color = color1;
|
||||||
if(index > width*2/3-1) color = color_from_palette(i, true, PALETTE_SOLID_WRAP, 1);
|
if (index > (width<<1)-1) color = color_from_palette(i, true, PALETTE_SOLID_WRAP, 1);
|
||||||
else if(index > width/3-1) color = color2;
|
else if (index > width-1) color = color2;
|
||||||
|
|
||||||
setPixelColor(SEGLEN - i -1, color);
|
setPixelColor(SEGLEN - i -1, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
return FRAMETIME;
|
return FRAMETIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -853,7 +853,7 @@ class WS2812FX {
|
|||||||
chase(uint32_t, uint32_t, uint32_t, bool),
|
chase(uint32_t, uint32_t, uint32_t, bool),
|
||||||
gradient_base(bool),
|
gradient_base(bool),
|
||||||
ripple_base(bool),
|
ripple_base(bool),
|
||||||
police_base(uint32_t, uint32_t, bool),
|
police_base(uint32_t, uint32_t, uint16_t),
|
||||||
running(uint32_t, uint32_t, bool theatre=false),
|
running(uint32_t, uint32_t, bool theatre=false),
|
||||||
tricolor_chase(uint32_t, uint32_t),
|
tricolor_chase(uint32_t, uint32_t),
|
||||||
twinklefox_base(bool),
|
twinklefox_base(bool),
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// version code in format yymmddb (b = daily build)
|
// version code in format yymmddb (b = daily build)
|
||||||
#define VERSION 2109061
|
#define VERSION 2109071
|
||||||
|
|
||||||
//uncomment this if you have a "my_config.h" file you'd like to use
|
//uncomment this if you have a "my_config.h" file you'd like to use
|
||||||
//#define WLED_USE_MY_CONFIG
|
//#define WLED_USE_MY_CONFIG
|
||||||
|
Loading…
Reference in New Issue
Block a user