diff --git a/TODO.txt b/TODO.txt index cf67ebd9c..c2419f68e 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,8 +1,8 @@ color cycle +other vfx (fire...) sequence simple slide transition additional color picker field -implement all settings setters (notifyNightlight \n udpPort) implement HSB slider option implement ranges implement discrete range color setter @@ -11,11 +11,32 @@ svg icons in html add preferred colors to settings -> quickly t. UI, button select, use iframe for settings, seperate tabs for wifi and application confg use iframe for all adv. features? -/dumpeeprom and /pusheeprom +/dumpeeprom and /pusheeprom (ota lock!) aux trigger pin -descriptive text +randomizer + +clock functions: +analog clock on range (dots) +5 min lines +slider clock on range (track) +get time from ntp +time zones + dst +adjustable chimes +timed light activation +alarm clock +countdown (= NL with seq. trans) + +more button functions (hold for bri select, double click, etc.): +hold +single click +double click +triple click +quad click +funcs: toggle on/off +toggle nightlight +toggle notifier +var. brightness BUGS static ip disables mdns ? authentification for security relevant areas ([/settings, /reset]) -(Unverified) led_amount does nothing (is always 16) because NeoPixelBus is initiated before EEPROM read diff --git a/wled00/data/settings.htm b/wled00/data/settings.htm index e4f104fdb..29a219f47 100644 --- a/wled00/data/settings.htm +++ b/wled00/data/settings.htm @@ -31,18 +31,19 @@ document.S_form.APHSSID.checked = (this.responseXML.getElementsByTagName('aphssid')[0].innerHTML)!=0?true:false; document.S_form.APPASS.value = this.responseXML.getElementsByTagName('appass')[0].innerHTML; //fake pass like ****** document.S_form.APCHAN.value = this.responseXML.getElementsByTagName('apchan')[0].innerHTML; - document.S_form.LEDS.value = this.responseXML.getElementsByTagName('leds')[0].innerHTML; + document.S_form.DESC.value = this.responseXML.getElementsByTagName('desc')[0].innerHTML; document.S_form.BTNON.checked = (this.responseXML.getElementsByTagName('btnon')[0].innerHTML)!=0?true:false; document.S_form.TFADE.checked = (this.responseXML.getElementsByTagName('tfade')[0].innerHTML)!=0?true:false; document.S_form.TDLAY.value = this.responseXML.getElementsByTagName('tdlay')[0].innerHTML; + document.S_form.TLBRI.value = this.responseXML.getElementsByTagName('tlbri')[0].innerHTML; document.S_form.TLDUR.value = this.responseXML.getElementsByTagName('tldur')[0].innerHTML; document.S_form.TLFDE.checked = (this.responseXML.getElementsByTagName('tlfde')[0].innerHTML)!=0?true:false; + document.S_form.NUDPP.value = this.responseXML.getElementsByTagName('nudpp')[0].innerHTML; document.S_form.NRCVE.checked = (this.responseXML.getElementsByTagName('nrcve')[0].innerHTML)!=0?true:false; document.S_form.NRBRI.value = this.responseXML.getElementsByTagName('nrbri')[0].innerHTML; document.S_form.NSDIR.checked = (this.responseXML.getElementsByTagName('nsdir')[0].innerHTML)!=0?true:false; document.S_form.NSBTN.checked = (this.responseXML.getElementsByTagName('nsbtn')[0].innerHTML)!=0?true:false; document.S_form.NSFWD.checked = (this.responseXML.getElementsByTagName('nsfwd')[0].innerHTML)!=0?true:false; - document.S_form.NSIPS.innerHTML = this.responseXML.getElementsByTagName('nsips')[0].innerHTML; document.S_form.NOOTA.checked = (this.responseXML.getElementsByTagName('noota')[0].innerHTML)!=0?true:false; document.S_form.NORAP.checked = (this.responseXML.getElementsByTagName('norap')[0].innerHTML)!=0?true:false; document.getElementsByClassName("sip")[0].innerHTML = this.responseXML.getElementsByTagName('sip')[0].innerHTML; @@ -102,25 +103,26 @@ AP IP: Not active

Application setup

+

Web setup

+ Server description:

LED setup

