diff --git a/wled00/WS2812FX.cpp b/wled00/WS2812FX.cpp index 7dee7f7a..c6eef0e4 100644 --- a/wled00/WS2812FX.cpp +++ b/wled00/WS2812FX.cpp @@ -979,7 +979,7 @@ uint16_t WS2812FX::mode_fire_flicker(void) { setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0, 255 - flicker)); } } - return 10 + (2 * (uint16_t)(255 - SEGMENT.speed)); + return 20 + random((255 - SEGMENT.speed),(2 * (uint16_t)(255 - SEGMENT.speed))); } diff --git a/wled00/WS2812FX_fcn.cpp b/wled00/WS2812FX_fcn.cpp index b60d95d8..dce048f9 100644 --- a/wled00/WS2812FX_fcn.cpp +++ b/wled00/WS2812FX_fcn.cpp @@ -446,7 +446,7 @@ void WS2812FX::lock(uint16_t i) void WS2812FX::lockRange(uint16_t i, uint16_t i2) { if (modeUsesLock(SEGMENT.mode)) return; - for (uint16_t x = i; x <= i2; x++) + for (uint16_t x = i; x < i2; x++) { if (i >= 0 && i < _length) _locked[i] = true; } diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 3f7516f6..97559810 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -8,7 +8,7 @@ */ -//ESP8266-01 (blue) got too little storage space to work with all features of WLED. To use it, you must use ESP8266 Arduino Core v2.3.0 and the setting 512K(64K SPIFFS). +//ESP8266-01 (blue) got too little storage space to work with all features of WLED. To use it, you must use ESP8266 Arduino Core v2.4.2 and the setting 512K(No SPIFFS). //ESP8266-01 (black) has 1MB flash and can thus fit the whole program. Use 1M(64K SPIFFS). //Uncomment some of the following lines to disable features to compile for ESP8266-01 (max flash size 434kB): @@ -30,7 +30,7 @@ //#define WLED_ENABLE_FS_EDITOR //enable /edit page for editing SPIFFS content. Will also be disabled with OTA lock //to toggle usb serial debug (un)comment the following line -//#define WLED_DEBUG +#define WLED_DEBUG //library inclusions @@ -98,7 +98,7 @@ //version code in format yymmddb (b = daily build) -#define VERSION 1904141 +#define VERSION 1905091 char versionString[] = "0.8.4"; @@ -373,10 +373,9 @@ IPAddress realtimeIP = (0,0,0,0); unsigned long realtimeTimeout = 0; //mqtt -long lastMQTTReconnectAttempt = 0; +long nextMQTTReconnectAttempt = 0; long lastInterfaceUpdate = 0; byte interfaceUpdateCallMode = 0; -uint32_t mqttFailedConAttempts = 0; #if AUXPIN >= 0 //auxiliary debug pin @@ -544,6 +543,13 @@ void loop() { if (!onlyAP) { handleHue(); handleBlynk(); + yield(); + if (millis() > nextMQTTReconnectAttempt) + { + yield(); + initMqtt(); + nextMQTTReconnectAttempt = millis() + 30000; + } } yield(); if (!offMode) strip.service(); diff --git a/wled00/wled03_set.ino b/wled00/wled03_set.ino index 4e3d2399..a9706da6 100644 --- a/wled00/wled03_set.ino +++ b/wled00/wled03_set.ino @@ -500,7 +500,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req) uint16_t index = getNumVal(&req, pos); pos = req.indexOf("L2="); bool unlock = req.indexOf("UL") > 0; - if (pos > 0){ + if (pos > 0) { uint16_t index2 = getNumVal(&req, pos); if (unlock) { strip.unlockRange(index, index2); diff --git a/wled00/wled05_init.ino b/wled00/wled05_init.ino index 215b8477..e4871399 100644 --- a/wled00/wled05_init.ino +++ b/wled00/wled05_init.ino @@ -85,13 +85,6 @@ void wledInit() strcpy(mqttDeviceTopic, "wled/"); strcat(mqttDeviceTopic, escapedMac.c_str()); } - - //smartInit, we only init some resources when connected - if (!onlyAP && WiFi.status() == WL_CONNECTED) - { - mqtt = new AsyncMqttClient(); - initMqtt(); - } strip.service(); diff --git a/wled00/wled17_mqtt.ino b/wled00/wled17_mqtt.ino index 09ffd5fe..5e6e4186 100644 --- a/wled00/wled17_mqtt.ino +++ b/wled00/wled17_mqtt.ino @@ -47,6 +47,7 @@ void onMqttConnect(bool sessionPresent) sendHADiscoveryMQTT(); publishMqtt(); + DEBUG_PRINTLN("MQTT ready"); } @@ -100,6 +101,8 @@ void publishMqtt() const char HA_static_JSON[] PROGMEM = R"=====(,"bri_val_tpl":"{{value}}","rgb_cmd_tpl":"{{'#%02x%02x%02x' | format(red, green, blue)}}","rgb_val_tpl":"{{value[1:3]|int(base=16)}},{{value[3:5]|int(base=16)}},{{value[5:7]|int(base=16)}}","qos":0,"opt":true,"pl_on":"ON","pl_off":"OFF","fx_val_tpl":"{{value}}","fx_list":[)====="; void sendHADiscoveryMQTT(){ + +#if ARDUINO_ARCH_ESP32 || LEDPIN != 3 /* YYYY is discovery tipic @@ -207,12 +210,15 @@ Send out HA MQTT Discovery message on MQTT connect (~2.4kB): strcat(pubt, escapedMac.c_str()); strcat(pubt, "/config"); mqtt->publish(pubt, 0, true, buffer); +#endif } bool initMqtt() { - if (WiFi.status() != WL_CONNECTED) return false; if (mqttServer[0] == 0) return false; + if (WiFi.status() != WL_CONNECTED) return false; + if (!mqtt) mqtt = new AsyncMqttClient(); + if (mqtt->connected()) return true; IPAddress mqttIP; if (mqttIP.fromString(mqttServer)) //see if server is IP or domain @@ -225,6 +231,5 @@ bool initMqtt() mqtt->onMessage(onMqttMessage); mqtt->onConnect(onMqttConnect); mqtt->connect(); - DEBUG_PRINTLN("MQTT ready"); return true; }