Finished RGBW HTML support

Version bump to 0.4pre
This commit is contained in:
cschwinne 2017-10-12 22:20:37 +02:00
parent f878c89069
commit f37f01c016
11 changed files with 85 additions and 35 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,12 +1,13 @@
<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>WLED 0.3</title>
<title>WLED 0.4p</title>
<script>
strA = "";
strR = "";
strG = "";
strB = "";
strW = "";
strNL = "";
strNR = "";
strNS = "";
@ -19,6 +20,7 @@
var sto = false;
var hsb = false;
var fxa = false;
var uwv = false;
var lastsx = 0;
function Startup()
@ -45,6 +47,14 @@
document.Ctrl_form.SR.value = this.responseXML.getElementsByTagName('cl')[0].childNodes[0].nodeValue;
document.Ctrl_form.SG.value = this.responseXML.getElementsByTagName('cl')[1].childNodes[0].nodeValue;
document.Ctrl_form.SB.value = this.responseXML.getElementsByTagName('cl')[2].childNodes[0].nodeValue;
if (this.responseXML.getElementsByTagName('wv')[0].childNodes[0].nodeValue >= 0) {
document.Ctrl_form.SW.value = this.responseXML.getElementsByTagName('wv')[0].childNodes[0].nodeValue;
if (!uwv) document.getElementById("slW").style.display="block";
uwv = true;
} else {
document.getElementById("slW").style.display="none";
uwv = false;
}
if (document.activeElement != document.getElementById("fxI")) document.Ctrl_form.TF.value = this.responseXML.getElementsByTagName('fx')[0].childNodes[0].nodeValue;
document.Ctrl_form.SX.value = this.responseXML.getElementsByTagName('sx')[0].childNodes[0].nodeValue;
nla = (this.responseXML.getElementsByTagName('nl')[0].innerHTML)!=0?true:false;
@ -58,12 +68,13 @@
}
}
// send HTTP request
request.open("GET", "win/" + strA + strR + strG + strB + strNL + strNR + strNS + strMD + strFX + strSX +nocache, true);
request.open("GET", "win/" + strA + strR + strG + strB + strW + strNL + strNR + strNS + strMD + strFX + strSX +nocache, true);
request.send(null);
strA = "";
strR = "";
strG = "";
strB = "";
strW = "";
strNL = "";
strNR = "";
strNS = "";
@ -77,6 +88,7 @@
strR = "&R=" + Ctrl_form.SR.value;
strG = "&G=" + Ctrl_form.SG.value;
strB = "&B=" + Ctrl_form.SB.value;
if (uwv) strW = "&W=" + Ctrl_form.SW.value;
UpdateVals();
GetArduinoIO();
}
@ -144,7 +156,7 @@
{
document.Ctrl_form.TF.value = parseInt(document.Ctrl_form.TF.value) +s;
if (document.Ctrl_form.TF.value < 0) document.Ctrl_form.TF.value = 0;
if (document.Ctrl_form.TF.value > 47) document.Ctrl_form.TF.value = 47;
if (document.Ctrl_form.TF.value > 52) document.Ctrl_form.TF.value = 52;
GetFX();
}
function SetFX()
@ -157,6 +169,7 @@
document.getElementById("slB").style.display="none";
document.getElementById("slH").style.display="none";
document.getElementById("slS").style.display="none";
document.getElementById("slW").style.display="none";
document.getElementById("slX").style.display="block";
document.getElementById("tlX").style.display="block";
} else {
@ -164,6 +177,7 @@
document.getElementById("slA").style.display="block";
document.getElementById("slX").style.display="none";
document.getElementById("tlX").style.display="none";
if (uwv) document.getElementById("slW").style.display="block";
SetHSB();
}
}
@ -363,6 +377,14 @@
width: 77vw;
background: linear-gradient(to right, black, blue);
}
.sliderW {
display:none;
margin-left: auto;
margin-right: auto;
margin-top: 2vh;
width: 77vw;
background: linear-gradient(to right, black, white);
}
.sliderH {
display:none;
margin-left: auto;
@ -540,6 +562,8 @@
<input type="range" title="Hue" class="sliders" name="SH" value="0" min="0" max="1" step="0.025" onchange="GetRGB()"> </div>
<div id="slS" class="sliderS">
<input type="range" title="Saturation" class="sliders" name="SS" value="0" min="0" max="1" step="0.025" onchange="GetRGB()"> </div>
<div id="slW" class="sliderW">
<input type="range" title="White Value" class="sliders" name="SW" value="0" min="0" max="255" step="1" onchange="GetCheck()"> </div>
<div id="tlX" class = "toolsFX">
<svg id="fmr" onclick="SwitchFX(-10)"><use xlink:href="#icon-backward2"></use></svg>
<svg id="for" onclick="SwitchFX(-1)"><use xlink:href="#icon-circle-left"></use></svg>

File diff suppressed because one or more lines are too long

View File

@ -38,6 +38,7 @@
document.S_form.CLDFG.value = this.responseXML.getElementsByTagName('cldef')[1].innerHTML;
document.S_form.CLDFB.value = this.responseXML.getElementsByTagName('cldef')[2].innerHTML;
document.S_form.CLDFA.value = this.responseXML.getElementsByTagName('cldfa')[0].innerHTML;
document.S_form.CLDFW.value = this.responseXML.getElementsByTagName('cldfw')[0].innerHTML;
document.S_form.FXDEF.value = this.responseXML.getElementsByTagName('fxdef')[0].innerHTML;
document.S_form.SXDEF.value = this.responseXML.getElementsByTagName('sxdef')[0].innerHTML;
document.S_form.BOOTN.checked = (this.responseXML.getElementsByTagName('bootn')[0].innerHTML)!=0?true:false;
@ -127,6 +128,7 @@
<input name="CLDFG" maxlength="3" size="2">
<input name="CLDFB" maxlength="3" size="2"> <br>
Default brightness: <input name="CLDFA" maxlength="3" size="2"> (0-255) <br>
Default white value (only RGBW, -1 to disable): <input name="CLDFW" maxlength="3" size="2"> <br>
Default effect ID: <input name="FXDEF" maxlength="3" size="2"> <br>
Default effect speed: <input name="SXDEF" maxlength="3" size="2"> <br>
Ignore and use current color, brightness and effects: <input type="checkbox" name="CBEOR"> <br>
@ -152,9 +154,8 @@
Emulate Alexa device: <input type="checkbox" name="ALEXA"> <br>
Alexa invocation name: <input name="AINVN" maxlength="32"><br>
Send Alexa notifications: <input type="checkbox" name="NSALX"> <br>
<h3>Time (highly experimental!)</h3>
<b> Warning! </b>NTP was updated but still causes crashes. Requires reboot. <br>
It is really not recommended to use this! <br>
<h3>Time (experimental!)</h3>
NTP was updated but still causes crashes. Requires reboot. <br>
Get time from NTP server: <input type="checkbox" name="NTPON"> <br>
Current local time is <span class="times">unknown</span> <br>
<h3>Advanced</h3>
@ -174,7 +175,7 @@
HTTP traffic is not encrypted. An attacker in the same network could intercept form data!<br>
<h3>About</h3>
WLED version 0.3 <br>
WLED version 0.4p <br>
(c) 2016-2017 Christian Schwinne <br>
<i>Licensed under the MIT license</i> <br>
<i>Uses libraries:</i> <br>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -20,7 +20,7 @@
#include "CallbackFunction.h"
//version in format yymmddb (b = daily build)
#define VERSION 1710120
#define VERSION 1710121
//uncomment if you have an RGBW strip
#define RGBW
@ -50,7 +50,7 @@
/*
* @title WLED project sketch
* @version 0.3
* @version 0.4p
* @author Christian Schwinne
*/
//Hardware-settings (only changeble via code)
@ -87,6 +87,7 @@ IPAddress staticsubnet(255, 255, 255, 0);
boolean useHSB = false, useHSBDefault = false;
boolean turnOnAtBoot = true;
byte col_s[]{255, 159, 0};
boolean useRGBW = false;
byte white_s = 0;
byte bri_s = 127;
uint8_t bri_nl = 0, bri_nls;

View File

@ -102,6 +102,7 @@ void saveSettingsToEEPROM()
EEPROM.write(369, turnOnAtBoot);
EEPROM.write(370, useHSBDefault);
EEPROM.write(371, white_s);
EEPROM.write(372, useRGBW);
EEPROM.commit();
}
@ -214,5 +215,6 @@ void loadSettingsFromEEPROM()
turnOnAtBoot = EEPROM.read(369);
useHSBDefault = EEPROM.read(370);
white_s = EEPROM.read(371);
useRGBW = EEPROM.read(372);
useHSB = useHSBDefault;
}

