Changed preset cycle API format

Added secondary color transition
Added option to have UI while receiving realtime
Fixed mDNS not working
Fixed Arduino OTA not working when locked but enabled
This commit is contained in:
cschwinne 2018-05-10 19:55:58 +02:00
parent 356ff57005
commit 3afb499930
14 changed files with 128 additions and 109 deletions

View File

@ -2,7 +2,7 @@
<html> <html>
<head><meta charset="utf-8"> <head><meta charset="utf-8">
<link rel='shortcut icon' type='image/x-icon' href='/favicon.ico'/> <link rel='shortcut icon' type='image/x-icon' href='/favicon.ico'/>
<title>WLED 0.6.4</title> <title>WLED 0.6.5</title>
<script> <script>
var d=document; var d=document;
var w=window.getComputedStyle(d.querySelector("html")); var w=window.getComputedStyle(d.querySelector("html"));
@ -217,21 +217,22 @@
if (d.Cf.FF.value < 1) d.Cf.FF.value = 1; if (d.Cf.FF.value < 1) d.Cf.FF.value = 1;
if (d.Cf.FF.value > 25) d.Cf.FF.value = 25; if (d.Cf.FF.value > 25) d.Cf.FF.value = 25;
} }
function PAt()
{
resp+=(d.Cf.BC.checked)?"&PA=1":"&PA=0";
resp+=(d.Cf.CC.checked)?"&PC=1":"&PC=0";
resp+=(d.Cf.FC.checked)?"&PX=1":"&PX=0";
}
function PSIO(sv) function PSIO(sv)
{ {
PAt();
if(sv) if(sv)
{ {
resp+="&PS="; resp+="&PS=";
resp+=d.Cf.FF.value; resp+=d.Cf.FF.value;
} else } else
{ {
if (d.Cf.BC.checked&&d.Cf.CC.checked&&d.Cf.FC.checked) resp+="&PL=";resp+=d.Cf.FF.value;
{resp+="&PL=";resp+=d.Cf.FF.value;}
else {
if(d.Cf.BC.checked){resp+="&PA=";resp+=d.Cf.FF.value;}
if(d.Cf.CC.checked){resp+="&PC=";resp+=d.Cf.FF.value;}
if(d.Cf.FC.checked){resp+="&PX=";resp+=d.Cf.FF.value;}
}
} }
GIO(); GIO();
} }
@ -337,13 +338,11 @@
} }
function uCY() function uCY()
{ {
PAt();
resp+=(d.Cf.CY.checked)?"&CY=1":"&CY=0"; resp+=(d.Cf.CY.checked)?"&CY=1":"&CY=0";
resp+="&P1=" + Cf.P1.value; resp+="&P1=" + Cf.P1.value;
resp+="&P2=" + Cf.P2.value; resp+="&P2=" + Cf.P2.value;
resp+="&PT=" + Cf.PT.value; resp+="&PT=" + Cf.PT.value;
if(d.Cf.BC.checked){resp+="&PA";}
if(d.Cf.CC.checked){resp+="&PC";}
if(d.Cf.FC.checked){resp+="&PX";}
GIO(); GIO();
} }
function R() function R()

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -109,7 +109,8 @@ Brightness factor: <input name="BF" type="number" min="0" max="255" required> %
<h3>Transitions</h3> <h3>Transitions</h3>
Fade: <input type="checkbox" name="TF"><br> Fade: <input type="checkbox" name="TF"><br>
Sweep: <input type="checkbox" name="TS"> Invert direction: <input type="checkbox" name="TI"><br> Sweep: <input type="checkbox" name="TS"> Invert direction: <input type="checkbox" name="TI"><br>
Transition Time: <input name="TD" maxlength="5" size="2"> ms Transition Time: <input name="TD" maxlength="5" size="2"> ms<br>
Enable transition for secondary color: <input type="checkbox" name="T2"><br>
<h3>Timed light</h3> <h3>Timed light</h3>
Default Duration: <input name="TL" type="number" min="1" max="255" required> min<br> Default Duration: <input name="TL" type="number" min="1" max="255" required> min<br>
Default Target brightness: <input name="TB" type="number" min="0" max="255" required><br> Default Target brightness: <input name="TB" type="number" min="0" max="255" required><br>
@ -196,7 +197,9 @@ Send notifications on direct change: <input type="checkbox" name="SD"><br>
Send notifications on button press: <input type="checkbox" name="SB"><br> Send notifications on button press: <input type="checkbox" name="SB"><br>
Send Alexa notifications: <input type="checkbox" name="SA"><br> Send Alexa notifications: <input type="checkbox" name="SA"><br>
Send Philips Hue change notifications: <input type="checkbox" name="SH"><br> Send Philips Hue change notifications: <input type="checkbox" name="SH"><br>
Send notifications twice: <input type="checkbox" name="S2"> Send notifications twice: <input type="checkbox" name="S2"><br>
Receive UDP realtime: <input type="checkbox" name="RD"><br>
Enable UI access during realtime: <input type="checkbox" name="RU"> (can cause issues)
<h3>Alexa Voice Assistant</h3> <h3>Alexa Voice Assistant</h3>
Emulate Alexa device: <input type="checkbox" name="AL"><br> Emulate Alexa device: <input type="checkbox" name="AL"><br>
Alexa invocation name: <input name="AI" maxlength="32"><br> Alexa invocation name: <input name="AI" maxlength="32"><br>
@ -318,7 +321,7 @@ const char PAGE_settings_sec1[] PROGMEM = R"=====(
<div class="helpB"><button type="button" onclick="H()">?</button></div> <div class="helpB"><button type="button" onclick="H()">?</button></div>
<button type="button" onclick="B()">Back</button><button type="submit">Save & Reboot</button><hr> <button type="button" onclick="B()">Back</button><button type="submit">Save & Reboot</button><hr>
<h2>Security & Update setup</h2> <h2>Security & Update setup</h2>
Enable OTA lock: <input type="checkbox" name="NO"><br> Lock wireless (OTA) software update: <input type="checkbox" name="NO"><br>
Passphrase: <input type="password" name="OP" maxlength="32"><br> Passphrase: <input type="password" name="OP" maxlength="32"><br>
To enable OTA, for security reasons you need to also enter the correct password!<br> To enable OTA, for security reasons you need to also enter the correct password!<br>
The password should be changed when OTA is enabled.<br> The password should be changed when OTA is enabled.<br>
@ -335,7 +338,7 @@ HTTP traffic is unencrypted. An attacker in the same network can intercept form
<button type="button" onclick="U()">Manual OTA Update</button><br> <button type="button" onclick="U()">Manual OTA Update</button><br>
Enable ArduinoOTA: <input type="checkbox" name="AO"><br> Enable ArduinoOTA: <input type="checkbox" name="AO"><br>
<h3>About</h3> <h3>About</h3>
<a href="https://github.com/Aircoookie/WLED">WLED</a> version 0.6.4<br> <a href="https://github.com/Aircoookie/WLED">WLED</a> version 0.6.5<br>
(c) 2016-2018 Christian Schwinne <br> (c) 2016-2018 Christian Schwinne <br>
<i>Licensed under the MIT license</i><br><br> <i>Licensed under the MIT license</i><br><br>
<i>Uses libraries:</i><br> <i>Uses libraries:</i><br>

