diff --git a/platformio.ini b/platformio.ini index 6532f467..19c18bab 100644 --- a/platformio.ini +++ b/platformio.ini @@ -95,16 +95,6 @@ debug_flags = -D DEBUG=1 -D WLED_DEBUG -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_CLIENT # This reduces the OTA size with ~45KB, so it's especially useful on low memory boards (512k/1m). # ------------------------------------------------------------------------------ build_flags = - -Wno-switch - -Wno-deprecated-declarations - -Wno-write-strings - -Wno-unused-variable - -Wno-unused-value - -Wno-sign-compare - -Wno-unused-but-set-variable - -Wno-return-type - -Wno-sequence-point - -Wno-narrowing -DMQTT_MAX_PACKET_SIZE=1024 -DSECURE_CLIENT=SECURE_CLIENT_BEARSSL -DBEARSSL_SSL_BASIC @@ -121,9 +111,6 @@ build_flags = ; -D USERMOD_SENSORSTOMQTT build_unflags = - -Wall - -Wreorder - -Wdeprecated-declarations # enables all features for travis CI build_flags_all_features = @@ -159,7 +146,7 @@ build_flags = -DMIMETYPE_MINIMAL [esp32] -build_flags = -w -g +build_flags = -g -DARDUINO_ARCH_ESP32 -DCONFIG_LITTLEFS_FOR_IDF_3_2 @@ -197,7 +184,7 @@ lib_deps = AsyncTCP @ 1.0.3 IRremoteESP8266 @ 2.7.3 https://github.com/lorol/LITTLEFS.git - https://github.com/Aircoookie/ESPAsyncWebServer.git @ ~2.0.0 + https://github.com/Aircoookie/ESPAsyncWebServer.git @ ~2.0.2 #For use of the TTGO T-Display ESP32 Module with integrated TFT display uncomment the following line #TFT_eSPI #For use SSD1306 OLED display uncomment following diff --git a/wled00/FX.cpp b/wled00/FX.cpp index e0172261..e813741a 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -516,7 +516,7 @@ uint16_t WS2812FX::dissolve(uint32_t color) { } } - if (SEGENV.call > (255 - SEGMENT.speed) + 15) + if (SEGENV.call > (255 - SEGMENT.speed) + 15U) { SEGENV.aux0 = !SEGENV.aux0; SEGENV.call = 0; @@ -1003,7 +1003,7 @@ uint16_t WS2812FX::mode_running_random(void) { } SEGENV.step++; - if (SEGENV.step > ((255-SEGMENT.intensity) >> 4)) + if (SEGENV.step > (uint8_t)((255-SEGMENT.intensity) >> 4)) { SEGENV.step = 0; } @@ -1537,9 +1537,9 @@ uint16_t WS2812FX::mode_oscillate(void) if (SEGENV.call == 0) { - oscillators[0] = {SEGLEN/4, SEGLEN/8, 1, 1}; - oscillators[1] = {SEGLEN/4*3, SEGLEN/8, 1, 2}; - oscillators[2] = {SEGLEN/4*2, SEGLEN/8, -1, 1}; + oscillators[0] = {(int16_t)(SEGLEN/4), (int8_t)(SEGLEN/8), 1, 1}; + oscillators[1] = {(int16_t)(SEGLEN/4*3), (int8_t)(SEGLEN/8), 1, 2}; + oscillators[2] = {(int16_t)(SEGLEN/4*2), (int8_t)(SEGLEN/8), -1, 1}; } uint32_t cycleTime = 20 + (2 * (uint32_t)(255 - SEGMENT.speed)); @@ -1888,7 +1888,6 @@ uint16_t WS2812FX::mode_noise16_2() 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; uint32_t real_x = (i + shift_x) * scale; // calculate the coordinates within the noise field @@ -3126,7 +3125,7 @@ uint16_t WS2812FX::mode_tetrix(void) { } if (SEGENV.step == 0) { //init - drop->speed = 0.0238 * (SEGMENT.speed ? (SEGMENT.speed>>3)+1 : random8(6,40)); // set speed + drop->speed = 0.0238 * (SEGMENT.speed ? (SEGMENT.speed>>2)+1 : random8(6,64)); // set speed drop->pos = SEGLEN; // start at end of segment (no need to subtract 1) drop->col = color_from_palette(random8(0,15)<<4,false,false,0); // limit color choices so there is enough HUE gap SEGENV.step = 1; // drop state (0 init, 1 forming, 2 falling) diff --git a/wled00/FX.h b/wled00/FX.h index 01d83b38..3371cbdc 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -76,7 +76,7 @@ #define SEGENV _segment_runtimes[_segment_index] #define SEGLEN _virtualSegmentLength #define SEGACT SEGMENT.stop -#define SPEED_FORMULA_L 5 + (50*(255 - SEGMENT.speed))/SEGLEN +#define SPEED_FORMULA_L (uint16_t)(5 + (50*(255 - SEGMENT.speed))/SEGLEN) #define RESET_RUNTIME memset(_segment_runtimes, 0, sizeof(_segment_runtimes)) // some common colors diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 79551af8..649ed048 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -69,6 +69,11 @@ void WS2812FX::finalizeInit(void) _useRgbw |= bus->isRgbw(); _length += bus->getLength(); } +/* + //make segment 0 cover the entire strip + _segments[0].start = 0; + _segments[0].stop = _length; +*/ setBrightness(_brightness); @@ -360,7 +365,6 @@ uint8_t WS2812FX::getPaletteCount() bool WS2812FX::setEffectConfig(uint8_t m, uint8_t s, uint8_t in, uint8_t p) { - uint8_t mainSeg = getMainSegmentId(); Segment& seg = _segments[getMainSegmentId()]; uint8_t modePrev = seg.mode, speedPrev = seg.speed, intensityPrev = seg.intensity, palettePrev = seg.palette; diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 4c820419..d38e4092 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -338,6 +338,29 @@ class BusManager { BusManager() { }; + + //utility to get the approx. memory usage of a given BusConfig + uint32_t memUsage(BusConfig &bc) { + uint8_t type = bc.type; + uint16_t len = bc.count; + if (type < 32) { + #ifdef ESP8266 + if (bc.pins[0] == 3) { //8266 DMA uses 5x the mem + if (type > 29) return len*20; //RGBW + return len*15; + } + if (type > 29) return len*4; //RGBW + return len*3; + #else //ESP32 RMT uses double buffer? + if (type > 29) return len*8; //RGBW + return len*6; + #endif + } + + if (type > 31 && type < 48) return 5; + if (type == 44 || type == 45) return len*4; //RGBW + return len*3; + } int add(BusConfig &bc) { if (numBusses >= WLED_MAX_BUSSES) return -1; @@ -357,7 +380,6 @@ class BusManager { for (uint8_t i = 0; i < numBusses; i++) delete busses[i]; numBusses = 0; } - //void remove(uint8_t id); void show() { for (uint8_t i = 0; i < numBusses; i++) { diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index fed97495..527eadfd 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -100,10 +100,11 @@ void deserializeConfig() { CJSON(strip.rgbwMode, hw_led[F("rgbwm")]); JsonArray ins = hw_led["ins"]; - uint8_t s = 0; + uint8_t s = 0; // bus iterator bool skipFirst = skipFirstLed = false; useRGBW = false; busses.removeAll(); + uint32_t mem = 0; for (JsonObject elm : ins) { if (s >= WLED_MAX_BUSSES) break; uint8_t pins[5] = {255, 255, 255, 255, 255}; @@ -132,7 +133,8 @@ void deserializeConfig() { s++; lC += length; BusConfig bc = BusConfig(ledType, pins, start, length, colorOrder, reversed, skipFirst); - busses.add(bc); + mem += busses.memUsage(bc); + if (mem <= MAX_LED_MEMORY) busses.add(bc); } if (lC > ledCount) ledCount = lC; // fix incorrect total length (honour analog setup) strip.finalizeInit(); @@ -449,7 +451,6 @@ void serializeConfig() { JsonArray hw_led_ins = hw_led.createNestedArray("ins"); - uint16_t start = 0; for (uint8_t s = 0; s < busses.getNumBusses(); s++) { Bus *bus = busses.getBus(s); if (!bus || bus->getLength()==0) break; diff --git a/wled00/const.h b/wled00/const.h index de1fe41b..faf5729f 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -188,13 +188,19 @@ // maximum number of LEDs - more than 1500 LEDs (or 500 DMA "LEDPIN 3" driven ones) will cause a low memory condition on ESP8266 #ifndef MAX_LEDS #ifdef ESP8266 -#define MAX_LEDS 1536 +#define MAX_LEDS 1664 #else #define MAX_LEDS 8192 #endif #endif -#define MAX_LEDS_DMA 500 +#ifndef MAX_LED_MEMORY +#ifdef ESP8266 +#define MAX_LED_MEMORY 5000 +#else +#define MAX_LED_MEMORY 64000 +#endif +#endif // string temp buffer (now stored in stack locally) #define OMAX 2048 diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index 9026d94e..7388b363 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -5,7 +5,7 @@