This commit is contained in:
Ser Ko 2020-02-24 16:39:37 -05:00
commit e8e04db7b4
18 changed files with 242 additions and 139 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@
!.vscode/extensions.json !.vscode/extensions.json
/wled00/Release /wled00/Release
/wled00/extLibs /wled00/extLibs
/platformio_override.ini

View File

@ -6,6 +6,7 @@ src_dir = ./wled00
data_dir = ./wled00/data data_dir = ./wled00/data
;lib_extra_dirs = ./wled00/src ;lib_extra_dirs = ./wled00/src
lib_dir = ./wled00/src lib_dir = ./wled00/src
extra_configs = platformio_override.ini
; Please uncomment one of the 5 lines below to select your board ; Please uncomment one of the 5 lines below to select your board
default_envs = nodemcuv2 default_envs = nodemcuv2
; default_envs = esp01 ; default_envs = esp01
@ -16,6 +17,10 @@ default_envs = nodemcuv2
; default_envs = esp8285_4CH_MagicHome ; default_envs = esp8285_4CH_MagicHome
; default_envs = esp8285_4CH_H801 ; default_envs = esp8285_4CH_H801
; default_envs = esp8285_5CH_H801 ; default_envs = esp8285_5CH_H801
# Release binaries follow
; default_envs = nodemcuv2, esp01, esp01_1m, esp32dev,
[common] [common]
framework = arduino 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} platform = ${common:esp8266.arduino_core_2_6_3}
build_flags = build_flags =
-D ESP8266 -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 -Wl,-Teagle.flash.4m1m.ld ;;;; Required for core > v2.5.0 or staging version 4MB Flash 3MB SPIFFs
lib_ignore = AsyncTCP lib_ignore = AsyncTCP
[common:esp8266_1M] [common:esp8266_1M]
platform = espressif8266@1.8.0 platform = ${common:esp8266.arduino_core_2_6_3}
build_flags = build_flags =
-D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH -D PIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
-Wl,-Teagle.flash.1m0.ld ;;;; Compile with no SPIFFS to leave space for OTA -Wl,-Teagle.flash.1m.ld ;;;; Compile with no SPIFFS to leave space for OTA
; -D WLED_DISABLE_MOBILE_UI
; -D WLED_DISABLE_OTA ; -D WLED_DISABLE_OTA
; -D WLED_DISABLE_ALEXA ; -D WLED_DISABLE_ALEXA
-D WLED_DISABLE_BLYNK -D WLED_DISABLE_BLYNK
-D WLED_DISABLE_CRONIXIE -D WLED_DISABLE_CRONIXIE
; -D WLED_DISABLE_HUESYNC ; -D WLED_DISABLE_HUESYNC
; -D WLED_DISABLE_INFRARED -D WLED_DISABLE_INFRARED
lib_ignore = ${common:esp8266.lib_ignore} lib_ignore = ${common:esp8266.lib_ignore}
[common:esp8266_512k] [common:esp8266_512k]
platform = espressif8266@1.8.0 platform = ${common:esp8266.arduino_core_2_6_3}
build_flags = build_flags =
-D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH -D PIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
-Wl,-Teagle.flash.512k0.ld ;;;; Compile with no SPIFFS -Wl,-Teagle.flash.512k.ld ;;;; Compile with no SPIFFS
; -D WLED_DISABLE_MOBILE_UI
-D WLED_DISABLE_OTA -D WLED_DISABLE_OTA
; -D WLED_DISABLE_ALEXA -D WLED_DISABLE_ALEXA
-D WLED_DISABLE_BLYNK -D WLED_DISABLE_BLYNK
-D WLED_DISABLE_CRONIXIE -D WLED_DISABLE_CRONIXIE
-D WLED_DISABLE_HUESYNC -D WLED_DISABLE_HUESYNC
; -D WLED_DISABLE_INFRARED -D WLED_DISABLE_INFRARED
lib_ignore = ${common:esp8266.lib_ignore} lib_ignore = ${common:esp8266.lib_ignore}
[common:esp32] [common:esp32]
@ -177,7 +180,6 @@ framework = ${common.framework}
build_flags = build_flags =
${common.build_flags} ${common.build_flags}
${common:esp8266_512k.build_flags} ${common:esp8266_512k.build_flags}
-D WLED_DISABLE_INFRARED
lib_deps = lib_deps =
${common.lib_deps_external} ${common.lib_deps_external}
lib_compat_mode = strict lib_compat_mode = strict

