diff --git a/CHANGELOG.md b/CHANGELOG.md index 33bdd5f18..d482a0059 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ ## WLED changelog +### Builds after release 0.12.0 + +#### Build 2104030 + +- Fixed ESP32 crash on Drip effect with reversed segment (#1854) +- Added flag `WLED_DISABLE_BROWNOUT_DET` to disable ESP32 brownout detector (off by default) + #### Build 2104020 - Allow clearing button/IR/relay pin on platforms that don't support negative numbers diff --git a/wled00/FX.cpp b/wled00/FX.cpp index cc712bf46..28c3be6b6 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -3034,7 +3034,7 @@ uint16_t WS2812FX::mode_exploding_fireworks(void) uint16_t WS2812FX::mode_drip(void) { //allocate segment data - uint16_t numDrops = 4; + uint8_t numDrops = 4; uint16_t dataSize = sizeof(spark) * numDrops; if (!SEGENV.allocateData(dataSize)) return mode_static(); //allocation failed @@ -3042,13 +3042,13 @@ uint16_t WS2812FX::mode_drip(void) Spark* drops = reinterpret_cast(SEGENV.data); - numDrops = 1 + (SEGMENT.intensity >> 6); + numDrops = 1 + (SEGMENT.intensity >> 6); // 255>>6 = 3 float gravity = -0.001 - (SEGMENT.speed/50000.0); gravity *= SEGLEN; int sourcedrop = 12; - for (int j=0;j255) drops[j].col=255; - setPixelColor(int(drops[j].pos),color_blend(BLACK,SEGCOLOR(0),drops[j].col)); - + setPixelColor(uint16_t(drops[j].pos),color_blend(BLACK,SEGCOLOR(0),drops[j].col)); + drops[j].col += map(SEGMENT.speed, 0, 255, 1, 6); // swelling if (random8() < drops[j].col/10) { // random drop @@ -3072,12 +3072,12 @@ uint16_t WS2812FX::mode_drip(void) if (drops[j].pos > 0) { // fall until end of segment drops[j].pos += drops[j].vel; if (drops[j].pos < 0) drops[j].pos = 0; - drops[j].vel += gravity; + drops[j].vel += gravity; // gravity is negative - for (int i=1;i<7-drops[j].colIndex;i++) { // some minor math so we don't expand bouncing droplets - setPixelColor(int(drops[j].pos)+i,color_blend(BLACK,SEGCOLOR(0),drops[j].col/i)); //spread pixel with fade while falling + for (uint8_t i=1;i<7-drops[j].colIndex;i++) { // some minor math so we don't expand bouncing droplets + setPixelColor(MIN(uint16_t(drops[j].pos)+i,SEGLEN-1),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(0,color_blend(SEGCOLOR(0),BLACK,drops[j].col)); } diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index b1961ed29..3c0e4247a 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -206,12 +206,12 @@ void WS2812FX::setPixelColor(uint16_t i, byte r, byte g, byte b, byte w) uint16_t realIndex = realPixelIndex(i); for (uint16_t j = 0; j < SEGMENT.grouping; j++) { - int16_t indexSet = realIndex + (IS_REVERSE ? -j : j); + uint16_t indexSet = realIndex + (IS_REVERSE ? -j : j); if (indexSet >= SEGMENT.start && indexSet < SEGMENT.stop) { // watch for group out of bounds condition if (IS_MIRROR) { //set the corresponding mirrored pixel - int16_t indexSetRev = SEGMENT.stop + SEGMENT.start - indexSet - 1; - if (indexSetRev < customMappingSize) indexSetRev = customMappingTable[indexSetRev]; - busses.setPixelColor(indexSetRev, col); + uint16_t indexMir = SEGMENT.stop + SEGMENT.start - indexSet - 1; + if (indexMir < customMappingSize) indexMir = customMappingTable[indexMir]; + busses.setPixelColor(indexMir, col); } if (indexSet < customMappingSize) indexSet = customMappingTable[indexSet]; busses.setPixelColor(indexSet, col); diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 30cb9cb86..b82060cf0 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -2,6 +2,11 @@ #include "wled.h" #include +#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_DISABLE_BROWNOUT_DET) +#include "soc/soc.h" +#include "soc/rtc_cntl_reg.h" +#endif + /* * Main WLED class implementation. Mostly initialization and connection logic */ @@ -290,6 +295,10 @@ void WLED::loop() void WLED::setup() { + #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_DISABLE_BROWNOUT_DET) + WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detection + #endif + Serial.begin(115200); Serial.setTimeout(50); DEBUG_PRINTLN(); @@ -337,7 +346,7 @@ void WLED::setup() DEBUG_PRINTLN(F("Reading config")); deserializeConfig(); - +/* #if STATUSLED bool lStatusLed = false; for (uint8_t i=0; i #ifdef ESP8266