View File

@ -1,3 +1,7 @@
//USER HTML
const char PAGE_usermod[] PROGMEM = R"=====(
<html><body>There is no usermod installed or it doesn't specify a custom web page.</body></html>
)=====";
/* /*
* Various * Various
*/ */

View File

@ -3,7 +3,7 @@
*/ */
/* /*
* @title WLED project sketch * @title WLED project sketch
* @version 0.6.4 * @version 0.6.5
* @author Christian Schwinne * @author Christian Schwinne
*/ */
@ -33,8 +33,8 @@
#include "WS2812FX.h" #include "WS2812FX.h"
//version in format yymmddb (b = daily build) //version in format yymmddb (b = daily build)
#define VERSION 1804221 #define VERSION 1805061
const String versionString = "0.6.4"; const String versionString = "0.6.5";
//AP and OTA default passwords (change them!) //AP and OTA default passwords (change them!)
String apPass = "wled1234"; 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 byte auxTriggeredState = 0; //0: input 1: high 2: low
//Default CONFIG //Default CONFIG
String serverDescription = versionString; String serverDescription = "WLED Light";
byte currentTheme = 0; byte currentTheme = 0;
String clientSSID = "Your_Network"; String clientSSID = "Your_Network";
String clientPass = ""; String clientPass = "";
@ -81,6 +81,7 @@ byte briS = 127;
byte nightlightTargetBri = 0; byte nightlightTargetBri = 0;
bool fadeTransition = true; bool fadeTransition = true;
bool sweepTransition = false, sweepDirection = true; bool sweepTransition = false, sweepDirection = true;
bool disableSecTransition = true;
uint16_t transitionDelay = 1200, transitionDelayDefault = transitionDelay; uint16_t transitionDelay = 1200, transitionDelayDefault = transitionDelay;
bool reverseMode = false; bool reverseMode = false;
bool otaLock = false, wifiLock = false; bool otaLock = false, wifiLock = false;
@ -134,9 +135,11 @@ byte colOld[]{0, 0, 0};
byte colT[]{0, 0, 0}; byte colT[]{0, 0, 0};
byte colIT[]{0, 0, 0}; byte colIT[]{0, 0, 0};
byte colSec[]{0, 0, 0}; byte colSec[]{0, 0, 0};
byte colSecT[]{0, 0, 0};
byte colSecOld[]{0, 0, 0};
byte colSecIT[]{0, 0, 0}; byte colSecIT[]{0, 0, 0};
byte white, whiteOld, whiteT, whiteIT; byte white, whiteOld, whiteT, whiteIT;
byte whiteSec, whiteSecIT; byte whiteSec, whiteSecOld, whiteSecT, whiteSecIT;
byte lastRandomIndex = 0; byte lastRandomIndex = 0;
uint16_t transitionDelayTemp = transitionDelay; uint16_t transitionDelayTemp = transitionDelay;
unsigned long transitionStartTime; unsigned long transitionStartTime;
@ -209,11 +212,11 @@ bool presetCyclingEnabled = false;
byte presetCycleMin = 1, presetCycleMax = 5; byte presetCycleMin = 1, presetCycleMax = 5;
uint16_t presetCycleTime = 1250; uint16_t presetCycleTime = 1250;
unsigned long presetCycledTime = 0; byte presetCycCurr = presetCycleMin; unsigned long presetCycledTime = 0; byte presetCycCurr = presetCycleMin;
bool presetCycleBri, presetCycleCol, presetCycleFx; bool presetApplyBri = true, presetApplyCol = true, presetApplyFx = true;
uint32_t arlsTimeoutMillis = 2500; uint32_t arlsTimeoutMillis = 2500;
bool arlsTimeout = false; bool arlsTimeout = false;
bool receiveDirect = true; bool receiveDirect = true, enableRealtimeUI = false;
unsigned long arlsTimeoutTime; unsigned long arlsTimeoutTime;
byte auxTime = 0; byte auxTime = 0;
unsigned long auxStartTime; unsigned long auxStartTime;
@ -242,7 +245,7 @@ ESP8266WebServer server(80);
#endif #endif
HTTPClient hueClient; HTTPClient hueClient;
ESP8266HTTPUpdateServer httpUpdater; ESP8266HTTPUpdateServer httpUpdater;
WiFiUDP notifierUdp; WiFiUDP notifierUdp;//, rgbUdp;
WiFiUDP ntpUdp; WiFiUDP ntpUdp;
IPAddress ntpServerIP; IPAddress ntpServerIP;
unsigned int ntpLocalPort = 2390; unsigned int ntpLocalPort = 2390;
@ -325,7 +328,7 @@ void loop() {
yield(); yield();
handleButton(); handleButton();
handleNetworkTime(); handleNetworkTime();
if (!otaLock && aOtaEnabled) ArduinoOTA.handle(); if (aOtaEnabled) ArduinoOTA.handle();
handleAlexa(); handleAlexa();
handleOverlays(); handleOverlays();
if (!arlsTimeout) //block stuff if WARLS/Adalight is enabled if (!arlsTimeout) //block stuff if WARLS/Adalight is enabled

View File

@ -148,6 +148,7 @@ void saveSettingsToEEPROM()
EEPROM.write(396, (utcOffsetSecs<0)); //is negative EEPROM.write(396, (utcOffsetSecs<0)); //is negative
EEPROM.write(397, initLedsLast); EEPROM.write(397, initLedsLast);
EEPROM.write(398, (ledCount >> 8) & 0xFF); EEPROM.write(398, (ledCount >> 8) & 0xFF);
EEPROM.write(399, disableSecTransition);
for (int k=0;k<6;k++){ for (int k=0;k<6;k++){
int in = 900+k*8; int in = 900+k*8;
@ -209,6 +210,9 @@ void saveSettingsToEEPROM()
EEPROM.write(2180, macroCountdown); EEPROM.write(2180, macroCountdown);
EEPROM.write(2181, macroNl); EEPROM.write(2181, macroNl);
EEPROM.write(2200,!receiveDirect);
EEPROM.write(2201,enableRealtimeUI);
EEPROM.commit(); EEPROM.commit();
} }
@ -260,7 +264,7 @@ void loadSettingsFromEEPROM(bool first)
if (apChannel > 13 || apChannel < 1) apChannel = 1; if (apChannel > 13 || apChannel < 1) apChannel = 1;
apHide = EEPROM.read(228); apHide = EEPROM.read(228);
if (apHide > 1) apHide = 1; 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); notifyButton = EEPROM.read(230);
notifyTwice = EEPROM.read(231); notifyTwice = EEPROM.read(231);
buttonEnabled = EEPROM.read(232); buttonEnabled = EEPROM.read(232);
@ -416,14 +420,17 @@ void loadSettingsFromEEPROM(bool first)
macroCountdown = EEPROM.read(2180); macroCountdown = EEPROM.read(2180);
macroNl = EEPROM.read(2181); macroNl = EEPROM.read(2181);
} }
receiveDirect = !EEPROM.read(2200);
enableRealtimeUI = EEPROM.read(2201);
bootPreset = EEPROM.read(389); bootPreset = EEPROM.read(389);
wifiLock = EEPROM.read(393); wifiLock = EEPROM.read(393);
utcOffsetSecs = ((EEPROM.read(394) << 0) & 0xFF) + ((EEPROM.read(395) << 8) & 0xFF00); utcOffsetSecs = ((EEPROM.read(394) << 0) & 0xFF) + ((EEPROM.read(395) << 8) & 0xFF00);
if (EEPROM.read(396)) utcOffsetSecs = -utcOffsetSecs; //negative if (EEPROM.read(396)) utcOffsetSecs = -utcOffsetSecs; //negative
initLedsLast = EEPROM.read(397); 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 //400 - 899 reserved
currentTheme = EEPROM.read(948); currentTheme = EEPROM.read(948);

