Improved colortwinkles on longer strips

Added offMode
This commit is contained in:
cschwinne 2018-12-16 20:38:00 +01:00
parent d3fc0309c0
commit bec745d095
2 changed files with 29 additions and 12 deletions

View File

@ -2582,16 +2582,19 @@ uint16_t WS2812FX::mode_colortwinkle()
setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
}
}
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(SEGMENT_LENGTH);
if(getPixelColor(i) == 0) {
fastled_col = ColorFromPalette(currentPalette, random8(), 64, NOBLEND);
_locked[i] = true;
setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
return 20; //only spawn 1 new pixel per frame
for (uint16_t j = 0; j <= SEGMENT_LENGTH / 50; j++)
{
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(SEGMENT_LENGTH);
if(getPixelColor(i) == 0) {
fastled_col = ColorFromPalette(currentPalette, random8(), 64, NOBLEND);
_locked[i] = true;
setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
break; //only spawn 1 new pixel per frame per 50 LEDs
}
}
}
}

View File

@ -74,7 +74,7 @@
//version code in format yymmddb (b = daily build)
#define VERSION 1812052
#define VERSION 1812141
char versionString[] = "0.8.2";
@ -271,6 +271,8 @@ unsigned long nightlightStartTime;
byte briNlT = 0; //current nightlight brightness
//brightness
bool offMode = false;
unsigned long lastOnTime = 0;
byte bri = briS;
byte briOld = 0;
byte briT = 0;
@ -528,7 +530,19 @@ void loop() {
handleHue();
handleBlynk();
}
if (briT) strip.service(); //do not update strip if off, prevents flicker on ESP32
if (briT) lastOnTime = millis();
if (millis() - lastOnTime < 600)
{
offMode = false;
strip.service();
} else if (!offMode)
{
/*#if LEDPIN == 2 //turn off onboard LED
pinMode(2, OUTPUT);
digitalWrite(2, HIGH);
#endif*/
offMode = true;
}
}
//DEBUG serial logging