Refactored code to improve readability (merge dev PR)
Refactored code to improve readability Fixed non-2-char indentations
This commit is contained in:
commit
a3bef49124
@ -10,6 +10,7 @@
|
|||||||
//uncomment this if red and green are swapped
|
//uncomment this if red and green are swapped
|
||||||
//#define SWAPRG
|
//#define SWAPRG
|
||||||
|
|
||||||
|
|
||||||
//automatically uses the right driver method for each platform
|
//automatically uses the right driver method for each platform
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
#ifdef WORKAROUND_ESP32_BITBANG
|
#ifdef WORKAROUND_ESP32_BITBANG
|
||||||
@ -71,8 +72,8 @@ public:
|
|||||||
cleanup();
|
cleanup();
|
||||||
_type = type;
|
_type = type;
|
||||||
|
|
||||||
switch (_type) {
|
switch (_type)
|
||||||
|
{
|
||||||
case NeoPixelType_Grb:
|
case NeoPixelType_Grb:
|
||||||
_pGrb = new NeoPixelBrightnessBus<PIXELFEATURE3,PIXELMETHOD>(countPixels, LEDPIN);
|
_pGrb = new NeoPixelBrightnessBus<PIXELFEATURE3,PIXELMETHOD>(countPixels, LEDPIN);
|
||||||
_pGrb->Begin();
|
_pGrb->Begin();
|
||||||
@ -94,7 +95,8 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (_type) {
|
switch (_type)
|
||||||
|
{
|
||||||
case NeoPixelType_Grb: _pGrb->Show(); break;
|
case NeoPixelType_Grb: _pGrb->Show(); break;
|
||||||
case NeoPixelType_Grbw: _pGrbw->Show(); break;
|
case NeoPixelType_Grbw: _pGrbw->Show(); break;
|
||||||
}
|
}
|
||||||
@ -105,6 +107,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CanShow() const
|
bool CanShow() const
|
||||||
{
|
{
|
||||||
switch (_type) {
|
switch (_type) {
|
||||||
|
@ -67,9 +67,11 @@ void WS2812FX::service() {
|
|||||||
if(_running || _triggered) {
|
if(_running || _triggered) {
|
||||||
unsigned long now = millis(); // Be aware, millis() rolls over every 49 days
|
unsigned long now = millis(); // Be aware, millis() rolls over every 49 days
|
||||||
bool doShow = false;
|
bool doShow = false;
|
||||||
for(uint8_t i=0; i < _num_segments; i++) {
|
for(uint8_t i=0; i < _num_segments; i++)
|
||||||
|
{
|
||||||
_segment_index = i;
|
_segment_index = i;
|
||||||
if(now > SEGMENT_RUNTIME.next_time || _triggered) {
|
if(now > SEGMENT_RUNTIME.next_time || _triggered)
|
||||||
|
{
|
||||||
doShow = true;
|
doShow = true;
|
||||||
handle_palette();
|
handle_palette();
|
||||||
uint16_t delay = (this->*_mode[SEGMENT.mode])();
|
uint16_t delay = (this->*_mode[SEGMENT.mode])();
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
#define WS2812FX_h
|
#define WS2812FX_h
|
||||||
|
|
||||||
#include "NpbWrapper.h"
|
#include "NpbWrapper.h"
|
||||||
|
|
||||||
|
#define FASTLED_INTERNAL //remove annoying pragma messages
|
||||||
#include "FastLED.h"
|
#include "FastLED.h"
|
||||||
|
|
||||||
#define DEFAULT_BRIGHTNESS (uint8_t)50
|
#define DEFAULT_BRIGHTNESS (uint8_t)50
|
||||||
|
@ -63,7 +63,7 @@
|
|||||||
|
|
||||||
|
|
||||||
//version code in format yymmddb (b = daily build)
|
//version code in format yymmddb (b = daily build)
|
||||||
#define VERSION 1811071
|
#define VERSION 1811091
|
||||||
char versionString[] = "0.8.1";
|
char versionString[] = "0.8.1";
|
||||||
|
|
||||||
|
|
||||||
@ -357,6 +357,7 @@ bool auxActive = false, auxActiveBefore = false;
|
|||||||
|
|
||||||
//alexa udp
|
//alexa udp
|
||||||
WiFiUDP alexaUDP;
|
WiFiUDP alexaUDP;
|
||||||
|
bool alexaUdpConnected = false;
|
||||||
IPAddress ipMulti(239, 255, 255, 250);
|
IPAddress ipMulti(239, 255, 255, 250);
|
||||||
unsigned int portMulti = 1900;
|
unsigned int portMulti = 1900;
|
||||||
String escapedMac;
|
String escapedMac;
|
||||||
@ -503,7 +504,6 @@ void loop() {
|
|||||||
|
|
||||||
yield();
|
yield();
|
||||||
|
|
||||||
|
|
||||||
if (!realtimeActive) //block stuff if WARLS/Adalight is enabled
|
if (!realtimeActive) //block stuff if WARLS/Adalight is enabled
|
||||||
{
|
{
|
||||||
if (dnsActive) dnsServer.processNextRequest();
|
if (dnsActive) dnsServer.processNextRequest();
|
||||||
|
@ -2,17 +2,12 @@
|
|||||||
* Sending XML status files to client
|
* Sending XML status files to client
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//build XML response to HTTP /win API request
|
||||||
void XML_response(bool isHTTP)
|
void XML_response(bool isHTTP)
|
||||||
{
|
{
|
||||||
olen = 0;
|
olen = 0;
|
||||||
oappend("<?xml version = \"1.0\" ?><vs><ac>");
|
oappend("<?xml version = \"1.0\" ?><vs><ac>");
|
||||||
if (nightlightActive && nightlightFade)
|
oappendi((nightlightActive && nightlightFade) ? briT : bri);
|
||||||
{
|
|
||||||
oappendi(briT);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
oappendi(bri);
|
|
||||||
}
|
|
||||||
oappend("</ac>");
|
oappend("</ac>");
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
@ -21,6 +16,7 @@ void XML_response(bool isHTTP)
|
|||||||
oappendi(col[i]);
|
oappendi(col[i]);
|
||||||
oappend("</cl>");
|
oappend("</cl>");
|
||||||
}
|
}
|
||||||
|
|
||||||
oappend("<ns>");
|
oappend("<ns>");
|
||||||
oappendi(notifyDirect);
|
oappendi(notifyDirect);
|
||||||
oappend("</ns><nr>");
|
oappend("</ns><nr>");
|
||||||
@ -55,7 +51,8 @@ void XML_response(bool isHTTP)
|
|||||||
if (isHTTP) server.send(200, "text/xml", obuf);
|
if (isHTTP) server.send(200, "text/xml", obuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sappend(char stype, char* key, int val) //append a setting to string buffer
|
//append a numeric setting to string buffer
|
||||||
|
void sappend(char stype, char* key, int val)
|
||||||
{
|
{
|
||||||
char ds[] = "d.Sf.";
|
char ds[] = "d.Sf.";
|
||||||
|
|
||||||
@ -85,7 +82,8 @@ void sappend(char stype, char* key, int val) //append a setting to string buffer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sappends(char stype, char* key, char* val) //append a string setting
|
//append a string setting to buffer
|
||||||
|
void sappends(char stype, char* key, char* val)
|
||||||
{
|
{
|
||||||
switch(stype)
|
switch(stype)
|
||||||
{
|
{
|
||||||
@ -106,7 +104,8 @@ void sappends(char stype, char* key, char* val) //append a string setting
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void getSettingsJS(byte subPage) //get values for settings form in javascript
|
//get values for settings form in javascript
|
||||||
|
void getSettingsJS(byte subPage)
|
||||||
{
|
{
|
||||||
//0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec
|
//0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec
|
||||||
DEBUG_PRINT("settings resp");
|
DEBUG_PRINT("settings resp");
|
||||||
|
@ -61,7 +61,9 @@ void handleSettingsSet(byte subPage)
|
|||||||
#endif
|
#endif
|
||||||
useRGBW = server.hasArg("EW");
|
useRGBW = server.hasArg("EW");
|
||||||
autoRGBtoRGBW = server.hasArg("AW");
|
autoRGBtoRGBW = server.hasArg("AW");
|
||||||
if (server.hasArg("IS")) //ignore settings and save current brightness, colors and fx as default
|
|
||||||
|
//ignore settings and save current brightness, colors and fx as default
|
||||||
|
if (server.hasArg("IS"))
|
||||||
{
|
{
|
||||||
colS[0] = col[0];
|
colS[0] = col[0];
|
||||||
colS[1] = col[1];
|
colS[1] = col[1];
|
||||||
@ -170,7 +172,9 @@ void handleSettingsSet(byte subPage)
|
|||||||
strcpy(alexaInvocationName, server.arg("AI").c_str());
|
strcpy(alexaInvocationName, server.arg("AI").c_str());
|
||||||
notifyAlexa = server.hasArg("SA");
|
notifyAlexa = server.hasArg("SA");
|
||||||
|
|
||||||
if (server.hasArg("BK") && !server.arg("BK").equals("Hidden")) {strcpy(blynkApiKey,server.arg("BK").c_str()); initBlynk(blynkApiKey);}
|
if (server.hasArg("BK") && !server.arg("BK").equals("Hidden")) {
|
||||||
|
strcpy(blynkApiKey,server.arg("BK").c_str()); initBlynk(blynkApiKey);
|
||||||
|
}
|
||||||
|
|
||||||
strcpy(mqttServer, server.arg("MS").c_str());
|
strcpy(mqttServer, server.arg("MS").c_str());
|
||||||
strcpy(mqttDeviceTopic, server.arg("MD").c_str());
|
strcpy(mqttDeviceTopic, server.arg("MD").c_str());
|
||||||
@ -209,7 +213,9 @@ void handleSettingsSet(byte subPage)
|
|||||||
useAMPM = !server.hasArg("CF");
|
useAMPM = !server.hasArg("CF");
|
||||||
currentTimezone = server.arg("TZ").toInt();
|
currentTimezone = server.arg("TZ").toInt();
|
||||||
utcOffsetSecs = server.arg("UO").toInt();
|
utcOffsetSecs = server.arg("UO").toInt();
|
||||||
if (ntpEnabled && WiFi.status() == WL_CONNECTED && !ntpConnected) ntpConnected = ntpUdp.begin(ntpLocalPort); //start if not already connected
|
|
||||||
|
//start ntp if not already connected
|
||||||
|
if (ntpEnabled && WiFi.status() == WL_CONNECTED && !ntpConnected) ntpConnected = ntpUdp.begin(ntpLocalPort);
|
||||||
|
|
||||||
if (server.hasArg("OL")){
|
if (server.hasArg("OL")){
|
||||||
overlayDefault = server.arg("OL").toInt();
|
overlayDefault = server.arg("OL").toInt();
|
||||||
@ -690,6 +696,7 @@ bool handleSet(String req)
|
|||||||
presetApplyFx = true;
|
presetApplyFx = true;
|
||||||
if (req.indexOf("PX=0") > 0) presetApplyFx = false;
|
if (req.indexOf("PX=0") > 0) presetApplyFx = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = req.indexOf("PS="); //saves current in preset
|
pos = req.indexOf("PS="); //saves current in preset
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
savePreset(req.substring(pos + 3).toInt());
|
savePreset(req.substring(pos + 3).toInt());
|
||||||
@ -724,6 +731,7 @@ bool handleSet(String req)
|
|||||||
if (overlayCurrent == 3) strip.setCronixieBacklight(cronixieBacklight);
|
if (overlayCurrent == 3) strip.setCronixieBacklight(cronixieBacklight);
|
||||||
overlayRefreshedTime = 0;
|
overlayRefreshedTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = req.indexOf("U0="); //user var 0
|
pos = req.indexOf("U0="); //user var 0
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
userVar0 = req.substring(pos + 3).toInt();
|
userVar0 = req.substring(pos + 3).toInt();
|
||||||
|
@ -3,18 +3,20 @@
|
|||||||
*/
|
*/
|
||||||
void handleSerial()
|
void handleSerial()
|
||||||
{
|
{
|
||||||
if (Serial.available() > 0) //support for Adalight protocol to high-speed control LEDs over serial (gamma correction done by PC)
|
if (Serial.available() > 0) //support for Adalight protocol to high-speed control LEDs over serial
|
||||||
{
|
|
||||||
if (Serial.find("Ada"))
|
|
||||||
{
|
{
|
||||||
|
if (!Serial.find("Ada")) return;
|
||||||
|
|
||||||
if (!realtimeActive && bri == 0) strip.setBrightness(briLast);
|
if (!realtimeActive && bri == 0) strip.setBrightness(briLast);
|
||||||
arlsLock(realtimeTimeoutMs);
|
arlsLock(realtimeTimeoutMs);
|
||||||
|
|
||||||
delay(1);
|
delay(1);
|
||||||
byte hi = Serial.read();
|
byte hi = Serial.read();
|
||||||
byte ledc = Serial.read();
|
byte ledc = Serial.read();
|
||||||
byte chk = Serial.read();
|
byte chk = Serial.read();
|
||||||
if(chk != (hi ^ ledc ^ 0x55)) return;
|
if(chk != (hi ^ ledc ^ 0x55)) return;
|
||||||
if (ledCount < ledc) ledc = ledCount;
|
if (ledCount < ledc) ledc = ledCount;
|
||||||
|
|
||||||
byte sc[3]; int t =-1; int to = 0;
|
byte sc[3]; int t =-1; int to = 0;
|
||||||
for (int i=0; i < ledc; i++)
|
for (int i=0; i < ledc; i++)
|
||||||
{
|
{
|
||||||
@ -34,7 +36,6 @@ void handleSerial()
|
|||||||
strip.show();
|
strip.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef USEFS
|
#ifdef USEFS
|
||||||
|
|
||||||
|
@ -139,7 +139,9 @@ void initStrip()
|
|||||||
|
|
||||||
if (bootPreset>0) applyPreset(bootPreset, turnOnAtBoot, true, true);
|
if (bootPreset>0) applyPreset(bootPreset, turnOnAtBoot, true, true);
|
||||||
colorUpdated(0);
|
colorUpdated(0);
|
||||||
if(digitalRead(buttonPin) == LOW) buttonEnabled = false; //disable button if it is "pressed" unintentionally
|
|
||||||
|
//disable button if it is "pressed" unintentionally
|
||||||
|
if(digitalRead(buttonPin) == LOW) buttonEnabled = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +175,8 @@ void initCon()
|
|||||||
WiFi.softAPdisconnect(true);
|
WiFi.softAPdisconnect(true);
|
||||||
}
|
}
|
||||||
int fail_count = 0;
|
int fail_count = 0;
|
||||||
if (strlen(clientSSID) <1 || strcmp(clientSSID,"Your_Network") == 0) fail_count = apWaitTimeSecs*2; //instantly go to ap mode
|
if (strlen(clientSSID) <1 || strcmp(clientSSID,"Your_Network") == 0)
|
||||||
|
fail_count = apWaitTimeSecs*2; //instantly go to ap mode
|
||||||
#ifndef ARDUINO_ARCH_ESP32
|
#ifndef ARDUINO_ARCH_ESP32
|
||||||
WiFi.hostname(serverDescription);
|
WiFi.hostname(serverDescription);
|
||||||
#endif
|
#endif
|
||||||
@ -211,9 +214,9 @@ void initCon()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//fill string buffer with build info
|
||||||
void getBuildInfo()
|
void getBuildInfo()
|
||||||
{
|
{
|
||||||
//fill string buffer with build info
|
|
||||||
olen = 0;
|
olen = 0;
|
||||||
oappend("hard-coded build info:\r\n\n");
|
oappend("hard-coded build info:\r\n\n");
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
@ -118,7 +118,8 @@ void handleNotifications()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//receive UDP notifications
|
//receive UDP notifications
|
||||||
if(udpConnected && (receiveNotifications || receiveDirect)){
|
if (!udpConnected || !(receiveNotifications || receiveDirect)) return;
|
||||||
|
|
||||||
uint16_t packetSize = notifierUdp.parsePacket();
|
uint16_t packetSize = notifierUdp.parsePacket();
|
||||||
|
|
||||||
//hyperion / raw RGB
|
//hyperion / raw RGB
|
||||||
@ -142,6 +143,7 @@ void handleNotifications()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//notifier and UDP realtime
|
||||||
if (packetSize > UDP_IN_MAXSIZE) return;
|
if (packetSize > UDP_IN_MAXSIZE) return;
|
||||||
if(packetSize && notifierUdp.remoteIP() != WiFi.localIP()) //don't process broadcasts we send ourselves
|
if(packetSize && notifierUdp.remoteIP() != WiFi.localIP()) //don't process broadcasts we send ourselves
|
||||||
{
|
{
|
||||||
@ -249,7 +251,6 @@ void handleNotifications()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void setRealtimePixel(uint16_t i, byte r, byte g, byte b, byte w)
|
void setRealtimePixel(uint16_t i, byte r, byte g, byte b, byte w)
|
||||||
{
|
{
|
||||||
|
@ -16,25 +16,23 @@ void alexaInit()
|
|||||||
{
|
{
|
||||||
if (alexaEnabled && WiFi.status() == WL_CONNECTED)
|
if (alexaEnabled && WiFi.status() == WL_CONNECTED)
|
||||||
{
|
{
|
||||||
udpConnected = connectUDP();
|
alexaUdpConnected = connectUDP();
|
||||||
|
|
||||||
if (udpConnected) alexaInitPages();
|
if (alexaUdpConnected) alexaInitPages();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleAlexa()
|
void handleAlexa()
|
||||||
{
|
{
|
||||||
if (alexaEnabled && WiFi.status() == WL_CONNECTED)
|
if (!alexaEnabled || WiFi.status() != WL_CONNECTED || !alexaUdpConnected) return;
|
||||||
{
|
|
||||||
if(udpConnected){
|
// if there's data available, read a packet
|
||||||
// if there’s data available, read a packet
|
|
||||||
int packetSize = alexaUDP.parsePacket();
|
int packetSize = alexaUDP.parsePacket();
|
||||||
if(packetSize>0) {
|
if(packetSize < 1) return;
|
||||||
|
|
||||||
IPAddress remote = alexaUDP.remoteIP();
|
IPAddress remote = alexaUDP.remoteIP();
|
||||||
int len = alexaUDP.read(obuf, 254);
|
int len = alexaUDP.read(obuf, 254);
|
||||||
if (len > 0) {
|
if (len > 0) obuf[len] = 0;
|
||||||
obuf[len] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(strstr(obuf,"M-SEARCH") > 0) {
|
if(strstr(obuf,"M-SEARCH") > 0) {
|
||||||
if(strstr(obuf,"upnp:rootdevice") > 0 || strstr(obuf,"device:basic:1") > 0) {
|
if(strstr(obuf,"upnp:rootdevice") > 0 || strstr(obuf,"device:basic:1") > 0) {
|
||||||
@ -43,9 +41,6 @@ void handleAlexa()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void alexaOn()
|
void alexaOn()
|
||||||
{
|
{
|
||||||
@ -212,7 +207,6 @@ void alexaInitPages() {
|
|||||||
statrespone[0] = '1';
|
statrespone[0] = '1';
|
||||||
}
|
}
|
||||||
server.send(200, "text/plain", statrespone);
|
server.send(200, "text/plain", statrespone);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,6 +282,7 @@ bool connectUDP(){
|
|||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
void alexaInit(){}
|
void alexaInit(){}
|
||||||
void handleAlexa(){}
|
void handleAlexa(){}
|
||||||
|
@ -25,29 +25,21 @@ void colorHStoRGB(uint16_t hue, byte sat, byte* rgb) //hue, sat to rgb
|
|||||||
void colorCTtoRGB(uint16_t mired, byte* rgb) //white spectrum to rgb
|
void colorCTtoRGB(uint16_t mired, byte* rgb) //white spectrum to rgb
|
||||||
{
|
{
|
||||||
//this is only an approximation using WS2812B with gamma correction enabled
|
//this is only an approximation using WS2812B with gamma correction enabled
|
||||||
if (mired > 475)
|
if (mired > 475) {
|
||||||
{
|
|
||||||
rgb[0]=255;rgb[1]=199;rgb[2]=92;//500
|
rgb[0]=255;rgb[1]=199;rgb[2]=92;//500
|
||||||
} else if (mired > 425)
|
} else if (mired > 425) {
|
||||||
{
|
|
||||||
rgb[0]=255;rgb[1]=213;rgb[2]=118;//450
|
rgb[0]=255;rgb[1]=213;rgb[2]=118;//450
|
||||||
} else if (mired > 375)
|
} else if (mired > 375) {
|
||||||
{
|
|
||||||
rgb[0]=255;rgb[1]=216;rgb[2]=118;//400
|
rgb[0]=255;rgb[1]=216;rgb[2]=118;//400
|
||||||
} else if (mired > 325)
|
} else if (mired > 325) {
|
||||||
{
|
|
||||||
rgb[0]=255;rgb[1]=234;rgb[2]=140;//350
|
rgb[0]=255;rgb[1]=234;rgb[2]=140;//350
|
||||||
} else if (mired > 275)
|
} else if (mired > 275) {
|
||||||
{
|
|
||||||
rgb[0]=255;rgb[1]=243;rgb[2]=160;//300
|
rgb[0]=255;rgb[1]=243;rgb[2]=160;//300
|
||||||
} else if (mired > 225)
|
} else if (mired > 225) {
|
||||||
{
|
|
||||||
rgb[0]=250;rgb[1]=255;rgb[2]=188;//250
|
rgb[0]=250;rgb[1]=255;rgb[2]=188;//250
|
||||||
} else if (mired > 175)
|
} else if (mired > 175) {
|
||||||
{
|
|
||||||
rgb[0]=247;rgb[1]=255;rgb[2]=215;//200
|
rgb[0]=247;rgb[1]=255;rgb[2]=215;//200
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
rgb[0]=237;rgb[1]=255;rgb[2]=239;//150
|
rgb[0]=237;rgb[1]=255;rgb[2]=239;//150
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ void parseMQTTBriPayload(char* payload)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void callbackMQTT(char* topic, byte* payload, unsigned int length) {
|
void callbackMQTT(char* topic, byte* payload, unsigned int length) {
|
||||||
|
|
||||||
DEBUG_PRINT("MQTT callb rec: ");
|
DEBUG_PRINT("MQTT callb rec: ");
|
||||||
@ -37,6 +38,7 @@ void callbackMQTT(char* topic, byte* payload, unsigned int length) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void publishMQTT()
|
void publishMQTT()
|
||||||
{
|
{
|
||||||
if (mqtt == NULL) return;
|
if (mqtt == NULL) return;
|
||||||
@ -64,6 +66,7 @@ void publishMQTT()
|
|||||||
mqtt->publish(subuf, obuf);*/
|
mqtt->publish(subuf, obuf);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool reconnectMQTT()
|
bool reconnectMQTT()
|
||||||
{
|
{
|
||||||
if (mqtt->connect(escapedMac.c_str()))
|
if (mqtt->connect(escapedMac.c_str()))
|
||||||
@ -99,6 +102,7 @@ bool reconnectMQTT()
|
|||||||
return mqtt->connected();
|
return mqtt->connected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool initMQTT()
|
bool initMQTT()
|
||||||
{
|
{
|
||||||
if (WiFi.status() != WL_CONNECTED) return false;
|
if (WiFi.status() != WL_CONNECTED) return false;
|
||||||
@ -116,6 +120,7 @@ bool initMQTT()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void handleMQTT()
|
void handleMQTT()
|
||||||
{
|
{
|
||||||
if (WiFi.status() != WL_CONNECTED || !mqttInit) return;
|
if (WiFi.status() != WL_CONNECTED || !mqttInit) return;
|
||||||
|
@ -259,8 +259,12 @@ void serveIndex()
|
|||||||
if (uiConfiguration == 0) serveMobile = checkClientIsMobile(server.header("User-Agent"));
|
if (uiConfiguration == 0) serveMobile = checkClientIsMobile(server.header("User-Agent"));
|
||||||
else if (uiConfiguration == 2) serveMobile = true;
|
else if (uiConfiguration == 2) serveMobile = true;
|
||||||
|
|
||||||
if (!realtimeActive || enableRealtimeUI) //do not serve while receiving realtime
|
if (realtimeActive && !enableRealtimeUI) //do not serve while receiving realtime
|
||||||
{
|
{
|
||||||
|
serveRealtimeError(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (serveMobile)
|
if (serveMobile)
|
||||||
{
|
{
|
||||||
server.setContentLength(strlen_P(PAGE_indexM));
|
server.setContentLength(strlen_P(PAGE_indexM));
|
||||||
@ -276,9 +280,6 @@ void serveIndex()
|
|||||||
server.sendContent_P(PAGE_index2);
|
server.sendContent_P(PAGE_index2);
|
||||||
server.sendContent_P(PAGE_index3);
|
server.sendContent_P(PAGE_index3);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
serveRealtimeError(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void serveMessage(int code, String headl, String subl="", int optionType)
|
void serveMessage(int code, String headl, String subl="", int optionType)
|
||||||
@ -314,15 +315,18 @@ void serveMessage(int code, String headl, String subl="", int optionType)
|
|||||||
|
|
||||||
void serveSettings(byte subPage)
|
void serveSettings(byte subPage)
|
||||||
{
|
{
|
||||||
//0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec 255: welcomepage
|
if (realtimeActive && !enableRealtimeUI) //do not serve while receiving realtime
|
||||||
if (!realtimeActive || enableRealtimeUI) //do not serve while receiving realtime
|
|
||||||
{
|
{
|
||||||
|
serveRealtimeError(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef WLED_DISABLE_MOBILE_UI //disable welcome page if not enough storage
|
#ifdef WLED_DISABLE_MOBILE_UI //disable welcome page if not enough storage
|
||||||
if (subPage == 255) {serveIndex(); return;}
|
if (subPage == 255) {serveIndex(); return;}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int pl0, pl1;
|
int pl0, pl1;
|
||||||
switch (subPage)
|
switch (subPage) //0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec 255: welcomepage
|
||||||
{
|
{
|
||||||
case 1: pl0 = strlen_P(PAGE_settings_wifi0); pl1 = strlen_P(PAGE_settings_wifi1); break;
|
case 1: pl0 = strlen_P(PAGE_settings_wifi0); pl1 = strlen_P(PAGE_settings_wifi1); break;
|
||||||
case 2: pl0 = strlen_P(PAGE_settings_leds0); pl1 = strlen_P(PAGE_settings_leds1); break;
|
case 2: pl0 = strlen_P(PAGE_settings_leds0); pl1 = strlen_P(PAGE_settings_leds1); break;
|
||||||
@ -365,7 +369,4 @@ void serveSettings(byte subPage)
|
|||||||
case 255: server.sendContent_P(PAGE_welcome1); break;
|
case 255: server.sendContent_P(PAGE_welcome1); break;
|
||||||
default: server.sendContent_P(PAGE_settings1);
|
default: server.sendContent_P(PAGE_settings1);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
serveRealtimeError(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user