View File

@ -158,6 +158,7 @@ String getSettings(byte subPage)
resp += ds + "TS" + c + sweepTransition +";"; resp += ds + "TS" + c + sweepTransition +";";
resp += ds + "TI" + c + !sweepDirection +";"; resp += ds + "TI" + c + !sweepDirection +";";
resp += ds + "TD" + v + transitionDelay +";"; resp += ds + "TD" + v + transitionDelay +";";
resp += ds + "T2" + c + !disableSecTransition +";";
resp += ds + "BF" + v + briMultiplier +";"; resp += ds + "BF" + v + briMultiplier +";";
resp += ds + "TB" + v + nightlightTargetBri +";"; resp += ds + "TB" + v + nightlightTargetBri +";";
resp += ds + "TL" + v + nightlightDelayMins +";"; resp += ds + "TL" + v + nightlightDelayMins +";";
@ -188,6 +189,8 @@ String getSettings(byte subPage)
resp += ds + "SB" + c + notifyButton +";"; resp += ds + "SB" + c + notifyButton +";";
resp += ds + "SH" + c + notifyHue +";"; resp += ds + "SH" + c + notifyHue +";";
resp += ds + "S2" + c + notifyTwice +";"; resp += ds + "S2" + c + notifyTwice +";";
resp += ds + "RD" + c + receiveDirect +";";
resp += ds + "RU" + c + enableRealtimeUI +";";
resp += ds + "AL" + c + alexaEnabled +";"; resp += ds + "AL" + c + alexaEnabled +";";
resp += ds + "AI" + v + "\"" + alexaInvocationName + "\";"; resp += ds + "AI" + v + "\"" + alexaInvocationName + "\";";
resp += ds + "SA" + c + alexaNotify +";"; resp += ds + "SA" + c + alexaNotify +";";

