Added defines for more granular feature disable control

This commit is contained in:
cschwinne 2018-11-01 15:36:13 +01:00
parent 48c165b0b4
commit 5e6b1e8175
12 changed files with 105 additions and 53 deletions

File diff suppressed because one or more lines are too long

View File

@ -24,7 +24,7 @@ button{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),sans-seri
//new user welcome page //new user welcome page
#ifndef WLED_FLASH_512K_MODE #ifndef WLED_DISABLE_MOBILE_UI
const char PAGE_welcome0[] PROGMEM = R"=====( const char PAGE_welcome0[] PROGMEM = R"=====(
<!DOCTYPE html> <!DOCTYPE html>
<html><head> <html><head>

View File

@ -12,16 +12,17 @@
//ESP8266-01 (black) has 1MB flash and can thus fit the whole program. Use 1M(64K SPIFFS). //ESP8266-01 (black) has 1MB flash and can thus fit the whole program. Use 1M(64K SPIFFS).
//If you want the OTA update function though, you need to make sure the sketch is smaller than 479kB. //If you want the OTA update function though, you need to make sure the sketch is smaller than 479kB.
//Uncomment some of the following lines to disable features to compile for ESP8266-01 (max flash size 434kB):
//Uncomment the following lines to disable some features to compile for ESP8266-01 (max flash size 438kB): //You are required to disable these two features:
//#define WLED_DISABLE_MOBILE_UI
//#define WLED_DISABLE_OTA
//You need to choose 1-2 of these features to disable:
//#define WLED_DISABLE_ALEXA //#define WLED_DISABLE_ALEXA
//#define WLED_DISABLE_BLYNK //#define WLED_DISABLE_BLYNK
//#define WLED_DISABLE_CRONIXIE //#define WLED_DISABLE_CRONIXIE
//#define WLED_DISABLE_HUESYNC //#define WLED_DISABLE_HUESYNC
//#define WLED_DISABLE_MOBILE_UI
//#define WLED_DISABLE_OTA
//to toggle usb serial debug (un)comment following line(s) //to toggle usb serial debug (un)comment following line(s)
//#define DEBUG //#define DEBUG
@ -41,14 +42,18 @@
#endif #endif
#include <EEPROM.h> #include <EEPROM.h>
#include <ArduinoOTA.h>
#include <WiFiUDP.h> #include <WiFiUDP.h>
#include <DNSServer.h> #include <DNSServer.h>
#ifndef WLED_DISABLE_OTA
#include <ArduinoOTA.h>
#include "src/dependencies/webserver/ESP8266HTTPUpdateServer.h" #include "src/dependencies/webserver/ESP8266HTTPUpdateServer.h"
#endif
#include "src/dependencies/time/Time.h" #include "src/dependencies/time/Time.h"
#include "src/dependencies/time/TimeLib.h" #include "src/dependencies/time/TimeLib.h"
#include "src/dependencies/timezone/Timezone.h" #include "src/dependencies/timezone/Timezone.h"
#ifndef WLED_DISABLE_BLYNK
#include "src/dependencies/blynk/BlynkSimpleEsp.h" #include "src/dependencies/blynk/BlynkSimpleEsp.h"
#endif
#include "src/dependencies/e131/E131.h" #include "src/dependencies/e131/E131.h"
#include "src/dependencies/pubsubclient/PubSubClient.h" #include "src/dependencies/pubsubclient/PubSubClient.h"
#include "htmls00.h" #include "htmls00.h"
@ -58,7 +63,7 @@
//version code in format yymmddb (b = daily build) //version code in format yymmddb (b = daily build)
#define VERSION 1810311 #define VERSION 1811011
char versionString[] = "0.8.1"; char versionString[] = "0.8.1";
@ -384,7 +389,9 @@ HTTPClient* hueClient = NULL;
WiFiClient* mqttTCPClient = NULL; WiFiClient* mqttTCPClient = NULL;
PubSubClient* mqtt = NULL; PubSubClient* mqtt = NULL;
#ifndef WLED_DISABLE_OTA
ESP8266HTTPUpdateServer httpUpdater; ESP8266HTTPUpdateServer httpUpdater;
#endif
//udp interface objects //udp interface objects
WiFiUDP notifierUdp, rgbUdp; WiFiUDP notifierUdp, rgbUdp;
@ -500,7 +507,9 @@ void loop() {
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();
#ifndef WLED_DISABLE_OTA
if (aOtaEnabled) ArduinoOTA.handle(); if (aOtaEnabled) ArduinoOTA.handle();
#endif
handleNightlight(); handleNightlight();
if (!onlyAP) { if (!onlyAP) {
handleHue(); handleHue();

View File

@ -446,7 +446,7 @@ void loadSettingsFromEEPROM(bool first)
enableRealtimeUI = EEPROM.read(2201); enableRealtimeUI = EEPROM.read(2201);
uiConfiguration = EEPROM.read(2202); uiConfiguration = EEPROM.read(2202);
#ifdef WLED_FLASH_512K_MODE #ifdef WLED_DISABLE_MOBILE_UI
uiConfiguration = 1; uiConfiguration = 1;
//force default UI since mobile is unavailable //force default UI since mobile is unavailable
#endif #endif

View File

@ -86,6 +86,7 @@ void wledInit()
//init ArduinoOTA //init ArduinoOTA
if (!onlyAP) { if (!onlyAP) {
#ifndef WLED_DISABLE_OTA
if (aOtaEnabled) if (aOtaEnabled)
{ {
ArduinoOTA.onStart([]() { ArduinoOTA.onStart([]() {
@ -97,6 +98,7 @@ void wledInit()
if (strlen(cmDNS) > 0) ArduinoOTA.setHostname(cmDNS); if (strlen(cmDNS) > 0) ArduinoOTA.setHostname(cmDNS);
ArduinoOTA.begin(); ArduinoOTA.begin();
} }
#endif
if (!initLedsLast) strip.service(); if (!initLedsLast) strip.service();
// Set up mDNS responder: // Set up mDNS responder:
@ -225,6 +227,25 @@ void getBuildInfo()
oappendi(VERSION); oappendi(VERSION);
oappend("\r\neepver: "); oappend("\r\neepver: ");
oappendi(EEPVER); oappendi(EEPVER);
oappend("\r\nopt: ");
#ifndef WLED_DISABLE_ALEXA
oappend("alexa ");
#endif
#ifndef WLED_DISABLE_BLYNK
oappend("blynk ");
#endif
#ifndef WLED_DISABLE_CRONIXIE
oappend("cronixie ");
#endif
#ifndef WLED_DISABLE_HUESYNC
oappend("huesync ");
#endif
#ifndef WLED_DISABLE_MOBILE_UI
oappend("mobile-ui ");
#endif
#ifndef WLED_DISABLE_OTA
oappend("ota");
#endif
#ifdef USEFS #ifdef USEFS
oappend("\r\nspiffs: true\r\n"); oappend("\r\nspiffs: true\r\n");
#else #else

View File

@ -184,7 +184,7 @@ void _overlayAnalogClock()
void _overlayNixieClock() void _overlayNixieClock()
{ {
#ifdef WLED_FLASH_512K_MODE #ifdef WLED_DISABLE_CRONIXIE
if (countdownMode) checkCountdown(); if (countdownMode) checkCountdown();
#else #else

View File

@ -5,7 +5,13 @@
* https://github.com/kakopappa/arduino-esp8266-alexa-wemo-switch * https://github.com/kakopappa/arduino-esp8266-alexa-wemo-switch
* https://github.com/probonopd/ESP8266HueEmulator * https://github.com/probonopd/ESP8266HueEmulator
*/ */
void prepareIds() {
escapedMac = WiFi.macAddress();
escapedMac.replace(":", "");
escapedMac.toLowerCase();
}
#ifndef WLED_DISABLE_ALEXA
void alexaInit() void alexaInit()
{ {
if (alexaEnabled && WiFi.status() == WL_CONNECTED) if (alexaEnabled && WiFi.status() == WL_CONNECTED)
@ -87,12 +93,6 @@ void alexaDim(byte briL)
handleSet(ct); handleSet(ct);
} }
void prepareIds() {
escapedMac = WiFi.macAddress();
escapedMac.replace(":", "");
escapedMac.toLowerCase();
}
void respondToSearch() { void respondToSearch() {
DEBUG_PRINTLN(""); DEBUG_PRINTLN("");
DEBUG_PRINT("Send resp to "); DEBUG_PRINT("Send resp to ");
@ -288,3 +288,9 @@ bool connectUDP(){
return state; return state;
} }
#else
void alexaInit(){}
void handleAlexa(){}
void alexaInitPages(){}
bool handleAlexaApiCall(String req, String body){return false;}
#endif

View File

@ -19,7 +19,7 @@ byte getSameCodeLength(char code, int index, char const cronixieDisplay[])
void setCronixie() void setCronixie()
{ {
#ifndef WLED_FLASH_512K_MODE #ifndef WLED_DISABLE_CRONIXIE
/* /*
* digit purpose index * digit purpose index
* 0-9 | 0-9 (incl. random) * 0-9 | 0-9 (incl. random)
@ -146,7 +146,7 @@ void setCronixie()
void _overlayCronixie() void _overlayCronixie()
{ {
if (countdownMode) checkCountdown(); if (countdownMode) checkCountdown();
#ifndef WLED_FLASH_512K_MODE #ifndef WLED_DISABLE_CRONIXIE
byte h = hour(local); byte h = hour(local);
byte h0 = h; byte h0 = h;
@ -214,4 +214,3 @@ void _overlayCronixie()
//strip.trigger(); //this has a drawback, no effects slower than RefreshMs. advantage: Quick update, not dependant on effect time //strip.trigger(); //this has a drawback, no effects slower than RefreshMs. advantage: Quick update, not dependant on effect time
#endif #endif
} }

View File

@ -1,6 +1,27 @@
/* /*
* Color conversion methods * Color conversion methods
*/ */
void colorHStoRGB(uint16_t hue, byte sat, byte* rgb) //hue, sat to rgb
{
float h = ((float)hue)/65535.0;
float s = ((float)sat)/255.0;
byte i = floor(h*6);
float f = h * 6-i;
float p = 255 * (1-s);
float q = 255 * (1-f*s);
float t = 255 * (1-(1-f)*s);
switch (i%6) {
case 0: rgb[0]=255,rgb[1]=t,rgb[2]=p;break;
case 1: rgb[0]=q,rgb[1]=255,rgb[2]=p;break;
case 2: rgb[0]=p,rgb[1]=255,rgb[2]=t;break;
case 3: rgb[0]=p,rgb[1]=q,rgb[2]=255;break;
case 4: rgb[0]=t,rgb[1]=p,rgb[2]=255;break;
case 5: rgb[0]=255,rgb[1]=p,rgb[2]=q;
}
}
#ifndef WLED_DISABLE_HUESYNC
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
@ -31,25 +52,6 @@ void colorCTtoRGB(uint16_t mired, byte* rgb) //white spectrum to rgb
} }
} }
void colorHStoRGB(uint16_t hue, byte sat, byte* rgb) //hue, sat to rgb
{
float h = ((float)hue)/65535.0;
float s = ((float)sat)/255.0;
byte i = floor(h*6);
float f = h * 6-i;
float p = 255 * (1-s);
float q = 255 * (1-f*s);
float t = 255 * (1-(1-f)*s);
switch (i%6) {
case 0: rgb[0]=255,rgb[1]=t,rgb[2]=p;break;
case 1: rgb[0]=q,rgb[1]=255,rgb[2]=p;break;
case 2: rgb[0]=p,rgb[1]=255,rgb[2]=t;break;
case 3: rgb[0]=p,rgb[1]=q,rgb[2]=255;break;
case 4: rgb[0]=t,rgb[1]=p,rgb[2]=255;break;
case 5: rgb[0]=255,rgb[1]=p,rgb[2]=q;
}
}
void colorXYtoRGB(float x, float y, byte* rgb) //coordinates to rgb (https://www.developers.meethue.com/documentation/color-conversions-rgb-xy) void colorXYtoRGB(float x, float y, byte* rgb) //coordinates to rgb (https://www.developers.meethue.com/documentation/color-conversions-rgb-xy)
{ {
float z = 1.0f - x - y; float z = 1.0f - x - y;
@ -106,6 +108,16 @@ void colorXYtoRGB(float x, float y, byte* rgb) //coordinates to rgb (https://www
rgb[2] = 255.0*b; rgb[2] = 255.0*b;
} }
void colorRGBtoXY(byte* rgb, float* xy) //rgb to coordinates (https://www.developers.meethue.com/documentation/color-conversions-rgb-xy)
{
float X = rgb[0] * 0.664511f + rgb[1] * 0.154324f + rgb[2] * 0.162028f;
float Y = rgb[0] * 0.283881f + rgb[1] * 0.668433f + rgb[2] * 0.047685f;
float Z = rgb[0] * 0.000088f + rgb[1] * 0.072310f + rgb[2] * 0.986039f;
xy[0] = X / (X + Y + Z);
xy[1] = Y / (X + Y + Z);
}
#endif
void colorFromDecOrHexString(byte* rgb, byte* wht, char* in) void colorFromDecOrHexString(byte* rgb, byte* wht, char* in)
{ {
if (in[0] == 0) return; if (in[0] == 0) return;
@ -126,15 +138,6 @@ void colorFromDecOrHexString(byte* rgb, byte* wht, char* in)
rgb[2] = c & 0xFF; rgb[2] = c & 0xFF;
} }
void colorRGBtoXY(byte* rgb, float* xy) //rgb to coordinates (https://www.developers.meethue.com/documentation/color-conversions-rgb-xy)
{
float X = rgb[0] * 0.664511f + rgb[1] * 0.154324f + rgb[2] * 0.162028f;
float Y = rgb[0] * 0.283881f + rgb[1] * 0.668433f + rgb[2] * 0.047685f;
float Z = rgb[0] * 0.000088f + rgb[1] * 0.072310f + rgb[2] * 0.986039f;
xy[0] = X / (X + Y + Z);
xy[1] = Y / (X + Y + Z);
}
float minf (float v, float w) float minf (float v, float w)
{ {
if (w > v) return v; if (w > v) return v;
@ -155,4 +158,3 @@ void colorRGBtoRGBW(byte* rgb, byte* wht) //rgb to rgbw (http://codewelt.com/rgb
float sat = 255.0f * ((high - low) / high); float sat = 255.0f * ((high - low) / high);
*wht = (byte)((255.0f - sat) / 255.0f * (rgb[0] + rgb[1] + rgb[2]) / 3); *wht = (byte)((255.0f - sat) / 255.0f * (rgb[0] + rgb[1] + rgb[2]) / 3);
} }

View File

@ -1,7 +1,7 @@
/* /*
* Sync to Philips hue lights * Sync to Philips hue lights
*/ */
#ifndef WLED_DISABLE_HUESYNC
void handleHue() void handleHue()
{ {
if (huePollingEnabled && WiFi.status() == WL_CONNECTED && hueClient != NULL) if (huePollingEnabled && WiFi.status() == WL_CONNECTED && hueClient != NULL)
@ -206,4 +206,7 @@ String getJsonValue(String* req, String key)
} }
return ""; return "";
} }
#else
void handleHue(){}
bool setupHue(){return false;}
#endif

View File

@ -7,19 +7,24 @@ byte blSat = 255;
void initBlynk(const char* auth) void initBlynk(const char* auth)
{ {
#ifndef WLED_DISABLE_BLYNK
if (WiFi.status() != WL_CONNECTED) return; if (WiFi.status() != WL_CONNECTED) return;
blynkEnabled = (auth[0] != 0); blynkEnabled = (auth[0] != 0);
if (blynkEnabled) Blynk.config(auth); if (blynkEnabled) Blynk.config(auth);
#endif
} }
void handleBlynk() void handleBlynk()
{ {
#ifndef WLED_DISABLE_BLYNK
if (WiFi.status() == WL_CONNECTED && blynkEnabled) if (WiFi.status() == WL_CONNECTED && blynkEnabled)
Blynk.run(); Blynk.run();
#endif
} }
void updateBlynk() void updateBlynk()
{ {
#ifndef WLED_DISABLE_BLYNK
if (onlyAP) return; if (onlyAP) return;
Blynk.virtualWrite(V0, bri); Blynk.virtualWrite(V0, bri);
//we need a RGB -> HSB convert here //we need a RGB -> HSB convert here
@ -29,8 +34,10 @@ void updateBlynk()
Blynk.virtualWrite(V6, effectIntensity); Blynk.virtualWrite(V6, effectIntensity);
Blynk.virtualWrite(V7, nightlightActive); Blynk.virtualWrite(V7, nightlightActive);
Blynk.virtualWrite(V8, notifyDirect); Blynk.virtualWrite(V8, notifyDirect);
#endif
} }
#ifndef WLED_DISABLE_BLYNK
BLYNK_WRITE(V0) BLYNK_WRITE(V0)
{ {
bri = param.asInt();//bri bri = param.asInt();//bri
@ -86,4 +93,4 @@ BLYNK_WRITE(V8)
{ {
notifyDirect = (param.asInt()>0); //send notifications notifyDirect = (param.asInt()>0); //send notifications
} }
#endif

View File

@ -132,7 +132,13 @@ void initServer()
server.on("/list", HTTP_GET, handleFileList); server.on("/list", HTTP_GET, handleFileList);
#endif #endif
//init ota page //init ota page
#ifndef WLED_DISABLE_OTA
httpUpdater.setup(&server); httpUpdater.setup(&server);
#else
server.on("/update", HTTP_GET, [](){
serveMessage(500, "Not implemented", "OTA updates are not supported in this build.", 254);
});
#endif
} else } else
{ {
server.on("/edit", HTTP_GET, [](){ server.on("/edit", HTTP_GET, [](){
@ -311,7 +317,7 @@ void serveSettings(byte subPage)
//0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec 255: welcomepage //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
{ {
#ifdef WLED_FLASH_512K_MODE //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
@ -363,4 +369,3 @@ void serveSettings(byte subPage)
serveRealtimeError(true); serveRealtimeError(true);
} }
} }