View File

@ -34,11 +34,11 @@ void XML_response()
resp = resp + "</fx><sx>";
resp = resp + effectSpeed;
resp = resp + "</sx><wv>";
#ifdef RGBW
resp = resp + white;
#else
resp = resp + "-1";
#endif
if (useRGBW) {
resp = resp + white;
} else {
resp = resp + "-1";
}
resp = resp + "</wv><md>";
resp = resp + useHSB;
resp = resp + "</md><desc>";
@ -116,7 +116,11 @@ void XML_response_settings()
resp = resp + "</cldef>";
}
resp = resp + "<cldfw>";
resp = resp + white_s;
if (useRGBW) {
resp = resp + white_s;
} else {
resp = resp + "-1";
}
resp = resp + "</cldfw><cldfa>";
resp = resp + bri_s;
resp = resp + "</cldfa>";
@ -218,7 +222,7 @@ void XML_response_settings()
resp = resp + "Not active";
}
resp = resp + "</sip>";
resp = resp + "<msg>WLED 0.3 (build ";
resp = resp + "<msg>WLED 0.4p (build ";
resp = resp + VERSION;
resp = resp + ") OK</msg>";
resp = resp + "</vs>";

View File

@ -133,7 +133,14 @@ void handleSettingsSet()
if (server.hasArg("CLDFW"))
{
int i = server.arg("CLDFW").toInt();
if (i >= 0 && i <= 255) white_s = i;
if (i >= 0 && i <= 255)
{
useRGBW = true;
white_s = i;
} else {
useRGBW = false;
white_s = 0;
}
}
if (server.hasArg("CLDFA"))
{

View File

@ -90,6 +90,12 @@ void wledInit()
server.on("/version", HTTP_GET, [](){
server.send(200, "text/plain", (String)VERSION);
});
server.on("/uptime", HTTP_GET, [](){
server.send(200, "text/plain", (String)millis());
});
server.on("/freeheap", HTTP_GET, [](){
server.send(200, "text/plain", (String)ESP.getFreeHeap());
});
if (!ota_lock){
server.on("/edit", HTTP_GET, [](){
if(!handleFileRead("/edit.htm")) server.send(200, "text/html", PAGE_edit);