View File

@ -211,6 +211,7 @@ void handleSettingsSet(byte subPage)
transitionDelay = i; transitionDelay = i;
} }
} }
disableSecTransition = !server.hasArg("T2");
if (server.hasArg("TB")) if (server.hasArg("TB"))
{ {
nightlightTargetBri = server.arg("TB").toInt(); nightlightTargetBri = server.arg("TB").toInt();
@ -267,6 +268,8 @@ void handleSettingsSet(byte subPage)
notifyDirect = notifyDirectDefault; notifyDirect = notifyDirectDefault;
notifyButton = server.hasArg("SB"); notifyButton = server.hasArg("SB");
notifyTwice = server.hasArg("S2"); notifyTwice = server.hasArg("S2");
receiveDirect = server.hasArg("RD");
enableRealtimeUI = server.hasArg("RU");
alexaEnabled = server.hasArg("AL"); alexaEnabled = server.hasArg("AL");
if (server.hasArg("AI")) alexaInvocationName = server.arg("AI"); if (server.hasArg("AI")) alexaInvocationName = server.arg("AI");
alexaNotify = server.hasArg("SA"); 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); if (_cc_updated) strip.setCustomChase(ccIndex1, ccIndex2, ccStart, ccNumPrimary, ccNumSecondary, ccStep, ccFromStart, ccFromEnd);
//set presets //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 if (req.indexOf("CY=") > 0) //preset cycle
{ {
presetCyclingEnabled = true; presetCyclingEnabled = true;
@ -736,61 +745,36 @@ bool handleSet(String req)
{ {
presetCyclingEnabled = false; presetCyclingEnabled = false;
} }
bool all = true; presetCycCurr = presetCycleMin;
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;
}
} }
pos = req.indexOf("PT="); //sets cycle time in ms pos = req.indexOf("PT="); //sets cycle time in ms
if (pos > 0) { if (pos > 0) {
int v = req.substring(pos + 3).toInt(); int v = req.substring(pos + 3).toInt();
if (v > 49) presetCycleTime = v; if (v > 49) presetCycleTime = v;
} }
pos = req.indexOf("P1="); //sets first preset for cycle if (req.indexOf("PA=") > 0) //apply brightness from preset
if (pos > 0) presetCycleMin = req.substring(pos + 3).toInt(); {
presetApplyBri = true;
pos = req.indexOf("P2="); //sets last preset for cycle if (req.indexOf("PA=0") > 0) presetApplyBri = false;
if (pos > 0) presetCycleMax = req.substring(pos + 3).toInt(); }
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 pos = req.indexOf("PS="); //saves current in preset
if (pos > 0) { if (pos > 0) {
savePreset(req.substring(pos + 3).toInt()); savePreset(req.substring(pos + 3).toInt());
} }
pos = req.indexOf("PL="); //applies entire preset pos = req.indexOf("PL="); //applies entire preset
if (pos > 0) { if (pos > 0) {
applyPreset(req.substring(pos + 3).toInt(), true, true, true); applyPreset(req.substring(pos + 3).toInt(), presetApplyBri, presetApplyCol, presetApplyFx);
effectUpdated = true; if (presetApplyFx) 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;
} }
//cronixie //cronixie

