WARLS support added

This commit is contained in:
cschwinne 2017-01-26 23:45:55 +01:00
parent e9ae7c34c7
commit 02443ed697
3 changed files with 50 additions and 24 deletions

View File

@ -17,7 +17,7 @@
#include <Timezone.h> #include <Timezone.h>
//to toggle usb serial debug (un)comment following line //to toggle usb serial debug (un)comment following line
#define DEBUG //#define DEBUG
#ifdef DEBUG #ifdef DEBUG
#define DEBUG_PRINT(x) Serial.print (x) #define DEBUG_PRINT(x) Serial.print (x)
@ -35,7 +35,7 @@
* @author Christian Schwinne * @author Christian Schwinne
*/ */
//Hardware-settings (only changeble via code) //Hardware-settings (only changeble via code)
uint8_t led_amount = 84; #define LEDCOUNT 84
uint8_t buttonPin = 0; //needs pull-up uint8_t buttonPin = 0; //needs pull-up
//AP and OTA default passwords (change them!) //AP and OTA default passwords (change them!)
@ -114,7 +114,7 @@ int nightlightDelayMs;
uint8_t effectCurrent = 0; uint8_t effectCurrent = 0;
uint8_t effectSpeed = 75; uint8_t effectSpeed = 75;
boolean udpConnected = false; boolean udpConnected = false;
byte udpIn[16]; byte udpIn[LEDCOUNT*4+2];
IPAddress ntpIp; IPAddress ntpIp;
IPAddress ntpBackupIp(134,130,5,17); IPAddress ntpBackupIp(134,130,5,17);
byte ntpBuffer[48]; byte ntpBuffer[48];
@ -131,13 +131,15 @@ int overlayPauseDur[6];
int nixieClockI = -1; int nixieClockI = -1;
boolean nixiePause; boolean nixiePause;
long countdownTime = 1483225200L; long countdownTime = 1483225200L;
boolean arlsTimeout = false;
long arlsTimeoutTime;
ESP8266WebServer server(80); ESP8266WebServer server(80);
ESP8266HTTPUpdateServer httpUpdater; ESP8266HTTPUpdateServer httpUpdater;
WiFiUDP notifierUdp; WiFiUDP notifierUdp;
WiFiUDP ntpUdp; WiFiUDP ntpUdp;
WS2812FX strip = WS2812FX(led_amount, 2, NEO_GRB + NEO_KHZ800); WS2812FX strip = WS2812FX(LEDCOUNT, 2, NEO_GRB + NEO_KHZ800);
File fsUploadFile; File fsUploadFile;

View File

@ -43,7 +43,7 @@ void saveSettingsToEEPROM()
EEPROM.write(226, notifyDirect); EEPROM.write(226, notifyDirect);
EEPROM.write(227, apchannel); EEPROM.write(227, apchannel);
EEPROM.write(228, aphide); EEPROM.write(228, aphide);
EEPROM.write(229, led_amount); EEPROM.write(229, LEDCOUNT);
EEPROM.write(230, notifyButton); EEPROM.write(230, notifyButton);
EEPROM.write(231, notifyNightlight); EEPROM.write(231, notifyNightlight);
EEPROM.write(232, buttonEnabled); EEPROM.write(232, buttonEnabled);
@ -135,7 +135,7 @@ void loadSettingsFromEEPROM()
if (apchannel > 13 || apchannel < 1) apchannel = 1; if (apchannel > 13 || apchannel < 1) apchannel = 1;
aphide = EEPROM.read(228); aphide = EEPROM.read(228);
if (aphide > 1) aphide = 1; if (aphide > 1) aphide = 1;
led_amount = EEPROM.read(229); //LEDCOUNT = EEPROM.read(229);
notifyButton = EEPROM.read(230); notifyButton = EEPROM.read(230);
notifyNightlight = EEPROM.read(231); notifyNightlight = EEPROM.read(231);
buttonEnabled = EEPROM.read(232); buttonEnabled = EEPROM.read(232);

View File

@ -15,7 +15,7 @@ void notify(uint8_t callMode)
default: return; default: return;
} }
byte udpOut[16]; byte udpOut[16];
udpOut[0] = 0; //reserved udpOut[0] = 0; //0: wled notifier protocol 1: WARLS protocol
udpOut[1] = callMode; udpOut[1] = callMode;
udpOut[2] = bri; udpOut[2] = bri;
udpOut[3] = col[0]; udpOut[3] = col[0];
@ -40,27 +40,51 @@ void handleNotifications()
int packetSize = notifierUdp.parsePacket(); int packetSize = notifierUdp.parsePacket();
if(packetSize && notifierUdp.remoteIP() != WiFi.localIP()) if(packetSize && notifierUdp.remoteIP() != WiFi.localIP())
{ {
notifierUdp.read(udpIn, 16); notifierUdp.read(udpIn, packetSize);
col[0] = udpIn[3]; if (udpIn[0] == 0) //wled notifier
col[1] = udpIn[4];
col[2] = udpIn[5];
if (udpIn[8] != effectCurrent)
{ {
effectCurrent = udpIn[8]; col[0] = udpIn[3];
strip.setMode(effectCurrent); col[1] = udpIn[4];
} col[2] = udpIn[5];
if (udpIn[9] != effectSpeed) if (udpIn[8] != effectCurrent)
{
effectCurrent = udpIn[8];
strip.setMode(effectCurrent);
}
if (udpIn[9] != effectSpeed)
{
effectSpeed = udpIn[9];
strip.setSpeed(effectSpeed);
}
nightlightActive = udpIn[6];
if (!udpIn[6])
{
bri = udpIn[2];
colorUpdated(3);
}
} else if (udpIn[0] == 1) //warls
{ {
effectSpeed = udpIn[9]; if (packetSize > 1) {
strip.setSpeed(effectSpeed); if (udpIn[1] == 0)
} {
nightlightActive = udpIn[6]; arlsTimeout = false;
if (!udpIn[6]) } else {
{ arlsTimeout = true;
bri = udpIn[2]; arlsTimeoutTime = millis() + 1000*udpIn[1];
colorUpdated(3); }
for (int i = 2; i < packetSize -3; i += 4)
{
if (udpIn[i] < LEDCOUNT)
strip.setIndividual(udpIn[i], ((uint32_t)udpIn[i+1] << 16) | ((uint32_t)udpIn[i+2] << 8) | udpIn[i+3]);
}
}
} }
} }
if (arlsTimeout && millis() > arlsTimeoutTime)
{
strip.unlockAll();
arlsTimeout = false;
}
} }
} }