From b460d0f53373001e9c3e0f26af5bf781f30d82ac Mon Sep 17 00:00:00 2001 From: Louis Beaudoin Date: Fri, 26 Feb 2021 23:20:31 +0000 Subject: [PATCH 1/5] Fix Warnings (#1744) * Remove -w (Suppress all warnings, including those which GNU CPP issues by default.) and add back in -Wall (Turn on all optional warnings which are desirable for normal code.) from build_flags * Fixes warning: suggest parentheses around '+' in operand of '&' [-Wparentheses] * Fixes warning: "CONFIG_LITTLEFS_FOR_IDF_3_2" redefined * Fixes warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'uint64_t {aka long long unsigned int}' [-Wformat=] * Fixes warning: enumeration value 'onoff' not handled in switch [-Wswitch] * Fixes warning: "ntohl" redefined, warning: "ntohs" redefined, warning: "htonl" redefined, warning: "htons" redefined - Original fix: https://github.com/blynkkk/blynk-library/commit/858f8f4ee93246c2550e3f61857681dc87ac43eb * Fixes warning: unused variable 'mainSeg' [-Wunused-variable] * Fixes warning: unused variable 'start' [-Wunused-variable] * (untested!) Fixes warning: operation on '...' may be undefined [-Wsequence-point] * Fixes warning: unused variable * Fixes warning: unused variable and warning: narrowing conversion * Fixes warning: unused variable * Fixes warning: unused variable * (untested!) Fixes warning: statement has no effect [-Wunused-value] * Fixes warning: control reaches end of non-void function * Fixes warning: unused variable * Fixes warning: left operand of comma operator has no effect * Fixes warning: no return statement in function returning non-void * (untested!) Fixes warning: ISO C++ forbids converting a string constant to 'char*' and fixes warning: unused variable 'nPins' * Fixes warning: deleting array 'dmxData' * Fixes warning: unused variable * Remove all warning suppression buildflags Co-authored-by: Louis Beaudoin Co-authored-by: Aircoookie --- platformio.ini | 15 +-------------- wled00/FX.cpp | 11 +++++------ wled00/FX_fcn.cpp | 1 - wled00/cfg.cpp | 1 - wled00/e131.cpp | 9 ++++++--- wled00/file.cpp | 2 -- wled00/json.cpp | 1 - wled00/lx_parser.cpp | 1 - .../async-mqtt-client/AsyncMqttClient.cpp | 4 ++-- .../dependencies/blynk/Blynk/BlynkProtocolDefs.h | 4 +++- wled00/src/dependencies/dmx/ESPDMX.cpp | 3 +-- wled00/src/dependencies/espalexa/Espalexa.h | 4 ++-- .../src/dependencies/espalexa/EspalexaDevice.cpp | 1 - wled00/um_manager.cpp | 1 + wled00/wled.cpp | 3 --- wled00/wled.h | 8 +++++--- wled00/wled_server.cpp | 2 +- wled00/xml.cpp | 2 +- 18 files changed, 28 insertions(+), 45 deletions(-) diff --git a/platformio.ini b/platformio.ini index 6532f467..3eb09e80 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 diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 3fdfcff1..af7cead8 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -1568,9 +1568,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)); @@ -1919,7 +1919,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 @@ -3198,8 +3197,8 @@ uint16_t WS2812FX::mode_plasma(void) { uint8_t thatPhase = beatsin8(7,-64,64); for (int i = 0; i < SEGLEN; i++) { // For each of the LED's in the strand, set color & brightness based on a wave as follows: - uint8_t colorIndex = cubicwave8((i*(1+ 3*(SEGMENT.speed >> 5)))+(thisPhase) & 0xFF)/2 // factor=23 // Create a wave and add a phase change and add another wave with its own phase change. - + cos8((i*(1+ 2*(SEGMENT.speed >> 5)))+(thatPhase) & 0xFF)/2; // factor=15 // Hey, you can even change the frequencies if you wish. + uint8_t colorIndex = cubicwave8(((i*(1+ 3*(SEGMENT.speed >> 5)))+(thisPhase)) & 0xFF)/2 // factor=23 // Create a wave and add a phase change and add another wave with its own phase change. + + cos8(((i*(1+ 2*(SEGMENT.speed >> 5)))+(thatPhase)) & 0xFF)/2; // factor=15 // Hey, you can even change the frequencies if you wish. uint8_t thisBright = qsub8(colorIndex, beatsin8(6,0, (255 - SEGMENT.intensity)|0x01 )); CRGB color = ColorFromPalette(currentPalette, colorIndex, thisBright, LINEARBLEND); setPixelColor(i, color.red, color.green, color.blue); diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index aa1f88a6..ea27e2ef 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -380,7 +380,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/cfg.cpp b/wled00/cfg.cpp index 2175c97b..b21fd147 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -446,7 +446,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/e131.cpp b/wled00/e131.cpp index 58d63779..9ca092a9 100644 --- a/wled00/e131.cpp +++ b/wled00/e131.cpp @@ -35,7 +35,8 @@ void handleDDPPacket(e131_packet_t* p) { realtimeLock(realtimeTimeoutMs, REALTIME_MODE_DDP); for (uint16_t i = start; i < stop; i++) { - setRealtimePixel(i, data[c++], data[c++], data[c++], 0); + setRealtimePixel(i, data[c], data[c+1], data[c+2], 0); + c+=3; } bool push = p->flags & DDP_PUSH_FLAG; @@ -187,11 +188,13 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){ uint16_t ledsTotal = previousLeds + (dmxChannels - dmxOffset +1) / dmxChannelsPerLed; if (!is4Chan) { for (uint16_t i = previousLeds; i < ledsTotal; i++) { - setRealtimePixel(i, e131_data[dmxOffset++], e131_data[dmxOffset++], e131_data[dmxOffset++], 0); + setRealtimePixel(i, e131_data[dmxOffset], e131_data[dmxOffset+1], e131_data[dmxOffset+2], 0); + dmxOffset+=3; } } else { for (uint16_t i = previousLeds; i < ledsTotal; i++) { - setRealtimePixel(i, e131_data[dmxOffset++], e131_data[dmxOffset++], e131_data[dmxOffset++], e131_data[dmxOffset++]); + setRealtimePixel(i, e131_data[dmxOffset], e131_data[dmxOffset+1], e131_data[dmxOffset+2], e131_data[dmxOffset+3]); + dmxOffset+=4; } } break; diff --git a/wled00/file.cpp b/wled00/file.cpp index c6e8c413..352b6af9 100644 --- a/wled00/file.cpp +++ b/wled00/file.cpp @@ -34,7 +34,6 @@ File f; //wrapper to find out how long closing takes void closeFile() { DEBUGFS_PRINT(F("Close -> ")); - uint32_t s = millis(); f.close(); DEBUGFS_PRINTF("took %d ms\n", millis() - s); doCloseFile = false; @@ -53,7 +52,6 @@ bool bufferedFind(const char *target, bool fromStart = true) { size_t targetLen = strlen(target); size_t index = 0; - byte c; uint16_t bufsize = 0, count = 0; byte buf[FS_BUFSIZE]; if (fromStart) f.seek(0); diff --git a/wled00/json.cpp b/wled00/json.cpp index fdd4accd..94d880a4 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -134,7 +134,6 @@ void deserializeSegment(JsonObject elem, byte it) if (sz == 0 && sz > 4) break; int rgbw[] = {0,0,0,0}; - byte cp = copyArray(icol, rgbw); if (set < 2) stop = start + 1; for (uint16_t i = start; i < stop; i++) { diff --git a/wled00/lx_parser.cpp b/wled00/lx_parser.cpp index 806bd74a..e51308c2 100644 --- a/wled00/lx_parser.cpp +++ b/wled00/lx_parser.cpp @@ -23,7 +23,6 @@ bool parseLx(int lxValue, byte rgbw[4]) ok = true; float tmpBri = floor((lxValue - 200000000) / 10000); ; uint16_t ct = (lxValue - 200000000) - (((uint8_t)tmpBri) * 10000); - float temp = 0; tmpBri *= 2.55; constrain(tmpBri, 0, 255); diff --git a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient.cpp b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient.cpp index f62e1ef4..d0c44cb6 100644 --- a/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient.cpp +++ b/wled00/src/dependencies/async-mqtt-client/AsyncMqttClient.cpp @@ -37,10 +37,10 @@ AsyncMqttClient::AsyncMqttClient() _client.onPoll([](void* obj, AsyncClient* c) { (static_cast(obj))->_onPoll(c); }, this); #ifdef ESP32 - sprintf(_generatedClientId, "esp32%06x", ESP.getEfuseMac()); + sprintf(_generatedClientId, "esp32%06x", (uint32_t)ESP.getEfuseMac()); _xSemaphore = xSemaphoreCreateMutex(); #elif defined(ESP8266) - sprintf(_generatedClientId, "esp8266%06x", ESP.getChipId()); + sprintf(_generatedClientId, "esp8266%06x", (uint32_t)ESP.getChipId()); #endif _clientId = _generatedClientId; diff --git a/wled00/src/dependencies/blynk/Blynk/BlynkProtocolDefs.h b/wled00/src/dependencies/blynk/Blynk/BlynkProtocolDefs.h index 56e6abae..d294a626 100644 --- a/wled00/src/dependencies/blynk/Blynk/BlynkProtocolDefs.h +++ b/wled00/src/dependencies/blynk/Blynk/BlynkProtocolDefs.h @@ -93,7 +93,9 @@ struct BlynkHeader } BLYNK_ATTR_PACKED; -#if !defined(htons) && (defined(ARDUINO) || defined(ESP8266) || defined(PARTICLE) || defined(__MBED__)) +#if defined(ESP32) + #include +#elif !defined(htons) && (defined(ARDUINO) || defined(ESP8266) || defined(PARTICLE) || defined(__MBED__)) #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #define htons(x) ( ((x)<<8) | (((x)>>8)&0xFF) ) #define htonl(x) ( ((x)<<24 & 0xFF000000UL) | \ diff --git a/wled00/src/dependencies/dmx/ESPDMX.cpp b/wled00/src/dependencies/dmx/ESPDMX.cpp index f3ece1c8..6ad1268e 100644 --- a/wled00/src/dependencies/dmx/ESPDMX.cpp +++ b/wled00/src/dependencies/dmx/ESPDMX.cpp @@ -77,10 +77,9 @@ void DMXESPSerial::write(int Channel, uint8_t value) { } void DMXESPSerial::end() { - delete dmxData; chanSize = 0; Serial1.end(); - dmxStarted == false; + dmxStarted = false; } void DMXESPSerial::update() { diff --git a/wled00/src/dependencies/espalexa/Espalexa.h b/wled00/src/dependencies/espalexa/Espalexa.h index 0ec4e2e5..5e7dc837 100644 --- a/wled00/src/dependencies/espalexa/Espalexa.h +++ b/wled00/src/dependencies/espalexa/Espalexa.h @@ -101,8 +101,8 @@ private: case EspalexaDeviceType::whitespectrum: return PSTR("Color temperature light"); case EspalexaDeviceType::color: return PSTR("Color light"); case EspalexaDeviceType::extendedcolor: return PSTR("Extended color light"); + default: return ""; } - return ""; } const char* modelidString(EspalexaDeviceType t) @@ -113,8 +113,8 @@ private: case EspalexaDeviceType::whitespectrum: return "LWT010"; case EspalexaDeviceType::color: return "LST001"; case EspalexaDeviceType::extendedcolor: return "LCT015"; + default: return ""; } - return ""; } void encodeLightId(uint8_t idx, char* out) diff --git a/wled00/src/dependencies/espalexa/EspalexaDevice.cpp b/wled00/src/dependencies/espalexa/EspalexaDevice.cpp index 8bdd780d..d7d0920f 100644 --- a/wled00/src/dependencies/espalexa/EspalexaDevice.cpp +++ b/wled00/src/dependencies/espalexa/EspalexaDevice.cpp @@ -112,7 +112,6 @@ uint32_t EspalexaDevice::getRGB() { if (_rgb != 0) return _rgb; //color has not changed byte rgb[4]{0, 0, 0, 0}; - float r, g, b, w; if (_mode == EspalexaColorMode::none) return 0; diff --git a/wled00/um_manager.cpp b/wled00/um_manager.cpp index 51fcd0ec..4d07226e 100644 --- a/wled00/um_manager.cpp +++ b/wled00/um_manager.cpp @@ -32,6 +32,7 @@ bool UsermodManager::add(Usermod* um) if (numMods >= WLED_MAX_USERMODS || um == nullptr) return false; ums[numMods] = um; numMods++; + return true; } byte UsermodManager::getModCount() {return numMods;} \ No newline at end of file diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 651f484e..bedec844 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -136,8 +136,6 @@ void prepareHostname(char* hostname) //handle Ethernet connection event void WiFiEvent(WiFiEvent_t event) { - char hostname[25] = "wled-"; - switch (event) { #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) case SYSTEM_EVENT_ETH_START: @@ -290,7 +288,6 @@ void WLED::setup() DEBUG_PRINT("esp8266 "); DEBUG_PRINTLN(ESP.getCoreVersion()); #endif - int heapPreAlloc = ESP.getFreeHeap(); DEBUG_PRINT("heap "); DEBUG_PRINTLN(ESP.getFreeHeap()); registerUsermods(); diff --git a/wled00/wled.h b/wled00/wled.h index 202b9da7..678a4ca6 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -65,7 +65,9 @@ #include #include //#include "SPIFFS.h" - #define CONFIG_LITTLEFS_FOR_IDF_3_2 + #ifndef CONFIG_LITTLEFS_FOR_IDF_3_2 + #define CONFIG_LITTLEFS_FOR_IDF_3_2 + #endif #include #endif @@ -310,7 +312,7 @@ WLED_GLOBAL bool huePollingEnabled _INIT(false); // poll hue bridge fo WLED_GLOBAL uint16_t huePollIntervalMs _INIT(2500); // low values (< 1sec) may cause lag but offer quicker response WLED_GLOBAL char hueApiKey[47] _INIT("api"); // key token will be obtained from bridge WLED_GLOBAL byte huePollLightId _INIT(1); // ID of hue lamp to sync to. Find the ID in the hue app ("about" section) -WLED_GLOBAL IPAddress hueIP _INIT((0, 0, 0, 0)); // IP address of the bridge +WLED_GLOBAL IPAddress hueIP _INIT_N((( 0, 0, 0, 0))); // IP address of the bridge WLED_GLOBAL bool hueApplyOnOff _INIT(true); WLED_GLOBAL bool hueApplyBri _INIT(true); WLED_GLOBAL bool hueApplyColor _INIT(true); @@ -473,7 +475,7 @@ WLED_GLOBAL int16_t currentPlaylist _INIT(0); // realtime WLED_GLOBAL byte realtimeMode _INIT(REALTIME_MODE_INACTIVE); WLED_GLOBAL byte realtimeOverride _INIT(REALTIME_OVERRIDE_NONE); -WLED_GLOBAL IPAddress realtimeIP _INIT((0, 0, 0, 0)); +WLED_GLOBAL IPAddress realtimeIP _INIT_N(((0, 0, 0, 0)));; WLED_GLOBAL unsigned long realtimeTimeout _INIT(0); WLED_GLOBAL uint8_t tpmPacketCount _INIT(0); WLED_GLOBAL uint16_t tpmPayloadFrameSize _INIT(0); diff --git a/wled00/wled_server.cpp b/wled00/wled_server.cpp index cae23c9d..2ae24a53 100644 --- a/wled00/wled_server.cpp +++ b/wled00/wled_server.cpp @@ -245,7 +245,7 @@ bool handleIfNoneMatchCacheHeader(AsyncWebServerRequest* request) return false; } -bool setStaticContentCacheHeaders(AsyncWebServerResponse *response) +void setStaticContentCacheHeaders(AsyncWebServerResponse *response) { response->addHeader(F("Cache-Control"),"max-age=2592000"); response->addHeader(F("ETag"), String(VERSION)); diff --git a/wled00/xml.cpp b/wled00/xml.cpp index 99b8b241..c7161193 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -313,7 +313,7 @@ void getSettingsJS(byte subPage, char* dest) sappend('v',SET_F("LA"),strip.milliampsPerLed); if (strip.currentMilliamps) { - sappends('m',SET_F("(\"pow\")[0]"),""); + sappends('m',SET_F("(\"pow\")[0]"),(char*)""); olen -= 2; //delete "; oappendi(strip.currentMilliamps); oappend(SET_F("mA\";")); From befeb55349d512aaca71cda0958ce60b547a7e96 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Sat, 27 Feb 2021 00:57:12 +0100 Subject: [PATCH 2/5] Memory check on bus creation --- wled00/FX_fcn.cpp | 1 + wled00/bus_manager.h | 24 +++++++++++++++++++++++- wled00/cfg.cpp | 6 ++++-- wled00/const.h | 10 ++++++++-- wled00/wled.cpp | 4 +++- wled00/xml.cpp | 4 ---- 6 files changed, 39 insertions(+), 10 deletions(-) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index aa1f88a6..75157d7d 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -70,6 +70,7 @@ void WS2812FX::finalizeInit(bool supportWhite, uint16_t countPixels, bool skipFi deserializeMap(); + //make segment 0 cover the entire strip _segments[0].start = 0; _segments[0].stop = _length; diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index e767fcc7..51965150 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -297,6 +297,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; @@ -317,7 +340,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 2175c97b..ee8482c0 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -99,9 +99,10 @@ void deserializeConfig() { CJSON(strip.rgbwMode, hw_led[F("rgbwm")]); JsonArray ins = hw_led["ins"]; - uint8_t s = 0; + uint8_t s = 0; //bus iterator 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}; @@ -130,7 +131,8 @@ void deserializeConfig() { useRGBW = (useRGBW || BusManager::isRgbw(ledType)); s++; BusConfig bc = BusConfig(ledType, pins, start, length, colorOrder, reversed); - busses.add(bc); + mem += busses.memUsage(bc); + if (mem <= MAX_LED_MEMORY) busses.add(bc); } strip.finalizeInit(useRGBW, ledCount, skipFirstLed); diff --git a/wled00/const.h b/wled00/const.h index 1f18d5cc..34eb650b 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 2048 #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/wled.cpp b/wled00/wled.cpp index 651f484e..94a34fa1 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -218,9 +218,11 @@ void WLED::loop() //LED settings have been saved, re-init busses if (busConfigs[0] != nullptr) { busses.removeAll(); + uint32_t mem = 0; for (uint8_t i = 0; i < WLED_MAX_BUSSES; i++) { if (busConfigs[i] == nullptr) break; - busses.add(*busConfigs[i]); + mem += busses.memUsage(*busConfigs[i]); + if (mem <= MAX_LED_MEMORY) busses.add(*busConfigs[i]); delete busConfigs[i]; busConfigs[i] = nullptr; } strip.finalizeInit(useRGBW, ledCount, skipFirstLed); diff --git a/wled00/xml.cpp b/wled00/xml.cpp index 99b8b241..8e987d3c 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -279,11 +279,7 @@ void getSettingsJS(byte subPage, char* dest) #endif oappend(SET_F("d.Sf.LC.max=")); //TODO Formula for max LEDs on ESP8266 depending on types. 500 DMA or 1500 UART (about 4kB mem usage) - #if defined(ESP8266) && LEDPIN == 3 - oappendi(MAX_LEDS_DMA); - #else oappendi(MAX_LEDS); - #endif oappend(";"); sappend('v',SET_F("LC"),ledCount); From cfc346abad78000fe1e880e960968c0faee6c44f Mon Sep 17 00:00:00 2001 From: cschwinne Date: Sat, 27 Feb 2021 01:16:06 +0100 Subject: [PATCH 3/5] Fix warnings misc fixes --- wled00/file.cpp | 5 ++++- wled00/json.cpp | 1 + wled00/lx_parser.cpp | 2 +- wled00/src/dependencies/json/AsyncJson-v6.h | 2 +- wled00/wled.cpp | 4 ++++ wled00/wled.h | 6 +++--- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/wled00/file.cpp b/wled00/file.cpp index 352b6af9..e3aac3ae 100644 --- a/wled00/file.cpp +++ b/wled00/file.cpp @@ -33,7 +33,10 @@ File f; //wrapper to find out how long closing takes void closeFile() { - DEBUGFS_PRINT(F("Close -> ")); + #ifdef WLED_DEBUG_FS + DEBUGFS_PRINT(F("Close -> ")); + uint32_t s = millis(); + #endif f.close(); DEBUGFS_PRINTF("took %d ms\n", millis() - s); doCloseFile = false; diff --git a/wled00/json.cpp b/wled00/json.cpp index 94d880a4..3212b3b4 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -134,6 +134,7 @@ void deserializeSegment(JsonObject elem, byte it) if (sz == 0 && sz > 4) break; int rgbw[] = {0,0,0,0}; + copyArray(icol, rgbw); if (set < 2) stop = start + 1; for (uint16_t i = start; i < stop; i++) { diff --git a/wled00/lx_parser.cpp b/wled00/lx_parser.cpp index e51308c2..526f10d5 100644 --- a/wled00/lx_parser.cpp +++ b/wled00/lx_parser.cpp @@ -25,7 +25,7 @@ bool parseLx(int lxValue, byte rgbw[4]) uint16_t ct = (lxValue - 200000000) - (((uint8_t)tmpBri) * 10000); tmpBri *= 2.55; - constrain(tmpBri, 0, 255); + tmpBri = constrain(tmpBri, 0, 255); colorKtoRGB(ct, rgbw); lxRed = rgbw[0]; lxGreen = rgbw[1]; lxBlue = rgbw[2]; diff --git a/wled00/src/dependencies/json/AsyncJson-v6.h b/wled00/src/dependencies/json/AsyncJson-v6.h index 7edab311..c1288d91 100644 --- a/wled00/src/dependencies/json/AsyncJson-v6.h +++ b/wled00/src/dependencies/json/AsyncJson-v6.h @@ -144,7 +144,7 @@ public: virtual void handleBody(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) override final { if (_onRequest) { _contentLength = total; - if (total > 0 && request->_tempObject == NULL && total < _maxContentLength) { + if (total > 0 && request->_tempObject == NULL && (int)total < _maxContentLength) { request->_tempObject = malloc(total); } if (request->_tempObject != NULL) { diff --git a/wled00/wled.cpp b/wled00/wled.cpp index bedec844..dfbe6967 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -136,6 +136,10 @@ void prepareHostname(char* hostname) //handle Ethernet connection event void WiFiEvent(WiFiEvent_t event) { + #ifdef WLED_USE_ETHERNET + char hostname[25] = "wled-"; + #endif + switch (event) { #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET) case SYSTEM_EVENT_ETH_START: diff --git a/wled00/wled.h b/wled00/wled.h index 678a4ca6..b6e8cfff 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -312,7 +312,7 @@ WLED_GLOBAL bool huePollingEnabled _INIT(false); // poll hue bridge fo WLED_GLOBAL uint16_t huePollIntervalMs _INIT(2500); // low values (< 1sec) may cause lag but offer quicker response WLED_GLOBAL char hueApiKey[47] _INIT("api"); // key token will be obtained from bridge WLED_GLOBAL byte huePollLightId _INIT(1); // ID of hue lamp to sync to. Find the ID in the hue app ("about" section) -WLED_GLOBAL IPAddress hueIP _INIT_N((( 0, 0, 0, 0))); // IP address of the bridge +WLED_GLOBAL IPAddress hueIP _INIT_N(((0, 0, 0, 0))); // IP address of the bridge WLED_GLOBAL bool hueApplyOnOff _INIT(true); WLED_GLOBAL bool hueApplyBri _INIT(true); WLED_GLOBAL bool hueApplyColor _INIT(true); @@ -481,8 +481,8 @@ WLED_GLOBAL uint8_t tpmPacketCount _INIT(0); WLED_GLOBAL uint16_t tpmPayloadFrameSize _INIT(0); // mqtt -WLED_GLOBAL long lastMqttReconnectAttempt _INIT(0); -WLED_GLOBAL long lastInterfaceUpdate _INIT(0); +WLED_GLOBAL unsigned long lastMqttReconnectAttempt _INIT(0); +WLED_GLOBAL unsigned long lastInterfaceUpdate _INIT(0); WLED_GLOBAL byte interfaceUpdateCallMode _INIT(NOTIFIER_CALL_MODE_INIT); WLED_GLOBAL char mqttStatusTopic[40] _INIT(""); // this must be global because of async handlers From 44a9fed8a9e3f8ec065150c9c3c5a47ad82b9985 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Sat, 27 Feb 2021 01:50:08 +0100 Subject: [PATCH 4/5] Fix more warnings --- platformio.ini | 2 +- wled00/FX.cpp | 4 ++-- wled00/json.cpp | 4 ++-- wled00/src/dependencies/blynk/BlynkSimpleEsp.h | 3 +-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/platformio.ini b/platformio.ini index 3eb09e80..887d2581 100644 --- a/platformio.ini +++ b/platformio.ini @@ -184,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.1 #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 af7cead8..1f855399 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -545,7 +545,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; @@ -1034,7 +1034,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; } diff --git a/wled00/json.cpp b/wled00/json.cpp index 3212b3b4..4b4714ac 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -200,8 +200,8 @@ bool deserializeState(JsonObject root) receiveNotifications = udpn[F("recv")] | receiveNotifications; bool noNotification = udpn[F("nn")]; //send no notification just for this request - unsigned long timein = root[F("time")] | -1; - if (timein != -1) { + unsigned long timein = root[F("time")] | UINT32_MAX; + if (timein != UINT32_MAX) { if (millis() - ntpLastSyncTime > 50000000L) setTime(timein); if (presetsModifiedTime == 0) presetsModifiedTime = timein; } diff --git a/wled00/src/dependencies/blynk/BlynkSimpleEsp.h b/wled00/src/dependencies/blynk/BlynkSimpleEsp.h index 6697686f..ee4d374b 100644 --- a/wled00/src/dependencies/blynk/BlynkSimpleEsp.h +++ b/wled00/src/dependencies/blynk/BlynkSimpleEsp.h @@ -45,8 +45,7 @@ public: } BLYNK_LOG1(BLYNK_F("Connected to WiFi")); - IPAddress myip = WiFi.localIP(); - BLYNK_LOG_IP("IP: ", myip); + BLYNK_LOG_IP("IP: ", WiFi.localIP()); } void config(const char* auth, From 38db8d2bfde396a06850c0c49ec1902cbbd5961e Mon Sep 17 00:00:00 2001 From: cschwinne Date: Sat, 27 Feb 2021 02:01:27 +0100 Subject: [PATCH 5/5] Update platformio.ini --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 887d2581..19c18bab 100644 --- a/platformio.ini +++ b/platformio.ini @@ -184,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.1 + 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