View File

@ -5,7 +5,7 @@
void wledInit() void wledInit()
{ {
EEPROM.begin(EEPSIZE); 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 //RMT eats up too much RAM
#ifdef ARDUINO_ARCH_ESP32 #ifdef ARDUINO_ARCH_ESP32
if (ledCount > 600) ledCount = 600; if (ledCount > 600) ledCount = 600;
@ -40,16 +40,10 @@ void wledInit()
hueIP[2] = WiFi.localIP()[2]; 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) if (udpPort > 0 && udpPort != ntpLocalPort && WiFi.status() == WL_CONNECTED)
{ {
udpConnected = notifierUdp.begin(udpPort); udpConnected = notifierUdp.begin(udpPort);
//if (udpConnected && udpRgbPort != udpPort) udpRgbConnected = rgbUdp.begin(udpRgbPort);
} }
if (ntpEnabled && WiFi.status() == WL_CONNECTED) if (ntpEnabled && WiFi.status() == WL_CONNECTED)
ntpConnected = ntpUdp.begin(ntpLocalPort); ntpConnected = ntpUdp.begin(ntpLocalPort);
@ -182,7 +176,9 @@ void wledInit()
}); });
server.on("/u", HTTP_GET, [](){ 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, [](){ server.on("/teapot", HTTP_GET, [](){
@ -241,8 +237,6 @@ void wledInit()
server.begin(); server.begin();
DEBUG_PRINTLN("HTTP server started"); DEBUG_PRINTLN("HTTP server started");
// Add service to MDNS
MDNS.addService("http", "tcp", 80);
//init ArduinoOTA //init ArduinoOTA
if (aOtaEnabled) if (aOtaEnabled)
@ -253,9 +247,20 @@ void wledInit()
#endif #endif
DEBUG_PRINTLN("Start ArduinoOTA"); DEBUG_PRINTLN("Start ArduinoOTA");
}); });
if (cmDNS.length() > 0) ArduinoOTA.setHostname(cmDNS.c_str());
ArduinoOTA.begin(); 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(); if (initLedsLast) initStrip();
userBegin(); userBegin();
if (macroBoot>0) applyMacro(macroBoot); if (macroBoot>0) applyMacro(macroBoot);
@ -272,6 +277,8 @@ void initStrip()
strip.start(); strip.start();
pinMode(buttonPin, INPUT_PULLUP); 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); if (bootPreset>0) applyPreset(bootPreset, turnOnAtBoot, true, true);
colorUpdated(0); colorUpdated(0);
@ -392,7 +399,7 @@ void serveIndexOrWelcome()
void serveIndex() 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.setContentLength(strlen_P(PAGE_index0) + cssColorString.length() + strlen_P(PAGE_index1) + strlen_P(PAGE_index2) + strlen_P(PAGE_index3));
server.send(200, "text/html", ""); server.send(200, "text/html", "");
@ -440,7 +447,7 @@ void serveMessage(int code, String headl, String subl="", int optionType)
void serveSettings(byte subPage) void serveSettings(byte subPage)
{ {
//0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec 255: welcomepage //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; int pl0, pl1;
switch (subPage) switch (subPage)
@ -518,7 +525,7 @@ String getBuildInfo()
#else #else
info += "strip-pin: gpio2\r\n"; info += "strip-pin: gpio2\r\n";
#endif #endif
info += "build-type: src\r\n"; info += "build-type: dev\r\n";
return info; return info;
} }

