diff --git a/wled00/data/index.htm b/wled00/data/index.htm index c79496a8d..300184bfd 100644 --- a/wled00/data/index.htm +++ b/wled00/data/index.htm @@ -2,7 +2,7 @@ - WLED 0.6.4 + WLED 0.6.5 +WLED 0.6.5 + )====="; //head1 (css) diff --git a/wled00/htmls01.h b/wled00/htmls01.h index 0f5425078..04f957d6c 100644 --- a/wled00/htmls01.h +++ b/wled00/htmls01.h @@ -109,7 +109,8 @@ Brightness factor: %

Transitions

Fade:
Sweep: Invert direction:
-Transition Time: ms +Transition Time: ms
+Enable transition for secondary color:

Timed light

Default Duration: min
Default Target brightness:
@@ -196,7 +197,9 @@ Send notifications on direct change:
Send notifications on button press:
Send Alexa notifications:
Send Philips Hue change notifications:
-Send notifications twice: +Send notifications twice:
+Receive UDP realtime:
+Enable UI access during realtime: (can cause issues)

Alexa Voice Assistant

Emulate Alexa device:
Alexa invocation name:
@@ -318,7 +321,7 @@ const char PAGE_settings_sec1[] PROGMEM = R"=====(

Security & Update setup

-Enable OTA lock:
+Lock wireless (OTA) software update:
Passphrase:
To enable OTA, for security reasons you need to also enter the correct password!
The password should be changed when OTA is enabled.
@@ -335,7 +338,7 @@ HTTP traffic is unencrypted. An attacker in the same network can intercept form
Enable ArduinoOTA:

About

-WLED version 0.6.4
+WLED version 0.6.5
(c) 2016-2018 Christian Schwinne
Licensed under the MIT license

