Started optimizing code by converting String to char*
This commit is contained in:
parent
4e3c83af94
commit
72f203e4fa
@ -38,12 +38,12 @@
|
|||||||
#include "src/dependencies/blynk/BlynkSimpleEsp.h"
|
#include "src/dependencies/blynk/BlynkSimpleEsp.h"
|
||||||
|
|
||||||
//version in format yymmddb (b = daily build)
|
//version in format yymmddb (b = daily build)
|
||||||
#define VERSION 1807122
|
#define VERSION 1807201
|
||||||
const String versionString = "0.7.1";
|
char versionString[] = "0.7.1";
|
||||||
|
|
||||||
//AP and OTA default passwords (change them!)
|
//AP and OTA default passwords (change them!)
|
||||||
String apPass = "wled1234";
|
String apPass[65] = "wled1234";
|
||||||
String otaPass = "wledota";
|
String otaPass[33] = "wledota";
|
||||||
|
|
||||||
//spiffs FS only useful for debug (only ESP8266)
|
//spiffs FS only useful for debug (only ESP8266)
|
||||||
//#define USEFS
|
//#define USEFS
|
||||||
@ -224,7 +224,6 @@ uint16_t presetCycleTime = 1250;
|
|||||||
unsigned long presetCycledTime = 0; byte presetCycCurr = presetCycleMin;
|
unsigned long presetCycledTime = 0; byte presetCycCurr = presetCycleMin;
|
||||||
bool presetApplyBri = true, presetApplyCol = true, presetApplyFx = true;
|
bool presetApplyBri = true, presetApplyCol = true, presetApplyFx = true;
|
||||||
bool saveCurrPresetCycConf = false;
|
bool saveCurrPresetCycConf = false;
|
||||||
|
|
||||||
uint32_t arlsTimeoutMillis = 2500;
|
uint32_t arlsTimeoutMillis = 2500;
|
||||||
bool arlsTimeout = false;
|
bool arlsTimeout = false;
|
||||||
bool receiveDirect = true, enableRealtimeUI = false;
|
bool receiveDirect = true, enableRealtimeUI = false;
|
||||||
@ -250,6 +249,11 @@ String escapedMac;
|
|||||||
DNSServer dnsServer;
|
DNSServer dnsServer;
|
||||||
bool dnsActive = false;
|
bool dnsActive = false;
|
||||||
|
|
||||||
|
//string temp buffer
|
||||||
|
#define OMAX 1750
|
||||||
|
char obuf[OMAX];
|
||||||
|
uint16_t olen = 0;
|
||||||
|
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
WebServer server(80);
|
WebServer server(80);
|
||||||
#else
|
#else
|
||||||
@ -319,7 +323,25 @@ void reset()
|
|||||||
ESP.restart();
|
ESP.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool oappend(char* txt) //append new c string to temp buffer efficiently
|
||||||
|
{
|
||||||
|
uint16_t len = strlen(txt);
|
||||||
|
if (olen + len >= OMAX) return false; //buffer full
|
||||||
|
strcpy(obuf + olen, txt);
|
||||||
|
olen += len;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool oappendi(int i) //append new number to temp buffer efficiently
|
||||||
|
{
|
||||||
|
char s[11];
|
||||||
|
sprintf(s,"%ld", i);
|
||||||
|
return oappend(s);
|
||||||
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
//init strings to defaults
|
||||||
|
|
||||||
wledInit();
|
wledInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,258 +4,287 @@
|
|||||||
|
|
||||||
void XML_response()
|
void XML_response()
|
||||||
{
|
{
|
||||||
String resp;
|
olen = 0;
|
||||||
resp = resp + "<?xml version = \"1.0\" ?>";
|
oappend("<?xml version = \"1.0\" ?><vs><ac>");
|
||||||
resp = resp + "<vs>";
|
|
||||||
resp = resp + "<ac>";
|
|
||||||
if (nightlightActive && nightlightFade)
|
if (nightlightActive && nightlightFade)
|
||||||
{
|
{
|
||||||
resp = resp + briT;
|
oappendi(briT);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
resp = resp + bri;
|
oappendi(bri);
|
||||||
}
|
}
|
||||||
resp = resp + "</ac>";
|
oappend("</ac>");
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
resp = resp + "<cl>";
|
oappend("<cl>");
|
||||||
resp = resp + col[i];
|
oappendi(col[i]);
|
||||||
resp = resp + "</cl>";
|
oappend("</cl>");
|
||||||
}
|
}
|
||||||
resp = resp + "<ns>";
|
oappend("<ns>");
|
||||||
resp = resp + notifyDirect;
|
oappendi(notifyDirect);
|
||||||
resp = resp + "</ns><nr>";
|
oappend("</ns><nr>");
|
||||||
resp = resp + receiveNotifications;
|
oappendi(receiveNotifications);
|
||||||
resp = resp + "</nr><nl>";
|
oappend("</nr><nl>");
|
||||||
resp = resp + nightlightActive;
|
oappendi(nightlightActive);
|
||||||
resp = resp + "</nl><nf>";
|
oappend("</nl><nf>");
|
||||||
resp = resp + nightlightFade;
|
oappendi(nightlightFade);
|
||||||
resp = resp + "</nf><nd>";
|
oappend("</nf><nd>");
|
||||||
resp = resp + nightlightDelayMins;
|
oappendi(nightlightDelayMins);
|
||||||
resp = resp + "</nd><nt>";
|
oappend("</nd><nt>");
|
||||||
resp = resp + nightlightTargetBri;
|
oappendi(nightlightTargetBri);
|
||||||
resp = resp + "</nt><fx>";
|
oappend("</nt><fx>");
|
||||||
resp = resp + effectCurrent;
|
oappendi(effectCurrent);
|
||||||
resp = resp + "</fx><sx>";
|
oappend("</fx><sx>");
|
||||||
resp = resp + effectSpeed;
|
oappendi(effectSpeed);
|
||||||
resp = resp + "</sx><ix>";
|
oappend("</sx><ix>");
|
||||||
resp = resp + effectIntensity;
|
oappendi(effectIntensity);
|
||||||
resp = resp + "</ix><wv>";
|
oappend("</ix><wv>");
|
||||||
if (useRGBW && !autoRGBtoRGBW) {
|
if (useRGBW && !autoRGBtoRGBW) {
|
||||||
resp = resp + white;
|
oappendi(white);
|
||||||
} else {
|
} else {
|
||||||
resp = resp + "-1";
|
oappend("-1");
|
||||||
}
|
}
|
||||||
resp = resp + "</wv><md>";
|
oappend("</wv><md>");
|
||||||
resp = resp + useHSB;
|
oappendi(useHSB);
|
||||||
resp = resp + "</md><ds>";
|
oappend("</md><ds>");
|
||||||
resp = resp + serverDescription;
|
oappend((char*)serverDescription.c_str());
|
||||||
resp = resp + "</ds>";
|
oappend("</ds></vs>");
|
||||||
resp = resp + "</vs>";
|
server.send(200, "text/xml", obuf);
|
||||||
server.send(200, "text/xml", resp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String getSettings(byte subPage)
|
void sappend(char stype, char* key, int val) //append a setting to string buffer
|
||||||
|
{
|
||||||
|
char ds[] = "d.Sf.";
|
||||||
|
|
||||||
|
switch(stype)
|
||||||
|
{
|
||||||
|
case 'c': //checkbox
|
||||||
|
oappend(ds);
|
||||||
|
oappend(key);
|
||||||
|
oappend(".checked=");
|
||||||
|
oappendi(val);
|
||||||
|
oappend(";");
|
||||||
|
break;
|
||||||
|
case 'v': //numeric
|
||||||
|
oappend(ds);
|
||||||
|
oappend(key);
|
||||||
|
oappend(".value=");
|
||||||
|
oappendi(val);
|
||||||
|
oappend(";");
|
||||||
|
break;
|
||||||
|
case 's': //string (we can interpret val as char*)
|
||||||
|
oappend(ds);
|
||||||
|
oappend(key);
|
||||||
|
oappend(".value=\"");
|
||||||
|
oappend((char*)val);
|
||||||
|
oappend("\";");
|
||||||
|
break;
|
||||||
|
case 'i': //selectedIndex
|
||||||
|
oappend(ds);
|
||||||
|
oappend(key);
|
||||||
|
oappend(".selectedIndex=");
|
||||||
|
oappendi(val);
|
||||||
|
oappend(";");
|
||||||
|
break;
|
||||||
|
case 'm': //message
|
||||||
|
oappend("d.getElementsByClassName");
|
||||||
|
oappend(key);
|
||||||
|
oappend(".innerHTML=\"");
|
||||||
|
oappend((char*)val);
|
||||||
|
oappend("\";");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void getSettingsJS(byte subPage) //get values for settings form in javascript
|
||||||
{
|
{
|
||||||
//0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec
|
//0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec
|
||||||
DEBUG_PRINT("settings resp");
|
DEBUG_PRINT("settings resp");
|
||||||
DEBUG_PRINTLN(subPage);
|
DEBUG_PRINTLN(subPage);
|
||||||
|
|
||||||
String resp = "";
|
olen = 0; obuf[0] = 0; //clear buffer
|
||||||
if (subPage <1 || subPage >6) return resp;
|
if (subPage <1 || subPage >6) return;
|
||||||
|
|
||||||
resp.reserve(1000);
|
|
||||||
String ds = "d.Sf.";
|
|
||||||
String dg = "d.getElementsByClassName";
|
|
||||||
String v = ".value=";
|
|
||||||
String c = ".checked=";
|
|
||||||
String ih = ".innerHTML=";
|
|
||||||
String si = ".selectedIndex=";
|
|
||||||
|
|
||||||
if (subPage == 1) {
|
if (subPage == 1) {
|
||||||
resp += ds + "CS" + v + "\"" + clientSSID + "\";";
|
sappend('s',"CS",(int)clientSSID.c_str());
|
||||||
resp += ds + "CP" + v + "\"";
|
|
||||||
for (int i = 0; i < clientPass.length(); i++)
|
byte l = clientPass.length();
|
||||||
|
char fpass[l+1]; //fill password field with ***
|
||||||
|
fpass[l] = 0;
|
||||||
|
memset(fpass,'*',l);
|
||||||
|
sappend('s',"CP",(int)fpass);
|
||||||
|
|
||||||
|
char k[3]; k[2] = 0; //IP addresses
|
||||||
|
for (int i = 0; i<4; i++)
|
||||||
{
|
{
|
||||||
resp += "*";
|
k[1] = 48+i; //ascii 0,1,2,3
|
||||||
|
k[0] = 'I'; sappend('v',k,staticIP[i]);
|
||||||
|
k[0] = 'G'; sappend('v',k,staticGateway[i]);
|
||||||
|
k[0] = 'S'; sappend('v',k,staticSubnet[i]);
|
||||||
}
|
}
|
||||||
resp += "\";";
|
|
||||||
resp += ds + "I0" + v + staticIP[0] +";";
|
sappend('s',"CM",(int)cmDNS.c_str());
|
||||||
resp += ds + "I1" + v + staticIP[1] +";";
|
sappend('v',"AT",apWaitTimeSecs);
|
||||||
resp += ds + "I2" + v + staticIP[2] +";";
|
sappend('s',"AS",(int)apSSID.c_str());
|
||||||
resp += ds + "I3" + v + staticIP[3] +";";
|
sappend('c',"AH",apHide);
|
||||||
resp += ds + "G0" + v + staticGateway[0] +";";
|
|
||||||
resp += ds + "G1" + v + staticGateway[1] +";";
|
l = apPass.length();
|
||||||
resp += ds + "G2" + v + staticGateway[2] +";";
|
char fapass[l+1]; //fill password field with ***
|
||||||
resp += ds + "G3" + v + staticGateway[3] +";";
|
fapass[l] = 0;
|
||||||
resp += ds + "S0" + v + staticSubnet[0] +";";
|
memset(fapass,'*',l);
|
||||||
resp += ds + "S1" + v + staticSubnet[1] +";";
|
sappend('s',"AP",(int)fapass);
|
||||||
resp += ds + "S2" + v + staticSubnet[2] +";";
|
|
||||||
resp += ds + "S3" + v + staticSubnet[3] +";";
|
sappend('v',"AC",apChannel);
|
||||||
resp += ds + "CM" + v + "\"" + cmDNS + "\";";
|
|
||||||
resp += ds + "AT" + v + apWaitTimeSecs +";";
|
if (WiFi.localIP()[0] != 0) //is connected
|
||||||
resp += ds + "AS" + v + "\"" + apSSID + "\";";
|
|
||||||
resp += ds + "AH" + c + apHide + ";";
|
|
||||||
resp += ds + "AP" + v + "\"";
|
|
||||||
for (int i = 0; i < apPass.length(); i++)
|
|
||||||
{
|
{
|
||||||
resp += "*";
|
sappend('m',"(\"sip\")[0]",(int)WiFi.localIP().toString().c_str());
|
||||||
}
|
|
||||||
resp += "\";";
|
|
||||||
resp += ds + "AC" + v + apChannel +";";
|
|
||||||
resp += dg + "(\"sip\")[0]" + ih + "\"";
|
|
||||||
if (!WiFi.localIP()[0] == 0)
|
|
||||||
{
|
|
||||||
resp += WiFi.localIP()[0];
|
|
||||||
resp += + ".";
|
|
||||||
resp += WiFi.localIP()[1];
|
|
||||||
resp += ".";
|
|
||||||
resp += WiFi.localIP()[2];
|
|
||||||
resp += ".";
|
|
||||||
resp += WiFi.localIP()[3];
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
resp += "Not connected";
|
sappend('m',"(\"sip\")[0]",(int)"Not connected");
|
||||||
}
|
}
|
||||||
resp += "\";";
|
|
||||||
resp += dg + "(\"sip\")[1]" + ih + "\"";
|
if (WiFi.softAPIP()[0] != 0) //is active
|
||||||
if (!WiFi.softAPIP()[0] == 0)
|
|
||||||
{
|
{
|
||||||
resp += WiFi.softAPIP()[0];
|
sappend('m',"(\"sip\")[1]",(int)WiFi.softAPIP().toString().c_str());
|
||||||
resp += + ".";
|
|
||||||
resp += WiFi.softAPIP()[1];
|
|
||||||
resp += ".";
|
|
||||||
resp += WiFi.softAPIP()[2];
|
|
||||||
resp += ".";
|
|
||||||
resp += WiFi.softAPIP()[3];
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
resp += "Not active";
|
sappend('m',"(\"sip\")[1]",(int)"Not active");
|
||||||
}
|
}
|
||||||
resp += "\";";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subPage == 2) {
|
if (subPage == 2) {
|
||||||
resp += ds + "LC" + v + ledCount +";";
|
sappend('v',"LC",ledCount);
|
||||||
resp += ds + "CR" + v + colS[0] +";";
|
sappend('v',"CR",colS[0]);
|
||||||
resp += ds + "CG" + v + colS[1] +";";
|
sappend('v',"CG",colS[1]);
|
||||||
resp += ds + "CB" + v + colS[2] +";";
|
sappend('v',"CB",colS[2]);
|
||||||
resp += ds + "CA" + v + briS +";";
|
sappend('v',"CA",briS);
|
||||||
resp += ds + "EW" + c + useRGBW +";";
|
sappend('c',"EW",useRGBW);
|
||||||
resp += ds + "AW" + c + autoRGBtoRGBW +";";
|
sappend('c',"AW",autoRGBtoRGBW);
|
||||||
resp += ds + "CW" + v + whiteS +";";
|
sappend('v',"CW",whiteS);
|
||||||
resp += ds + "SR" + v + colSecS[0] +";";
|
sappend('v',"SR",colSecS[0]);
|
||||||
resp += ds + "SG" + v + colSecS[1] +";";
|
sappend('v',"SG",colSecS[1]);
|
||||||
resp += ds + "SB" + v + colSecS[2] +";";
|
sappend('v',"SB",colSecS[2]);
|
||||||
resp += ds + "SW" + v + whiteSecS +";";
|
sappend('v',"SW",whiteSecS);
|
||||||
resp += ds + "BO" + c + turnOnAtBoot +";";
|
sappend('c',"BO",turnOnAtBoot);
|
||||||
resp += ds + "BP" + v + bootPreset +";";
|
sappend('v',"BP",bootPreset);
|
||||||
resp += ds + "FX" + v + effectDefault +";";
|
sappend('v',"FX",effectDefault);
|
||||||
resp += ds + "SX" + v + effectSpeedDefault +";";
|
sappend('v',"SX",effectSpeedDefault);
|
||||||
resp += ds + "IX" + v + effectIntensityDefault +";";
|
sappend('v',"IX",effectIntensityDefault);
|
||||||
resp += ds + "GB" + c + useGammaCorrectionBri +";";
|
sappend('c',"GB",useGammaCorrectionBri);
|
||||||
resp += ds + "GC" + c + useGammaCorrectionRGB +";";
|
sappend('c',"GC",useGammaCorrectionRGB);
|
||||||
resp += ds + "TF" + c + fadeTransition +";";
|
sappend('c',"TF",fadeTransition);
|
||||||
resp += ds + "TS" + c + sweepTransition +";";
|
sappend('c',"TS",sweepTransition);
|
||||||
resp += ds + "TI" + c + !sweepDirection +";";
|
sappend('c',"TI",!sweepDirection);
|
||||||
resp += ds + "TD" + v + transitionDelay +";";
|
sappend('v',"TD",transitionDelay);
|
||||||
resp += ds + "T2" + c + !disableSecTransition +";";
|
sappend('c',"T2",!disableSecTransition);
|
||||||
resp += ds + "BF" + v + briMultiplier +";";
|
sappend('v',"BF",briMultiplier);
|
||||||
resp += ds + "TB" + v + nightlightTargetBri +";";
|
sappend('v',"TB",nightlightTargetBri);
|
||||||
resp += ds + "TL" + v + nightlightDelayMins +";";
|
sappend('v',"TL",nightlightDelayMins);
|
||||||
resp += ds + "TW" + c + nightlightFade +";";
|
sappend('c',"TW",nightlightFade);
|
||||||
resp += ds + "RV" + c + reverseMode +";";
|
sappend('c',"RV",reverseMode);
|
||||||
resp += ds + "EI" + c + initLedsLast +";";
|
sappend('c',"EI",initLedsLast);
|
||||||
resp += ds + "WO" + v + arlsOffset +";";
|
sappend('v',"WO",arlsOffset);
|
||||||
resp += ds + "SL" + c + skipFirstLed +";";
|
sappend('c',"SL",skipFirstLed);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subPage == 3)
|
if (subPage == 3)
|
||||||
{
|
{
|
||||||
resp += ds + "UI" + si + String(uiConfiguration) + ";";
|
sappend('i',"UI",uiConfiguration);
|
||||||
resp += ds + "DS" + v + "\"" + serverDescription + "\";";
|
sappend('s',"DS",(int)serverDescription.c_str());
|
||||||
resp += ds + "MD" + c + useHSBDefault + ";";
|
sappend('c',"MD",useHSBDefault);
|
||||||
resp += ds + "TH" + si + String(currentTheme) + ";";
|
sappend('i',"TH",currentTheme);
|
||||||
for(int i=0;i<6;i++)
|
char k[3]; k[0] = 'C'; k[2] = 0; //keys
|
||||||
resp += ds + "C" + i + v + "\"" + cssCol[i] + "\";";
|
for (int i=0; i<6; i++)
|
||||||
resp += ds + "CF" + v + "\"" + cssFont + "\";";
|
{
|
||||||
|
k[1] = 48+i; //ascii 0,1,2,3,4,5
|
||||||
|
sappend('s',k,(int)cssCol[i].c_str());
|
||||||
|
}
|
||||||
|
sappend('s',"CF",(int)cssFont.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subPage == 4)
|
if (subPage == 4)
|
||||||
{
|
{
|
||||||
resp += ds + "BT" + c + buttonEnabled +";";
|
sappend('c',"BT",buttonEnabled);
|
||||||
resp += ds + "UP" + v + udpPort +";";
|
sappend('v',"UP",udpPort);
|
||||||
resp += ds + "RB" + c + receiveNotificationBrightness +";";
|
sappend('c',"RB",receiveNotificationBrightness);
|
||||||
resp += ds + "RC" + c + receiveNotificationColor +";";
|
sappend('c',"RC",receiveNotificationColor);
|
||||||
resp += ds + "RX" + c + receiveNotificationEffects +";";
|
sappend('c',"RX",receiveNotificationEffects);
|
||||||
resp += ds + "SD" + c + notifyDirectDefault +";";
|
sappend('c',"SD",notifyDirectDefault);
|
||||||
resp += ds + "SB" + c + notifyButton +";";
|
sappend('c',"SB",notifyButton);
|
||||||
resp += ds + "SH" + c + notifyHue +";";
|
sappend('c',"SH",notifyHue);
|
||||||
resp += ds + "S2" + c + notifyTwice +";";
|
sappend('c',"S2",notifyTwice);
|
||||||
resp += ds + "RD" + c + receiveDirect +";";
|
sappend('c',"RD",receiveDirect);
|
||||||
resp += ds + "RU" + c + enableRealtimeUI +";";
|
sappend('c',"RU",enableRealtimeUI);
|
||||||
resp += ds + "AL" + c + alexaEnabled +";";
|
sappend('c',"AL",alexaEnabled);
|
||||||
resp += ds + "AI" + v + "\"" + alexaInvocationName + "\";";
|
sappend('s',"AI",(int)alexaInvocationName.c_str());
|
||||||
resp += ds + "SA" + c + alexaNotify +";";
|
sappend('c',"SA",alexaNotify);
|
||||||
resp += ds + "BK" + v + "\"" + ((blynkEnabled)?"Hidden":"") + "\";";
|
sappend('s',"BK",(int)((blynkEnabled)?"Hidden":""));
|
||||||
resp += ds + "H0" + v + hueIP[0] +";";
|
sappend('v',"H0",hueIP[0]);
|
||||||
resp += ds + "H1" + v + hueIP[1] +";";
|
sappend('v',"H1",hueIP[1]);
|
||||||
resp += ds + "H2" + v + hueIP[2] +";";
|
sappend('v',"H2",hueIP[2]);
|
||||||
resp += ds + "H3" + v + hueIP[3] +";";
|
sappend('v',"H3",hueIP[3]);
|
||||||
resp += ds + "HL" + v + huePollLightId +";";
|
sappend('v',"HL",huePollLightId);
|
||||||
resp += ds + "HI" + v + huePollIntervalMs +";";
|
sappend('v',"HI",huePollIntervalMs);
|
||||||
resp += ds + "HP" + c + huePollingEnabled +";";
|
sappend('c',"HP",huePollingEnabled);
|
||||||
resp += ds + "HO" + c + hueApplyOnOff +";";
|
sappend('c',"HO",hueApplyOnOff);
|
||||||
resp += ds + "HB" + c + hueApplyBri +";";
|
sappend('c',"HB",hueApplyBri);
|
||||||
resp += ds + "HC" + c + hueApplyColor +";";
|
sappend('c',"HC",hueApplyColor);
|
||||||
resp += dg + "(\"hms\")[0]" + ih + "\"" + hueError + "\";";
|
sappend('m',"(\"hms\")[0]",(int)hueError.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subPage == 5)
|
if (subPage == 5)
|
||||||
{
|
{
|
||||||
resp += ds + "NT" + c + ntpEnabled +";";
|
sappend('c',"NT",ntpEnabled);
|
||||||
resp += ds + "CF" + c + !useAMPM +";";
|
sappend('c',"CF",!useAMPM);
|
||||||
resp += ds + "TZ" + si + String(currentTimezone) + ";";
|
sappend('i',"TZ",currentTimezone);
|
||||||
resp += ds + "UO" + v + utcOffsetSecs +";";
|
sappend('v',"UO",utcOffsetSecs);
|
||||||
resp += dg + "(\"times\")[0]" + ih + "\"" + getTimeString() + "\";";
|
sappend('m',"(\"times\")[0]",(int)getTimeString().c_str());
|
||||||
resp += ds + "OL" + si + String(overlayCurrent) + ";";
|
sappend('i',"OL",overlayCurrent);
|
||||||
resp += ds + "O1" + v + overlayMin +";";
|
sappend('v',"O1",overlayMin);
|
||||||
resp += ds + "O2" + v + overlayMax +";";
|
sappend('v',"O2",overlayMax);
|
||||||
resp += ds + "OM" + v + analogClock12pixel +";";
|
sappend('v',"OM",analogClock12pixel);
|
||||||
resp += ds + "OS" + c + analogClockSecondsTrail +";";
|
sappend('c',"OS",analogClockSecondsTrail);
|
||||||
resp += ds + "O5" + c + analogClock5MinuteMarks +";";
|
sappend('c',"O5",analogClock5MinuteMarks);
|
||||||
resp += ds + "CX" + v + "\"" + cronixieDisplay + "\";";
|
sappend('s',"CX",(int)cronixieDisplay.c_str());
|
||||||
resp += ds + "CB" + c + cronixieBacklight +";";
|
sappend('c',"CB",cronixieBacklight);
|
||||||
resp += ds + "CE" + c + countdownMode +";";
|
sappend('c',"CE",countdownMode);
|
||||||
resp += ds + "CY" + v + countdownYear +";";
|
sappend('v',"CY",countdownYear);
|
||||||
resp += ds + "CI" + v + countdownMonth +";";
|
sappend('v',"CI",countdownMonth);
|
||||||
resp += ds + "CD" + v + countdownDay +";";
|
sappend('v',"CD",countdownDay);
|
||||||
resp += ds + "CH" + v + countdownHour +";";
|
sappend('v',"CH",countdownHour);
|
||||||
resp += ds + "CM" + v + countdownMin +";";
|
sappend('v',"CM",countdownMin);
|
||||||
resp += ds + "CS" + v + countdownSec +";";
|
sappend('v',"CS",countdownSec);
|
||||||
|
|
||||||
|
char k[4]; k[0]= 'M';
|
||||||
for (int i=1;i<17;i++)
|
for (int i=1;i<17;i++)
|
||||||
{
|
{
|
||||||
resp += ds + "M" + String(i) + v + "\"" + loadMacro(i) + "\";";
|
sprintf(k+1,"%i",i);
|
||||||
|
sappend('s',k,(int)loadMacro(i).c_str());
|
||||||
}
|
}
|
||||||
resp += ds + "MB" + v + macroBoot +";";
|
|
||||||
resp += ds + "A0" + v + macroAlexaOn +";";
|
sappend('v',"MB",macroBoot);
|
||||||
resp += ds + "A1" + v + macroAlexaOff +";";
|
sappend('v',"A0",macroAlexaOn);
|
||||||
resp += ds + "MP" + v + macroButton +";";
|
sappend('v',"A1",macroAlexaOff);
|
||||||
resp += ds + "ML" + v + macroLongPress +";";
|
sappend('v',"MP",macroButton);
|
||||||
resp += ds + "MC" + v + macroCountdown +";";
|
sappend('v',"ML",macroLongPress);
|
||||||
resp += ds + "MN" + v + macroNl +";";
|
sappend('v',"MC",macroCountdown);
|
||||||
|
sappend('v',"MN",macroNl);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subPage == 6)
|
if (subPage == 6)
|
||||||
{
|
{
|
||||||
resp += ds + "NO" + c + otaLock +";";
|
sappend('c',"NO",otaLock);
|
||||||
resp += ds + "OW" + c + wifiLock +";";
|
sappend('c',"OW",wifiLock);
|
||||||
resp += ds + "AO" + c + aOtaEnabled +";";
|
sappend('c',"AO",aOtaEnabled);
|
||||||
resp += ds + "NA" + c + recoveryAPDisabled +";";
|
sappend('c',"NA",recoveryAPDisabled);
|
||||||
resp += dg + "(\"msg\")[0]" + ih + "\"WLED "+ versionString +" (build " + VERSION + ") OK\";";
|
sappend('m',"(\"msg\")[0]",(int)"WLED ");
|
||||||
|
olen -= 2; //delete ";
|
||||||
|
oappend(versionString);
|
||||||
|
oappend(" (build ");
|
||||||
|
oappendi(VERSION);
|
||||||
|
oappend(") OK\";");
|
||||||
}
|
}
|
||||||
resp += "}</script>";
|
oappend("}</script>");
|
||||||
|
|
||||||
return resp;
|
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,8 @@ void wledInit()
|
|||||||
});
|
});
|
||||||
|
|
||||||
server.on("/build", HTTP_GET, [](){
|
server.on("/build", HTTP_GET, [](){
|
||||||
server.send(200, "text/plain", getBuildInfo());
|
getBuildInfo();
|
||||||
|
server.send(200, "text/plain", obuf);
|
||||||
});
|
});
|
||||||
//if OTA is allowed
|
//if OTA is allowed
|
||||||
if (!otaLock){
|
if (!otaLock){
|
||||||
@ -494,10 +495,10 @@ void serveSettings(byte subPage)
|
|||||||
default: pl0 = strlen_P(PAGE_settings0); pl1 = strlen_P(PAGE_settings1);
|
default: pl0 = strlen_P(PAGE_settings0); pl1 = strlen_P(PAGE_settings1);
|
||||||
}
|
}
|
||||||
|
|
||||||
String settingsBuffer = getSettings(subPage);
|
getSettingsJS(subPage);
|
||||||
int sCssLength = (subPage >0 && subPage <7)?strlen_P(PAGE_settingsCss):0;
|
int sCssLength = (subPage >0 && subPage <7)?strlen_P(PAGE_settingsCss):0;
|
||||||
|
|
||||||
server.setContentLength(pl0 + cssColorString.length() + settingsBuffer.length() + sCssLength + pl1);
|
server.setContentLength(pl0 + cssColorString.length() + olen + sCssLength + pl1);
|
||||||
server.send(200, "text/html", "");
|
server.send(200, "text/html", "");
|
||||||
|
|
||||||
switch (subPage)
|
switch (subPage)
|
||||||
@ -511,7 +512,7 @@ void serveSettings(byte subPage)
|
|||||||
case 255: server.sendContent_P(PAGE_welcome0); break;
|
case 255: server.sendContent_P(PAGE_welcome0); break;
|
||||||
default: server.sendContent_P(PAGE_settings0);
|
default: server.sendContent_P(PAGE_settings0);
|
||||||
}
|
}
|
||||||
server.sendContent(settingsBuffer);
|
server.sendContent(obuf);
|
||||||
server.sendContent(cssColorString);
|
server.sendContent(cssColorString);
|
||||||
if (subPage >0 && subPage <7) server.sendContent_P(PAGE_settingsCss);
|
if (subPage >0 && subPage <7) server.sendContent_P(PAGE_settingsCss);
|
||||||
switch (subPage)
|
switch (subPage)
|
||||||
@ -530,35 +531,42 @@ void serveSettings(byte subPage)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String getBuildInfo()
|
void getBuildInfo()
|
||||||
{
|
{
|
||||||
String info = "hard-coded build info:\r\n\n";
|
//fill string buffer with build info
|
||||||
|
olen = 0;
|
||||||
|
oappend("hard-coded build info:\r\n\n");
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
info += "platform: esp32\r\n";
|
oappend("platform: esp32");
|
||||||
#else
|
#else
|
||||||
info += "platform: esp8266\r\n";
|
oappend("platform: esp8266");
|
||||||
#endif
|
#endif
|
||||||
info += "version: " + versionString + "\r\n";
|
oappend("\r\nversion: ");
|
||||||
info += "build: " + (String)VERSION + "\r\n";
|
oappend(versionString);
|
||||||
info += "eepver: " + String(EEPVER) + "\r\n";
|
oappend("\r\nbuild: ");
|
||||||
|
oappendi(VERSION);
|
||||||
|
oappend("\r\neepver: ");
|
||||||
|
oappendi(EEPVER);
|
||||||
#ifdef USEFS
|
#ifdef USEFS
|
||||||
info += "spiffs: true\r\n";
|
oappend("\r\nspiffs: true\r\n");
|
||||||
#else
|
#else
|
||||||
info += "spiffs: false\r\n";
|
oappend("\r\nspiffs: false\r\n");
|
||||||
#endif
|
#endif
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
info += "debug: true\r\n";
|
oappend("debug: true\r\n");
|
||||||
#else
|
#else
|
||||||
info += "debug: false\r\n";
|
oappend("debug: false\r\n");
|
||||||
#endif
|
#endif
|
||||||
info += "button-pin: gpio" + String(buttonPin) + "\r\n";
|
oappend("button-pin: gpio");
|
||||||
|
oappendi(buttonPin);
|
||||||
|
oappend("\r\n");
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
info += "strip-pin: gpio" + String(PIN) + "\r\n";
|
oappend("strip-pin: gpio");
|
||||||
|
oappendi(PIN);
|
||||||
#else
|
#else
|
||||||
info += "strip-pin: gpio2\r\n";
|
oappend("strip-pin: gpio2");
|
||||||
#endif
|
#endif
|
||||||
info += "build-type: dev\r\n";
|
oappend("\r\nbuild-type: dev\r\n");
|
||||||
return info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkClientIsMobile(String useragent)
|
bool checkClientIsMobile(String useragent)
|
||||||
|
Loading…
Reference in New Issue
Block a user