View File

@ -4,6 +4,8 @@
* EEPROM bytes 2944 to 3071 are reserved for your custom use case. * 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 userBeginPreConnection()
{ {
@ -18,14 +20,3 @@ void userLoop()
{ {
} }
//USER HTML
const char PAGE_usermod[] PROGMEM = R"=====(
<html><body>There is no usermod installed or it doesn't specify a custom web page.</body></html>
)=====";
void serveUserPage()
{
server.send(200, PAGE_usermod);
}

View File

@ -12,28 +12,39 @@ void setAllLeds() {
} else { } else {
strip.setBrightness(val); strip.setBrightness(val);
} }
if (disableSecTransition)
{
for (byte i = 0; i<3; i++)
{
colSecT[i] = colSec[i];
}
whiteSecT = whiteSec;
}
if (useGammaCorrectionRGB) if (useGammaCorrectionRGB)
{ {
strip.setColor(gamma8[colT[0]], gamma8[colT[1]], gamma8[colT[2]], gamma8[whiteT]); 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 { } else {
strip.setColor(colT[0], colT[1], colT[2], whiteT); 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() void setLedsStandard()
{ {
colOld[0] = col[0]; for (byte i = 0; i<3; i++)
colOld[1] = col[1]; {
colOld[2] = col[2]; colOld[i] = col[i];
colT[i] = col[i];
colSecOld[i] = colSec[i];
colSecT[i] = colSec[i];
}
whiteOld = white; whiteOld = white;
briOld = bri; briOld = bri;
colT[0] = col[0]; whiteSecOld = whiteSec;
colT[1] = col[1];
colT[2] = col[2];
whiteT = white; whiteT = white;
briT = bri; briT = bri;
whiteSecT = whiteSec;
setAllLeds(); setAllLeds();
} }
@ -86,6 +97,10 @@ void colorUpdated(int callMode)
colOld[1] = colT[1]; colOld[1] = colT[1];
colOld[2] = colT[2]; colOld[2] = colT[2];
whiteOld = whiteT; whiteOld = whiteT;
colSecOld[0] = colSecT[0];
colSecOld[1] = colSecT[1];
colSecOld[2] = colSecT[2];
whiteSecOld = whiteSecT;
briOld = briT; briOld = briT;
tperLast = 0; tperLast = 0;
} }
@ -120,10 +135,13 @@ void handleTransitions()
tperLast = tper; tperLast = tper;
if (fadeTransition) if (fadeTransition)
{ {
colT[0] = colOld[0]+((col[0] - colOld[0])*tper); for (byte i = 0; i<3; i++)
colT[1] = colOld[1]+((col[1] - colOld[1])*tper); {
colT[2] = colOld[2]+((col[2] - colOld[2])*tper); colT[i] = colOld[i]+((col[i] - colOld[i])*tper);
colSecT[i] = colSecOld[i]+((colSec[i] - colSecOld[i])*tper);
}
whiteT = whiteOld +((white - whiteOld )*tper); whiteT = whiteOld +((white - whiteOld )*tper);
whiteSecT = whiteSecOld +((whiteSec - whiteSecOld )*tper);
briT = briOld +((bri - briOld )*tper); briT = briOld +((bri - briOld )*tper);
} }
if (sweepTransition) if (sweepTransition)
@ -181,7 +199,7 @@ void handleNightlight()
//also handle preset cycle here //also handle preset cycle here
if (presetCyclingEnabled && (millis() - presetCycledTime > presetCycleTime)) if (presetCyclingEnabled && (millis() - presetCycledTime > presetCycleTime))
{ {
applyPreset(presetCycCurr,presetCycleBri,presetCycleCol,presetCycleFx); applyPreset(presetCycCurr,presetApplyBri,presetApplyCol,presetApplyFx);
presetCycCurr++; if (presetCycCurr > presetCycleMax) presetCycCurr = presetCycleMin; presetCycCurr++; if (presetCycCurr > presetCycleMax) presetCycCurr = presetCycleMin;
if (presetCycCurr > 25) presetCycCurr = 1; if (presetCycCurr > 25) presetCycCurr = 1;
colorUpdated(8); colorUpdated(8);