NTP server settable
Added segment commands to HTTP api Removed HA autodiscovery
This commit is contained in:
parent
334783f89a
commit
3b70488828
Binary file not shown.
@ -142,6 +142,7 @@
|
|||||||
<button type="button" onclick="B()">Back</button><button type="submit">Save</button><hr>
|
<button type="button" onclick="B()">Back</button><button type="submit">Save</button><hr>
|
||||||
<h2>Time setup</h2>
|
<h2>Time setup</h2>
|
||||||
Get time from NTP server: <input type="checkbox" name="NT"><br>
|
Get time from NTP server: <input type="checkbox" name="NT"><br>
|
||||||
|
<input name="NS" maxlength="32"><br>
|
||||||
Use 24h format: <input type="checkbox" name="CF"><br>
|
Use 24h format: <input type="checkbox" name="CF"><br>
|
||||||
Time zone:
|
Time zone:
|
||||||
<select name="TZ">
|
<select name="TZ">
|
||||||
|
@ -71,33 +71,18 @@ AP IP: <span class="sip"> Not active </span><hr>
|
|||||||
|
|
||||||
//LED settings
|
//LED settings
|
||||||
const char PAGE_settings_leds[] PROGMEM = R"=====(<!DOCTYPE html>
|
const char PAGE_settings_leds[] PROGMEM = R"=====(<!DOCTYPE html>
|
||||||
<html><head><meta name=viewport content="width=500"><meta charset="utf-8"><title>LED Settings</title>
|
<html><head>
|
||||||
<script>var f=0,p=0,d=document,laprev=55;function H()
|
<meta charset=utf-8>
|
||||||
{window.open("https://github.com/Aircoookie/WLED/wiki/Settings#led-settings");}
|
<meta name=viewport content="width=500">
|
||||||
function B()
|
<title>LED Settings</title>
|
||||||
{window.open("/settings","_self");}
|
<script>var d=document,laprev=55;function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#led-settings")}function B(){window.open("/settings","_self")}function S(){GetV();setABL()}function enABL(){var a=d.getElementById("able").checked;d.Sf.LA.value=(a)?laprev:0;d.getElementById("abl").style.display=(a)?"inline":"none";d.getElementById("psu2").style.display=(a)?"inline":"none";if(d.Sf.LA.value>0){setABL()}}function enLA(){var a=d.Sf.LAsel.value;d.Sf.LA.value=a;d.getElementById("LAdis").style.display=(a==50)?"inline":"none";UI()}function setABL(){d.getElementById("able").checked=true;d.Sf.LAsel.value=50;switch(parseInt(d.Sf.LA.value)){case 0:d.getElementById("able").checked=false;enABL();break;case 30:d.Sf.LAsel.value=30;break;case 35:d.Sf.LAsel.value=35;break;case 55:d.Sf.LAsel.value=55;break;default:d.getElementById("LAdis").style.display="inline"}UI()}function UI(){var b=d.querySelectorAll(".wc"),a=b.length;for(i=0;i<a;i++){b[i].style.display=(d.getElementById("rgbw").checked)?"inline":"none"}d.getElementById("ledwarning").style.display=(d.Sf.LC.value>1000)?"inline":"none";d.getElementById("ampwarning").style.display=(d.Sf.MA.value>7200)?"inline":"none";if(d.Sf.LA.value>0){laprev=d.Sf.LA.value}var j=Math.ceil((100+d.Sf.LC.value*laprev)/500)/2;j=(j>5)?Math.ceil(j):j;var g="";var e=(d.Sf.LAsel.value==30);if(j<1.02&&!e){g="ESP 5V pin with 1A USB supply"}else{g+=e?"12V ":"5V ";g+=j;g+="A supply connected to LEDs"}var h=Math.ceil((100+d.Sf.LC.value*laprev)/1500)/2;h=(h>5)?Math.ceil(h):h;var c="(for most effects, ~";c+=h;c+="A is enough)<br>";d.getElementById("psu").innerHTML=g;d.getElementById("psu2").innerHTML=c}function GetV(){var d=document;
|
||||||
function S(){GetV();setTimeout(function(){fillfx(0);},200);setTimeout(function(){fillfx(1);},400);setABL();}
|
%CSS%%SCSS%</head><body onload=S()>
|
||||||
function enABL(){var en=d.getElementById('able').checked;d.Sf.LA.value=(en)?laprev:0;d.getElementById('abl').style.display=(en)?'inline':'none';d.getElementById('psu2').style.display=(en)?'inline':'none';if(d.Sf.LA.value>0)setABL();}
|
|
||||||
function enLA(){var val=d.Sf.LAsel.value;d.Sf.LA.value=val;d.getElementById('LAdis').style.display=(val==50)?'inline':'none';UI();}
|
|
||||||
function setABL(){d.getElementById('able').checked = true;d.Sf.LAsel.value = 50;switch(parseInt(d.Sf.LA.value)){case 0:d.getElementById('able').checked=false;enABL();break;case 30:d.Sf.LAsel.value=30;break;case 35:d.Sf.LAsel.value=35;break;case 55:d.Sf.LAsel.value=55;break;default:d.getElementById('LAdis').style.display='inline';}
|
|
||||||
UI();}
|
|
||||||
function UI(){var myC=d.querySelectorAll('.wc'),l=myC.length;for(i=0;i<l;i++){myC[i].style.display=(d.getElementById('rgbw').checked)?'inline':'none';}
|
|
||||||
d.getElementById('ledwarning').style.display=(d.Sf.LC.value>1000)?'inline':'none';d.getElementById('ampwarning').style.display=(d.Sf.MA.value>7200)?'inline':'none';if(d.Sf.LA.value>0)laprev=d.Sf.LA.value;var val=Math.ceil((100+d.Sf.LC.value*laprev)/500)/2;val=(val>5)?Math.ceil(val):val;var s="";var is12V=(d.Sf.LAsel.value==30);if(val<1.02&&!is12V)
|
|
||||||
{s="ESP 5V pin with 1A USB supply";}else
|
|
||||||
{s+=is12V?"12V ":"5V ";s+=val;s+="A supply connected to LEDs";}
|
|
||||||
var val2=Math.ceil((100+d.Sf.LC.value*laprev)/1500)/2;val2=(val2>5)?Math.ceil(val2):val2;var s2="(for most effects, ~";s2+=val2;s2+="A is enough)<br>";d.getElementById('psu').innerHTML=s;d.getElementById('psu2').innerHTML=s2;}
|
|
||||||
function fillfx(pl)
|
|
||||||
{e="<option>Error loading list!</option>";el=pl?Sf.FP:Sf.FX;fetch(pl?'/json/palettes':'/json/effects').then(res=>{if(!res.ok){el.innerHTML=e;}
|
|
||||||
return res.json();}).then(json=>{var x="";for(i in json){x+="<option value=\""+i+"\">"+json[i]+" ("+i+")</option>";}
|
|
||||||
el.innerHTML=x;el.selectedIndex=pl?p:f;}).catch(function(){el.innerHTML=e;})}
|
|
||||||
function GetV(){%CSS%%SCSS%</head>
|
|
||||||
<body onload=S()>
|
|
||||||
<form id=form_s name=Sf method=post>
|
<form id=form_s name=Sf method=post>
|
||||||
<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</button><hr>
|
<button type=button onclick=B()>Back</button><button type=submit>Save</button><hr>
|
||||||
<h2>LED setup</h2>
|
<h2>LED setup</h2>
|
||||||
LED count: <input name=LC type=number min=1 max=1500 oninput=UI() required><br>
|
LED count: <input name=LC type=number min=1 max=1500 oninput=UI() required><br>
|
||||||
<div id=ledwarning style="color:orange; display: none;">
|
<div id=ledwarning style=color:orange;display:none>
|
||||||
⚠ You might run into stability or lag issues.<br>
|
⚠ You might run into stability or lag issues.<br>
|
||||||
Use less than 1000 LEDs per ESP for the best experience!<br>
|
Use less than 1000 LEDs per ESP for the best experience!<br>
|
||||||
</div>
|
</div>
|
||||||
@ -108,7 +93,7 @@ Use less than 1000 LEDs per ESP for the best experience!<br>
|
|||||||
Enable automatic brightness limiter: <input type=checkbox name=ABen onchange=enABL() id=able><br>
|
Enable automatic brightness limiter: <input type=checkbox name=ABen onchange=enABL() id=able><br>
|
||||||
<div id=abl>
|
<div id=abl>
|
||||||
Maximum Current: <input name=MA type=number min=250 max=65000 oninput=UI() required> mA<br>
|
Maximum Current: <input name=MA type=number min=250 max=65000 oninput=UI() required> mA<br>
|
||||||
<div id=ampwarning style="color:orange; display: none;">
|
<div id=ampwarning style=color:orange;display:none>
|
||||||
⚠ Your power supply provides high current.<br>
|
⚠ Your power supply provides high current.<br>
|
||||||
To improve the safety of your setup,<br>
|
To improve the safety of your setup,<br>
|
||||||
please use thick cables,<br>
|
please use thick cables,<br>
|
||||||
@ -130,49 +115,27 @@ LED voltage (Max. current for a single LED):<br>
|
|||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
LEDs are 4-channel type (RGBW): <input type=checkbox name=EW onchange=UI() id=rgbw><br>
|
LEDs are 4-channel type (RGBW): <input type=checkbox name=EW onchange=UI() id=rgbw><br>
|
||||||
|
<span class=wc>
|
||||||
|
Auto-calculate white channel from RGB: <input type=checkbox name=AW><br></span>
|
||||||
Color order:
|
Color order:
|
||||||
<select name=CO>
|
<select name=CO>
|
||||||
<option value=0>GRB</option>
|
<option value=0>GRB</option>
|
||||||
<option value=1>RGB</option>
|
<option value=1>RGB</option>
|
||||||
<option value=2>BRG</option>
|
<option value=2 disabled>BRG</option>
|
||||||
<option value=3>RBG</option>
|
<option value=3>RBG</option>
|
||||||
</select>
|
</select>
|
||||||
<h3>Defaults</h3>
|
<h3>Defaults</h3>
|
||||||
Turn LEDs on after power up/reset: <input type=checkbox name=BO><br>
|
Turn LEDs on after power up/reset: <input type=checkbox name=BO><br>
|
||||||
Default brightness: <input name=CA type=number min=0 max=255 required> (0-255)<br><br>
|
Default brightness: <input name=CA type=number min=0 max=255 required> (0-255)<br><br>
|
||||||
Set current color, brightness and effects as boot default: <input type=checkbox name=IS><br>
|
Apply preset <input name=BP type=number min=0 max=16 required> at boot (0 uses defaults)
|
||||||
Set current preset cycle setting as boot default: <input type=checkbox name=PC>
|
|
||||||
<br>- <i>or</i> -<br>
|
<br>- <i>or</i> -<br>
|
||||||
Apply preset <input name=BP type=number min=0 max=25 required> at boot (0 uses defaults)
|
Set current preset cycle setting as boot default: <input type=checkbox name=PC><br><br>
|
||||||
<br>- <i>or</i> -<br>
|
|
||||||
Default RGB<span class=wc>W</span> color:<br>
|
|
||||||
<input name=CR type=number min=0 max=255 required>
|
|
||||||
<input name=CG type=number min=0 max=255 required>
|
|
||||||
<input name=CB type=number min=0 max=255 required>
|
|
||||||
<span class=wc><input name=CW type=number min=0 max=255 required><br>
|
|
||||||
Auto-calculate white from RGB instead: <input type=checkbox name=AW></span><br>
|
|
||||||
Default secondary RGB<span class=wc>W</span>:<br>
|
|
||||||
<input name=SR type=number min=0 max=255 required>
|
|
||||||
<input name=SG type=number min=0 max=255 required>
|
|
||||||
<input name=SB type=number min=0 max=255 required>
|
|
||||||
<span class=wc><input name=SW type=number min=0 max=255 required></span><br>
|
|
||||||
Default effect ID:<br>
|
|
||||||
<select name=FX>
|
|
||||||
<option>Loading...</option>
|
|
||||||
</select>
|
|
||||||
<br>Default color palette:<br>
|
|
||||||
<select name=FP>
|
|
||||||
<option>Loading...</option>
|
|
||||||
</select><br>
|
|
||||||
Default effect speed: <input name=SX type=number min=0 max=255 required><br>
|
|
||||||
Default effect intensity: <input name=IX type=number min=0 max=255 required><br><br>
|
|
||||||
Use Gamma correction for color: <input type=checkbox name=GC> (strongly recommended)<br>
|
Use Gamma correction for color: <input type=checkbox name=GC> (strongly recommended)<br>
|
||||||
Use Gamma correction for brightness: <input type=checkbox name=GB> (not recommended)<br><br>
|
Use Gamma correction for brightness: <input type=checkbox name=GB> (not recommended)<br><br>
|
||||||
Brightness factor: <input name=BF type=number min=1 max=255 required> %
|
Brightness factor: <input name=BF type=number min=1 max=255 required> %
|
||||||
<h3>Transitions</h3>
|
<h3>Transitions</h3>
|
||||||
Crossfade: <input type=checkbox name=TF><br>
|
Crossfade: <input type=checkbox name=TF><br>
|
||||||
Transition Time: <input name=TD maxlength=5 size=2> ms<br>
|
Transition Time: <input name=TD maxlength=5 size=2> ms<br>
|
||||||
Enable transition for secondary color: <input type=checkbox name=T2><br>
|
|
||||||
Enable Palette transitions: <input type=checkbox name=PF>
|
Enable Palette transitions: <input type=checkbox name=PF>
|
||||||
<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>
|
||||||
@ -191,8 +154,7 @@ Skip first LED: <input type=checkbox name=SL><br>
|
|||||||
Disable repeating N LEDs: <input type=number min=0 max=255 name=DL><br>
|
Disable repeating N LEDs: <input type=number min=0 max=255 name=DL><br>
|
||||||
(Turns off N LEDs between each lit one, spacing out effects)<hr>
|
(Turns off N LEDs between each lit one, spacing out effects)<hr>
|
||||||
<button type=button onclick=B()>Back</button><button type=submit>Save</button>
|
<button type=button onclick=B()>Back</button><button type=submit>Save</button>
|
||||||
</form></body>
|
</form></body></html>)=====";
|
||||||
</html>)=====";
|
|
||||||
|
|
||||||
|
|
||||||
//User Interface settings
|
//User Interface settings
|
||||||
@ -298,6 +260,7 @@ function Wd(){a=[0,0,0,0,0,0,0,0];for(i=0;i<8;i++){m=1;for(j=0;j<8;j++){a[i]+=gI
|
|||||||
<button type="button" onclick="B()">Back</button><button type="submit">Save</button><hr>
|
<button type="button" onclick="B()">Back</button><button type="submit">Save</button><hr>
|
||||||
<h2>Time setup</h2>
|
<h2>Time setup</h2>
|
||||||
Get time from NTP server: <input type="checkbox" name="NT"><br>
|
Get time from NTP server: <input type="checkbox" name="NT"><br>
|
||||||
|
<input name="NS" maxlength="32"><br>
|
||||||
Use 24h format: <input type="checkbox" name="CF"><br>
|
Use 24h format: <input type="checkbox" name="CF"><br>
|
||||||
Time zone:
|
Time zone:
|
||||||
<select name="TZ">
|
<select name="TZ">
|
||||||
|
@ -111,7 +111,7 @@ char otaPass[33] = "wledota";
|
|||||||
|
|
||||||
byte auxDefaultState = 0; //0: input 1: high 2: low
|
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
|
||||||
char ntpServerName[] = "0.wled.pool.ntp.org"; //NTP server to use
|
char ntpServerName[33] = "0.wled.pool.ntp.org";//NTP server to use
|
||||||
|
|
||||||
|
|
||||||
//WiFi CONFIG (all these can be changed via web UI, no need to set them here)
|
//WiFi CONFIG (all these can be changed via web UI, no need to set them here)
|
||||||
@ -136,13 +136,9 @@ bool autoRGBtoRGBW = false; //if RGBW enabled, calculate White
|
|||||||
bool turnOnAtBoot = true; //turn on LEDs at power-up
|
bool turnOnAtBoot = true; //turn on LEDs at power-up
|
||||||
byte bootPreset = 0; //save preset to load after power-up
|
byte bootPreset = 0; //save preset to load after power-up
|
||||||
|
|
||||||
byte colS[]{255, 159, 0, 0}; //default RGB(W) color
|
byte col[]{255, 160, 0, 0}; //default RGB(W) color
|
||||||
byte colSecS[]{0, 0, 0, 0}; //default RGB(W) secondary color
|
byte colSec[]{0, 0, 0, 0}; //default RGB(W) secondary color
|
||||||
byte briS = 127; //default brightness
|
byte briS = 128; //default brightness
|
||||||
byte effectDefault = 0;
|
|
||||||
byte effectSpeedDefault = 75;
|
|
||||||
byte effectIntensityDefault = 128; //intensity is supported on some effects as an additional parameter (e.g. for blink you can change the duty cycle)
|
|
||||||
byte effectPaletteDefault = 0; //palette is supported on the FastLED effects, otherwise it has no effect
|
|
||||||
|
|
||||||
byte nightlightTargetBri = 0; //brightness after nightlight is over
|
byte nightlightTargetBri = 0; //brightness after nightlight is over
|
||||||
byte nightlightDelayMins = 60;
|
byte nightlightDelayMins = 60;
|
||||||
@ -227,7 +223,7 @@ char cronixieDisplay[7] = "HHMMSS"; //Cronixie Display mask. See wled1
|
|||||||
bool cronixieBacklight = true; //Allow digits to be back-illuminated
|
bool cronixieBacklight = true; //Allow digits to be back-illuminated
|
||||||
|
|
||||||
bool countdownMode = false; //Clock will count down towards date
|
bool countdownMode = false; //Clock will count down towards date
|
||||||
byte countdownYear = 19, countdownMonth = 1; //Countdown target date, year is last two digits
|
byte countdownYear = 20, countdownMonth = 1; //Countdown target date, year is last two digits
|
||||||
byte countdownDay = 1, countdownHour = 0;
|
byte countdownDay = 1, countdownHour = 0;
|
||||||
byte countdownMin = 0, countdownSec = 0;
|
byte countdownMin = 0, countdownSec = 0;
|
||||||
|
|
||||||
@ -257,11 +253,9 @@ bool interfacesInited = false;
|
|||||||
bool wasConnected = false;
|
bool wasConnected = false;
|
||||||
|
|
||||||
//color
|
//color
|
||||||
byte col[]{255, 159, 0, 0}; //target RGB(W) color
|
|
||||||
byte colOld[]{0, 0, 0, 0}; //color before transition
|
byte colOld[]{0, 0, 0, 0}; //color before transition
|
||||||
byte colT[]{0, 0, 0, 0}; //current color
|
byte colT[]{0, 0, 0, 0}; //current color
|
||||||
byte colIT[]{0, 0, 0, 0}; //color that was last sent to LEDs
|
byte colIT[]{0, 0, 0, 0}; //color that was last sent to LEDs
|
||||||
byte colSec[]{0, 0, 0, 0};
|
|
||||||
byte colSecT[]{0, 0, 0, 0};
|
byte colSecT[]{0, 0, 0, 0};
|
||||||
byte colSecOld[]{0, 0, 0, 0};
|
byte colSecOld[]{0, 0, 0, 0};
|
||||||
byte colSecIT[]{0, 0, 0, 0};
|
byte colSecIT[]{0, 0, 0, 0};
|
||||||
@ -291,7 +285,7 @@ byte bri = briS;
|
|||||||
byte briOld = 0;
|
byte briOld = 0;
|
||||||
byte briT = 0;
|
byte briT = 0;
|
||||||
byte briIT = 0;
|
byte briIT = 0;
|
||||||
byte briLast = 127; //brightness before turned off. Used for toggle function
|
byte briLast = 128; //brightness before turned off. Used for toggle function
|
||||||
|
|
||||||
//button
|
//button
|
||||||
bool buttonPressedBefore = false;
|
bool buttonPressedBefore = false;
|
||||||
@ -307,10 +301,10 @@ byte notificationSentCallMode = 0;
|
|||||||
bool notificationTwoRequired = false;
|
bool notificationTwoRequired = false;
|
||||||
|
|
||||||
//effects
|
//effects
|
||||||
byte effectCurrent = effectDefault;
|
byte effectCurrent = 0;
|
||||||
byte effectSpeed = effectSpeedDefault;
|
byte effectSpeed = 128;
|
||||||
byte effectIntensity = effectIntensityDefault;
|
byte effectIntensity = 128;
|
||||||
byte effectPalette = effectPaletteDefault;
|
byte effectPalette = 0;
|
||||||
|
|
||||||
//network
|
//network
|
||||||
bool udpConnected = false, udpRgbConnected = false;
|
bool udpConnected = false, udpRgbConnected = false;
|
||||||
@ -423,7 +417,6 @@ byte optionType;
|
|||||||
|
|
||||||
bool doReboot = false; //flag to initiate reboot from async handlers
|
bool doReboot = false; //flag to initiate reboot from async handlers
|
||||||
bool doPublishMqtt = false;
|
bool doPublishMqtt = false;
|
||||||
bool doSendHADiscovery = true;
|
|
||||||
|
|
||||||
//server library objects
|
//server library objects
|
||||||
AsyncWebServer server(80);
|
AsyncWebServer server(80);
|
||||||
@ -529,7 +522,6 @@ void loop() {
|
|||||||
handleAlexa();
|
handleAlexa();
|
||||||
|
|
||||||
handleOverlays();
|
handleOverlays();
|
||||||
if (doSendHADiscovery) sendHADiscoveryMQTT();
|
|
||||||
yield();
|
yield();
|
||||||
if (doReboot) reset();
|
if (doReboot) reset();
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#define EEPSIZE 2560
|
#define EEPSIZE 2560
|
||||||
|
|
||||||
//eeprom Version code, enables default settings instead of 0 init on update
|
//eeprom Version code, enables default settings instead of 0 init on update
|
||||||
#define EEPVER 12
|
#define EEPVER 13
|
||||||
//0 -> old version, default
|
//0 -> old version, default
|
||||||
//1 -> 0.4p 1711272 and up
|
//1 -> 0.4p 1711272 and up
|
||||||
//2 -> 0.4p 1711302 and up
|
//2 -> 0.4p 1711302 and up
|
||||||
@ -19,7 +19,8 @@
|
|||||||
//9 -> 0.8.0
|
//9 -> 0.8.0
|
||||||
//10-> 0.8.2
|
//10-> 0.8.2
|
||||||
//11-> 0.8.5-dev #mqttauth @TimothyBrown
|
//11-> 0.8.5-dev #mqttauth @TimothyBrown
|
||||||
//12-> 0.8.7
|
//12-> 0.8.7-dev
|
||||||
|
//13-> 0.9.0
|
||||||
|
|
||||||
void commit()
|
void commit()
|
||||||
{
|
{
|
||||||
@ -95,9 +96,6 @@ void saveSettingsToEEPROM()
|
|||||||
EEPROM.write(242+i, staticSubnet[i]);
|
EEPROM.write(242+i, staticSubnet[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
EEPROM.write(246, colS[0]);
|
|
||||||
EEPROM.write(247, colS[1]);
|
|
||||||
EEPROM.write(248, colS[2]);
|
|
||||||
EEPROM.write(249, briS);
|
EEPROM.write(249, briS);
|
||||||
|
|
||||||
EEPROM.write(250, receiveNotificationBrightness);
|
EEPROM.write(250, receiveNotificationBrightness);
|
||||||
@ -116,10 +114,6 @@ void saveSettingsToEEPROM()
|
|||||||
EEPROM.write(291, (udpPort >> 8) & 0xFF);
|
EEPROM.write(291, (udpPort >> 8) & 0xFF);
|
||||||
writeStringToEEPROM(292, serverDescription, 32);
|
writeStringToEEPROM(292, serverDescription, 32);
|
||||||
|
|
||||||
EEPROM.write(324, effectDefault);
|
|
||||||
EEPROM.write(325, effectSpeedDefault);
|
|
||||||
EEPROM.write(326, effectIntensityDefault);
|
|
||||||
|
|
||||||
EEPROM.write(327, ntpEnabled);
|
EEPROM.write(327, ntpEnabled);
|
||||||
EEPROM.write(328, currentTimezone);
|
EEPROM.write(328, currentTimezone);
|
||||||
EEPROM.write(329, useAMPM);
|
EEPROM.write(329, useAMPM);
|
||||||
@ -134,19 +128,14 @@ void saveSettingsToEEPROM()
|
|||||||
EEPROM.write(367, (arlsOffset>=0));
|
EEPROM.write(367, (arlsOffset>=0));
|
||||||
EEPROM.write(368, abs(arlsOffset));
|
EEPROM.write(368, abs(arlsOffset));
|
||||||
EEPROM.write(369, turnOnAtBoot);
|
EEPROM.write(369, turnOnAtBoot);
|
||||||
EEPROM.write(371, colS[3]); //white default
|
|
||||||
EEPROM.write(372, useRGBW);
|
EEPROM.write(372, useRGBW);
|
||||||
EEPROM.write(373, effectPaletteDefault);
|
|
||||||
EEPROM.write(374, strip.paletteFade);
|
EEPROM.write(374, strip.paletteFade);
|
||||||
EEPROM.write(375, strip.milliampsPerLed); //was apWaitTimeSecs up to 0.8.5
|
EEPROM.write(375, strip.milliampsPerLed); //was apWaitTimeSecs up to 0.8.5
|
||||||
EEPROM.write(376, apBehavior);
|
EEPROM.write(376, apBehavior);
|
||||||
|
|
||||||
EEPROM.write(377, EEPVER); //eeprom was updated to latest
|
EEPROM.write(377, EEPVER); //eeprom was updated to latest
|
||||||
|
|
||||||
EEPROM.write(378, colSecS[0]);
|
|
||||||
EEPROM.write(379, colSecS[1]);
|
|
||||||
EEPROM.write(380, colSecS[2]);
|
|
||||||
EEPROM.write(381, colSecS[3]);
|
|
||||||
EEPROM.write(382, strip.paletteBlend);
|
EEPROM.write(382, strip.paletteBlend);
|
||||||
EEPROM.write(383, strip.colorOrder);
|
EEPROM.write(383, strip.colorOrder);
|
||||||
|
|
||||||
@ -168,7 +157,8 @@ void saveSettingsToEEPROM()
|
|||||||
EEPROM.write(399, !enableSecTransition);
|
EEPROM.write(399, !enableSecTransition);
|
||||||
|
|
||||||
//favorite setting (preset) memory (25 slots/ each 20byte)
|
//favorite setting (preset) memory (25 slots/ each 20byte)
|
||||||
//400 - 899 reserved
|
//400 - 940 reserved
|
||||||
|
writeStringToEEPROM(990, ntpServerName, 32);
|
||||||
|
|
||||||
EEPROM.write(2048, huePollingEnabled);
|
EEPROM.write(2048, huePollingEnabled);
|
||||||
//EEPROM.write(2049, hueUpdatingEnabled);
|
//EEPROM.write(2049, hueUpdatingEnabled);
|
||||||
@ -314,9 +304,6 @@ void loadSettingsFromEEPROM(bool first)
|
|||||||
staticSubnet[2] = EEPROM.read(244);
|
staticSubnet[2] = EEPROM.read(244);
|
||||||
staticSubnet[3] = EEPROM.read(245);
|
staticSubnet[3] = EEPROM.read(245);
|
||||||
|
|
||||||
colS[0] = EEPROM.read(246); col[0] = colS[0];
|
|
||||||
colS[1] = EEPROM.read(247); col[1] = colS[1];
|
|
||||||
colS[2] = EEPROM.read(248); col[2] = colS[2];
|
|
||||||
briS = EEPROM.read(249); bri = briS;
|
briS = EEPROM.read(249); bri = briS;
|
||||||
if (!EEPROM.read(369) && first)
|
if (!EEPROM.read(369) && first)
|
||||||
{
|
{
|
||||||
@ -337,8 +324,6 @@ void loadSettingsFromEEPROM(bool first)
|
|||||||
|
|
||||||
readStringFromEEPROM(292, serverDescription, 32);
|
readStringFromEEPROM(292, serverDescription, 32);
|
||||||
|
|
||||||
effectDefault = EEPROM.read(324); effectCurrent = effectDefault;
|
|
||||||
effectSpeedDefault = EEPROM.read(325); effectSpeed = effectSpeedDefault;
|
|
||||||
ntpEnabled = EEPROM.read(327);
|
ntpEnabled = EEPROM.read(327);
|
||||||
currentTimezone = EEPROM.read(328);
|
currentTimezone = EEPROM.read(328);
|
||||||
useAMPM = EEPROM.read(329);
|
useAMPM = EEPROM.read(329);
|
||||||
@ -355,32 +340,19 @@ void loadSettingsFromEEPROM(bool first)
|
|||||||
arlsOffset = EEPROM.read(368);
|
arlsOffset = EEPROM.read(368);
|
||||||
if (!EEPROM.read(367)) arlsOffset = -arlsOffset;
|
if (!EEPROM.read(367)) arlsOffset = -arlsOffset;
|
||||||
turnOnAtBoot = EEPROM.read(369);
|
turnOnAtBoot = EEPROM.read(369);
|
||||||
colS[3] = EEPROM.read(371); col[3] = colS[3];
|
|
||||||
useRGBW = EEPROM.read(372);
|
useRGBW = EEPROM.read(372);
|
||||||
effectPaletteDefault = EEPROM.read(373); effectPalette = effectPaletteDefault;
|
|
||||||
//374 - strip.paletteFade
|
//374 - strip.paletteFade
|
||||||
|
|
||||||
apBehavior = EEPROM.read(376);
|
apBehavior = EEPROM.read(376);
|
||||||
|
|
||||||
//377 = lastEEPROMversion
|
//377 = lastEEPROMversion
|
||||||
if (lastEEPROMversion > 1) {
|
|
||||||
for (byte i=0; i<4; i++)
|
|
||||||
{
|
|
||||||
colSecS[i] = EEPROM.read(378+i); colSec[i] = colSecS[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (lastEEPROMversion > 3) {
|
if (lastEEPROMversion > 3) {
|
||||||
effectIntensityDefault = EEPROM.read(326); effectIntensity = effectIntensityDefault;
|
|
||||||
aOtaEnabled = EEPROM.read(390);
|
aOtaEnabled = EEPROM.read(390);
|
||||||
receiveNotificationColor = EEPROM.read(391);
|
receiveNotificationColor = EEPROM.read(391);
|
||||||
receiveNotificationEffects = EEPROM.read(392);
|
receiveNotificationEffects = EEPROM.read(392);
|
||||||
|
|
||||||
} else //keep receiving notification behavior from pre0.5.0 after update
|
|
||||||
{
|
|
||||||
receiveNotificationColor = receiveNotificationBrightness;
|
|
||||||
receiveNotificationEffects = receiveNotificationBrightness;
|
|
||||||
}
|
}
|
||||||
receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects);
|
receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects);
|
||||||
|
|
||||||
if (lastEEPROMversion > 4) {
|
if (lastEEPROMversion > 4) {
|
||||||
huePollingEnabled = EEPROM.read(2048);
|
huePollingEnabled = EEPROM.read(2048);
|
||||||
//hueUpdatingEnabled = EEPROM.read(2049);
|
//hueUpdatingEnabled = EEPROM.read(2049);
|
||||||
@ -486,6 +458,10 @@ void loadSettingsFromEEPROM(bool first)
|
|||||||
strip.ablMilliampsMax = ABL_MILLIAMPS_DEFAULT;
|
strip.ablMilliampsMax = ABL_MILLIAMPS_DEFAULT;
|
||||||
strip.milliampsPerLed = 0; //disable ABL
|
strip.milliampsPerLed = 0; //disable ABL
|
||||||
}
|
}
|
||||||
|
if (lastEEPROMversion > 12)
|
||||||
|
{
|
||||||
|
readStringFromEEPROM(990, ntpServerName, 32);
|
||||||
|
}
|
||||||
|
|
||||||
receiveDirect = !EEPROM.read(2200);
|
receiveDirect = !EEPROM.read(2200);
|
||||||
notifyMacro = EEPROM.read(2201);
|
notifyMacro = EEPROM.read(2201);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//build XML response to HTTP /win API request
|
//build XML response to HTTP /win API request
|
||||||
char* XML_response(AsyncWebServerRequest *request, bool includeTheme, char* dest = nullptr)
|
char* XML_response(AsyncWebServerRequest *request, char* dest = nullptr)
|
||||||
{
|
{
|
||||||
char sbuf[(dest == nullptr)?1024:1]; //allocate local buffer if none passed
|
char sbuf[(dest == nullptr)?1024:1]; //allocate local buffer if none passed
|
||||||
obuf = (dest == nullptr)? sbuf:dest;
|
obuf = (dest == nullptr)? sbuf:dest;
|
||||||
@ -216,33 +216,20 @@ void getSettingsJS(byte subPage, char* dest)
|
|||||||
oappendi(strip.currentMilliamps);
|
oappendi(strip.currentMilliamps);
|
||||||
oappend("mA\";");
|
oappend("mA\";");
|
||||||
}
|
}
|
||||||
sappend('v',"CR",colS[0]);
|
|
||||||
sappend('v',"CG",colS[1]);
|
|
||||||
sappend('v',"CB",colS[2]);
|
|
||||||
sappend('v',"CA",briS);
|
sappend('v',"CA",briS);
|
||||||
sappend('c',"EW",useRGBW);
|
sappend('c',"EW",useRGBW);
|
||||||
sappend('i',"CO",strip.colorOrder);
|
sappend('i',"CO",strip.colorOrder);
|
||||||
sappend('c',"AW",autoRGBtoRGBW);
|
sappend('c',"AW",autoRGBtoRGBW);
|
||||||
sappend('v',"CW",colS[3]);
|
|
||||||
sappend('v',"SR",colSecS[0]);
|
|
||||||
sappend('v',"SG",colSecS[1]);
|
|
||||||
sappend('v',"SB",colSecS[2]);
|
|
||||||
sappend('v',"SW",colSecS[3]);
|
|
||||||
sappend('c',"BO",turnOnAtBoot);
|
sappend('c',"BO",turnOnAtBoot);
|
||||||
sappend('v',"BP",bootPreset);
|
sappend('v',"BP",bootPreset);
|
||||||
oappend("f=");
|
|
||||||
oappendi(effectDefault);
|
|
||||||
oappend(";p=");
|
|
||||||
oappendi(effectPaletteDefault);
|
|
||||||
oappend(";");
|
|
||||||
sappend('v',"SX",effectSpeedDefault);
|
|
||||||
sappend('v',"IX",effectIntensityDefault);
|
|
||||||
sappend('c',"GB",strip.gammaCorrectBri);
|
sappend('c',"GB",strip.gammaCorrectBri);
|
||||||
sappend('c',"GC",strip.gammaCorrectCol);
|
sappend('c',"GC",strip.gammaCorrectCol);
|
||||||
sappend('c',"TF",fadeTransition);
|
sappend('c',"TF",fadeTransition);
|
||||||
sappend('v',"TD",transitionDelay);
|
sappend('v',"TD",transitionDelay);
|
||||||
sappend('c',"PF",strip.paletteFade);
|
sappend('c',"PF",strip.paletteFade);
|
||||||
sappend('c',"T2",enableSecTransition);
|
|
||||||
sappend('v',"BF",briMultiplier);
|
sappend('v',"BF",briMultiplier);
|
||||||
sappend('v',"TB",nightlightTargetBri);
|
sappend('v',"TB",nightlightTargetBri);
|
||||||
sappend('v',"TL",nightlightDelayMinsDefault);
|
sappend('v',"TL",nightlightDelayMinsDefault);
|
||||||
@ -310,6 +297,7 @@ void getSettingsJS(byte subPage, char* dest)
|
|||||||
if (subPage == 5)
|
if (subPage == 5)
|
||||||
{
|
{
|
||||||
sappend('c',"NT",ntpEnabled);
|
sappend('c',"NT",ntpEnabled);
|
||||||
|
sappends('s',"NS",ntpServerName);
|
||||||
sappend('c',"CF",!useAMPM);
|
sappend('c',"CF",!useAMPM);
|
||||||
sappend('i',"TZ",currentTimezone);
|
sappend('i',"TZ",currentTimezone);
|
||||||
sappend('v',"UO",utcOffsetSecs);
|
sappend('v',"UO",utcOffsetSecs);
|
||||||
|
@ -68,34 +68,8 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
strip.colorOrder = request->arg("CO").toInt();
|
strip.colorOrder = request->arg("CO").toInt();
|
||||||
autoRGBtoRGBW = request->hasArg("AW");
|
autoRGBtoRGBW = request->hasArg("AW");
|
||||||
|
|
||||||
//ignore settings and save current brightness, colors and fx as default
|
|
||||||
if (request->hasArg("IS"))
|
|
||||||
{
|
|
||||||
for (byte i=0; i<4; i++)
|
|
||||||
{
|
|
||||||
colS[i] = col[i];
|
|
||||||
colSecS[i] = colSec[i];
|
|
||||||
}
|
|
||||||
briS = bri;
|
|
||||||
effectDefault = effectCurrent;
|
|
||||||
effectSpeedDefault = effectSpeed;
|
|
||||||
effectIntensityDefault = effectIntensity;
|
|
||||||
effectPaletteDefault = effectPalette;
|
|
||||||
} else {
|
|
||||||
colS[0] = request->arg("CR").toInt();
|
|
||||||
colS[1] = request->arg("CG").toInt();
|
|
||||||
colS[2] = request->arg("CB").toInt();
|
|
||||||
colS[3] = request->arg("CW").toInt();
|
|
||||||
colSecS[0] = request->arg("SR").toInt();
|
|
||||||
colSecS[1] = request->arg("SG").toInt();
|
|
||||||
colSecS[2] = request->arg("SB").toInt();
|
|
||||||
colSecS[3] = request->arg("SW").toInt();
|
|
||||||
briS = request->arg("CA").toInt();
|
briS = request->arg("CA").toInt();
|
||||||
effectDefault = request->arg("FX").toInt();
|
|
||||||
effectSpeedDefault = request->arg("SX").toInt();
|
|
||||||
effectIntensityDefault = request->arg("IX").toInt();
|
|
||||||
effectPaletteDefault = request->arg("FP").toInt();
|
|
||||||
}
|
|
||||||
saveCurrPresetCycConf = request->hasArg("PC");
|
saveCurrPresetCycConf = request->hasArg("PC");
|
||||||
turnOnAtBoot = request->hasArg("BO");
|
turnOnAtBoot = request->hasArg("BO");
|
||||||
t = request->arg("BP").toInt();
|
t = request->arg("BP").toInt();
|
||||||
@ -108,7 +82,6 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
if (t > 0) transitionDelay = t;
|
if (t > 0) transitionDelay = t;
|
||||||
transitionDelayDefault = t;
|
transitionDelayDefault = t;
|
||||||
strip.paletteFade = request->hasArg("PF");
|
strip.paletteFade = request->hasArg("PF");
|
||||||
enableSecTransition = request->hasArg("T2");
|
|
||||||
|
|
||||||
nightlightTargetBri = request->arg("TB").toInt();
|
nightlightTargetBri = request->arg("TB").toInt();
|
||||||
t = request->arg("TL").toInt();
|
t = request->arg("TL").toInt();
|
||||||
@ -200,6 +173,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
if (subPage == 5)
|
if (subPage == 5)
|
||||||
{
|
{
|
||||||
ntpEnabled = request->hasArg("NT");
|
ntpEnabled = request->hasArg("NT");
|
||||||
|
strlcpy(ntpServerName, request->arg("NS").c_str(), 33);
|
||||||
useAMPM = !request->hasArg("CF");
|
useAMPM = !request->hasArg("CF");
|
||||||
currentTimezone = request->arg("TZ").toInt();
|
currentTimezone = request->arg("TZ").toInt();
|
||||||
utcOffsetSecs = request->arg("UO").toInt();
|
utcOffsetSecs = request->arg("UO").toInt();
|
||||||
@ -366,7 +340,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pos = req.indexOf("IN");
|
pos = req.indexOf("IN");
|
||||||
if (pos < 1) XML_response(request, false);
|
if (pos < 1) XML_response(request);
|
||||||
return true;
|
return true;
|
||||||
//if you save a macro in one request, other commands in that request are ignored due to unwanted behavior otherwise
|
//if you save a macro in one request, other commands in that request are ignored due to unwanted behavior otherwise
|
||||||
}
|
}
|
||||||
@ -374,15 +348,26 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
|
|||||||
strip.applyToAllSelected = true;
|
strip.applyToAllSelected = true;
|
||||||
|
|
||||||
//segment select (sets main segment)
|
//segment select (sets main segment)
|
||||||
pos = req.indexOf("SS=");
|
byte prevMain = strip.getMainSegmentId();
|
||||||
|
pos = req.indexOf("SM=");
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
strip.mainSegment = getNumVal(&req, pos);
|
strip.mainSegment = getNumVal(&req, pos);
|
||||||
}
|
}
|
||||||
byte main = strip.getMainSegmentId();
|
byte main = strip.getMainSegmentId();
|
||||||
|
if (main != prevMain) setValuesFromMainSeg();
|
||||||
|
|
||||||
|
pos = req.indexOf("SS=");
|
||||||
|
if (pos > 0) {
|
||||||
|
byte t = getNumVal(&req, pos);
|
||||||
|
if (t < strip.getMaxSegments()) main = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
pos = req.indexOf("SV="); //segment selected
|
||||||
|
if (pos > 0) strip.getSegment(main).setOption(0, (req.charAt(pos+3) != '0'));
|
||||||
|
|
||||||
uint16_t startI = strip.getSegment(main).start;
|
uint16_t startI = strip.getSegment(main).start;
|
||||||
uint16_t stopI = strip.getSegment(main).stop;
|
uint16_t stopI = strip.getSegment(main).stop;
|
||||||
pos = req.indexOf("S="); //segment start
|
pos = req.indexOf("&S="); //segment start
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
startI = getNumVal(&req, pos);
|
startI = getNumVal(&req, pos);
|
||||||
}
|
}
|
||||||
@ -429,45 +414,12 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
|
|||||||
colorFromDecOrHexString(colSec, (char*)req.substring(pos + 3).c_str());
|
colorFromDecOrHexString(colSec, (char*)req.substring(pos + 3).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
//set 2nd to white
|
|
||||||
pos = req.indexOf("SW");
|
|
||||||
if (pos > 0) {
|
|
||||||
if(useRGBW) {
|
|
||||||
colSec[3] = 255;
|
|
||||||
colSec[0] = 0;
|
|
||||||
colSec[1] = 0;
|
|
||||||
colSec[2] = 0;
|
|
||||||
} else {
|
|
||||||
colSec[0] = 255;
|
|
||||||
colSec[1] = 255;
|
|
||||||
colSec[2] = 255;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//set 2nd to black
|
|
||||||
pos = req.indexOf("SB");
|
|
||||||
if (pos > 0) {
|
|
||||||
colSec[3] = 0;
|
|
||||||
colSec[0] = 0;
|
|
||||||
colSec[1] = 0;
|
|
||||||
colSec[2] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//set to random hue SR=0->1st SR=1->2nd
|
//set to random hue SR=0->1st SR=1->2nd
|
||||||
pos = req.indexOf("SR");
|
pos = req.indexOf("SR");
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
_setRandomColor(getNumVal(&req, pos));
|
_setRandomColor(getNumVal(&req, pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
//set 2nd to 1st
|
|
||||||
pos = req.indexOf("SP");
|
|
||||||
if (pos > 0) {
|
|
||||||
colSec[0] = col[0];
|
|
||||||
colSec[1] = col[1];
|
|
||||||
colSec[2] = col[2];
|
|
||||||
colSec[3] = col[3];
|
|
||||||
}
|
|
||||||
|
|
||||||
//swap 2nd & 1st
|
//swap 2nd & 1st
|
||||||
pos = req.indexOf("SC");
|
pos = req.indexOf("SC");
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
@ -486,21 +438,6 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
|
|||||||
updateVal(&req, "IX=", &effectIntensity);
|
updateVal(&req, "IX=", &effectIntensity);
|
||||||
updateVal(&req, "FP=", &effectPalette, 0, strip.getPaletteCount()-1);
|
updateVal(&req, "FP=", &effectPalette, 0, strip.getPaletteCount()-1);
|
||||||
|
|
||||||
//set hue polling light: 0 -off
|
|
||||||
#ifndef WLED_DISABLE_HUESYNC
|
|
||||||
pos = req.indexOf("HP=");
|
|
||||||
if (pos > 0) {
|
|
||||||
int id = getNumVal(&req, pos);
|
|
||||||
if (id > 0)
|
|
||||||
{
|
|
||||||
if (id < 100) huePollLightId = id;
|
|
||||||
reconnectHue();
|
|
||||||
} else {
|
|
||||||
huePollingEnabled = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//set advanced overlay
|
//set advanced overlay
|
||||||
pos = req.indexOf("OL=");
|
pos = req.indexOf("OL=");
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
@ -674,13 +611,10 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
|
|||||||
setCronixie();
|
setCronixie();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.indexOf("NB=") > 0) //sets backlight
|
pos = req.indexOf("NB=");
|
||||||
|
if (pos > 0) //sets backlight
|
||||||
{
|
{
|
||||||
cronixieBacklight = true;
|
presetApplyFx = (req.charAt(pos+3) != '0');
|
||||||
if (req.indexOf("NB=0") > 0)
|
|
||||||
{
|
|
||||||
cronixieBacklight = false;
|
|
||||||
}
|
|
||||||
if (overlayCurrent == 3) strip.setCronixieBacklight(cronixieBacklight);
|
if (overlayCurrent == 3) strip.setCronixieBacklight(cronixieBacklight);
|
||||||
overlayRefreshedTime = 0;
|
overlayRefreshedTime = 0;
|
||||||
}
|
}
|
||||||
@ -702,7 +636,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
|
|||||||
|
|
||||||
//internal call, does not send XML response
|
//internal call, does not send XML response
|
||||||
pos = req.indexOf("IN");
|
pos = req.indexOf("IN");
|
||||||
if (pos < 1) XML_response(request, (req.indexOf("&IT") > 0)); //include theme if firstload
|
if (pos < 1) XML_response(request);
|
||||||
|
|
||||||
pos = req.indexOf("&NN"); //do not send UDP notifications this time
|
pos = req.indexOf("&NN"); //do not send UDP notifications this time
|
||||||
colorUpdated((pos > 0) ? 5:1);
|
colorUpdated((pos > 0) ? 5:1);
|
||||||
|
@ -75,7 +75,15 @@ void handleNetworkTime()
|
|||||||
|
|
||||||
void sendNTPPacket()
|
void sendNTPPacket()
|
||||||
{
|
{
|
||||||
|
if (!ntpServerIP.fromString(ntpServerName)) //see if server is IP or domain
|
||||||
|
{
|
||||||
|
#ifdef ESP8266
|
||||||
|
WiFi.hostByName(ntpServerName, ntpServerIP, 750);
|
||||||
|
#else
|
||||||
WiFi.hostByName(ntpServerName, ntpServerIP);
|
WiFi.hostByName(ntpServerName, ntpServerIP);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG_PRINTLN("send NTP");
|
DEBUG_PRINTLN("send NTP");
|
||||||
byte pbuf[NTP_PACKET_SIZE];
|
byte pbuf[NTP_PACKET_SIZE];
|
||||||
memset(pbuf, 0, NTP_PACKET_SIZE);
|
memset(pbuf, 0, NTP_PACKET_SIZE);
|
||||||
|
@ -42,7 +42,6 @@ void onMqttConnect(bool sessionPresent)
|
|||||||
mqtt->subscribe(subuf, 0);
|
mqtt->subscribe(subuf, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
doSendHADiscovery = true;
|
|
||||||
doPublishMqtt = true;
|
doPublishMqtt = true;
|
||||||
DEBUG_PRINTLN("MQTT ready");
|
DEBUG_PRINTLN("MQTT ready");
|
||||||
}
|
}
|
||||||
@ -93,136 +92,14 @@ void publishMqtt()
|
|||||||
mqtt->publish(subuf, 0, true, "online");
|
mqtt->publish(subuf, 0, true, "online");
|
||||||
|
|
||||||
char apires[1024];
|
char apires[1024];
|
||||||
XML_response(nullptr, false, apires);
|
XML_response(nullptr, apires);
|
||||||
strcpy(subuf, mqttDeviceTopic);
|
strcpy(subuf, mqttDeviceTopic);
|
||||||
strcat(subuf, "/v");
|
strcat(subuf, "/v");
|
||||||
mqtt->publish(subuf, 0, true, apires);
|
mqtt->publish(subuf, 0, true, apires);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char HA_static_JSON[] PROGMEM = R"=====(,"bri_val_tpl":"{{value}}","rgb_cmd_tpl":"{{'#%02x%02x%02x' | format(red, green, blue)}}","rgb_val_tpl":"{{value[1:3]|int(base=16)}},{{value[3:5]|int(base=16)}},{{value[5:7]|int(base=16)}}","qos":0,"opt":true,"pl_on":"ON","pl_off":"OFF","fx_val_tpl":"{{value}}","fx_list":[)=====";
|
|
||||||
|
|
||||||
char* buffer;
|
//HA autodiscovery was removed in favor of the native integration in HA v0.102.0
|
||||||
|
|
||||||
void sendHADiscoveryMQTT()
|
|
||||||
{
|
|
||||||
//TODO: With LwIP 1 the ESP loses MQTT connection and causes memory leak when sending discovery packet
|
|
||||||
#if ARDUINO_ARCH_ESP32 || LWIP_VERSION_MAJOR > 1
|
|
||||||
/*
|
|
||||||
|
|
||||||
YYYY is device topic
|
|
||||||
XXXX is device name
|
|
||||||
|
|
||||||
Send out HA MQTT Discovery message on MQTT connect (~2.4kB):
|
|
||||||
{
|
|
||||||
"name": "XXXX",
|
|
||||||
"stat_t":"YYYY/c",
|
|
||||||
"cmd_t":"YYYY",
|
|
||||||
"rgb_stat_t":"YYYY/c",
|
|
||||||
"rgb_cmd_t":"YYYY/col",
|
|
||||||
"bri_cmd_t":"YYYY",
|
|
||||||
"bri_stat_t":"YYYY/g",
|
|
||||||
"bri_val_tpl":"{{value}}",
|
|
||||||
"rgb_cmd_tpl":"{{'#%02x%02x%02x' | format(red, green, blue)}}",
|
|
||||||
"rgb_val_tpl":"{{value[1:3]|int(base=16)}},{{value[3:5]|int(base=16)}},{{value[5:7]|int(base=16)}}",
|
|
||||||
"qos": 0,
|
|
||||||
"opt":true,
|
|
||||||
"pl_on": "ON",
|
|
||||||
"pl_off": "OFF",
|
|
||||||
"fx_cmd_t":"YYYY/api",
|
|
||||||
"fx_stat_t":"YYYY/api",
|
|
||||||
"fx_val_tpl":"{{value}}",
|
|
||||||
"fx_list":[
|
|
||||||
"[FX=00] Solid",
|
|
||||||
"[FX=01] Blink",
|
|
||||||
"[FX=02] ...",
|
|
||||||
"[FX=79] Ripple"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
doSendHADiscovery = false;
|
|
||||||
if (mqtt == nullptr || !mqtt->connected()) return;
|
|
||||||
buffer = new char[2400];
|
|
||||||
if (!buffer) {delete[] buffer; return;}
|
|
||||||
|
|
||||||
char bufc[36], bufcol[38], bufg[36], bufapi[38];
|
|
||||||
|
|
||||||
strcpy(bufc, mqttDeviceTopic);
|
|
||||||
strcpy(bufcol, mqttDeviceTopic);
|
|
||||||
strcpy(bufg, mqttDeviceTopic);
|
|
||||||
strcpy(bufapi, mqttDeviceTopic);
|
|
||||||
|
|
||||||
strcat(bufc, "/c");
|
|
||||||
strcat(bufcol, "/col");
|
|
||||||
strcat(bufg, "/g");
|
|
||||||
strcat(bufapi, "/api");
|
|
||||||
|
|
||||||
StaticJsonDocument<JSON_OBJECT_SIZE(9) +512> root;
|
|
||||||
root["name"] = serverDescription;
|
|
||||||
root["stat_t"] = bufc;
|
|
||||||
root["cmd_t"] = mqttDeviceTopic;
|
|
||||||
root["rgb_stat_t"] = bufc;
|
|
||||||
root["rgb_cmd_t"] = bufcol;
|
|
||||||
root["bri_cmd_t"] = mqttDeviceTopic;
|
|
||||||
root["bri_stat_t"] = bufg;
|
|
||||||
root["fx_cmd_t"] = bufapi;
|
|
||||||
root["fx_stat_t"] = bufapi;
|
|
||||||
|
|
||||||
size_t jlen = measureJson(root);
|
|
||||||
//DEBUG_PRINTLN(jlen);
|
|
||||||
serializeJson(root, buffer, jlen);
|
|
||||||
|
|
||||||
//add values which don't change
|
|
||||||
strcpy_P(buffer + jlen -1, HA_static_JSON);
|
|
||||||
|
|
||||||
olen = 0;
|
|
||||||
obuf = buffer + jlen -1 + strlen_P(HA_static_JSON);
|
|
||||||
|
|
||||||
//add fx_list
|
|
||||||
uint16_t jmnlen = strlen_P(JSON_mode_names);
|
|
||||||
uint16_t nameStart = 0, nameEnd = 0;
|
|
||||||
int i = 0;
|
|
||||||
bool isNameStart = true;
|
|
||||||
|
|
||||||
for (uint16_t j = 0; j < jmnlen; j++)
|
|
||||||
{
|
|
||||||
if (pgm_read_byte(JSON_mode_names + j) == '\"' || j == jmnlen -1)
|
|
||||||
{
|
|
||||||
if (isNameStart)
|
|
||||||
{
|
|
||||||
nameStart = j +1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nameEnd = j;
|
|
||||||
char mdnfx[64], mdn[56];
|
|
||||||
uint16_t namelen = nameEnd - nameStart;
|
|
||||||
strncpy_P(mdn, JSON_mode_names + nameStart, namelen);
|
|
||||||
mdn[namelen] = 0;
|
|
||||||
snprintf(mdnfx, 64, "\"[FX=%02d] %s\",", i, mdn);
|
|
||||||
oappend(mdnfx);
|
|
||||||
//DEBUG_PRINTLN(mdnfx);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
isNameStart = !isNameStart;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
olen--;
|
|
||||||
oappend("]}");
|
|
||||||
|
|
||||||
DEBUG_PRINT("HA Discovery Sending >>");
|
|
||||||
DEBUG_PRINTLN(buffer);
|
|
||||||
|
|
||||||
char pubt[25 + 12 + 8];
|
|
||||||
strcpy(pubt, "homeassistant/light/");
|
|
||||||
strcat(pubt, mqttClientID);
|
|
||||||
strcat(pubt, "/config");
|
|
||||||
bool success = mqtt->publish(pubt, 0, true, buffer);
|
|
||||||
DEBUG_PRINTLN(success);
|
|
||||||
yield();
|
|
||||||
delete[] buffer;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool initMqtt()
|
bool initMqtt()
|
||||||
{
|
{
|
||||||
|
@ -105,7 +105,9 @@ bool deserializeState(JsonObject root)
|
|||||||
int timein = root["time"] | -1;
|
int timein = root["time"] | -1;
|
||||||
if (timein != -1) setTime(timein);
|
if (timein != -1) setTime(timein);
|
||||||
|
|
||||||
strip.mainSegment = root["mainseg"] | strip.mainSegment;
|
byte prevMain = strip.getMainSegmentId();
|
||||||
|
strip.mainSegment = root["mainseg"] | prevMain;
|
||||||
|
if (strip.getMainSegmentId() != prevMain) setValuesFromMainSeg();
|
||||||
|
|
||||||
int it = 0;
|
int it = 0;
|
||||||
JsonVariant segVar = root["seg"];
|
JsonVariant segVar = root["seg"];
|
||||||
|
Loading…
Reference in New Issue
Block a user