The default boot LED color is the current color when settings are saved.
- LED amount:
+ Brightness factor: %

Button setup

On/Off button enabled:

Transitions

Fade:
Transition Delay: ms

Timed light

- Turn off after: min
- Fade down:
+ Target brightness: (0-255)
+ Change after: min
+ Fade:

Daisy chain

+ UDP Port:
Receive notifications:
- Received brightness factor: %

Send notifications on direct change:
Send notifications on button press:
- Forward received notifications:
- Hosts to send notifications to: (1 IP per line)
- + Send nightlight notifications:

Security

OTA locked:
Passphrase:
diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 66dfba771..03e422d7d 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -14,7 +14,11 @@ * @version 0.3pd * @author Christian Schwinne */ +//Hardware-settings (only changeble via code) +uint8_t led_amount = 16; +uint8_t buttonPin = 0; //needs pull-up //Default CONFIG +String serverDescription = "WLED 0.3pd"; String clientssid = "Your_Network_Here"; String clientpass = "Dummy_Pass"; String cmdns = "led"; @@ -27,21 +31,20 @@ IPAddress staticip(0, 0, 0, 0); IPAddress staticgateway(0, 0, 0, 0); IPAddress staticsubnet(255, 255, 255, 0); byte col[]{255, 127, 0}; +uint8_t bri_nl = 0; boolean fadeTransition = true; boolean seqTransition = false; uint16_t transitionDelay = 1500; boolean ota_lock = true; String otapass = "wledota"; boolean only_ap = false; -uint8_t led_amount = 16; -uint8_t buttonPin = 3; //needs pull-up boolean buttonEnabled = true; -boolean notifyDirect = true, notifyButton = true, notifyForward = true, notifyNightlight = false; +boolean notifyDirect = true, notifyButton = true, notifyNightlight = false; boolean receiveNotifications = true; uint8_t bri_n = 100; uint8_t nightlightDelayMins = 60; boolean nightlightFade = true; -unsigned int udpPort = 21324; +uint16_t udpPort = 21324; double transitionResolution = 0.011; @@ -62,7 +65,6 @@ boolean buttonPressedBefore = false; boolean nightlightActive = false; boolean nightlightActive_old = false; int transitionDelay_old; -long nightlightPassedTime = 0; int nightlightDelayMs; boolean udpConnected = false; byte notifierBuffer[16]; diff --git a/wled00/wled01_eeprom.ino b/wled00/wled01_eeprom.ino index 381c304e0..52da768ba 100644 --- a/wled00/wled01_eeprom.ino +++ b/wled00/wled01_eeprom.ino @@ -41,7 +41,7 @@ void saveSettingsToEEPROM() EEPROM.write(228, aphide); EEPROM.write(229, led_amount); EEPROM.write(230, notifyButton); - EEPROM.write(231, notifyForward); + EEPROM.write(231, notifyNightlight); EEPROM.write(232, buttonEnabled); //233 reserved for first boot flag EEPROM.write(234, staticip[0]); @@ -70,7 +70,14 @@ void saveSettingsToEEPROM() { EEPROM.write(i, otapass.charAt(i-256)); } + EEPROM.write(288, bri_nl); EEPROM.write(289, ota_lock); + EEPROM.write(290, (udpPort >> 0) & 0xFF); + EEPROM.write(291, (udpPort >> 8) & 0xFF); + for (int i = 292; i < 324; ++i) + { + EEPROM.write(i, serverDescription.charAt(i-292)); + } EEPROM.commit(); } @@ -120,7 +127,7 @@ void loadSettingsFromEEPROM() if (aphide > 1) aphide = 1; led_amount = EEPROM.read(229); notifyButton = EEPROM.read(230); - notifyForward = EEPROM.read(231); + notifyNightlight = EEPROM.read(231); buttonEnabled = EEPROM.read(232); staticip[0] = EEPROM.read(234); staticip[1] = EEPROM.read(235); @@ -149,5 +156,13 @@ void loadSettingsFromEEPROM() if (EEPROM.read(i) == 0) break; otapass += char(EEPROM.read(i)); } + bri_nl = EEPROM.read(288); ota_lock = EEPROM.read(289); + udpPort = ((EEPROM.read(290) << 0) & 0xFF) + ((EEPROM.read(291) << 8) & 0xFF00); + serverDescription = ""; + for (int i = 292; i < 324; ++i) + { + if (EEPROM.read(i) == 0) break; + serverDescription += char(EEPROM.read(i)); + } } diff --git a/wled00/wled02_xml.ino b/wled00/wled02_xml.ino index af5da99d3..e356e4c60 100644 --- a/wled00/wled02_xml.ino +++ b/wled00/wled02_xml.ino @@ -19,6 +19,12 @@ void XML_response() resp = resp + col[i]; resp = resp + ""; } + resp = resp + ""; + resp = resp + nightlightActive; + resp = resp + ""; + resp = resp + ""; + resp = resp + serverDescription; + resp = resp + ""; //enable toolbar here resp = resp + ""; server.send(200, "text/xml", resp); @@ -75,9 +81,9 @@ void XML_response_settings() resp = resp + ""; resp = resp + apchannel; resp = resp + ""; - resp = resp + ""; - resp = resp + led_amount; - resp = resp + ""; + resp = resp + ""; + resp = resp + serverDescription; + resp = resp + ""; resp = resp + ""; resp = resp + bool2int(buttonEnabled); resp = resp + ""; @@ -85,12 +91,18 @@ void XML_response_settings() resp = resp + ""; resp = resp + transitionDelay; resp = resp + ""; + resp = resp + ""; + resp = resp + bri_nl; + resp = resp + ""; resp = resp + ""; resp = resp + nightlightDelayMins; resp = resp + ""; resp = resp + ""; resp = resp + bool2int(nightlightFade); resp = resp + ""; + resp = resp + ""; + resp = resp + udpPort; + resp = resp + ""; resp = resp + ""; resp = resp + bool2int(receiveNotifications); resp = resp + ""; @@ -100,8 +112,8 @@ void XML_response_settings() resp = resp + ""; resp = resp + bool2int(notifyButton); resp = resp + ""; - resp = resp + bool2int(notifyForward); - resp = resp + "Legacy"; + resp = resp + bool2int(notifyNightlight); + resp = resp + ""; resp = resp + ""; resp = resp + bool2int(ota_lock); resp = resp +""; @@ -134,7 +146,7 @@ void XML_response_settings() { resp = resp + "Not active"; } - resp = resp + "LS"; + resp = resp + ""; resp = resp + "WLED 0.3pd OK"; resp = resp + ""; Serial.println(resp); diff --git a/wled00/wled03_set.ino b/wled00/wled03_set.ino index fddf1beaf..41ac57ce5 100644 --- a/wled00/wled03_set.ino +++ b/wled00/wled03_set.ino @@ -93,11 +93,7 @@ void handleSettingsSet() int i = server.arg("CSSN3").toInt(); if (i >= 0 && i <= 255) staticsubnet[3] = i; } - if (server.hasArg("LEDS")) - { - int i = server.arg("LEDS").toInt(); - if (i > 0) led_amount = i; - } + if (server.hasArg("DESC")) serverDescription = server.arg("DESC"); buttonEnabled = server.hasArg("BTNON"); fadeTransition = server.hasArg("TFADE"); if (server.hasArg("TDLAY")) @@ -108,12 +104,20 @@ void handleSettingsSet() transitionDelay_old = transitionDelay; } } + if (server.hasArg("TLBRI")) + { + bri_nl = server.arg("TLBRI").toInt(); + } if (server.hasArg("TLDUR")) { int i = server.arg("TLDUR").toInt(); if (i > 0) nightlightDelayMins = i; } nightlightFade = server.hasArg("TLFDE"); + if (server.hasArg("NUDPP")) + { + udpPort = server.arg("NUDPP").toInt(); + } receiveNotifications = server.hasArg("NRCVE"); if (server.hasArg("NRBRI")) { @@ -122,7 +126,7 @@ void handleSettingsSet() } notifyDirect = server.hasArg("NSDIR"); notifyButton = server.hasArg("NSBTN"); - notifyForward = server.hasArg("NSFWD"); + notifyNightlight = server.hasArg("NSFWD"); if (server.hasArg("OPASS")) { if (!ota_lock) @@ -173,6 +177,7 @@ boolean handleSet(String req) if (req.indexOf("NL=0") > 0) { nightlightActive = false; + bri = bri_t; } else { nightlightActive = true; nightlightStartTime = millis(); diff --git a/wled00/wled05_init.ino b/wled00/wled05_init.ino index 9f6cd373c..021d30fb6 100644 --- a/wled00/wled05_init.ino +++ b/wled00/wled05_init.ino @@ -59,7 +59,10 @@ void wledInit() } Serial.println("mDNS responder started"); - udpConnected = notifierUdp.begin(udpPort); + if (udpPort > 0) + { + udpConnected = notifierUdp.begin(udpPort); + } //SERVER INIT //settings page diff --git a/wled00/wled07_notify.ino b/wled00/wled07_notify.ino index 7b474c929..31c20eb4a 100644 --- a/wled00/wled07_notify.ino +++ b/wled00/wled07_notify.ino @@ -1,15 +1,16 @@ void notify(uint8_t callMode) { + if (!udpConnected) return; switch (callMode) { case 1: if (!notifyDirect) return; break; case 2: if (!notifyButton) return; break; - case 3: if (!notifyForward) return; break; + case 3: return; case 4: if (!notifyNightlight) return; break; default: return; } byte udpOut[16]; - udpOut[0] = 0; //reserved for future "port" feature + udpOut[0] = 0; //reserved udpOut[1] = callMode; udpOut[2] = bri; udpOut[3] = col[0]; @@ -32,21 +33,13 @@ void handleNotifications() if(packetSize && notifierUdp.remoteIP() != WiFi.localIP()) { notifierUdp.read(notifierBuffer, 16); - int bri_r = notifierBuffer[2]*(((float)bri_n)/100); - if (bri_r < 256) - { - bri_n = bri_r; - } else - { - bri_n = 255; - } - col[0] = notifierBuffer[3] + col[0] = notifierBuffer[3]; col[1] = notifierBuffer[4]; col[2] = notifierBuffer[5]; - if (notifierBuffer[6]) + nightlightActive = notifierBuffer[6]; + if (!notifierBuffer[6]) { - nightlightActive = true; - } else { + bri = notifierBuffer[2]; colorUpdated(3); } } diff --git a/wled00/wled08_led.ino b/wled00/wled08_led.ino index d64c9bdcd..d56d6f7d7 100644 --- a/wled00/wled08_led.ino +++ b/wled00/wled08_led.ino @@ -1,6 +1,10 @@ void setAllLeds() { - double d = bri_t; - double val = d /256; + double d = bri_t*bri_n; + double val = d/25600; + if (val > 1.0) + { + val = 1.0; + } int r = col_t[0]*val; int g = col_t[1]*val; int b = col_t[2]*val; @@ -25,7 +29,7 @@ void setLedsStandard() void colorUpdated(int callMode) { - //call for notifier -> 0: init 1: direct change 2: button 3: notification 4: nightlight + //call for notifier -> 0: init 1: direct change 2: button 3: notification 4: nightlight 5: other (no not.) if (col[0] == col_it[0] && col[1] == col_it[1] && col[2] == col_it[2] && bri == bri_it) { return; //no change @@ -97,8 +101,8 @@ void initNightlightFade() { return; } - bri = 0; - bri_it = 0; + bri = bri_nl; + bri_it = bri_nl; transitionDelay = (int)(nightlightDelayMins*60000); transitionStartTime = nightlightStartTime; transitionActive = true; @@ -111,6 +115,7 @@ void handleNightlight() { if (!nightlightActive_old) //init { + nightlightStartTime = millis(); notify(4); nightlightDelayMs = (int)(nightlightDelayMins*60000); nightlightActive_old = true; @@ -123,19 +128,19 @@ void handleNightlight() if (nper >= 1) { nightlightActive = false; + if (!nightlightFade) + { + bri = bri_nl; + colorUpdated(5); + } } - } else if (nightlightActive_old) //de-init + } else if (nightlightActive_old) //early de-init { - nightlightPassedTime = 0; nightlightActive_old = false; if (nightlightFade) { transitionDelay = transitionDelay_old; transitionActive = false; - } else - { - bri = 0; - colorUpdated(4); } } }