nightlight dev in progress
BUILD UNTESTED notifier bugs 2A no udp
This commit is contained in:
parent
9a06c748c0
commit
25e9967dae
2
TODO.txt
2
TODO.txt
@ -14,6 +14,8 @@ add preferred colors to settings -> quickly t. UI, button select,
|
|||||||
use iframe for settings, seperate tabs for wifi and application confg
|
use iframe for settings, seperate tabs for wifi and application confg
|
||||||
use iframe for all adv. features?
|
use iframe for all adv. features?
|
||||||
/dumpeeprom and /pusheeprom
|
/dumpeeprom and /pusheeprom
|
||||||
|
aux trigger pin
|
||||||
|
descriptive text
|
||||||
|
|
||||||
BUGS
|
BUGS
|
||||||
static ip disables mdns
|
static ip disables mdns
|
||||||
|
@ -37,7 +37,7 @@ uint8_t led_amount = 16;
|
|||||||
uint8_t buttonPin = 3; //needs pull-up
|
uint8_t buttonPin = 3; //needs pull-up
|
||||||
boolean buttonEnabled = true;
|
boolean buttonEnabled = true;
|
||||||
String notifier_ips[]{"10.10.1.191","10.10.1.129"};
|
String notifier_ips[]{"10.10.1.191","10.10.1.129"};
|
||||||
boolean notifyDirect = true, notifyButton = true, notifyForward = true;
|
boolean notifyDirect = true, notifyButton = true, notifyForward = true, notifyNightlight = false;
|
||||||
boolean receiveNotifications = true;
|
boolean receiveNotifications = true;
|
||||||
uint8_t bri_n = 100;
|
uint8_t bri_n = 100;
|
||||||
uint8_t nightlightDelayMins = 60;
|
uint8_t nightlightDelayMins = 60;
|
||||||
@ -62,6 +62,9 @@ boolean buttonPressedBefore = false;
|
|||||||
int notifier_ips_count = 1;
|
int notifier_ips_count = 1;
|
||||||
String notifier_ips_raw = "";
|
String notifier_ips_raw = "";
|
||||||
boolean nightlightActive = false;
|
boolean nightlightActive = false;
|
||||||
|
boolean nightlightFade_old = false;
|
||||||
|
boolean nightlightActive_old = false;
|
||||||
|
int transitionDelay_old;
|
||||||
|
|
||||||
|
|
||||||
NeoPixelBus<NeoGrbFeature, NeoEsp8266Uart800KbpsMethod> strip(led_amount, 1);
|
NeoPixelBus<NeoGrbFeature, NeoEsp8266Uart800KbpsMethod> strip(led_amount, 1);
|
||||||
@ -97,10 +100,34 @@ void handleNightlight()
|
|||||||
{
|
{
|
||||||
if (nightlightActive)
|
if (nightlightActive)
|
||||||
{
|
{
|
||||||
float nper = (millis() - nightlightStartTime)/(float)(((int)nightlightDelayMins)*60000);
|
if (!nightlightActive_old) //init
|
||||||
|
{
|
||||||
|
nightlightActive_old = true;
|
||||||
|
if (nightlightFade)
|
||||||
|
{
|
||||||
|
transitionDelay_old = transitionDelay;
|
||||||
|
transitionDelay = (int)(nightlightDelayMins*60000);
|
||||||
|
transitionStartTime = nightlightStartTime;
|
||||||
|
transitionActive = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
float nper = (millis() - nightlightStartTime)/(float)transitionDelay;
|
||||||
if (nper >= 1)
|
if (nper >= 1)
|
||||||
{
|
{
|
||||||
|
nightlightActive = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (nightlightActive_old) //de-init
|
||||||
|
{
|
||||||
|
nightlightActive_old = false;
|
||||||
|
if (nightlightFade)
|
||||||
|
{
|
||||||
|
transitionDelay = transitionDelay_old;
|
||||||
|
transitionActive = false;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
bri = 0;
|
||||||
|
colorUpdated(4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,7 @@ void handleSettingsSet()
|
|||||||
if (i > 0) nightlightDelayMins = i;
|
if (i > 0) nightlightDelayMins = i;
|
||||||
}
|
}
|
||||||
nightlightFade = server.hasArg("TLFDE");
|
nightlightFade = server.hasArg("TLFDE");
|
||||||
|
nightlightFade_old = nightlightFade;
|
||||||
receiveNotifications = server.hasArg("NRCVE");
|
receiveNotifications = server.hasArg("NRCVE");
|
||||||
if (server.hasArg("NRBRI"))
|
if (server.hasArg("NRBRI"))
|
||||||
{
|
{
|
||||||
|
@ -76,6 +76,31 @@ void handleFileDelete(){
|
|||||||
path = String();
|
path = String();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handleFileList() {
|
||||||
|
if(!server.hasArg("dir")) {server.send(500, "text/plain", "BAD ARGS"); return;}
|
||||||
|
|
||||||
|
String path = server.arg("dir");
|
||||||
|
Serial.println("handleFileList: " + path);
|
||||||
|
Dir dir = SPIFFS.openDir(path);
|
||||||
|
path = String();
|
||||||
|
|
||||||
|
String output = "[";
|
||||||
|
while(dir.next()){
|
||||||
|
File entry = dir.openFile("r");
|
||||||
|
if (output != "[") output += ',';
|
||||||
|
bool isDir = false;
|
||||||
|
output += "{\"type\":\"";
|
||||||
|
output += (isDir)?"dir":"file";
|
||||||
|
output += "\",\"name\":\"";
|
||||||
|
output += String(entry.name()).substring(1);
|
||||||
|
output += "\"}";
|
||||||
|
entry.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
output += "]";
|
||||||
|
server.send(200, "text/json", output);
|
||||||
|
}
|
||||||
|
|
||||||
void handleFileCreate(){
|
void handleFileCreate(){
|
||||||
if(server.args() == 0)
|
if(server.args() == 0)
|
||||||
return server.send(500, "text/plain", "BAD ARGS");
|
return server.send(500, "text/plain", "BAD ARGS");
|
||||||
|
@ -22,7 +22,7 @@ void wledInit()
|
|||||||
Serial.println("Init EEPROM");
|
Serial.println("Init EEPROM");
|
||||||
EEPROM.begin(1024);
|
EEPROM.begin(1024);
|
||||||
loadSettingsFromEEPROM();
|
loadSettingsFromEEPROM();
|
||||||
|
nightlightFade_old = nightlightFade;
|
||||||
Serial.print("CC: SSID: ");
|
Serial.print("CC: SSID: ");
|
||||||
Serial.print(clientssid);
|
Serial.print(clientssid);
|
||||||
|
|
||||||
@ -94,6 +94,7 @@ void wledInit()
|
|||||||
server.on("/edit", HTTP_POST, [](){ server.send(200, "text/plain", ""); }, handleFileUpload);
|
server.on("/edit", HTTP_POST, [](){ server.send(200, "text/plain", ""); }, handleFileUpload);
|
||||||
server.on("/down", HTTP_GET, down);
|
server.on("/down", HTTP_GET, down);
|
||||||
server.on("/cleareeprom", HTTP_GET, clearEEPROM);
|
server.on("/cleareeprom", HTTP_GET, clearEEPROM);
|
||||||
|
server.on("/list", HTTP_GET, handleFileList);
|
||||||
//init ota page
|
//init ota page
|
||||||
httpUpdater.setup(&server);
|
httpUpdater.setup(&server);
|
||||||
} else
|
} else
|
||||||
@ -110,6 +111,9 @@ void wledInit()
|
|||||||
server.on("/update", HTTP_GET, [](){
|
server.on("/update", HTTP_GET, [](){
|
||||||
server.send(500, "text/plain", "OTA lock active");
|
server.send(500, "text/plain", "OTA lock active");
|
||||||
});
|
});
|
||||||
|
server.on("/list", HTTP_GET, [](){
|
||||||
|
server.send(500, "text/plain", "OTA lock active");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
//called when the url is not defined here, ajax-in; get-settings
|
//called when the url is not defined here, ajax-in; get-settings
|
||||||
server.onNotFound([](){
|
server.onNotFound([](){
|
||||||
|
@ -5,6 +5,7 @@ void notify(int callMode)
|
|||||||
case 1: if (!notifyDirect) return; break;
|
case 1: if (!notifyDirect) return; break;
|
||||||
case 2: if (!notifyButton) return; break;
|
case 2: if (!notifyButton) return; break;
|
||||||
case 3: if (!notifyForward) return; break;
|
case 3: if (!notifyForward) return; break;
|
||||||
|
case 4: if (!notifyNightlight) return; break;
|
||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
String snd = "/ajax_inputs&N=1&A=";
|
String snd = "/ajax_inputs&N=1&A=";
|
||||||
|
@ -25,7 +25,7 @@ void setLedsStandard()
|
|||||||
|
|
||||||
void colorUpdated(int callMode)
|
void colorUpdated(int callMode)
|
||||||
{
|
{
|
||||||
//call for notifier -> 0: init 1: direct change 2: button 3: notification
|
//call for notifier -> 0: init 1: direct change 2: button 3: notification 4: nightlight
|
||||||
if (col[0] == col_it[0] && col[1] == col_it[1] && col[2] == col_it[2] && bri == bri_it)
|
if (col[0] == col_it[0] && col[1] == col_it[1] && col[2] == col_it[2] && bri == bri_it)
|
||||||
{
|
{
|
||||||
return; //no change
|
return; //no change
|
||||||
@ -47,6 +47,11 @@ void colorUpdated(int callMode)
|
|||||||
}
|
}
|
||||||
transitionActive = true;
|
transitionActive = true;
|
||||||
transitionStartTime = millis();
|
transitionStartTime = millis();
|
||||||
|
if (nightlightActive)
|
||||||
|
{
|
||||||
|
nightlightFade_old = nightlightFade;
|
||||||
|
nightlightFade = false;
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
setLedsStandard();
|
setLedsStandard();
|
||||||
@ -62,6 +67,7 @@ void handleTransitions()
|
|||||||
{
|
{
|
||||||
transitionActive = false;
|
transitionActive = false;
|
||||||
tper_last = 0;
|
tper_last = 0;
|
||||||
|
nightlightFade = nightlightFade_old;
|
||||||
setLedsStandard();
|
setLedsStandard();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user