Began FX implementation
This commit is contained in:
parent
945839e3d3
commit
e710eace18
@ -5,7 +5,8 @@
|
||||
#include <ESP8266mDNS.h>
|
||||
#include <EEPROM.h>
|
||||
#include <Hash.h>
|
||||
#include <NeoPixelBus.h>
|
||||
//#include <NeoPixelBus.h>
|
||||
#include <WS2812FX.h>
|
||||
#include <FS.h>
|
||||
#include <WiFiUDP.h>
|
||||
|
||||
@ -39,12 +40,14 @@ boolean ota_lock = true;
|
||||
String otapass = "wledota";
|
||||
boolean only_ap = false;
|
||||
boolean buttonEnabled = true;
|
||||
boolean notifyDirect = true, notifyButton = true, notifyNightlight = false;
|
||||
boolean receiveNotifications = true;
|
||||
boolean notifyDirect = true, notifyButton = true, notifyNightlight = false, notifyMaster = true;
|
||||
boolean receiveNotifications = true, receiveNotificationsDefault = true;
|
||||
uint8_t bri_n = 100;
|
||||
uint8_t nightlightDelayMins = 60;
|
||||
boolean nightlightFade = true;
|
||||
uint16_t udpPort = 21324;
|
||||
uint8_t effectCurrent = 0;
|
||||
uint8_t effectSpeed = 75;
|
||||
|
||||
double transitionResolution = 0.011;
|
||||
|
||||
@ -67,7 +70,7 @@ boolean nightlightActive_old = false;
|
||||
int transitionDelay_old;
|
||||
int nightlightDelayMs;
|
||||
boolean udpConnected = false;
|
||||
byte notifierBuffer[16];
|
||||
byte udpIn[16];
|
||||
|
||||
NeoPixelBus<NeoGrbFeature, NeoEsp8266Uart800KbpsMethod> strip(led_amount, 1);
|
||||
|
||||
|
@ -60,7 +60,7 @@ void saveSettingsToEEPROM()
|
||||
EEPROM.write(247, col[1]);
|
||||
EEPROM.write(248, col[2]);
|
||||
EEPROM.write(249, bri);
|
||||
EEPROM.write(250, receiveNotifications);
|
||||
EEPROM.write(250, receiveNotificationsDefault);
|
||||
EEPROM.write(251, fadeTransition);
|
||||
EEPROM.write(253, (transitionDelay >> 0) & 0xFF);
|
||||
EEPROM.write(254, (transitionDelay >> 8) & 0xFF);
|
||||
@ -146,6 +146,7 @@ void loadSettingsFromEEPROM()
|
||||
col[2] = EEPROM.read(248);
|
||||
bri = EEPROM.read(249);
|
||||
receiveNotifications = EEPROM.read(250);
|
||||
receiveNotificationsDefault = receiveNotifications;
|
||||
fadeTransition = EEPROM.read(251);
|
||||
transitionDelay = ((EEPROM.read(253) << 0) & 0xFF) + ((EEPROM.read(254) << 8) & 0xFF00);
|
||||
transitionDelay_old = transitionDelay;
|
||||
|
@ -19,9 +19,21 @@ void XML_response()
|
||||
resp = resp + col[i];
|
||||
resp = resp + "</cl>";
|
||||
}
|
||||
resp = resp + "<ns>";
|
||||
resp = resp + notifyMaster;
|
||||
resp = resp + "</ns>";
|
||||
resp = resp + "<nr>";
|
||||
resp = resp + receiveNotifications;
|
||||
resp = resp + "</nr>";
|
||||
resp = resp + "<nl>";
|
||||
resp = resp + nightlightActive;
|
||||
resp = resp + "</nl>";
|
||||
resp = resp + "<fx>";
|
||||
resp = resp + effectCurrent;
|
||||
resp = resp + "</fx>";
|
||||
resp = resp + "<fx>";
|
||||
resp = resp + effectSpeed;
|
||||
resp = resp + "</fx>";
|
||||
resp = resp + "<desc>";
|
||||
resp = resp + serverDescription;
|
||||
resp = resp + "</desc>";
|
||||
@ -104,7 +116,7 @@ void XML_response_settings()
|
||||
resp = resp + udpPort;
|
||||
resp = resp + "</nudpp>";
|
||||
resp = resp + "<nrcve>";
|
||||
resp = resp + bool2int(receiveNotifications);
|
||||
resp = resp + bool2int(receiveNotificationsDefault);
|
||||
resp = resp + "</nrcve><nrbri>";
|
||||
resp = resp + bri_n;
|
||||
resp = resp + "</nrbri><nsdir>";
|
||||
|
@ -119,6 +119,7 @@ void handleSettingsSet()
|
||||
udpPort = server.arg("NUDPP").toInt();
|
||||
}
|
||||
receiveNotifications = server.hasArg("NRCVE");
|
||||
receiveNotificationsDefault = receiveNotifications;
|
||||
if (server.hasArg("NRBRI"))
|
||||
{
|
||||
int i = server.arg("NRBRI").toInt();
|
||||
@ -172,6 +173,30 @@ boolean handleSet(String req)
|
||||
if (pos > 0) {
|
||||
col[2] = req.substring(pos + 2).toInt();
|
||||
}
|
||||
pos = req.indexOf("FX=");
|
||||
if (pos > 0) {
|
||||
effectCurrent = req.substring(pos + 3).toInt();
|
||||
}
|
||||
pos = req.indexOf("XS=");
|
||||
if (pos > 0) {
|
||||
effectSpeed = req.substring(pos + 3).toInt();
|
||||
}
|
||||
if (req.indexOf("NS=") > 0)
|
||||
{
|
||||
notifyMaster = true;
|
||||
if (req.indexOf("NS=0") > 0)
|
||||
{
|
||||
notifyMaster = false;
|
||||
}
|
||||
}
|
||||
if (req.indexOf("NR=") > 0)
|
||||
{
|
||||
receiveNotifications = true;
|
||||
if (req.indexOf("NR=0") > 0)
|
||||
{
|
||||
receiveNotifications = false;
|
||||
}
|
||||
}
|
||||
if (req.indexOf("NL=") > 0)
|
||||
{
|
||||
if (req.indexOf("NL=0") > 0)
|
||||
|
@ -1,6 +1,6 @@
|
||||
void notify(uint8_t callMode)
|
||||
{
|
||||
if (!udpConnected) return;
|
||||
if (!udpConnected || !notifyMaster) return;
|
||||
switch (callMode)
|
||||
{
|
||||
case 1: if (!notifyDirect) return; break;
|
||||
@ -17,6 +17,9 @@ void notify(uint8_t callMode)
|
||||
udpOut[4] = col[1];
|
||||
udpOut[5] = col[2];
|
||||
udpOut[6] = nightlightActive;
|
||||
udpOut[7] = nightlightDelayMins;
|
||||
udpOut[8] = effectCurrent;
|
||||
udpOut[9] = effectSpeed;
|
||||
|
||||
IPAddress broadcastIp;
|
||||
broadcastIp = ~WiFi.subnetMask() | WiFi.gatewayIP();
|
||||
@ -32,14 +35,19 @@ void handleNotifications()
|
||||
int packetSize = notifierUdp.parsePacket();
|
||||
if(packetSize && notifierUdp.remoteIP() != WiFi.localIP())
|
||||
{
|
||||
notifierUdp.read(notifierBuffer, 16);
|
||||
col[0] = notifierBuffer[3];
|
||||
col[1] = notifierBuffer[4];
|
||||
col[2] = notifierBuffer[5];
|
||||
nightlightActive = notifierBuffer[6];
|
||||
if (!notifierBuffer[6])
|
||||
notifierUdp.read(udpIn, 16);
|
||||
col[0] = udpIn[3];
|
||||
col[1] = udpIn[4];
|
||||
col[2] = udpIn[5];
|
||||
if (true) //always receive effects?
|
||||
{
|
||||
bri = notifierBuffer[2];
|
||||
effectCurrent = udpIn[8];
|
||||
effectSpeed = udpIn[9];
|
||||
}
|
||||
nightlightActive = udpIn[6];
|
||||
if (!udpIn[6])
|
||||
{
|
||||
bri = udpIn[2];
|
||||
colorUpdated(3);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user