Fix Police All, Sinelon and Lighthouse (Comet) effects (#634)

pull/640/head
Def3nder 2020-01-28 13:48:59 +01:00 zatwierdzone przez Aircoookie
rodzic 2b0a38d25d
commit f3b399b31f
2 zmienionych plików z 40 dodań i 15 usunięć

Wyświetl plik

@ -1025,15 +1025,22 @@ uint16_t WS2812FX::larson_scanner(bool dual) {
/* /*
* Firing comets from one end. * Firing comets from one end. "Lighthouse"
*/ */
uint16_t WS2812FX::mode_comet(void) { uint16_t WS2812FX::mode_comet(void) {
uint16_t counter = now * (SEGMENT.speed >>3) +1; uint16_t counter = now * ((SEGMENT.speed >>2) +1);
uint16_t index = counter * SEGLEN >> 16; uint16_t index = counter * SEGLEN >> 16;
if (SEGENV.call == 0) SEGENV.aux0 = index;
fade_out(SEGMENT.intensity); fade_out(SEGMENT.intensity);
setPixelColor( index, color_from_palette(index, true, PALETTE_SOLID_WRAP, 0)); setPixelColor( index, color_from_palette(index, true, PALETTE_SOLID_WRAP, 0));
if (index > SEGENV.aux0) {
for (uint16_t i = SEGENV.aux0; i < index ; i++) {
setPixelColor( i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
}
}
SEGENV.aux0 = index++;
return FRAMETIME; return FRAMETIME;
} }
@ -1172,19 +1179,26 @@ 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) uint16_t WS2812FX::police_base(uint32_t color1, uint32_t color2)
{ {
uint16_t counter = now * ((SEGMENT.speed >> 3) +1); uint16_t counter = now * ((SEGMENT.speed >> 2) +1);
uint16_t idexR = (counter * SEGLEN) >> 16; uint16_t idexR = (counter * SEGLEN) >> 16;
if (idexR >= SEGLEN) idexR = 0; if (idexR >= SEGLEN) idexR = 0;
uint16_t topindex = SEGLEN >> 1; uint16_t topindex = SEGLEN >> 1;
uint16_t idexB = idexR + topindex; uint16_t idexB = idexR + topindex;
if (SEGENV.call == 0) SEGENV.aux0 = idexR;
if (idexR > topindex) idexB -= SEGLEN; if (idexR > topindex) idexB -= SEGLEN;
if (idexB >= SEGLEN) idexB = 0; //otherwise overflow on odd number of LEDs if (idexB >= SEGLEN) idexB = 0; //otherwise overflow on odd number of LEDs
setPixelColor(idexR, color1); uint8_t gap = (SEGENV.aux0 < idexR)? idexR - SEGENV.aux0:SEGLEN - SEGENV.aux0 + idexR;
setPixelColor(idexB, color2); 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;
return FRAMETIME; return FRAMETIME;
} }
@ -2486,22 +2500,33 @@ uint16_t WS2812FX::mode_bouncing_balls(void) {
*/ */
uint16_t WS2812FX::sinelon_base(bool dual, bool rainbow=false) { uint16_t WS2812FX::sinelon_base(bool dual, bool rainbow=false) {
fade_out(SEGMENT.intensity); fade_out(SEGMENT.intensity);
int pos = beatsin16(SEGMENT.speed/10,0,SEGLEN-1); uint16_t pos = beatsin16(SEGMENT.speed/10,0,SEGLEN-1);
if (SEGENV.call == 0) SEGENV.aux0 = pos;
uint32_t color1 = color_from_palette(pos, true, false, 0); uint32_t color1 = color_from_palette(pos, true, false, 0);
uint32_t color2 = SEGCOLOR(2);
if (rainbow) { if (rainbow) {
color1 = color_wheel((pos & 0x07) * 32); color1 = color_wheel((pos & 0x07) * 32);
} }
setPixelColor(pos, color1); setPixelColor(pos, color1);
if (dual) { if (dual) {
uint32_t color2 = SEGCOLOR(2);
if (!color2) color2 = color_from_palette(pos, true, false, 0); if (!color2) color2 = color_from_palette(pos, true, false, 0);
if (rainbow) color2 = color1; //rainbow if (rainbow) color2 = color1; //rainbow
setPixelColor(SEGLEN-1-pos, color2); setPixelColor(SEGLEN-1-pos, color2);
} }
if (SEGENV.aux0 != pos) {
if (SEGENV.aux0 < pos) {
for (uint16_t i = SEGENV.aux0; i < pos ; i++) {
setPixelColor(i, color1);
if (dual) setPixelColor(SEGLEN-1-i, color2);
}
} else {
for (uint16_t i = SEGENV.aux0; i > pos ; i--) {
setPixelColor(i, color1);
if (dual) setPixelColor(SEGLEN-1-i, color2);
}
}
SEGENV.aux0 = pos;
}
return FRAMETIME; return FRAMETIME;
} }

Wyświetl plik

@ -34,7 +34,7 @@
#define RPIN 15 //R pin for analog LED strip #define RPIN 15 //R pin for analog LED strip
#define GPIN 13 //G pin for analog LED strip #define GPIN 13 //G pin for analog LED strip
#define BPIN 12 //B pin for analog LED strip #define BPIN 12 //B pin for analog LED strip
#define WPIN 14 //W pin for analog LED strip (W1: 14, W2: 04) #define WPIN 14 //W pin for analog LED strip
#define W2PIN 04 //W2 pin for analog LED strip #define W2PIN 04 //W2 pin for analog LED strip
#undef BTNPIN #undef BTNPIN
#undef IR_PIN #undef IR_PIN
@ -44,7 +44,7 @@
#define RPIN 5 //R pin for analog LED strip #define RPIN 5 //R pin for analog LED strip
#define GPIN 12 //G pin for analog LED strip #define GPIN 12 //G pin for analog LED strip
#define BPIN 15 //B pin for analog LED strip #define BPIN 15 //B pin for analog LED strip
#define WPIN 13 //W pin for analog LED strip (W1: 14, W2: 04) #define WPIN 13 //W pin for analog LED strip
#endif #endif
#undef RLYPIN #undef RLYPIN
#define RLYPIN -1 //disable as pin 12 is used by analog LEDs #define RLYPIN -1 //disable as pin 12 is used by analog LEDs