diff --git a/.gitignore b/.gitignore index 2116e693..ea49cb51 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ !.vscode/extensions.json /wled00/Release /wled00/extLibs +/platformio_override.ini diff --git a/platformio.ini b/platformio.ini index dd5f7a73..581bc995 100644 --- a/platformio.ini +++ b/platformio.ini @@ -6,6 +6,7 @@ src_dir = ./wled00 data_dir = ./wled00/data ;lib_extra_dirs = ./wled00/src lib_dir = ./wled00/src +extra_configs = platformio_override.ini ; Please uncomment one of the 5 lines below to select your board default_envs = nodemcuv2 ; default_envs = esp01 @@ -16,6 +17,10 @@ default_envs = nodemcuv2 ; default_envs = esp8285_4CH_MagicHome ; default_envs = esp8285_4CH_H801 ; default_envs = esp8285_5CH_H801 +# Release binaries follow +; default_envs = nodemcuv2, esp01, esp01_1m, esp32dev, + + [common] framework = arduino @@ -82,36 +87,34 @@ arduino_core_stage = https://github.com/platformio/platform-espressif8266.git#fe platform = ${common:esp8266.arduino_core_2_6_3} build_flags = -D ESP8266 - -D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH + -D PIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH -Wl,-Teagle.flash.4m1m.ld ;;;; Required for core > v2.5.0 or staging version 4MB Flash 3MB SPIFFs lib_ignore = AsyncTCP [common:esp8266_1M] -platform = espressif8266@1.8.0 +platform = ${common:esp8266.arduino_core_2_6_3} build_flags = - -D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH - -Wl,-Teagle.flash.1m0.ld ;;;; Compile with no SPIFFS to leave space for OTA - ; -D WLED_DISABLE_MOBILE_UI + -D PIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH + -Wl,-Teagle.flash.1m.ld ;;;; Compile with no SPIFFS to leave space for OTA ; -D WLED_DISABLE_OTA ; -D WLED_DISABLE_ALEXA -D WLED_DISABLE_BLYNK -D WLED_DISABLE_CRONIXIE ; -D WLED_DISABLE_HUESYNC - ; -D WLED_DISABLE_INFRARED + -D WLED_DISABLE_INFRARED lib_ignore = ${common:esp8266.lib_ignore} [common:esp8266_512k] -platform = espressif8266@1.8.0 +platform = ${common:esp8266.arduino_core_2_6_3} build_flags = - -D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH - -Wl,-Teagle.flash.512k0.ld ;;;; Compile with no SPIFFS - ; -D WLED_DISABLE_MOBILE_UI + -D PIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH + -Wl,-Teagle.flash.512k.ld ;;;; Compile with no SPIFFS -D WLED_DISABLE_OTA - ; -D WLED_DISABLE_ALEXA + -D WLED_DISABLE_ALEXA -D WLED_DISABLE_BLYNK -D WLED_DISABLE_CRONIXIE -D WLED_DISABLE_HUESYNC - ; -D WLED_DISABLE_INFRARED + -D WLED_DISABLE_INFRARED lib_ignore = ${common:esp8266.lib_ignore} [common:esp32] @@ -177,7 +180,6 @@ framework = ${common.framework} build_flags = ${common.build_flags} ${common:esp8266_512k.build_flags} - -D WLED_DISABLE_INFRARED lib_deps = ${common.lib_deps_external} lib_compat_mode = strict diff --git a/platformio_override.ini.example b/platformio_override.ini.example new file mode 100644 index 00000000..03a77056 --- /dev/null +++ b/platformio_override.ini.example @@ -0,0 +1,18 @@ +; Example PlatformIO Project Configuration Override +; ------------------------------------------------------------------------------ +; Copy to platformio_override.ini to activate overrides +; ------------------------------------------------------------------------------ +; Please visit documentation: https://docs.platformio.org/page/projectconf.html + +[env:esp8266_1m_custom] +platform = ${common:esp8266.arduino_core_2_6_3} +build_flags = + -D PIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH + -Wl,-Teagle.flash.1m.ld ;;;; Compile with no SPIFFS to leave space for OTA + ; -D WLED_DISABLE_OTA + -D WLED_DISABLE_ALEXA + -D WLED_DISABLE_BLYNK + -D WLED_DISABLE_CRONIXIE + -D WLED_DISABLE_HUESYNC + -D WLED_DISABLE_INFRARED +lib_ignore = ${common:esp8266.lib_ignore} \ No newline at end of file diff --git a/readme.md b/readme.md index 044344ea..1cbe9b80 100644 --- a/readme.md +++ b/readme.md @@ -11,7 +11,7 @@ A fast and feature-rich implementation of an ESP8266/ESP32 webserver to control NeoPixel (WS2812B, WS2811, SK6812, APA102) LEDs! ### Features: -- WS2812FX library integrated for almost 100 special effects +- WS2812FX library integrated for over 100 special effects - FastLED noise effects and palettes - Modern UI with color, effect and segment controls - Segments to set different effects and colors to parts of the LEDs diff --git a/usermods/Wemos_D1_mini+Wemos32_mini_shield/wled06_usermod.ino b/usermods/Wemos_D1_mini+Wemos32_mini_shield/wled06_usermod.ino index 9e6e0b79..c0f6ce85 100644 --- a/usermods/Wemos_D1_mini+Wemos32_mini_shield/wled06_usermod.ino +++ b/usermods/Wemos_D1_mini+Wemos32_mini_shield/wled06_usermod.ino @@ -7,6 +7,7 @@ OneWire oneWire(23); #else //ESP8266 boards uint8_t SCL_PIN = 5; uint8_t SDA_PIN = 4; +// uint8_t RST_PIN = 16; // Uncoment for Heltec WiFi-Kit-8 OneWire oneWire(13); #endif //The SCL and SDA pins are defined here. diff --git a/wled00/FX.h b/wled00/FX.h index eec42990..a518317f 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -56,6 +56,9 @@ #define MAX_SEGMENT_DATA 8192 #endif +#define LED_SKIP_AMOUNT 1 +#define MIN_SHOW_DELAY 15 + #define NUM_COLORS 3 /* number of colors per segment */ #define SEGMENT _segments[_segment_index] #define SEGCOLOR(x) gamma32(_segments[_segment_index].colors[x]) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 0707392d..b495de64 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -27,9 +27,6 @@ #include "FX.h" #include "palettes.h" -#define LED_SKIP_AMOUNT 1 -#define MIN_SHOW_DELAY 15 - void WS2812FX::init(bool supportWhite, uint16_t countPixels, bool skipFirst) { if (supportWhite == _useRgbw && countPixels == _length) return; @@ -380,7 +377,7 @@ void WS2812FX::setBrightness(uint8_t b) { if (_brightness == b) return; _brightness = (gammaCorrectBri) ? gamma8(b) : b; _segment_index = 0; - if (SEGENV.next_time > millis() + 22) show();//apply brightness change immediately if no refresh soon + if (SEGENV.next_time > millis() + 22 && millis() - _lastShow > MIN_SHOW_DELAY) show();//apply brightness change immediately if no refresh soon } uint8_t WS2812FX::getMode(void) { diff --git a/wled00/NpbWrapper.h b/wled00/NpbWrapper.h index a9fbd7c2..9709d8aa 100644 --- a/wled00/NpbWrapper.h +++ b/wled00/NpbWrapper.h @@ -13,12 +13,25 @@ //#define WLED_USE_H801 //H801 controller. Please uncomment #define WLED_USE_ANALOG_LEDS as well //#define WLED_USE_5CH_LEDS //5 Channel H801 for cold and warm white +#ifndef BTNPIN #define BTNPIN 0 //button pin. Needs to have pullup (gpio0 recommended) -#define IR_PIN 4 //infrared pin (-1 to disable) MagicHome: 4, H801 Wifi: 0 -#define RLYPIN 12 //pin for relay, will be set HIGH if LEDs are on (-1 to disable). Also usable for standby leds, triggers,... -#define AUXPIN -1 //debug auxiliary output pin (-1 to disable) +#endif +#ifndef IR_PIN +#define IR_PIN 4 //infrared pin (-1 to disable) MagicHome: 4, H801 Wifi: 0 +#endif + +#ifndef RLYPIN +#define RLYPIN 12 //pin for relay, will be set HIGH if LEDs are on (-1 to disable). Also usable for standby leds, triggers,... +#endif + +#ifndef AUXPIN +#define AUXPIN -1 //debug auxiliary output pin (-1 to disable) +#endif + +#ifndef RLYMDE #define RLYMDE 1 //mode for relay, 0: LOW if LEDs are on 1: HIGH if LEDs are on +#endif //END CONFIGURATION diff --git a/wled00/const.h b/wled00/const.h index 4d287572..242536c9 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -1,6 +1,11 @@ #ifndef wled_const_h #define wled_const_h +//Defaults +#define DEFAULT_CLIENT_SSID "Your_Network" +#define DEFAULT_AP_PASS "wled1234" +#define DEFAULT_OTA_PASS "wledota" + //Access point behavior #define AP_BEHAVIOR_BOOT_NO_CONN 0 //Open AP when no connection after boot #define AP_BEHAVIOR_NO_CONN 1 //Open when no connection (either after boot or if connection is lost) @@ -8,13 +13,13 @@ #define AP_BEHAVIOR_BUTTON_ONLY 3 //Only when button pressed for 6 sec //Notifier callMode -#define NOTIFIER_CALL_MODE_INIT 0 // no updates on init, can be used to disable updates +#define NOTIFIER_CALL_MODE_INIT 0 //no updates on init, can be used to disable updates #define NOTIFIER_CALL_MODE_DIRECT_CHANGE 1 #define NOTIFIER_CALL_MODE_BUTTON 2 #define NOTIFIER_CALL_MODE_NOTIFICATION 3 #define NOTIFIER_CALL_MODE_NIGHTLIGHT 4 #define NOTIFIER_CALL_MODE_NO_NOTIFY 5 -#define NOTIFIER_CALL_MODE_FX_CHANGED 6 +#define NOTIFIER_CALL_MODE_FX_CHANGED 6 //no longer used #define NOTIFIER_CALL_MODE_HUE 7 #define NOTIFIER_CALL_MODE_PRESET_CYCLE 8 #define NOTIFIER_CALL_MODE_BLYNK 9 @@ -36,11 +41,24 @@ #define REALTIME_MODE_ADALIGHT 5 //E1.31 DMX modes -#define DMX_MODE_DISABLED 0 //not used -#define DMX_MODE_SINGLE_RGB 1 //all LEDs same RGB color (3 channels) -#define DMX_MODE_SINGLE_DRGB 2 //all LEDs same RGB color and master dimmer (4 channels) -#define DMX_MODE_EFFECT 3 //trigger standalone effects of WLED (11 channels) -#define DMX_MODE_MULTIPLE_RGB 4 //every LED is addressed with its own RGB (ledCount * 3 channels) -#define DMX_MODE_MULTIPLE_DRGB 5 //every LED is addressed with its own RGB and share a master dimmer (ledCount * 3 + 1 channels) +#define DMX_MODE_DISABLED 0 //not used +#define DMX_MODE_SINGLE_RGB 1 //all LEDs same RGB color (3 channels) +#define DMX_MODE_SINGLE_DRGB 2 //all LEDs same RGB color and master dimmer (4 channels) +#define DMX_MODE_EFFECT 3 //trigger standalone effects of WLED (11 channels) +#define DMX_MODE_MULTIPLE_RGB 4 //every LED is addressed with its own RGB (ledCount * 3 channels) +#define DMX_MODE_MULTIPLE_DRGB 5 //every LED is addressed with its own RGB and share a master dimmer (ledCount * 3 + 1 channels) + +//Light capability byte (unused) +#define TYPE_WS2812_RGB 0 +#define TYPE_SK6812_RGBW 1 +#define TYPE_WS2812_WWA 2 //amber + warm + cold white +#define TYPE_APA102 3 +#define TYPE_LPD8806 4 +#define TYPE_WS2801 5 +#define TYPE_ANALOG_1CH 6 //single channel PWM. Uses value of brightest RGBW channel +#define TYPE_ANALOG_2CH 7 //analog WW + CW +#define TYPE_ANALOG_3CH 8 //analog RGB +#define TYPE_ANALOG_4CH 9 //analog RGBW +#define TYPE_ANALOG_5CH 10 //analog RGB + WW + CW #endif diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 8ec833d0..c147dca3 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -21,7 +21,7 @@ //#define WLED_DISABLE_BLYNK //saves 6kb //#define WLED_DISABLE_CRONIXIE //saves 3kb //#define WLED_DISABLE_HUESYNC //saves 4kb -//#define WLED_DISABLE_INFRARED //there is no pin left for this on ESP8266-01, saves 25kb (!) +//#define WLED_DISABLE_INFRARED //there is no pin left for this on ESP8266-01, saves 12kb #define WLED_ENABLE_MQTT //saves 12kb #define WLED_ENABLE_ADALIGHT //saves 500b only //#define WLED_ENABLE_DMX //uses 3.5kb @@ -36,22 +36,22 @@ //library inclusions #include #ifdef WLED_ENABLE_DMX -#include -DMXESPSerial dmx; + #include + DMXESPSerial dmx; #endif #ifdef ESP8266 - #include - #include - #include - extern "C" { - #include - } -#else -#include -#include "esp_wifi.h" -#include -#include -#include "SPIFFS.h" + #include + #include + #include + extern "C" { + #include + } +#else //ESP32 + #include + #include "esp_wifi.h" + #include + #include + #include "SPIFFS.h" #endif #include @@ -59,20 +59,20 @@ DMXESPSerial dmx; #include #include #ifndef WLED_DISABLE_OTA -#include + #include #endif #include #include "src/dependencies/time/TimeLib.h" #include "src/dependencies/timezone/Timezone.h" #ifndef WLED_DISABLE_ALEXA -#define ESPALEXA_ASYNC -#define ESPALEXA_NO_SUBPAGE -#define ESPALEXA_MAXDEVICES 1 -//#define ESPALEXA_DEBUG -#include "src/dependencies/espalexa/Espalexa.h" + #define ESPALEXA_ASYNC + #define ESPALEXA_NO_SUBPAGE + #define ESPALEXA_MAXDEVICES 1 + // #define ESPALEXA_DEBUG + #include "src/dependencies/espalexa/Espalexa.h" #endif #ifndef WLED_DISABLE_BLYNK -#include "src/dependencies/blynk/BlynkSimpleEsp.h" + #include "src/dependencies/blynk/BlynkSimpleEsp.h" #endif #include "src/dependencies/e131/ESPAsyncE131.h" #include "src/dependencies/async-mqtt-client/AsyncMqttClient.h" @@ -85,17 +85,25 @@ DMXESPSerial dmx; #include "ir_codes.h" #include "const.h" +#ifndef CLIENT_SSID +#define CLIENT_SSID DEFAULT_CLIENT_SSID +#endif + +#ifndef CLIENT_PASS +#define CLIENT_PASS "" +#endif + #if IR_PIN < 0 -#ifndef WLED_DISABLE_INFRARED -#define WLED_DISABLE_INFRARED -#endif + #ifndef WLED_DISABLE_INFRARED + #define WLED_DISABLE_INFRARED + #endif #endif #ifndef WLED_DISABLE_INFRARED -#include -#include -#include + #include + #include + #include #endif // remove flicker because PWM signal of RGB channels can become out of phase @@ -111,13 +119,14 @@ DMXESPSerial dmx; #endif //version code in format yymmddb (b = daily build) -#define VERSION 2002192 +#define VERSION 2002243 + char versionString[] = "0.9.1"; //AP and OTA default passwords (for maximum change them!) -char apPass[65] = "wled1234"; -char otaPass[33] = "wledota"; +char apPass[65] = DEFAULT_AP_PASS; +char otaPass[33] = DEFAULT_OTA_PASS; //Hardware CONFIG (only changeble HERE, not at runtime) @@ -129,8 +138,8 @@ char ntpServerName[33] = "0.wled.pool.ntp.org";//NTP server to use //WiFi CONFIG (all these can be changed via web UI, no need to set them here) -char clientSSID[33] = "Your_Network"; -char clientPass[65] = ""; +char clientSSID[33] = CLIENT_SSID; +char clientPass[65] = CLIENT_PASS; char cmDNS[33] = "x"; //mDNS address (placeholder, will be replaced by wledXXXXXXXXXXXX.local) char apSSID[33] = ""; //AP off by default (unless setup) byte apChannel = 1; //2.4GHz WiFi AP channel (1-13) @@ -149,8 +158,8 @@ bool useRGBW = false; //SK6812 strips can contain an ext bool turnOnAtBoot = true; //turn on LEDs at power-up byte bootPreset = 0; //save preset to load after power-up -byte col[] {255, 160, 0, 0}; //default RGB(W) color -byte colSec[] {0, 0, 0, 0}; //default RGB(W) secondary color +byte col[] {255, 160, 0, 0}; //current RGB(W) primary color. col[] should be updated if you want to change the color. +byte colSec[] {0, 0, 0, 0}; //current RGB(W) secondary color byte briS = 128; //default brightness byte nightlightTargetBri = 0; //brightness after nightlight is over @@ -158,7 +167,6 @@ byte nightlightDelayMins = 60; bool nightlightFade = true; //if enabled, light will gradually dim towards the target bri. Otherwise, it will instantly set after delay over bool nightlightColorFade = false; //if enabled, light will gradually fade color from primary to secondary color. bool fadeTransition = true; //enable crossfading color transition -bool enableSecTransition = true; //also enable transition for secondary color uint16_t transitionDelay = 750; //default crossfade duration in ms bool skipFirstLed = false; //ignore first LED in strip (useful if you need the LED as signal repeater) @@ -261,13 +269,14 @@ bool aOtaEnabled = true; //ArduinoOTA allows easy updates d uint16_t userVar0 = 0, userVar1 = 0; -//dmx CONFIG -uint16_t DMXChannels = 7; // number of channels per fixture -uint16_t DMXFixtureMap[15] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +#ifdef WLED_ENABLE_DMX + //dmx CONFIG + byte DMXChannels = 7; // number of channels per fixture + byte DMXFixtureMap[15] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // assigns the different channels to different functions. See wled21_dmx.ino for more information. -uint16_t DMXGap = 10; // gap between the fixtures. makes addressing easier because you don't have to memorize odd numbers when climbing up onto a rig. -uint16_t DMXStart = 10; // start address of the first fixture - + uint16_t DMXGap = 10; // gap between the fixtures. makes addressing easier because you don't have to memorize odd numbers when climbing up onto a rig. + uint16_t DMXStart = 10; // start address of the first fixture +#endif //internal global variable declarations @@ -280,7 +289,7 @@ bool wasConnected = false; //color byte colOld[] {0, 0, 0, 0}; //color before transition -byte colT[] {0, 0, 0, 0}; //current color +byte colT[] {0, 0, 0, 0}; //color that is currently displayed on the LEDs byte colIT[] {0, 0, 0, 0}; //color that was last sent to LEDs byte colSecT[] {0, 0, 0, 0}; byte colSecOld[] {0, 0, 0, 0}; @@ -389,7 +398,6 @@ byte realtimeMode = REALTIME_MODE_INACTIVE; IPAddress realtimeIP = (0,0,0,0); unsigned long realtimeTimeout = 0; - //mqtt long lastMqttReconnectAttempt = 0; long lastInterfaceUpdate = 0; @@ -397,17 +405,17 @@ byte interfaceUpdateCallMode = NOTIFIER_CALL_MODE_INIT; char mqttStatusTopic[40] = ""; //this must be global because of async handlers #if AUXPIN >= 0 -//auxiliary debug pin -byte auxTime = 0; -unsigned long auxStartTime = 0; -bool auxActive = false, auxActiveBefore = false; + //auxiliary debug pin + byte auxTime = 0; + unsigned long auxStartTime = 0; + bool auxActive = false, auxActiveBefore = false; #endif //alexa udp String escapedMac; #ifndef WLED_DISABLE_ALEXA -Espalexa espalexa; -EspalexaDevice* espalexaDevice; + Espalexa espalexa; + EspalexaDevice* espalexaDevice; #endif //dns server @@ -422,6 +430,7 @@ IPAddress ntpServerIP; uint16_t ntpLocalPort = 2390; #define NTP_PACKET_SIZE 48 +//maximum number of LEDs - MAX_LEDS is comming from the JSON response getting too big, MAX_LEDS_DMA will become a timing issue #define MAX_LEDS 1500 #define MAX_LEDS_DMA 500 @@ -430,6 +439,7 @@ uint16_t ntpLocalPort = 2390; char* obuf; uint16_t olen = 0; +//presets uint16_t savedPresets = 0; int8_t currentPreset = -1; bool isPreset = false; @@ -466,30 +476,30 @@ bool e131NewData = false; WS2812FX strip = WS2812FX(); #define WLED_CONNECTED (WiFi.status() == WL_CONNECTED) -#define WLED_WIFI_CONFIGURED (strlen(clientSSID) >= 1 && strcmp(clientSSID,"Your_Network") != 0) +#define WLED_WIFI_CONFIGURED (strlen(clientSSID) >= 1 && strcmp(clientSSID,DEFAULT_CLIENT_SSID) != 0) //debug macros #ifdef WLED_DEBUG -#define DEBUG_PRINT(x) Serial.print (x) -#define DEBUG_PRINTLN(x) Serial.println (x) -#define DEBUG_PRINTF(x) Serial.printf (x) -unsigned long debugTime = 0; -int lastWifiState = 3; -unsigned long wifiStateChangedTime = 0; -int loops = 0; + #define DEBUG_PRINT(x) Serial.print (x) + #define DEBUG_PRINTLN(x) Serial.println (x) + #define DEBUG_PRINTF(x) Serial.printf (x) + unsigned long debugTime = 0; + int lastWifiState = 3; + unsigned long wifiStateChangedTime = 0; + int loops = 0; #else -#define DEBUG_PRINT(x) -#define DEBUG_PRINTLN(x) -#define DEBUG_PRINTF(x) + #define DEBUG_PRINT(x) + #define DEBUG_PRINTLN(x) + #define DEBUG_PRINTF(x) #endif //filesystem #ifndef WLED_DISABLE_FILESYSTEM -#include -#ifdef ARDUINO_ARCH_ESP32 -#include "SPIFFS.h" -#endif -#include "SPIFFSEditor.h" + #include + #ifdef ARDUINO_ARCH_ESP32 + #include "SPIFFS.h" + #endif + #include "SPIFFSEditor.h" #endif @@ -555,9 +565,9 @@ void loop() { handleOverlays(); yield(); - #ifdef WLED_USE_ANALOG_LEDS +#ifdef WLED_USE_ANALOG_LEDS strip.setRgbwPwm(); - #endif +#endif if (doReboot) reset(); @@ -577,9 +587,9 @@ void loop() { if (!offMode) strip.service(); } yield(); - #ifdef ESP8266 +#ifdef ESP8266 MDNS.update(); - #endif +#endif if (millis() - lastMqttReconnectAttempt > 30000) initMqtt(); //DEBUG serial logging diff --git a/wled00/wled01_eeprom.ino b/wled00/wled01_eeprom.ino index 73508a4f..703785c1 100644 --- a/wled00/wled01_eeprom.ino +++ b/wled00/wled01_eeprom.ino @@ -159,7 +159,7 @@ void saveSettingsToEEPROM() EEPROM.write(396, (utcOffsetSecs<0)); //is negative EEPROM.write(397, syncToggleReceive); EEPROM.write(398, (ledCount >> 8) & 0xFF); - EEPROM.write(399, !enableSecTransition); + //EEPROM.write(399, was !enableSecTransition); //favorite setting (preset) memory (25 slots/ each 20byte) //400 - 940 reserved @@ -258,15 +258,17 @@ void saveSettingsToEEPROM() EEPROM.write(2523, (mqttPort >> 8) & 0xFF); // DMX (2530 - 2549) + #ifdef WLED_ENABLE_DMX EEPROM.write(2530, DMXChannels); EEPROM.write(2531, DMXGap & 0xFF); EEPROM.write(2532, (DMXGap >> 8) & 0xFF); EEPROM.write(2533, DMXStart & 0xFF); EEPROM.write(2534, (DMXStart >> 8) & 0xFF); - for (int i=0;i<15;i++) { + for (int i=0; i<15; i++) { EEPROM.write(2535+i, DMXFixtureMap[i]); } // last used: 2549. maybe leave a few bytes for future expansion and go on with 2600 kthxbye. + #endif commit(); } @@ -525,7 +527,7 @@ void loadSettingsFromEEPROM(bool first) wifiLock = EEPROM.read(393); utcOffsetSecs = EEPROM.read(394) + ((EEPROM.read(395) << 8) & 0xFF00); if (EEPROM.read(396)) utcOffsetSecs = -utcOffsetSecs; //negative - enableSecTransition = !EEPROM.read(399); + //!EEPROM.read(399); was enableSecTransition //favorite setting (preset) memory (25 slots/ each 20byte) //400 - 899 reserved @@ -536,7 +538,7 @@ void loadSettingsFromEEPROM(bool first) readStringFromEEPROM(2220, blynkApiKey, 35); if (strlen(blynkApiKey) < 25) blynkApiKey[0] = 0; - + #ifdef WLED_ENABLE_DMX // DMX (2530 - 2549)2535 DMXChannels = EEPROM.read(2530); DMXGap = EEPROM.read(2531) + ((EEPROM.read(2532) << 8) & 0xFF00); @@ -545,7 +547,7 @@ void loadSettingsFromEEPROM(bool first) for (int i=0;i<15;i++) { DMXFixtureMap[i] = EEPROM.read(2535+i); } //last used: 2549. maybe leave a few bytes for future expansion and go on with 2600 kthxbye. - + #endif //user MOD memory //2944 - 3071 reserved diff --git a/wled00/wled02_xml.ino b/wled00/wled02_xml.ino index 561f7723..e5083131 100644 --- a/wled00/wled02_xml.ino +++ b/wled00/wled02_xml.ino @@ -99,6 +99,53 @@ char* XML_response(AsyncWebServerRequest *request, char* dest = nullptr) if (request != nullptr) request->send(200, "text/xml", obuf); } +char* URL_response(AsyncWebServerRequest *request) +{ + char sbuf[256]; //allocate local buffer if none passed + char s2buf[100]; + obuf = s2buf; + olen = 0; + + char s[16]; + oappend("http://"); + IPAddress localIP = WiFi.localIP(); + sprintf(s, "%d.%d.%d.%d", localIP[0], localIP[1], localIP[2], localIP[3]); + oappend(s); + oappend("/win&A="); + oappendi(bri); + oappend("&CL=h"); + for (int i = 0; i < 3; i++) + { + sprintf(s,"%02X", col[i]); + oappend(s); + } + oappend("&C2=h"); + for (int i = 0; i < 3; i++) + { + sprintf(s,"%02X", colSec[i]); + oappend(s); + } + oappend("&FX="); + oappendi(effectCurrent); + oappend("&SX="); + oappendi(effectSpeed); + oappend("&IX="); + oappendi(effectIntensity); + oappend("&FP="); + oappendi(effectPalette); + + obuf = sbuf; + olen = 0; + + oappend(""); + oappend(s2buf); + oappend(""); + + if (request != nullptr) request->send(200, "text/html", obuf); +} + //append a numeric setting to string buffer void sappend(char stype, const char* key, int val) { diff --git a/wled00/wled05_init.ino b/wled00/wled05_init.ino index bf1be5d9..40e3bef6 100644 --- a/wled00/wled05_init.ino +++ b/wled00/wled05_init.ino @@ -43,7 +43,7 @@ void wledInit() loadSettingsFromEEPROM(true); beginStrip(); userSetup(); - if (strcmp(clientSSID,"Your_Network") == 0) showWelcomePage = true; + if (strcmp(clientSSID,DEFAULT_CLIENT_SSID) == 0) showWelcomePage = true; WiFi.persistent(false); if (macroBoot>0) applyMacro(macroBoot); @@ -126,7 +126,7 @@ void initAP(bool resetAP=false){ if (apBehavior == AP_BEHAVIOR_BUTTON_ONLY && !resetAP) return; if (!apSSID[0] || resetAP) strcpy(apSSID, "WLED-AP"); - if (resetAP) strcpy(apPass,"wled1234"); + if (resetAP) strcpy(apPass,DEFAULT_AP_PASS); DEBUG_PRINT("Opening access point "); DEBUG_PRINTLN(apSSID); WiFi.softAPConfig(IPAddress(4, 3, 2, 1), IPAddress(4, 3, 2, 1), IPAddress(255,255,255,0)); diff --git a/wled00/wled07_notify.ino b/wled00/wled07_notify.ino index fd83f1f8..7f691dd0 100644 --- a/wled00/wled07_notify.ino +++ b/wled00/wled07_notify.ino @@ -15,7 +15,6 @@ void notify(byte callMode, bool followUp=false) case NOTIFIER_CALL_MODE_DIRECT_CHANGE: if (!notifyDirect) return; break; case NOTIFIER_CALL_MODE_BUTTON: if (!notifyButton) return; break; case NOTIFIER_CALL_MODE_NIGHTLIGHT: if (!notifyDirect) return; break; - case NOTIFIER_CALL_MODE_FX_CHANGED: if (!notifyDirect) return; break; //fx change case NOTIFIER_CALL_MODE_HUE: if (!notifyHue) return; break; case NOTIFIER_CALL_MODE_PRESET_CYCLE: if (!notifyDirect) return; break; case NOTIFIER_CALL_MODE_BLYNK: if (!notifyDirect) return; break; diff --git a/wled00/wled08_led.ino b/wled00/wled08_led.ino index d1ccc0d6..93642fc2 100644 --- a/wled00/wled08_led.ino +++ b/wled00/wled08_led.ino @@ -40,13 +40,6 @@ void setAllLeds() { if (val > 255) val = 255; strip.setBrightness(val); } - if (!enableSecTransition) - { - for (byte i = 0; i<4; i++) - { - colSecT[i] = colSec[i]; - } - } if (useRGBW && strip.rgbwMode == RGBW_MODE_LEGACY) { colorRGBtoRGBW(colT); @@ -95,28 +88,30 @@ void colorUpdated(int callMode) callMode != NOTIFIER_CALL_MODE_NO_NOTIFY) strip.applyToAllSelected = true; //if not from JSON api, which directly sets segments bool fxChanged = strip.setEffectConfig(effectCurrent, effectSpeed, effectIntensity, effectPalette); - if (!colorChanged()) + bool colChanged = colorChanged(); + + if (fxChanged || colChanged) { + if (realtimeTimeout == UINT32_MAX) realtimeTimeout = 0; + if (isPreset) {isPreset = false;} + else {currentPreset = -1;} + + notify(callMode); + + //set flag to update blynk and mqtt + if (callMode != NOTIFIER_CALL_MODE_PRESET_CYCLE) interfaceUpdateCallMode = callMode; + } else { if (nightlightActive && !nightlightActiveOld && callMode != NOTIFIER_CALL_MODE_NOTIFICATION && callMode != NOTIFIER_CALL_MODE_NO_NOTIFY) { notify(NOTIFIER_CALL_MODE_NIGHTLIGHT); interfaceUpdateCallMode = NOTIFIER_CALL_MODE_NIGHTLIGHT; - return; } - else if (fxChanged) { - notify(NOTIFIER_CALL_MODE_FX_CHANGED); - if (callMode != NOTIFIER_CALL_MODE_PRESET_CYCLE) interfaceUpdateCallMode = NOTIFIER_CALL_MODE_FX_CHANGED; - if (realtimeTimeout == UINT32_MAX) realtimeTimeout = 0; - if (isPreset) {isPreset = false;} - else {currentPreset = -1;} - } - return; //no change } - if (realtimeTimeout == UINT32_MAX) realtimeTimeout = 0; - if (isPreset) {isPreset = false;} - else {currentPreset = -1;} + + if (!colChanged) return; //following code is for e.g. initiating transitions + if (callMode != NOTIFIER_CALL_MODE_NO_NOTIFY && nightlightActive && nightlightFade) { briNlT = bri; @@ -137,8 +132,6 @@ void colorUpdated(int callMode) briIT = bri; if (bri > 0) briLast = bri; - notify(callMode); - if (fadeTransition) { //set correct delay if not using notification delay @@ -164,10 +157,6 @@ void colorUpdated(int callMode) setLedsStandard(); strip.trigger(); } - - if (callMode == NOTIFIER_CALL_MODE_PRESET_CYCLE) return; - //set flag to update blynk and mqtt - interfaceUpdateCallMode = callMode; } @@ -231,15 +220,15 @@ void handleNightlight() nightlightDelayMs = (int)(nightlightDelayMins*60000); nightlightActiveOld = true; briNlT = bri; - for (byte i=0; i<4; i++) colNlT[i] = colT[i]; // remember starting color + for (byte i=0; i<4; i++) colNlT[i] = col[i]; // remember starting color } float nper = (millis() - nightlightStartTime)/((float)nightlightDelayMs); if (nightlightFade) { bri = briNlT + ((nightlightTargetBri - briNlT)*nper); - if (nightlightColorFade) // color fading only is enabled with "NF=2" + if (nightlightColorFade) // color fading only is enabled with "NF=2" { - for (byte i=0; i<4; i++) colT[i] = colNlT[i]+ ((colSecT[i] - colNlT[i])*nper); // fading from actual color to secondary color + for (byte i=0; i<4; i++) col[i] = colNlT[i]+ ((colSec[i] - colNlT[i])*nper); // fading from actual color to secondary color } colorUpdated(NOTIFIER_CALL_MODE_NO_NOTIFY); } diff --git a/wled00/wled10_ntp.ino b/wled00/wled10_ntp.ino index bf8df064..2c5a64c4 100644 --- a/wled00/wled10_ntp.ino +++ b/wled00/wled10_ntp.ino @@ -164,9 +164,9 @@ void setCountdown() bool checkCountdown() { unsigned long n = now(); - local = countdownTime - n; + if (countdownMode) local = countdownTime - n + utcOffsetSecs; if (n > countdownTime) { - local = n - countdownTime; + if (countdownMode) local = n - countdownTime + utcOffsetSecs; if (!countdownOverTriggered) { if (macroCountdown != 0) applyMacro(macroCountdown); diff --git a/wled00/wled18_server.ino b/wled00/wled18_server.ino index cf67e79f..826425d1 100644 --- a/wled00/wled18_server.ino +++ b/wled00/wled18_server.ino @@ -143,6 +143,10 @@ void initServer() request->send_P(200, "text/html", PAGE_usermod); }); + server.on("/url", HTTP_GET, [](AsyncWebServerRequest *request){ + URL_response(request); + }); + server.on("/teapot", HTTP_GET, [](AsyncWebServerRequest *request){ serveMessage(request, 418, "418. I'm a teapot.", "(Tangible Embedded Advanced Project Of Twinkling)", 254); }); diff --git a/wled00/wled19_json.ino b/wled00/wled19_json.ino index 6bf9aafd..5cc1f519 100644 --- a/wled00/wled19_json.ino +++ b/wled00/wled19_json.ino @@ -321,7 +321,6 @@ void serializeInfo(JsonObject root) root["brand"] = "WLED"; root["product"] = "DIY light"; - root["btype"] = "src"; root["mac"] = escapedMac; }