View File

@ -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}

View File

@ -11,7 +11,7 @@
A fast and feature-rich implementation of an ESP8266/ESP32 webserver to control NeoPixel (WS2812B, WS2811, SK6812, APA102) LEDs! A fast and feature-rich implementation of an ESP8266/ESP32 webserver to control NeoPixel (WS2812B, WS2811, SK6812, APA102) LEDs!
### Features: ### Features:
- WS2812FX library integrated for almost 100 special effects - WS2812FX library integrated for over 100 special effects
- FastLED noise effects and palettes - FastLED noise effects and palettes
- Modern UI with color, effect and segment controls - Modern UI with color, effect and segment controls
- Segments to set different effects and colors to parts of the LEDs - Segments to set different effects and colors to parts of the LEDs

View File

@ -7,6 +7,7 @@ OneWire oneWire(23);
#else //ESP8266 boards #else //ESP8266 boards
uint8_t SCL_PIN = 5; uint8_t SCL_PIN = 5;
uint8_t SDA_PIN = 4; uint8_t SDA_PIN = 4;
// uint8_t RST_PIN = 16; // Uncoment for Heltec WiFi-Kit-8
OneWire oneWire(13); OneWire oneWire(13);
#endif #endif
//The SCL and SDA pins are defined here. //The SCL and SDA pins are defined here.

View File

@ -56,6 +56,9 @@
#define MAX_SEGMENT_DATA 8192 #define MAX_SEGMENT_DATA 8192
#endif #endif
#define LED_SKIP_AMOUNT 1
#define MIN_SHOW_DELAY 15
#define NUM_COLORS 3 /* number of colors per segment */ #define NUM_COLORS 3 /* number of colors per segment */
#define SEGMENT _segments[_segment_index] #define SEGMENT _segments[_segment_index]
#define SEGCOLOR(x) gamma32(_segments[_segment_index].colors[x]) #define SEGCOLOR(x) gamma32(_segments[_segment_index].colors[x])

View File

