diff --git a/readme.md b/readme.md index 48ab1d40..87d710f5 100644 --- a/readme.md +++ b/readme.md @@ -54,6 +54,7 @@ Add one or multiple of the following parameters after the base url to change val "&R=<0-255>" set LED red value (red slider) "&G=<0-255>" set LED green value (green slider) "&B=<0-255>" set LED blue value (blue slider) +"&T=<0 or 1 or 2-255>" 0: switch off, on, toggle "&FX=<0-47>" set LED effect (refer to WS2812FX library) "&SX=<0-255>" set LED effect speed (refer to WS2812FX library) "&NR=<0 or 1>" receive notifications on or off diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 6ef5cf40..23ad7a44 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -19,7 +19,7 @@ #include "htmls01.h" //to toggle usb serial debug (un)comment following line -//#define DEBUG +#define DEBUG #ifdef DEBUG #define DEBUG_PRINT(x) Serial.print (x) @@ -123,7 +123,6 @@ uint8_t effectSpeed = 75; boolean udpConnected = false; byte udpIn[LEDCOUNT*4+2]; IPAddress ntpIp; -IPAddress ntpBackupIp(134,130,5,17); byte ntpBuffer[48]; boolean ntpConnected = false; boolean ntpSyncNeeded = true; @@ -148,7 +147,6 @@ boolean auxActive, auxActiveBefore; ESP8266WebServer server(80); ESP8266HTTPUpdateServer httpUpdater; WiFiUDP notifierUdp; -WiFiUDP ntpUdp; WS2812FX strip = WS2812FX(LEDCOUNT, 2, NEO_GRB + NEO_KHZ800); @@ -223,6 +221,7 @@ void loop() { DEBUG_PRINTLN("---MODULE DEBUG INFO---"); DEBUG_PRINT("Runtime: "); DEBUG_PRINTLN(millis()); DEBUG_PRINT("Unix time: "); DEBUG_PRINTLN(now()); + DEBUG_PRINT("Free heap: "); DEBUG_PRINTLN(ESP.getFreeHeap()); DEBUG_PRINT("Wifi state: "); DEBUG_PRINTLN(WiFi.status()); if (WiFi.status() != lastWifiState) { diff --git a/wled00/wled03_set.ino b/wled00/wled03_set.ino index fb9aeab3..e606be27 100644 --- a/wled00/wled03_set.ino +++ b/wled00/wled03_set.ino @@ -285,9 +285,25 @@ boolean handleSet(String req) } pos = req.indexOf("AX="); if (pos > 0) { - auxTime = req.substring(pos + 3).toInt(); - auxActive = true; - if (auxTime == 0) auxActive = false; + auxTime = req.substring(pos + 3).toInt(); + auxActive = true; + if (auxTime == 0) auxActive = false; + } + pos = req.indexOf("T="); + if (pos > 0) { + switch (req.substring(pos + 2).toInt()) + { + case 0: if (bri != 0){bri_last = bri; bri = 0;} break; //off + case 1: bri = bri_last; break; //on + default: if (bri == 0) //toggle + { + bri = bri_last; + } else + { + bri_last = bri; + bri = 0; + } + } } XML_response(); if (effectUpdated) diff --git a/wled00/wled05_init.ino b/wled00/wled05_init.ino index fe243017..7729e5d3 100644 --- a/wled00/wled05_init.ino +++ b/wled00/wled05_init.ino @@ -58,14 +58,10 @@ void wledInit() } DEBUG_PRINTLN("mDNS responder started"); - if (udpPort > 0 && udpPort != 123) + if (udpPort > 0) { udpConnected = notifierUdp.begin(udpPort); } - if (ntpEnabled && !only_ap) - { - ntpConnected = ntpUdp.begin(123); - } //SERVER INIT //settings page diff --git a/wled00/wled08_led.ino b/wled00/wled08_led.ino index faabc1ce..702a43bc 100644 --- a/wled00/wled08_led.ino +++ b/wled00/wled08_led.ino @@ -34,7 +34,7 @@ void setLedsStandard() void colorUpdated(int callMode) { - //call for notifier -> 0: init 1: direct change 2: button 3: notification 4: nightlight 5: other (no not.) + //call for notifier -> 0: init 1: direct change 2: button 3: notification 4: nightlight 5: other (no not.) 6: fx changed if (col[0] == col_it[0] && col[1] == col_it[1] && col[2] == col_it[2] && bri == bri_it) { if (callMode == 6) notify(6); diff --git a/wled00/wled10_ntp.ino b/wled00/wled10_ntp.ino index 4c70f563..a8bfa226 100644 --- a/wled00/wled10_ntp.ino +++ b/wled00/wled10_ntp.ino @@ -4,7 +4,7 @@ void handleNetworkTime() { - if (ntpEnabled && ntpConnected) + if (ntpEnabled && udpConnected) { if (ntpSyncNeeded) { @@ -27,11 +27,6 @@ void handleNetworkTime() } else { WiFi.hostByName(ntpServerName, ntpIp); - if (ntpIp[0] == 0) - { - DEBUG_PRINTLN("DNS f!"); - ntpIp = ntpBackupIp; - } sendNTPpacket(); ntpPacketSent = true; ntpPacketSentTime = millis(); @@ -45,8 +40,8 @@ void handleNetworkTime() bool getNtpTime() { - if (ntpUdp.parsePacket()) { - ntpUdp.read(ntpBuffer, 48); // read packet into the buffer + if (notifierUdp.parsePacket()) { + notifierUdp.read(ntpBuffer, 48); // read packet into the buffer #ifdef DEBUG int i= 0; @@ -78,8 +73,8 @@ bool getNtpTime() void sendNTPpacket() { - while (ntpUdp.parsePacket()>0); - ntpUdp.flush(); //discard old packets + while (notifierUdp.parsePacket()>0); + notifierUdp.flush(); //discard old packets DEBUG_PRINTLN("Sending NTP packet"); memset(ntpBuffer, 0, 48); ntpBuffer[0] = 0b11100011; // LI, Version, Mode @@ -90,9 +85,9 @@ void sendNTPpacket() ntpBuffer[13] = 0x4E; ntpBuffer[14] = 49; ntpBuffer[15] = 52; - ntpUdp.beginPacket(ntpIp, 123); //NTP requests are to port 123 - ntpUdp.write(ntpBuffer, 48); - ntpUdp.endPacket(); + notifierUdp.beginPacket(ntpIp, 123); //NTP requests are to port 123 + notifierUdp.write(ntpBuffer, 48); + notifierUdp.endPacket(); } String getTimeString()