Uses libraries:
diff --git a/wled00/htmls02.h b/wled00/htmls02.h index 946aaa11f..131b16555 100644 --- a/wled00/htmls02.h +++ b/wled00/htmls02.h @@ -1,3 +1,7 @@ +//USER HTML +const char PAGE_usermod[] PROGMEM = R"=====( +There is no usermod installed or it doesn't specify a custom web page. +)====="; /* * Various */ diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 1b15fa7a4..53e0d7dfe 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -3,7 +3,7 @@ */ /* * @title WLED project sketch - * @version 0.6.4 + * @version 0.6.5 * @author Christian Schwinne */ @@ -33,8 +33,8 @@ #include "WS2812FX.h" //version in format yymmddb (b = daily build) -#define VERSION 1804221 -const String versionString = "0.6.4"; +#define VERSION 1805061 +const String versionString = "0.6.5"; //AP and OTA default passwords (change them!) String apPass = "wled1234"; @@ -54,7 +54,7 @@ byte auxDefaultState = 0; //0: input 1: high 2: low byte auxTriggeredState = 0; //0: input 1: high 2: low //Default CONFIG -String serverDescription = versionString; +String serverDescription = "WLED Light"; byte currentTheme = 0; String clientSSID = "Your_Network"; String clientPass = ""; @@ -81,6 +81,7 @@ byte briS = 127; byte nightlightTargetBri = 0; bool fadeTransition = true; bool sweepTransition = false, sweepDirection = true; +bool disableSecTransition = true; uint16_t transitionDelay = 1200, transitionDelayDefault = transitionDelay; bool reverseMode = false; bool otaLock = false, wifiLock = false; @@ -134,9 +135,11 @@ byte colOld[]{0, 0, 0}; byte colT[]{0, 0, 0}; byte colIT[]{0, 0, 0}; byte colSec[]{0, 0, 0}; +byte colSecT[]{0, 0, 0}; +byte colSecOld[]{0, 0, 0}; byte colSecIT[]{0, 0, 0}; byte white, whiteOld, whiteT, whiteIT; -byte whiteSec, whiteSecIT; +byte whiteSec, whiteSecOld, whiteSecT, whiteSecIT; byte lastRandomIndex = 0; uint16_t transitionDelayTemp = transitionDelay; unsigned long transitionStartTime; @@ -209,11 +212,11 @@ bool presetCyclingEnabled = false; byte presetCycleMin = 1, presetCycleMax = 5; uint16_t presetCycleTime = 1250; unsigned long presetCycledTime = 0; byte presetCycCurr = presetCycleMin; -bool presetCycleBri, presetCycleCol, presetCycleFx; +bool presetApplyBri = true, presetApplyCol = true, presetApplyFx = true; uint32_t arlsTimeoutMillis = 2500; bool arlsTimeout = false; -bool receiveDirect = true; +bool receiveDirect = true, enableRealtimeUI = false; unsigned long arlsTimeoutTime; byte auxTime = 0; unsigned long auxStartTime; @@ -242,7 +245,7 @@ ESP8266WebServer server(80); #endif HTTPClient hueClient; ESP8266HTTPUpdateServer httpUpdater; -WiFiUDP notifierUdp; +WiFiUDP notifierUdp;//, rgbUdp; WiFiUDP ntpUdp; IPAddress ntpServerIP; unsigned int ntpLocalPort = 2390; @@ -325,7 +328,7 @@ void loop() { yield(); handleButton(); handleNetworkTime(); - if (!otaLock && aOtaEnabled) ArduinoOTA.handle(); + if (aOtaEnabled) ArduinoOTA.handle(); handleAlexa(); handleOverlays(); if (!arlsTimeout) //block stuff if WARLS/Adalight is enabled diff --git a/wled00/wled01_eeprom.ino b/wled00/wled01_eeprom.ino index 37743c06a..70b20100c 100644 --- a/wled00/wled01_eeprom.ino +++ b/wled00/wled01_eeprom.ino @@ -148,6 +148,7 @@ void saveSettingsToEEPROM() EEPROM.write(396, (utcOffsetSecs<0)); //is negative EEPROM.write(397, initLedsLast); EEPROM.write(398, (ledCount >> 8) & 0xFF); + EEPROM.write(399, disableSecTransition); for (int k=0;k<6;k++){ int in = 900+k*8; @@ -208,6 +209,9 @@ void saveSettingsToEEPROM() EEPROM.write(2179, macroLongPress); EEPROM.write(2180, macroCountdown); EEPROM.write(2181, macroNl); + + EEPROM.write(2200,!receiveDirect); + EEPROM.write(2201,enableRealtimeUI); EEPROM.commit(); } @@ -260,7 +264,7 @@ void loadSettingsFromEEPROM(bool first) if (apChannel > 13 || apChannel < 1) apChannel = 1; apHide = EEPROM.read(228); if (apHide > 1) apHide = 1; - ledCount = ((EEPROM.read(229) << 0) & 0xFF) + ((EEPROM.read(398) << 8) & 0xFF00); if (ledCount > 1200) ledCount = 10; + ledCount = ((EEPROM.read(229) << 0) & 0xFF) + ((EEPROM.read(398) << 8) & 0xFF00); if (ledCount > 1200 || ledCount == 0) ledCount = 10; notifyButton = EEPROM.read(230); notifyTwice = EEPROM.read(231); buttonEnabled = EEPROM.read(232); @@ -416,14 +420,17 @@ void loadSettingsFromEEPROM(bool first) macroCountdown = EEPROM.read(2180); macroNl = EEPROM.read(2181); } + receiveDirect = !EEPROM.read(2200); + enableRealtimeUI = EEPROM.read(2201); bootPreset = EEPROM.read(389); wifiLock = EEPROM.read(393); utcOffsetSecs = ((EEPROM.read(394) << 0) & 0xFF) + ((EEPROM.read(395) << 8) & 0xFF00); if (EEPROM.read(396)) utcOffsetSecs = -utcOffsetSecs; //negative initLedsLast = EEPROM.read(397); + disableSecTransition = EEPROM.read(399); - //favorite setting memory (25 slots/ each 20byte) + //favorite setting (preset) memory (25 slots/ each 20byte) //400 - 899 reserved currentTheme = EEPROM.read(948); diff --git a/wled00/wled02_xml.ino b/wled00/wled02_xml.ino index 310e4a4c0..e6725cf25 100644 --- a/wled00/wled02_xml.ino +++ b/wled00/wled02_xml.ino @@ -158,6 +158,7 @@ String getSettings(byte subPage) resp += ds + "TS" + c + sweepTransition +";"; resp += ds + "TI" + c + !sweepDirection +";"; resp += ds + "TD" + v + transitionDelay +";"; + resp += ds + "T2" + c + !disableSecTransition +";"; resp += ds + "BF" + v + briMultiplier +";"; resp += ds + "TB" + v + nightlightTargetBri +";"; resp += ds + "TL" + v + nightlightDelayMins +";"; @@ -188,6 +189,8 @@ String getSettings(byte subPage) resp += ds + "SB" + c + notifyButton +";"; resp += ds + "SH" + c + notifyHue +";"; resp += ds + "S2" + c + notifyTwice +";"; + resp += ds + "RD" + c + receiveDirect +";"; + resp += ds + "RU" + c + enableRealtimeUI +";"; resp += ds + "AL" + c + alexaEnabled +";"; resp += ds + "AI" + v + "\"" + alexaInvocationName + "\";"; resp += ds + "SA" + c + alexaNotify +";"; diff --git a/wled00/wled03_set.ino b/wled00/wled03_set.ino index a799b9ca0..117f143d3 100644 --- a/wled00/wled03_set.ino +++ b/wled00/wled03_set.ino @@ -211,6 +211,7 @@ void handleSettingsSet(byte subPage) transitionDelay = i; } } + disableSecTransition = !server.hasArg("T2"); if (server.hasArg("TB")) { nightlightTargetBri = server.arg("TB").toInt(); @@ -267,6 +268,8 @@ void handleSettingsSet(byte subPage) notifyDirect = notifyDirectDefault; notifyButton = server.hasArg("SB"); notifyTwice = server.hasArg("S2"); + receiveDirect = server.hasArg("RD"); + enableRealtimeUI = server.hasArg("RU"); alexaEnabled = server.hasArg("AL"); if (server.hasArg("AI")) alexaInvocationName = server.arg("AI"); alexaNotify = server.hasArg("SA"); @@ -729,6 +732,12 @@ bool handleSet(String req) if (_cc_updated) strip.setCustomChase(ccIndex1, ccIndex2, ccStart, ccNumPrimary, ccNumSecondary, ccStep, ccFromStart, ccFromEnd); //set presets + pos = req.indexOf("P1="); //sets first preset for cycle + if (pos > 0) presetCycleMin = req.substring(pos + 3).toInt(); + + pos = req.indexOf("P2="); //sets last preset for cycle + if (pos > 0) presetCycleMax = req.substring(pos + 3).toInt(); + if (req.indexOf("CY=") > 0) //preset cycle { presetCyclingEnabled = true; @@ -736,61 +745,36 @@ bool handleSet(String req) { presetCyclingEnabled = false; } - bool all = true; - if (req.indexOf("&PA") > 0) - { - presetCycleBri = true; - all = false; - } - if (req.indexOf("&PC") > 0) - { - presetCycleCol = true; - all = false; - } - if (req.indexOf("&PX") > 0) - { - presetCycleFx = true; - all = false; - } - if (all) - { - presetCycleBri = true; - presetCycleCol = true; - presetCycleFx = true; - } + presetCycCurr = presetCycleMin; } pos = req.indexOf("PT="); //sets cycle time in ms if (pos > 0) { int v = req.substring(pos + 3).toInt(); if (v > 49) presetCycleTime = v; } - pos = req.indexOf("P1="); //sets first preset for cycle - if (pos > 0) presetCycleMin = req.substring(pos + 3).toInt(); - - pos = req.indexOf("P2="); //sets last preset for cycle - if (pos > 0) presetCycleMax = req.substring(pos + 3).toInt(); - + if (req.indexOf("PA=") > 0) //apply brightness from preset + { + presetApplyBri = true; + if (req.indexOf("PA=0") > 0) presetApplyBri = false; + } + if (req.indexOf("PC=") > 0) //apply color from preset + { + presetApplyCol = true; + if (req.indexOf("PC=0") > 0) presetApplyCol = false; + } + if (req.indexOf("PX=") > 0) //apply effects from preset + { + presetApplyFx = true; + if (req.indexOf("PX=0") > 0) presetApplyFx = false; + } pos = req.indexOf("PS="); //saves current in preset if (pos > 0) { savePreset(req.substring(pos + 3).toInt()); } pos = req.indexOf("PL="); //applies entire preset if (pos > 0) { - applyPreset(req.substring(pos + 3).toInt(), true, true, true); - effectUpdated = true; - } - pos = req.indexOf("PA="); //applies brightness from preset - if (pos > 0) { - applyPreset(req.substring(pos + 3).toInt(), true, false, false); - } - pos = req.indexOf("PC="); //applies color from preset - if (pos > 0) { - applyPreset(req.substring(pos + 3).toInt(), false, true, false); - } - pos = req.indexOf("PX="); //applies effects from preset - if (pos > 0) { - applyPreset(req.substring(pos + 3).toInt(), false, false, true); - effectUpdated = true; + applyPreset(req.substring(pos + 3).toInt(), presetApplyBri, presetApplyCol, presetApplyFx); + if (presetApplyFx) effectUpdated = true; } //cronixie diff --git a/wled00/wled05_init.ino b/wled00/wled05_init.ino index 754a97348..30a5da398 100644 --- a/wled00/wled05_init.ino +++ b/wled00/wled05_init.ino @@ -5,7 +5,7 @@ void wledInit() { EEPROM.begin(EEPSIZE); - ledCount = ((EEPROM.read(229) << 0) & 0xFF) + ((EEPROM.read(398) << 8) & 0xFF00); if (ledCount > 1200) ledCount = 10; + ledCount = ((EEPROM.read(229) << 0) & 0xFF) + ((EEPROM.read(398) << 8) & 0xFF00); if (ledCount > 1200 || ledCount == 0) ledCount = 10; //RMT eats up too much RAM #ifdef ARDUINO_ARCH_ESP32 if (ledCount > 600) ledCount = 600; @@ -39,17 +39,11 @@ void wledInit() hueIP[1] = WiFi.localIP()[1]; hueIP[2] = WiFi.localIP()[2]; } - - // Set up mDNS responder: - if (cmDNS != NULL && !onlyAP && !MDNS.begin(cmDNS.c_str())) { - DEBUG_PRINTLN("Error setting up MDNS responder!"); - down(); - } - DEBUG_PRINTLN("mDNS responder started"); if (udpPort > 0 && udpPort != ntpLocalPort && WiFi.status() == WL_CONNECTED) { udpConnected = notifierUdp.begin(udpPort); + //if (udpConnected && udpRgbPort != udpPort) udpRgbConnected = rgbUdp.begin(udpRgbPort); } if (ntpEnabled && WiFi.status() == WL_CONNECTED) ntpConnected = ntpUdp.begin(ntpLocalPort); @@ -182,7 +176,9 @@ void wledInit() }); server.on("/u", HTTP_GET, [](){ - if(!handleFileRead("/user.htm")) serveUserPage(); + server.setContentLength(strlen_P(PAGE_usermod)); + server.send(200, "text/html", ""); + server.sendContent_P(PAGE_usermod); }); server.on("/teapot", HTTP_GET, [](){ @@ -241,8 +237,6 @@ void wledInit() server.begin(); DEBUG_PRINTLN("HTTP server started"); - // Add service to MDNS - MDNS.addService("http", "tcp", 80); //init ArduinoOTA if (aOtaEnabled) @@ -253,9 +247,20 @@ void wledInit() #endif DEBUG_PRINTLN("Start ArduinoOTA"); }); + if (cmDNS.length() > 0) ArduinoOTA.setHostname(cmDNS.c_str()); ArduinoOTA.begin(); } + if (!initLedsLast) strip.service(); + // Set up mDNS responder: + if (cmDNS.length() > 0 && !onlyAP) + { + MDNS.begin(cmDNS.c_str()); + DEBUG_PRINTLN("mDNS responder started"); + // Add service to MDNS + MDNS.addService("http", "tcp", 80); + } + if (initLedsLast) initStrip(); userBegin(); if (macroBoot>0) applyMacro(macroBoot); @@ -272,6 +277,8 @@ void initStrip() strip.start(); pinMode(buttonPin, INPUT_PULLUP); + pinMode(4,OUTPUT); //this is only needed in special cases + digitalWrite(4,LOW); if (bootPreset>0) applyPreset(bootPreset, turnOnAtBoot, true, true); colorUpdated(0); @@ -392,7 +399,7 @@ void serveIndexOrWelcome() void serveIndex() { - if (!arlsTimeout) //do not serve while receiving realtime + if (!arlsTimeout || enableRealtimeUI) //do not serve while receiving realtime { server.setContentLength(strlen_P(PAGE_index0) + cssColorString.length() + strlen_P(PAGE_index1) + strlen_P(PAGE_index2) + strlen_P(PAGE_index3)); server.send(200, "text/html", ""); @@ -440,7 +447,7 @@ void serveMessage(int code, String headl, String subl="", int optionType) void serveSettings(byte subPage) { //0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec 255: welcomepage - if (!arlsTimeout) //do not serve while receiving realtime + if (!arlsTimeout || enableRealtimeUI) //do not serve while receiving realtime { int pl0, pl1; switch (subPage) @@ -518,7 +525,7 @@ String getBuildInfo() #else info += "strip-pin: gpio2\r\n"; #endif - info += "build-type: src\r\n"; + info += "build-type: dev\r\n"; return info; } diff --git a/wled00/wled06_usermod.ino b/wled00/wled06_usermod.ino index 0bae45bba..1c75ad1d4 100644 --- a/wled00/wled06_usermod.ino +++ b/wled00/wled06_usermod.ino @@ -4,9 +4,11 @@ * EEPROM bytes 2944 to 3071 are reserved for your custom use case. */ +//Use userVar0 and userVar1 (API calls &U0=,&U1=, uint16_t) + void userBeginPreConnection() { - + } void userBegin() @@ -18,14 +20,3 @@ void userLoop() { } - -//USER HTML -const char PAGE_usermod[] PROGMEM = R"=====( -There is no usermod installed or it doesn't specify a custom web page. -)====="; - -void serveUserPage() -{ - server.send(200, PAGE_usermod); -} - diff --git a/wled00/wled08_led.ino b/wled00/wled08_led.ino index 7abea58a0..4e97d076c 100644 --- a/wled00/wled08_led.ino +++ b/wled00/wled08_led.ino @@ -12,28 +12,39 @@ void setAllLeds() { } else { strip.setBrightness(val); } + if (disableSecTransition) + { + for (byte i = 0; i<3; i++) + { + colSecT[i] = colSec[i]; + } + whiteSecT = whiteSec; + } if (useGammaCorrectionRGB) { strip.setColor(gamma8[colT[0]], gamma8[colT[1]], gamma8[colT[2]], gamma8[whiteT]); - strip.setSecondaryColor(gamma8[colSec[0]], gamma8[colSec[1]], gamma8[colSec[2]], gamma8[whiteSec]); + strip.setSecondaryColor(gamma8[colSecT[0]], gamma8[colSecT[1]], gamma8[colSecT[2]], gamma8[whiteSecT]); } else { strip.setColor(colT[0], colT[1], colT[2], whiteT); - strip.setSecondaryColor(colSec[0], colSec[1], colSec[2], whiteSec); + strip.setSecondaryColor(colSecT[0], colSecT[1], colSecT[2], whiteSecT); } } void setLedsStandard() { - colOld[0] = col[0]; - colOld[1] = col[1]; - colOld[2] = col[2]; + for (byte i = 0; i<3; i++) + { + colOld[i] = col[i]; + colT[i] = col[i]; + colSecOld[i] = colSec[i]; + colSecT[i] = colSec[i]; + } whiteOld = white; briOld = bri; - colT[0] = col[0]; - colT[1] = col[1]; - colT[2] = col[2]; + whiteSecOld = whiteSec; whiteT = white; briT = bri; + whiteSecT = whiteSec; setAllLeds(); } @@ -86,6 +97,10 @@ void colorUpdated(int callMode) colOld[1] = colT[1]; colOld[2] = colT[2]; whiteOld = whiteT; + colSecOld[0] = colSecT[0]; + colSecOld[1] = colSecT[1]; + colSecOld[2] = colSecT[2]; + whiteSecOld = whiteSecT; briOld = briT; tperLast = 0; } @@ -120,10 +135,13 @@ void handleTransitions() tperLast = tper; if (fadeTransition) { - colT[0] = colOld[0]+((col[0] - colOld[0])*tper); - colT[1] = colOld[1]+((col[1] - colOld[1])*tper); - colT[2] = colOld[2]+((col[2] - colOld[2])*tper); + for (byte i = 0; i<3; i++) + { + colT[i] = colOld[i]+((col[i] - colOld[i])*tper); + colSecT[i] = colSecOld[i]+((colSec[i] - colSecOld[i])*tper); + } whiteT = whiteOld +((white - whiteOld )*tper); + whiteSecT = whiteSecOld +((whiteSec - whiteSecOld )*tper); briT = briOld +((bri - briOld )*tper); } if (sweepTransition) @@ -181,7 +199,7 @@ void handleNightlight() //also handle preset cycle here if (presetCyclingEnabled && (millis() - presetCycledTime > presetCycleTime)) { - applyPreset(presetCycCurr,presetCycleBri,presetCycleCol,presetCycleFx); + applyPreset(presetCycCurr,presetApplyBri,presetApplyCol,presetApplyFx); presetCycCurr++; if (presetCycCurr > presetCycleMax) presetCycCurr = presetCycleMin; if (presetCycCurr > 25) presetCycCurr = 1; colorUpdated(8);