@ -27,9 +27,6 @@
#include "FX.h" #include "FX.h"
#include "palettes.h" #include "palettes.h"
#define LED_SKIP_AMOUNT 1
#define MIN_SHOW_DELAY 15
void WS2812FX::init(bool supportWhite, uint16_t countPixels, bool skipFirst) void WS2812FX::init(bool supportWhite, uint16_t countPixels, bool skipFirst)
{ {
if (supportWhite == _useRgbw && countPixels == _length) return; if (supportWhite == _useRgbw && countPixels == _length) return;
@ -380,7 +377,7 @@ void WS2812FX::setBrightness(uint8_t b) {
if (_brightness == b) return; if (_brightness == b) return;
_brightness = (gammaCorrectBri) ? gamma8(b) : b; _brightness = (gammaCorrectBri) ? gamma8(b) : b;
_segment_index = 0; _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) { uint8_t WS2812FX::getMode(void) {

View File

@ -13,12 +13,25 @@
//#define WLED_USE_H801 //H801 controller. Please uncomment #define WLED_USE_ANALOG_LEDS as well //#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 //#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 BTNPIN 0 //button pin. Needs to have pullup (gpio0 recommended)
#define IR_PIN 4 //infrared pin (-1 to disable) MagicHome: 4, H801 Wifi: 0 #endif
#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)
#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 #define RLYMDE 1 //mode for relay, 0: LOW if LEDs are on 1: HIGH if LEDs are on
#endif
//END CONFIGURATION //END CONFIGURATION

View File

@ -1,6 +1,11 @@
#ifndef wled_const_h #ifndef wled_const_h
#define 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 //Access point behavior
#define AP_BEHAVIOR_BOOT_NO_CONN 0 //Open AP when no connection after boot #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) #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 #define AP_BEHAVIOR_BUTTON_ONLY 3 //Only when button pressed for 6 sec
//Notifier callMode //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_DIRECT_CHANGE 1
#define NOTIFIER_CALL_MODE_BUTTON 2 #define NOTIFIER_CALL_MODE_BUTTON 2
#define NOTIFIER_CALL_MODE_NOTIFICATION 3 #define NOTIFIER_CALL_MODE_NOTIFICATION 3
#define NOTIFIER_CALL_MODE_NIGHTLIGHT 4 #define NOTIFIER_CALL_MODE_NIGHTLIGHT 4
#define NOTIFIER_CALL_MODE_NO_NOTIFY 5 #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_HUE 7
#define NOTIFIER_CALL_MODE_PRESET_CYCLE 8 #define NOTIFIER_CALL_MODE_PRESET_CYCLE 8
#define NOTIFIER_CALL_MODE_BLYNK 9 #define NOTIFIER_CALL_MODE_BLYNK 9
@ -36,11 +41,24 @@
#define REALTIME_MODE_ADALIGHT 5 #define REALTIME_MODE_ADALIGHT 5
//E1.31 DMX modes //E1.31 DMX modes
#define DMX_MODE_DISABLED 0 //not used #define DMX_MODE_DISABLED 0 //not used
#define DMX_MODE_SINGLE_RGB 1 //all LEDs same RGB color (3 channels) #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_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_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_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_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 #endif

View File

@ -21,7 +21,7 @@
//#define WLED_DISABLE_BLYNK //saves 6kb //#define WLED_DISABLE_BLYNK //saves 6kb
//#define WLED_DISABLE_CRONIXIE //saves 3kb //#define WLED_DISABLE_CRONIXIE //saves 3kb
//#define WLED_DISABLE_HUESYNC //saves 4kb //#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_MQTT //saves 12kb
#define WLED_ENABLE_ADALIGHT //saves 500b only #define WLED_ENABLE_ADALIGHT //saves 500b only
//#define WLED_ENABLE_DMX //uses 3.5kb //#define WLED_ENABLE_DMX //uses 3.5kb
@ -36,22 +36,22 @@
//library inclusions //library inclusions
#include <Arduino.h> #include <Arduino.h>
#ifdef WLED_ENABLE_DMX #ifdef WLED_ENABLE_DMX
#include <ESPDMX.h> #include <ESPDMX.h>
DMXESPSerial dmx; DMXESPSerial dmx;
#endif #endif
#ifdef ESP8266 #ifdef ESP8266
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <ESP8266mDNS.h> #include <ESP8266mDNS.h>
#include <ESPAsyncTCP.h> #include <ESPAsyncTCP.h>
extern "C" { extern "C" {
#include <user_interface.h> #include <user_interface.h>
} }
#else #else //ESP32
#include <WiFi.h> #include <WiFi.h>
#include "esp_wifi.h" #include "esp_wifi.h"
#include <ESPmDNS.h> #include <ESPmDNS.h>
#include <AsyncTCP.h> #include <AsyncTCP.h>
#include "SPIFFS.h" #include "SPIFFS.h"
#endif #endif
#include <ESPAsyncWebServer.h> #include <ESPAsyncWebServer.h>
@ -59,20 +59,20 @@ DMXESPSerial dmx;
#include <WiFiUdp.h> #include <WiFiUdp.h>
#include <DNSServer.h> #include <DNSServer.h>
#ifndef WLED_DISABLE_OTA #ifndef WLED_DISABLE_OTA
#include <ArduinoOTA.h> #include <ArduinoOTA.h>
#endif #endif
#include <SPIFFSEditor.h> #include <SPIFFSEditor.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_ALEXA #ifndef WLED_DISABLE_ALEXA
#define ESPALEXA_ASYNC #define ESPALEXA_ASYNC
#define ESPALEXA_NO_SUBPAGE #define ESPALEXA_NO_SUBPAGE
#define ESPALEXA_MAXDEVICES 1 #define ESPALEXA_MAXDEVICES 1
//#define ESPALEXA_DEBUG // #define ESPALEXA_DEBUG
#include "src/dependencies/espalexa/Espalexa.h" #include "src/dependencies/espalexa/Espalexa.h"
#endif #endif
#ifndef WLED_DISABLE_BLYNK #ifndef WLED_DISABLE_BLYNK
#include "src/dependencies/blynk/BlynkSimpleEsp.h" #include "src/dependencies/blynk/BlynkSimpleEsp.h"
#endif #endif
#include "src/dependencies/e131/ESPAsyncE131.h" #include "src/dependencies/e131/ESPAsyncE131.h"
#include "src/dependencies/async-mqtt-client/AsyncMqttClient.h" #include "src/dependencies/async-mqtt-client/AsyncMqttClient.h"
@ -85,17 +85,25 @@ DMXESPSerial dmx;
#include "ir_codes.h" #include "ir_codes.h"
#include "const.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 #if IR_PIN < 0
#ifndef WLED_DISABLE_INFRARED #ifndef WLED_DISABLE_INFRARED
#define WLED_DISABLE_INFRARED #define WLED_DISABLE_INFRARED
#endif #endif
#endif #endif
#ifndef WLED_DISABLE_INFRARED #ifndef WLED_DISABLE_INFRARED
#include <IRremoteESP8266.h> #include <IRremoteESP8266.h>
#include <IRrecv.h> #include <IRrecv.h>
#include <IRutils.h> #include <IRutils.h>
#endif #endif
// remove flicker because PWM signal of RGB channels can become out of phase // remove flicker because PWM signal of RGB channels can become out of phase
@ -111,13 +119,14 @@ DMXESPSerial dmx;
#endif #endif
//version code in format yymmddb (b = daily build) //version code in format yymmddb (b = daily build)
#define VERSION 2002192 #define VERSION 2002243
char versionString[] = "0.9.1"; char versionString[] = "0.9.1";
//AP and OTA default passwords (for maximum change them!) //AP and OTA default passwords (for maximum change them!)
char apPass[65] = "wled1234"; char apPass[65] = DEFAULT_AP_PASS;
char otaPass[33] = "wledota"; char otaPass[33] = DEFAULT_OTA_PASS;
//Hardware CONFIG (only changeble HERE, not at runtime) //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) //WiFi CONFIG (all these can be changed via web UI, no need to set them here)
char clientSSID[33] = "Your_Network"; char clientSSID[33] = CLIENT_SSID;
char clientPass[65] = ""; char clientPass[65] = CLIENT_PASS;
char cmDNS[33] = "x"; //mDNS address (placeholder, will be replaced by wledXXXXXXXXXXXX.local) char cmDNS[33] = "x"; //mDNS address (placeholder, will be replaced by wledXXXXXXXXXXXX.local)
char apSSID[33] = ""; //AP off by default (unless setup) char apSSID[33] = ""; //AP off by default (unless setup)
byte apChannel = 1; //2.4GHz WiFi AP channel (1-13) 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 bool turnOnAtBoot = true; //turn on LEDs at power-up
byte bootPreset = 0; //save preset to load after power-up byte bootPreset = 0; //save preset to load after power-up
byte col[] {255, 160, 0, 0}; //default RGB(W) 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}; //default RGB(W) secondary color byte colSec[] {0, 0, 0, 0}; //current RGB(W) secondary color
byte briS = 128; //default brightness byte briS = 128; //default brightness
byte nightlightTargetBri = 0; //brightness after nightlight is over 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 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 nightlightColorFade = false; //if enabled, light will gradually fade color from primary to secondary color.
bool fadeTransition = true; //enable crossfading color transition 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 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) 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; uint16_t userVar0 = 0, userVar1 = 0;
//dmx CONFIG #ifdef WLED_ENABLE_DMX
uint16_t DMXChannels = 7; // number of channels per fixture //dmx CONFIG
uint16_t DMXFixtureMap[15] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 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. // 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 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 DMXStart = 10; // start address of the first fixture
#endif
//internal global variable declarations //internal global variable declarations
@ -280,7 +289,7 @@ bool wasConnected = false;
//color //color
byte colOld[] {0, 0, 0, 0}; //color before transition 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 colIT[] {0, 0, 0, 0}; //color that was last sent to LEDs
byte colSecT[] {0, 0, 0, 0}; byte colSecT[] {0, 0, 0, 0};
byte colSecOld[] {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); IPAddress realtimeIP = (0,0,0,0);
unsigned long realtimeTimeout = 0; unsigned long realtimeTimeout = 0;
//mqtt //mqtt
long lastMqttReconnectAttempt = 0; long lastMqttReconnectAttempt = 0;
long lastInterfaceUpdate = 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 char mqttStatusTopic[40] = ""; //this must be global because of async handlers
#if AUXPIN >= 0 #if AUXPIN >= 0
//auxiliary debug pin //auxiliary debug pin
byte auxTime = 0; byte auxTime = 0;
unsigned long auxStartTime = 0; unsigned long auxStartTime = 0;
bool auxActive = false, auxActiveBefore = false; bool auxActive = false, auxActiveBefore = false;
#endif #endif
//alexa udp //alexa udp
String escapedMac; String escapedMac;
#ifndef WLED_DISABLE_ALEXA #ifndef WLED_DISABLE_ALEXA
Espalexa espalexa; Espalexa espalexa;
EspalexaDevice* espalexaDevice; EspalexaDevice* espalexaDevice;
#endif #endif
//dns server //dns server
@ -422,6 +430,7 @@ IPAddress ntpServerIP;
uint16_t ntpLocalPort = 2390; uint16_t ntpLocalPort = 2390;
#define NTP_PACKET_SIZE 48 #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 1500
#define MAX_LEDS_DMA 500 #define MAX_LEDS_DMA 500
@ -430,6 +439,7 @@ uint16_t ntpLocalPort = 2390;
char* obuf; char* obuf;
uint16_t olen = 0; uint16_t olen = 0;
//presets
uint16_t savedPresets = 0; uint16_t savedPresets = 0;
int8_t currentPreset = -1; int8_t currentPreset = -1;
bool isPreset = false; bool isPreset = false;
@ -466,30 +476,30 @@ bool e131NewData = false;
WS2812FX strip = WS2812FX(); WS2812FX strip = WS2812FX();
#define WLED_CONNECTED (WiFi.status() == WL_CONNECTED) #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 //debug macros
#ifdef WLED_DEBUG #ifdef WLED_DEBUG
#define DEBUG_PRINT(x) Serial.print (x) #define DEBUG_PRINT(x) Serial.print (x)
#define DEBUG_PRINTLN(x) Serial.println (x) #define DEBUG_PRINTLN(x) Serial.println (x)
#define DEBUG_PRINTF(x) Serial.printf (x) #define DEBUG_PRINTF(x) Serial.printf (x)
unsigned long debugTime = 0; unsigned long debugTime = 0;
int lastWifiState = 3; int lastWifiState = 3;
unsigned long wifiStateChangedTime = 0; unsigned long wifiStateChangedTime = 0;
int loops = 0; int loops = 0;
#else #else
#define DEBUG_PRINT(x) #define DEBUG_PRINT(x)
#define DEBUG_PRINTLN(x) #define DEBUG_PRINTLN(x)
#define DEBUG_PRINTF(x) #define DEBUG_PRINTF(x)
#endif #endif
//filesystem //filesystem
#ifndef WLED_DISABLE_FILESYSTEM #ifndef WLED_DISABLE_FILESYSTEM
#include <FS.h> #include <FS.h>
#ifdef ARDUINO_ARCH_ESP32 #ifdef ARDUINO_ARCH_ESP32
#include "SPIFFS.h" #include "SPIFFS.h"
#endif #endif
#include "SPIFFSEditor.h" #include "SPIFFSEditor.h"
#endif #endif
@ -555,9 +565,9 @@ void loop() {
handleOverlays(); handleOverlays();
yield(); yield();
#ifdef WLED_USE_ANALOG_LEDS #ifdef WLED_USE_ANALOG_LEDS
strip.setRgbwPwm(); strip.setRgbwPwm();
#endif #endif
if (doReboot) reset(); if (doReboot) reset();
@ -577,9 +587,9 @@ void loop() {
if (!offMode) strip.service(); if (!offMode) strip.service();
} }
yield(); yield();
#ifdef ESP8266 #ifdef ESP8266
MDNS.update(); MDNS.update();
#endif #endif
if (millis() - lastMqttReconnectAttempt > 30000) initMqtt(); if (millis() - lastMqttReconnectAttempt > 30000) initMqtt();
//DEBUG serial logging //DEBUG serial logging

View File

@ -159,7 +159,7 @@ void saveSettingsToEEPROM()
EEPROM.write(396, (utcOffsetSecs<0)); //is negative EEPROM.write(396, (utcOffsetSecs<0)); //is negative
EEPROM.write(397, syncToggleReceive); EEPROM.write(397, syncToggleReceive);
EEPROM.write(398, (ledCount >> 8) & 0xFF); EEPROM.write(398, (ledCount >> 8) & 0xFF);
EEPROM.write(399, !enableSecTransition); //EEPROM.write(399, was !enableSecTransition);
//favorite setting (preset) memory (25 slots/ each 20byte) //favorite setting (preset) memory (25 slots/ each 20byte)
//400 - 940 reserved //400 - 940 reserved
@ -258,15 +258,17 @@ void saveSettingsToEEPROM()
EEPROM.write(2523, (mqttPort >> 8) & 0xFF); EEPROM.write(2523, (mqttPort >> 8) & 0xFF);
// DMX (2530 - 2549) // DMX (2530 - 2549)
#ifdef WLED_ENABLE_DMX
EEPROM.write(2530, DMXChannels); EEPROM.write(2530, DMXChannels);
EEPROM.write(2531, DMXGap & 0xFF); EEPROM.write(2531, DMXGap & 0xFF);
EEPROM.write(2532, (DMXGap >> 8) & 0xFF); EEPROM.write(2532, (DMXGap >> 8) & 0xFF);
EEPROM.write(2533, DMXStart & 0xFF); EEPROM.write(2533, DMXStart & 0xFF);
EEPROM.write(2534, (DMXStart >> 8) & 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]); EEPROM.write(2535+i, DMXFixtureMap[i]);
} // last used: 2549. maybe leave a few bytes for future expansion and go on with 2600 kthxbye. } // last used: 2549. maybe leave a few bytes for future expansion and go on with 2600 kthxbye.
#endif
commit(); commit();
} }
@ -525,7 +527,7 @@ void loadSettingsFromEEPROM(bool first)
wifiLock = EEPROM.read(393); wifiLock = EEPROM.read(393);
utcOffsetSecs = EEPROM.read(394) + ((EEPROM.read(395) << 8) & 0xFF00); utcOffsetSecs = EEPROM.read(394) + ((EEPROM.read(395) << 8) & 0xFF00);
if (EEPROM.read(396)) utcOffsetSecs = -utcOffsetSecs; //negative if (EEPROM.read(396)) utcOffsetSecs = -utcOffsetSecs; //negative
enableSecTransition = !EEPROM.read(399); //!EEPROM.read(399); was enableSecTransition
//favorite setting (preset) memory (25 slots/ each 20byte) //favorite setting (preset) memory (25 slots/ each 20byte)
//400 - 899 reserved //400 - 899 reserved
@ -536,7 +538,7 @@ void loadSettingsFromEEPROM(bool first)
readStringFromEEPROM(2220, blynkApiKey, 35); readStringFromEEPROM(2220, blynkApiKey, 35);
if (strlen(blynkApiKey) < 25) blynkApiKey[0] = 0; if (strlen(blynkApiKey) < 25) blynkApiKey[0] = 0;
#ifdef WLED_ENABLE_DMX
// DMX (2530 - 2549)2535 // DMX (2530 - 2549)2535
DMXChannels = EEPROM.read(2530); DMXChannels = EEPROM.read(2530);
DMXGap = EEPROM.read(2531) + ((EEPROM.read(2532) << 8) & 0xFF00); DMXGap = EEPROM.read(2531) + ((EEPROM.read(2532) << 8) & 0xFF00);
@ -545,7 +547,7 @@ void loadSettingsFromEEPROM(bool first)
for (int i=0;i<15;i++) { for (int i=0;i<15;i++) {
DMXFixtureMap[i] = EEPROM.read(2535+i); DMXFixtureMap[i] = EEPROM.read(2535+i);
} //last used: 2549. maybe leave a few bytes for future expansion and go on with 2600 kthxbye. } //last used: 2549. maybe leave a few bytes for future expansion and go on with 2600 kthxbye.
#endif
//user MOD memory //user MOD memory
//2944 - 3071 reserved //2944 - 3071 reserved

View File

@ -99,6 +99,53 @@ char* XML_response(AsyncWebServerRequest *request, char* dest = nullptr)
if (request != nullptr) request->send(200, "text/xml", obuf); 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("<html><body><a href=\"");
oappend(s2buf);
oappend("\" target=\"_blank\">");
oappend(s2buf);
oappend("</a></body></html>");
if (request != nullptr) request->send(200, "text/html", obuf);
}
//append a numeric setting to string buffer //append a numeric setting to string buffer
void sappend(char stype, const char* key, int val) void sappend(char stype, const char* key, int val)
{ {

View File

@ -43,7 +43,7 @@ void wledInit()
loadSettingsFromEEPROM(true); loadSettingsFromEEPROM(true);
beginStrip(); beginStrip();
userSetup(); userSetup();
if (strcmp(clientSSID,"Your_Network") == 0) showWelcomePage = true; if (strcmp(clientSSID,DEFAULT_CLIENT_SSID) == 0) showWelcomePage = true;
WiFi.persistent(false); WiFi.persistent(false);
if (macroBoot>0) applyMacro(macroBoot); if (macroBoot>0) applyMacro(macroBoot);
@ -126,7 +126,7 @@ void initAP(bool resetAP=false){
if (apBehavior == AP_BEHAVIOR_BUTTON_ONLY && !resetAP) return; if (apBehavior == AP_BEHAVIOR_BUTTON_ONLY && !resetAP) return;
if (!apSSID[0] || resetAP) strcpy(apSSID, "WLED-AP"); 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_PRINT("Opening access point ");
DEBUG_PRINTLN(apSSID); DEBUG_PRINTLN(apSSID);
WiFi.softAPConfig(IPAddress(4, 3, 2, 1), IPAddress(4, 3, 2, 1), IPAddress(255,255,255,0)); WiFi.softAPConfig(IPAddress(4, 3, 2, 1), IPAddress(4, 3, 2, 1), IPAddress(255,255,255,0));

View File

@ -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_DIRECT_CHANGE: if (!notifyDirect) return; break;
case NOTIFIER_CALL_MODE_BUTTON: if (!notifyButton) return; break; case NOTIFIER_CALL_MODE_BUTTON: if (!notifyButton) return; break;
case NOTIFIER_CALL_MODE_NIGHTLIGHT: if (!notifyDirect) 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_HUE: if (!notifyHue) return; break;
case NOTIFIER_CALL_MODE_PRESET_CYCLE: if (!notifyDirect) return; break; case NOTIFIER_CALL_MODE_PRESET_CYCLE: if (!notifyDirect) return; break;
case NOTIFIER_CALL_MODE_BLYNK: if (!notifyDirect) return; break; case NOTIFIER_CALL_MODE_BLYNK: if (!notifyDirect) return; break;

View File

@ -40,13 +40,6 @@ void setAllLeds() {
if (val > 255) val = 255; if (val > 255) val = 255;
strip.setBrightness(val); strip.setBrightness(val);
} }
if (!enableSecTransition)
{
for (byte i = 0; i<4; i++)
{
colSecT[i] = colSec[i];
}
}
if (useRGBW && strip.rgbwMode == RGBW_MODE_LEGACY) if (useRGBW && strip.rgbwMode == RGBW_MODE_LEGACY)
{ {
colorRGBtoRGBW(colT); 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 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); 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 && if (nightlightActive && !nightlightActiveOld &&
callMode != NOTIFIER_CALL_MODE_NOTIFICATION && callMode != NOTIFIER_CALL_MODE_NOTIFICATION &&
callMode != NOTIFIER_CALL_MODE_NO_NOTIFY) callMode != NOTIFIER_CALL_MODE_NO_NOTIFY)
{ {
notify(NOTIFIER_CALL_MODE_NIGHTLIGHT); notify(NOTIFIER_CALL_MODE_NIGHTLIGHT);
interfaceUpdateCallMode = 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;} if (!colChanged) return; //following code is for e.g. initiating transitions
else {currentPreset = -1;}
if (callMode != NOTIFIER_CALL_MODE_NO_NOTIFY && nightlightActive && nightlightFade) if (callMode != NOTIFIER_CALL_MODE_NO_NOTIFY && nightlightActive && nightlightFade)
{ {
briNlT = bri; briNlT = bri;
@ -137,8 +132,6 @@ void colorUpdated(int callMode)
briIT = bri; briIT = bri;
if (bri > 0) briLast = bri; if (bri > 0) briLast = bri;
notify(callMode);
if (fadeTransition) if (fadeTransition)
{ {
//set correct delay if not using notification delay //set correct delay if not using notification delay
@ -164,10 +157,6 @@ void colorUpdated(int callMode)
setLedsStandard(); setLedsStandard();
strip.trigger(); 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); nightlightDelayMs = (int)(nightlightDelayMins*60000);
nightlightActiveOld = true; nightlightActiveOld = true;
briNlT = bri; 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); float nper = (millis() - nightlightStartTime)/((float)nightlightDelayMs);
if (nightlightFade) if (nightlightFade)
{ {
bri = briNlT + ((nightlightTargetBri - briNlT)*nper); 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); colorUpdated(NOTIFIER_CALL_MODE_NO_NOTIFY);
} }

View File

@ -164,9 +164,9 @@ void setCountdown()
bool checkCountdown() bool checkCountdown()
{ {
unsigned long n = now(); unsigned long n = now();
local = countdownTime - n; if (countdownMode) local = countdownTime - n + utcOffsetSecs;
if (n > countdownTime) { if (n > countdownTime) {
local = n - countdownTime; if (countdownMode) local = n - countdownTime + utcOffsetSecs;
if (!countdownOverTriggered) if (!countdownOverTriggered)
{ {
if (macroCountdown != 0) applyMacro(macroCountdown); if (macroCountdown != 0) applyMacro(macroCountdown);

View File

@ -143,6 +143,10 @@ void initServer()
request->send_P(200, "text/html", PAGE_usermod); 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){ server.on("/teapot", HTTP_GET, [](AsyncWebServerRequest *request){
serveMessage(request, 418, "418. I'm a teapot.", "(Tangible Embedded Advanced Project Of Twinkling)", 254); serveMessage(request, 418, "418. I'm a teapot.", "(Tangible Embedded Advanced Project Of Twinkling)", 254);
}); });

View File

@ -321,7 +321,6 @@ void serializeInfo(JsonObject root)
root["brand"] = "WLED"; root["brand"] = "WLED";
root["product"] = "DIY light"; root["product"] = "DIY light";
root["btype"] = "src";
root["mac"] = escapedMac; root["mac"] = escapedMac;
} }