2020-04-10 10:30:08 +00:00
# ifndef WLED_H
# define WLED_H
/*
Main sketch , global variable declarations
@ title WLED project sketch
2024-09-10 14:07:37 +00:00
@ version 0.15 .0 - b5
2020-04-10 10:30:08 +00:00
@ author Christian Schwinne
*/
// version code in format yymmddb (b = daily build)
2024-09-17 14:21:52 +00:00
# define VERSION 2409170
2020-04-10 10:30:08 +00:00
2020-11-17 23:54:41 +00:00
//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG
2020-09-09 07:51:04 +00:00
// ESP8266-01 (blue) got too little storage space to work with WLED. 0.10.2 is the last release supporting this unit.
2020-04-10 10:30:08 +00:00
2020-09-09 07:51:04 +00:00
// ESP8266-01 (black) has 1MB flash and can thus fit the whole program, although OTA update is not possible. Use 1M(128K SPIFFS).
2022-01-14 13:27:11 +00:00
// 2-step OTA may still be possible: https://github.com/Aircoookie/WLED/issues/2040#issuecomment-981111096
2021-04-03 17:43:08 +00:00
// Uncomment some of the following lines to disable features:
// Alternatively, with platformio pass your chosen flags to your custom build target in platformio_override.ini
2020-04-10 10:30:08 +00:00
// You are required to disable over-the-air updates:
//#define WLED_DISABLE_OTA // saves 14kb
2020-12-22 12:15:57 +00:00
// You can choose some of these features to disable:
2020-04-10 10:30:08 +00:00
//#define WLED_DISABLE_ALEXA // saves 11kb
//#define WLED_DISABLE_HUESYNC // saves 4kb
2022-10-03 17:17:28 +00:00
//#define WLED_DISABLE_INFRARED // saves 12kb, there is no pin left for this on ESP8266-01
2020-05-28 00:20:02 +00:00
# ifndef WLED_DISABLE_MQTT
# define WLED_ENABLE_MQTT // saves 12kb
# endif
2023-11-23 16:13:13 +00:00
# ifndef WLED_DISABLE_ADALIGHT // can be used to disable reading commands from serial RX pin (see issue #3128).
# define WLED_ENABLE_ADALIGHT // disable saves 5Kb (uses GPIO3 (RX) for serial). Related serial protocols: Adalight/TPM2, Improv, Serial JSON, Continuous Serial Streaming
2023-03-19 13:42:01 +00:00
# else
# undef WLED_ENABLE_ADALIGHT // disable has priority over enable
# endif
2024-09-14 20:30:56 +00:00
//#define WLED_ENABLE_DMX // uses 3.5kb
2024-08-22 15:08:51 +00:00
//#define WLED_ENABLE_JSONLIVE // peek LED output via /json/live (WS binary peek is always enabled)
2021-08-17 14:28:12 +00:00
# ifndef WLED_DISABLE_LOXONE
# define WLED_ENABLE_LOXONE // uses 1.2kb
# endif
2020-08-31 15:03:07 +00:00
# ifndef WLED_DISABLE_WEBSOCKETS
# define WLED_ENABLE_WEBSOCKETS
# endif
2020-04-10 10:30:08 +00:00
2023-11-23 16:13:13 +00:00
//#define WLED_DISABLE_ESPNOW // Removes dependence on esp now
2023-06-22 08:06:19 +00:00
2020-11-15 14:45:51 +00:00
# define WLED_ENABLE_FS_EDITOR // enable /edit page for editing FS content. Will also be disabled with OTA lock
2020-04-10 10:30:08 +00:00
// to toggle usb serial debug (un)comment the following line
//#define WLED_DEBUG
2020-09-13 20:00:47 +00:00
// filesystem specific debugging
2020-10-23 15:48:01 +00:00
//#define WLED_DEBUG_FS
2020-09-13 20:00:47 +00:00
2022-05-05 11:24:41 +00:00
# ifndef WLED_WATCHDOG_TIMEOUT
// 3 seconds should be enough to detect a lockup
2022-08-21 23:17:10 +00:00
// define WLED_WATCHDOG_TIMEOUT=0 to disable watchdog, default
# define WLED_WATCHDOG_TIMEOUT 0
2022-05-05 11:24:41 +00:00
# endif
2021-04-06 20:30:23 +00:00
//optionally disable brownout detector on ESP32.
//This is generally a terrible idea, but improves boot success on boards with a 3.3v regulator + cap setup that can't provide 400mA peaks
//#define WLED_DISABLE_BROWNOUT_DET
2021-04-21 22:41:36 +00:00
// Library inclusions.
2020-04-10 10:30:08 +00:00
# include <Arduino.h>
# ifdef ESP8266
# include <ESP8266WiFi.h>
# include <ESP8266mDNS.h>
# include <ESPAsyncTCP.h>
2020-09-13 20:00:47 +00:00
# include <LittleFS.h>
2020-04-10 10:30:08 +00:00
extern " C "
{
# include <user_interface.h>
}
2023-06-22 08:06:19 +00:00
# ifndef WLED_DISABLE_ESPNOW
# include <espnow.h>
2023-09-10 16:52:14 +00:00
# define WIFI_MODE_STA WIFI_STA
# define WIFI_MODE_AP WIFI_AP
# include <QuickEspNow.h>
2023-06-22 08:06:19 +00:00
# endif
2020-04-10 10:30:08 +00:00
# else // ESP32
2022-12-21 21:07:15 +00:00
# include <HardwareSerial.h> // ensure we have the correct "Serial" on new MCUs (depends on ARDUINO_USB_MODE and ARDUINO_USB_CDC_ON_BOOT)
2020-04-10 10:30:08 +00:00
# include <WiFi.h>
2020-11-13 17:25:13 +00:00
# include <ETH.h>
2020-04-10 10:30:08 +00:00
# include "esp_wifi.h"
# include <ESPmDNS.h>
# include <AsyncTCP.h>
2022-02-01 11:02:04 +00:00
# if LOROL_LITTLEFS
2022-01-14 16:19:33 +00:00
# ifndef CONFIG_LITTLEFS_FOR_IDF_3_2
# define CONFIG_LITTLEFS_FOR_IDF_3_2
# endif
# include <LITTLEFS.h>
# else
# include <LittleFS.h>
2021-02-26 23:20:31 +00:00
# endif
2022-05-05 11:24:41 +00:00
# include "esp_task_wdt.h"
2023-06-22 08:06:19 +00:00
# ifndef WLED_DISABLE_ESPNOW
# include <esp_now.h>
2023-09-10 16:52:14 +00:00
# include <QuickEspNow.h>
2023-06-22 08:06:19 +00:00
# endif
2020-04-10 10:30:08 +00:00
# endif
2022-08-07 14:43:29 +00:00
# include <Wire.h>
# include <SPI.h>
2020-04-10 10:30:08 +00:00
2020-11-17 07:57:05 +00:00
# include "src/dependencies/network/Network.h"
2020-11-13 17:25:13 +00:00
2020-11-17 23:54:41 +00:00
# ifdef WLED_USE_MY_CONFIG
# include "my_config.h"
# endif
2020-04-10 10:30:08 +00:00
# include <ESPAsyncWebServer.h>
2022-07-30 09:04:04 +00:00
# ifdef WLED_ADD_EEPROM_SUPPORT
# include <EEPROM.h>
# endif
2020-04-10 10:30:08 +00:00
# include <WiFiUdp.h>
# include <DNSServer.h>
# ifndef WLED_DISABLE_OTA
2021-09-28 21:27:40 +00:00
# define NO_OTA_PORT
2020-04-10 10:30:08 +00:00
# include <ArduinoOTA.h>
# endif
# include <SPIFFSEditor.h>
# include "src/dependencies/time/TimeLib.h"
# include "src/dependencies/timezone/Timezone.h"
2021-05-24 12:34:03 +00:00
# include "src/dependencies/toki/Toki.h"
2020-04-10 10:30:08 +00:00
# ifndef WLED_DISABLE_ALEXA
# define ESPALEXA_ASYNC
# define ESPALEXA_NO_SUBPAGE
2022-10-25 21:42:26 +00:00
# define ESPALEXA_MAXDEVICES 10
2020-04-10 10:30:08 +00:00
// #define ESPALEXA_DEBUG
# include "src/dependencies/espalexa/Espalexa.h"
2023-01-12 19:35:34 +00:00
# include "src/dependencies/espalexa/EspalexaDevice.h"
2020-04-10 10:30:08 +00:00
# endif
2020-04-21 20:56:14 +00:00
# ifdef WLED_ENABLE_DMX
2024-02-09 21:15:29 +00:00
# if defined(ESP8266) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S2)
2020-04-21 20:56:14 +00:00
# include "src/dependencies/dmx/ESPDMX.h"
2022-05-05 00:28:09 +00:00
# else //ESP32
# include "src/dependencies/dmx/SparkFunDMX.h"
2022-12-15 14:50:44 +00:00
# endif
2020-04-21 20:56:14 +00:00
# endif
2020-04-10 10:30:08 +00:00
# include "src/dependencies/e131/ESPAsyncE131.h"
2024-08-15 14:18:34 +00:00
# ifndef WLED_DISABLE_MQTT
2020-04-10 10:30:08 +00:00
# include "src/dependencies/async-mqtt-client/AsyncMqttClient.h"
2023-01-12 19:35:34 +00:00
# endif
2020-09-19 23:18:31 +00:00
# define ARDUINOJSON_DECODE_UNICODE 0
2020-04-10 10:30:08 +00:00
# include "src/dependencies/json/AsyncJson-v6.h"
# include "src/dependencies/json/ArduinoJson-v6.h"
2021-05-13 14:05:52 +00:00
// ESP32-WROVER features SPI RAM (aka PSRAM) which can be allocated using ps_malloc()
// we can create custom PSRAMDynamicJsonDocument to use such feature (replacing DynamicJsonDocument)
// The following is a construct to enable code to compile without it.
2024-02-06 13:47:20 +00:00
// There is a code that will still not use PSRAM though:
2021-05-13 14:05:52 +00:00
// AsyncJsonResponse is a derived class that implements DynamicJsonDocument (AsyncJson-v6.h)
2024-03-24 16:37:11 +00:00
# if defined(ARDUINO_ARCH_ESP32)
2024-03-28 15:03:06 +00:00
extern bool psramSafe ;
2021-05-13 14:05:52 +00:00
struct PSRAM_Allocator {
void * allocate ( size_t size ) {
2024-03-28 15:03:06 +00:00
if ( psramSafe & & psramFound ( ) ) return ps_malloc ( size ) ; // use PSRAM if it exists
else return malloc ( size ) ; // fallback
2021-05-13 14:05:52 +00:00
}
2023-05-21 12:33:25 +00:00
void * reallocate ( void * ptr , size_t new_size ) {
2024-03-28 15:03:06 +00:00
if ( psramSafe & & psramFound ( ) ) return ps_realloc ( ptr , new_size ) ; // use PSRAM if it exists
else return realloc ( ptr , new_size ) ; // fallback
2023-05-21 12:33:25 +00:00
}
2021-05-13 14:05:52 +00:00
void deallocate ( void * pointer ) {
free ( pointer ) ;
}
} ;
using PSRAMDynamicJsonDocument = BasicJsonDocument < PSRAM_Allocator > ;
# else
# define PSRAMDynamicJsonDocument DynamicJsonDocument
# endif
2024-01-28 13:19:46 +00:00
# define FASTLED_INTERNAL //remove annoying pragma messages
# define USE_GET_MILLISECOND_TIMER
2024-01-27 19:36:59 +00:00
# include "FastLED.h"
2020-04-10 10:30:08 +00:00
# include "const.h"
# include "fcn_declare.h"
2021-01-22 15:17:18 +00:00
# include "NodeStruct.h"
2021-01-15 23:50:43 +00:00
# include "pin_manager.h"
2021-01-21 00:21:16 +00:00
# include "bus_manager.h"
2022-07-10 20:23:25 +00:00
# include "FX.h"
2020-04-10 10:30:08 +00:00
# ifndef CLIENT_SSID
# define CLIENT_SSID DEFAULT_CLIENT_SSID
# endif
# ifndef CLIENT_PASS
# define CLIENT_PASS ""
# endif
2023-05-31 15:35:43 +00:00
# ifndef MDNS_NAME
# define MDNS_NAME DEFAULT_MDNS_NAME
# endif
2022-11-20 14:55:38 +00:00
# if defined(WLED_AP_PASS) && !defined(WLED_AP_SSID)
# error WLED_AP_PASS is defined but WLED_AP_SSID is still the default. \
Please change WLED_AP_SSID to something unique .
# endif
# ifndef WLED_AP_SSID
# define WLED_AP_SSID DEFAULT_AP_SSID
# endif
# ifndef WLED_AP_PASS
# define WLED_AP_PASS DEFAULT_AP_PASS
# endif
2020-11-09 10:09:47 +00:00
# ifndef SPIFFS_EDITOR_AIRCOOOKIE
2020-11-02 23:35:04 +00:00
# error You are not using the Aircoookie fork of the ESPAsyncWebserver library.\
Using upstream puts your WiFi password at risk of being served by the filesystem . \
Comment out this error message to build regardless .
2020-11-09 10:09:47 +00:00
# endif
2020-11-02 23:35:04 +00:00
2020-04-10 10:30:08 +00:00
# ifndef WLED_DISABLE_INFRARED
# include <IRremoteESP8266.h>
# include <IRrecv.h>
# include <IRutils.h>
# endif
2020-11-08 22:44:10 +00:00
//Filesystem to use for preset and config files. SPIFFS or LittleFS on ESP8266, SPIFFS only on ESP32 (now using LITTLEFS port by lorol)
2020-09-13 22:31:38 +00:00
# ifdef ESP8266
# define WLED_FS LittleFS
# else
2022-02-01 11:02:04 +00:00
# if LOROL_LITTLEFS
2022-01-14 16:19:33 +00:00
# define WLED_FS LITTLEFS
# else
# define WLED_FS LittleFS
# endif
2020-09-13 22:31:38 +00:00
# endif
2020-09-09 07:51:04 +00:00
2020-04-10 10:30:08 +00:00
// GLOBAL VARIABLES
// both declared and defined in header (solution from http://www.keil.com/support/docs/1868.htm)
//
//e.g. byte test = 2 becomes WLED_GLOBAL byte test _INIT(2);
// int arr[]{0,1,2} becomes WLED_GLOBAL int arr[] _INIT_N(({0,1,2}));
# ifndef WLED_DEFINE_GLOBAL_VARS
2024-04-23 17:05:49 +00:00
# define WLED_GLOBAL extern
# define _INIT(x)
# define _INIT_N(x)
# define _INIT_PROGMEM(x)
2020-04-10 10:30:08 +00:00
# else
2024-04-23 17:05:49 +00:00
# define WLED_GLOBAL
# define _INIT(x) = x
//needed to ignore commas in array definitions
# define UNPACK( ... ) __VA_ARGS__
# define _INIT_N(x) UNPACK x
# define _INIT_PROGMEM(x) PROGMEM = x
2020-04-10 10:30:08 +00:00
# endif
2021-04-21 22:41:36 +00:00
# define STRINGIFY(X) #X
# define TOSTRING(X) STRINGIFY(X)
# ifndef WLED_VERSION
2024-04-23 17:05:49 +00:00
# define WLED_VERSION dev
# endif
# ifndef WLED_RELEASE_NAME
# define WLED_RELEASE_NAME dev_release
2021-04-21 22:41:36 +00:00
# endif
2020-04-10 10:30:08 +00:00
// Global Variable definitions
2021-04-21 22:41:36 +00:00
WLED_GLOBAL char versionString [ ] _INIT ( TOSTRING ( WLED_VERSION ) ) ;
2024-06-14 20:12:09 +00:00
WLED_GLOBAL char releaseString [ ] _INIT ( TOSTRING ( WLED_RELEASE_NAME ) ) ; // somehow this will not work if using "const char releaseString[]
2023-09-26 18:34:52 +00:00
# define WLED_CODENAME "Kōsen"
2020-04-10 10:30:08 +00:00
// AP and OTA default passwords (for maximum security change them!)
2022-11-20 14:55:38 +00:00
WLED_GLOBAL char apPass [ 65 ] _INIT ( WLED_AP_PASS ) ;
2020-04-10 10:30:08 +00:00
WLED_GLOBAL char otaPass [ 33 ] _INIT ( DEFAULT_OTA_PASS ) ;
2021-06-29 22:45:36 +00:00
// Hardware and pin config
2021-01-16 23:20:31 +00:00
# ifndef BTNPIN
2024-03-05 15:27:28 +00:00
# define BTNPIN 0,-1
# endif
# ifndef BTNTYPE
# define BTNTYPE BTN_TYPE_PUSH,BTN_TYPE_NONE
2021-01-16 23:20:31 +00:00
# endif
# ifndef RLYPIN
2022-02-07 23:15:24 +00:00
WLED_GLOBAL int8_t rlyPin _INIT ( - 1 ) ;
2021-01-16 23:20:31 +00:00
# else
WLED_GLOBAL int8_t rlyPin _INIT ( RLYPIN ) ;
# endif
2021-03-04 13:24:25 +00:00
//Relay mode (1 = active high, 0 = active low, flipped in cfg.json)
2021-01-16 23:20:31 +00:00
# ifndef RLYMDE
2021-03-04 13:24:25 +00:00
WLED_GLOBAL bool rlyMde _INIT ( true ) ;
2021-01-16 23:20:31 +00:00
# else
WLED_GLOBAL bool rlyMde _INIT ( RLYMDE ) ;
# endif
2024-04-21 11:37:07 +00:00
//Use open drain (floating pin) when relay should be off
# ifndef RLYODRAIN
WLED_GLOBAL bool rlyOpenDrain _INIT ( false ) ;
# else
WLED_GLOBAL bool rlyOpenDrain _INIT ( RLYODRAIN ) ;
# endif
2021-01-16 23:20:31 +00:00
# ifndef IRPIN
2024-03-05 15:27:28 +00:00
# define IRPIN -1
# endif
# ifndef IRTYPE
# define IRTYPE 0
2021-01-16 23:20:31 +00:00
# endif
2020-04-10 10:30:08 +00:00
2022-09-10 22:16:48 +00:00
# if defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S2) || (defined(RX) && defined(TX))
// use RX/TX as set by the framework - these boards do _not_ have RX=3 and TX=1
constexpr uint8_t hardwareRX = RX ;
constexpr uint8_t hardwareTX = TX ;
# else
// use defaults for RX/TX
constexpr uint8_t hardwareRX = 3 ;
constexpr uint8_t hardwareTX = 1 ;
# endif
2021-04-21 22:41:36 +00:00
//WLED_GLOBAL byte presetToApply _INIT(0);
2020-05-05 07:01:09 +00:00
2020-04-10 10:30:08 +00:00
WLED_GLOBAL char ntpServerName [ 33 ] _INIT ( " 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)
2024-01-20 23:30:15 +00:00
WLED_GLOBAL std : : vector < WiFiConfig > multiWiFi ;
WLED_GLOBAL IPAddress dnsAddress _INIT_N ( ( ( 8 , 8 , 8 , 8 ) ) ) ; // Google's DNS
WLED_GLOBAL char cmDNS [ 33 ] _INIT ( MDNS_NAME ) ; // mDNS address (*.local, replaced by wledXXXXXX if default is used)
WLED_GLOBAL char apSSID [ 33 ] _INIT ( " " ) ; // AP off by default (unless setup)
2024-08-17 13:09:41 +00:00
# ifdef WLED_SAVE_RAM
typedef class WiFiOptions {
public :
struct {
uint8_t selectedWiFi : 4 ; // max 16 SSIDs
uint8_t apChannel : 4 ;
2024-08-22 15:08:51 +00:00
uint8_t apHide : 3 ;
2024-08-17 13:09:41 +00:00
uint8_t apBehavior : 3 ;
bool noWifiSleep : 1 ;
bool force802_3g : 1 ;
} ;
WiFiOptions ( uint8_t s , uint8_t c , bool h , uint8_t b , bool sl , bool g ) {
selectedWiFi = s ;
apChannel = c ;
apHide = h ;
apBehavior = b ;
noWifiSleep = sl ;
force802_3g = g ;
}
} __attribute__ ( ( aligned ( 1 ) , packed ) ) wifi_options_t ;
# ifdef ARDUINO_ARCH_ESP32
WLED_GLOBAL wifi_options_t wifiOpt _INIT_N ( ( { 0 , 1 , false , AP_BEHAVIOR_BOOT_NO_CONN , true , false } ) ) ;
# else
WLED_GLOBAL wifi_options_t wifiOpt _INIT_N ( ( { 0 , 1 , false , AP_BEHAVIOR_BOOT_NO_CONN , false , false } ) ) ;
# endif
# define selectedWiFi wifiOpt.selectedWiFi
# define apChannel wifiOpt.apChannel
# define apHide wifiOpt.apHide
# define apBehavior wifiOpt.apBehavior
# define noWifiSleep wifiOpt.noWifiSleep
# define force802_3g wifiOpt.force802_3g
# else
WLED_GLOBAL uint8_t selectedWiFi _INIT ( 0 ) ;
2024-01-20 23:30:15 +00:00
WLED_GLOBAL byte apChannel _INIT ( 1 ) ; // 2.4GHz WiFi AP channel (1-13)
WLED_GLOBAL byte apHide _INIT ( 0 ) ; // hidden AP SSID
WLED_GLOBAL byte apBehavior _INIT ( AP_BEHAVIOR_BOOT_NO_CONN ) ; // access point opens when no connection after boot by default
2024-08-17 13:09:41 +00:00
# ifdef ARDUINO_ARCH_ESP32
2024-01-20 23:30:15 +00:00
WLED_GLOBAL bool noWifiSleep _INIT ( true ) ; // disabling modem sleep modes will increase heat output and power usage, but may help with connection issues
2024-08-17 13:09:41 +00:00
# else
2021-06-09 10:57:16 +00:00
WLED_GLOBAL bool noWifiSleep _INIT ( false ) ;
2024-08-17 13:09:41 +00:00
# endif
WLED_GLOBAL bool force802_3g _INIT ( false ) ;
# endif // WLED_SAVE_RAM
2024-06-23 12:08:18 +00:00
# ifdef ARDUINO_ARCH_ESP32
# if defined(LOLIN_WIFI_FIX) && (defined(ARDUINO_ARCH_ESP32C3) || defined(ARDUINO_ARCH_ESP32S2) || defined(ARDUINO_ARCH_ESP32S3))
WLED_GLOBAL uint8_t txPower _INIT ( WIFI_POWER_8_5dBm ) ;
# else
WLED_GLOBAL uint8_t txPower _INIT ( WIFI_POWER_19_5dBm ) ;
# endif
# endif
2024-01-20 23:30:15 +00:00
# define WLED_WIFI_CONFIGURED (strlen(multiWiFi[0].clientSSID) >= 1 && strcmp(multiWiFi[0].clientSSID, DEFAULT_CLIENT_SSID) != 0)
2021-06-09 10:57:16 +00:00
2021-01-15 09:37:45 +00:00
# ifdef WLED_USE_ETHERNET
2021-02-20 09:18:37 +00:00
# ifdef WLED_ETH_DEFAULT // default ethernet board type if specified
2021-02-20 08:54:54 +00:00
WLED_GLOBAL int ethernetType _INIT ( WLED_ETH_DEFAULT ) ; // ethernet board type
# else
2021-02-20 09:18:37 +00:00
WLED_GLOBAL int ethernetType _INIT ( WLED_ETH_NONE ) ; // use none for ethernet board type if default not defined
2021-04-21 22:41:36 +00:00
# endif
2021-01-15 09:37:45 +00:00
# endif
2020-04-10 10:30:08 +00:00
// LED CONFIG
2021-04-15 08:55:22 +00:00
WLED_GLOBAL bool turnOnAtBoot _INIT ( true ) ; // turn on LEDs at power-up
WLED_GLOBAL byte bootPreset _INIT ( 0 ) ; // save preset to load after power-up
2020-04-10 10:30:08 +00:00
2021-09-10 23:17:42 +00:00
//if true, a segment per bus will be created on boot and LED settings save
//if false, only one segment spanning the total LEDs is created,
//but not on LED settings save if there is more than one segment currently
2023-07-05 21:57:46 +00:00
# ifdef ESP8266
WLED_GLOBAL bool useGlobalLedBuffer _INIT ( false ) ; // double buffering disabled on ESP8266
# else
WLED_GLOBAL bool useGlobalLedBuffer _INIT ( true ) ; // double buffering enabled on ESP32
# endif
2024-03-28 15:03:06 +00:00
# ifdef WLED_USE_IC_CCT
WLED_GLOBAL bool cctICused _INIT ( true ) ; // CCT IC used (Athom 15W bulbs)
# else
WLED_GLOBAL bool cctICused _INIT ( false ) ; // CCT IC used (Athom 15W bulbs)
# endif
2023-06-30 19:12:59 +00:00
WLED_GLOBAL bool gammaCorrectCol _INIT ( true ) ; // use gamma correction on colors
WLED_GLOBAL bool gammaCorrectBri _INIT ( false ) ; // use gamma correction on brightness
WLED_GLOBAL float gammaCorrectVal _INIT ( 2.8f ) ; // gamma correction value
2021-09-10 23:17:42 +00:00
2020-04-10 10:30:08 +00:00
WLED_GLOBAL byte col [ ] _INIT_N ( ( { 255 , 160 , 0 , 0 } ) ) ; // current RGB(W) primary color. col[] should be updated if you want to change the color.
WLED_GLOBAL byte colSec [ ] _INIT_N ( ( { 0 , 0 , 0 , 0 } ) ) ; // current RGB(W) secondary color
WLED_GLOBAL byte nightlightTargetBri _INIT ( 0 ) ; // brightness after nightlight is over
WLED_GLOBAL byte nightlightDelayMins _INIT ( 60 ) ;
2020-06-22 10:30:31 +00:00
WLED_GLOBAL byte nightlightMode _INIT ( NL_MODE_FADE ) ; // See const.h for available modes. Was nightlightFade
2020-04-10 10:30:08 +00:00
WLED_GLOBAL byte briMultiplier _INIT ( 100 ) ; // % of brightness to set (to limit power, if you set it to 50 and set bri to 255, actual brightness will be 127)
// User Interface CONFIG
2022-03-15 08:55:23 +00:00
# ifndef SERVERNAME
WLED_GLOBAL char serverDescription [ 33 ] _INIT ( " WLED " ) ; // Name of module - use default
# else
WLED_GLOBAL char serverDescription [ 33 ] _INIT ( SERVERNAME ) ; // use predefined name
# endif
2021-08-10 15:11:17 +00:00
WLED_GLOBAL bool simplifiedUI _INIT ( false ) ; // enable simplified UI
2023-11-14 20:19:38 +00:00
WLED_GLOBAL byte cacheInvalidate _INIT ( 0 ) ; // used to invalidate browser cache
2020-04-10 10:30:08 +00:00
// Sync CONFIG
2021-02-24 19:23:32 +00:00
WLED_GLOBAL NodesMap Nodes ;
2021-03-13 21:04:37 +00:00
WLED_GLOBAL bool nodeListEnabled _INIT ( true ) ;
WLED_GLOBAL bool nodeBroadcastEnabled _INIT ( true ) ;
2021-02-24 19:23:32 +00:00
2024-03-05 15:27:28 +00:00
# ifndef WLED_DISABLE_INFRARED
WLED_GLOBAL int8_t irPin _INIT ( IRPIN ) ;
2022-02-09 16:16:22 +00:00
WLED_GLOBAL byte irEnabled _INIT ( IRTYPE ) ; // Infrared receiver
# endif
2024-03-05 15:27:28 +00:00
WLED_GLOBAL bool irApplyToAllSelected _INIT ( true ) ; //apply IR or ESP-NOW to all selected segments
2020-04-10 10:30:08 +00:00
2024-08-17 13:09:41 +00:00
# ifndef WLED_DISABLE_ALEXA
2020-05-08 22:29:42 +00:00
WLED_GLOBAL bool alexaEnabled _INIT ( false ) ; // enable device discovery by Amazon Echo
2020-04-10 10:30:08 +00:00
WLED_GLOBAL char alexaInvocationName [ 33 ] _INIT ( " Light " ) ; // speech control name of device. Choose something voice-to-text can understand
2022-10-25 21:42:26 +00:00
WLED_GLOBAL byte alexaNumPresets _INIT ( 0 ) ; // number of presets to expose to Alexa, starting from preset 1, up to 9
2024-08-17 13:09:41 +00:00
# endif
2020-04-10 10:30:08 +00:00
WLED_GLOBAL uint16_t realtimeTimeoutMs _INIT ( 2500 ) ; // ms timeout of realtime mode before returning to normal mode
WLED_GLOBAL int arlsOffset _INIT ( 0 ) ; // realtime LED offset
WLED_GLOBAL bool arlsDisableGammaCorrection _INIT ( true ) ; // activate if gamma correction is handled by the source
WLED_GLOBAL bool arlsForceMaxBri _INIT ( false ) ; // enable to force max brightness if source has very dark colors that would be black
2020-04-21 20:56:14 +00:00
# ifdef WLED_ENABLE_DMX
2024-02-09 21:15:29 +00:00
# if defined(ESP8266) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S2)
2022-05-05 00:28:09 +00:00
WLED_GLOBAL DMXESPSerial dmx ;
# else //ESP32
2022-12-15 14:50:44 +00:00
WLED_GLOBAL SparkFunDMX dmx ;
# endif
2024-02-09 21:15:29 +00:00
WLED_GLOBAL uint16_t e131ProxyUniverse _INIT ( 0 ) ; // output this E1.31 (sACN) / ArtNet universe via MAX485 (0 = disabled)
// dmx CONFIG
WLED_GLOBAL byte DMXChannels _INIT ( 7 ) ; // number of channels per fixture
WLED_GLOBAL byte DMXFixtureMap [ 15 ] _INIT_N ( ( { 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.
WLED_GLOBAL uint16_t DMXGap _INIT ( 10 ) ; // gap between the fixtures. makes addressing easier because you don't have to memorize odd numbers when climbing up onto a rig.
WLED_GLOBAL uint16_t DMXStart _INIT ( 10 ) ; // start address of the first fixture
WLED_GLOBAL uint16_t DMXStartLED _INIT ( 0 ) ; // LED from which DMX fixtures start
2020-04-21 20:56:14 +00:00
# endif
2024-02-06 13:47:20 +00:00
WLED_GLOBAL uint16_t e131Universe _INIT ( 1 ) ; // settings for E1.31 (sACN) protocol (only DMX_MODE_MULTIPLE_* can span over consecutive universes)
2020-04-12 22:42:27 +00:00
WLED_GLOBAL uint16_t e131Port _INIT ( 5568 ) ; // DMX in port. E1.31 default is 5568, Art-Net is 6454
2023-02-21 16:13:15 +00:00
WLED_GLOBAL byte e131Priority _INIT ( 0 ) ; // E1.31 port priority (if != 0 priority handling is active)
WLED_GLOBAL E131Priority highPriority _INIT ( 3 ) ; // E1.31 highest priority tracking, init = timeout in seconds
2020-04-10 10:30:08 +00:00
WLED_GLOBAL byte DMXMode _INIT ( DMX_MODE_MULTIPLE_RGB ) ; // DMX mode (s.a.)
WLED_GLOBAL uint16_t DMXAddress _INIT ( 1 ) ; // DMX start address of fixture, a.k.a. first Channel [for E1.31 (sACN) protocol]
2022-11-19 13:10:40 +00:00
WLED_GLOBAL uint16_t DMXSegmentSpacing _INIT ( 0 ) ; // Number of void/unused channels between each segments DMX channels
2020-04-10 10:30:08 +00:00
WLED_GLOBAL byte e131LastSequenceNumber [ E131_MAX_UNIVERSE_COUNT ] ; // to detect packet loss
WLED_GLOBAL bool e131Multicast _INIT ( false ) ; // multicast or unicast
WLED_GLOBAL bool e131SkipOutOfSequence _INIT ( false ) ; // freeze instead of flickering
2022-09-22 18:34:46 +00:00
WLED_GLOBAL uint16_t pollReplyCount _INIT ( 0 ) ; // count number of replies for ArtPoll node report
2020-04-10 10:30:08 +00:00
2023-01-12 19:35:34 +00:00
// mqtt
WLED_GLOBAL unsigned long lastMqttReconnectAttempt _INIT ( 0 ) ; // used for other periodic tasks too
# ifndef WLED_DISABLE_MQTT
2023-09-01 23:05:45 +00:00
# ifndef MQTT_MAX_TOPIC_LEN
# define MQTT_MAX_TOPIC_LEN 32
# endif
# ifndef MQTT_MAX_SERVER_LEN
# define MQTT_MAX_SERVER_LEN 32
# endif
2023-01-12 19:35:34 +00:00
WLED_GLOBAL AsyncMqttClient * mqtt _INIT ( NULL ) ;
2020-04-10 10:30:08 +00:00
WLED_GLOBAL bool mqttEnabled _INIT ( false ) ;
2023-01-12 19:35:34 +00:00
WLED_GLOBAL char mqttStatusTopic [ 40 ] _INIT ( " " ) ; // this must be global because of async handlers
2023-09-01 23:05:45 +00:00
WLED_GLOBAL char mqttDeviceTopic [ MQTT_MAX_TOPIC_LEN + 1 ] _INIT ( " " ) ; // main MQTT topic (individual per device, default is wled/mac)
WLED_GLOBAL char mqttGroupTopic [ MQTT_MAX_TOPIC_LEN + 1 ] _INIT ( " wled/all " ) ; // second MQTT topic (for example to group devices)
WLED_GLOBAL char mqttServer [ MQTT_MAX_SERVER_LEN + 1 ] _INIT ( " " ) ; // both domains and IPs should work (no SSL)
2020-04-10 10:30:08 +00:00
WLED_GLOBAL char mqttUser [ 41 ] _INIT ( " " ) ; // optional: username for MQTT auth
2021-06-29 23:23:35 +00:00
WLED_GLOBAL char mqttPass [ 65 ] _INIT ( " " ) ; // optional: password for MQTT auth
2020-04-10 10:30:08 +00:00
WLED_GLOBAL char mqttClientID [ 41 ] _INIT ( " " ) ; // override the client ID
WLED_GLOBAL uint16_t mqttPort _INIT ( 1883 ) ;
2023-05-28 20:50:19 +00:00
WLED_GLOBAL bool retainMqttMsg _INIT ( false ) ; // retain brightness and color
2023-01-12 19:35:34 +00:00
# define WLED_MQTT_CONNECTED (mqtt != nullptr && mqtt->connected())
# else
# define WLED_MQTT_CONNECTED false
# endif
2020-04-10 10:30:08 +00:00
2021-05-07 09:51:48 +00:00
# ifndef WLED_DISABLE_HUESYNC
2020-04-10 10:30:08 +00:00
WLED_GLOBAL bool huePollingEnabled _INIT ( false ) ; // poll hue bridge for light state
WLED_GLOBAL uint16_t huePollIntervalMs _INIT ( 2500 ) ; // low values (< 1sec) may cause lag but offer quicker response
WLED_GLOBAL char hueApiKey [ 47 ] _INIT ( " api " ) ; // key token will be obtained from bridge
WLED_GLOBAL byte huePollLightId _INIT ( 1 ) ; // ID of hue lamp to sync to. Find the ID in the hue app ("about" section)
2021-02-27 00:16:06 +00:00
WLED_GLOBAL IPAddress hueIP _INIT_N ( ( ( 0 , 0 , 0 , 0 ) ) ) ; // IP address of the bridge
2020-04-10 10:30:08 +00:00
WLED_GLOBAL bool hueApplyOnOff _INIT ( true ) ;
WLED_GLOBAL bool hueApplyBri _INIT ( true ) ;
WLED_GLOBAL bool hueApplyColor _INIT ( true ) ;
2021-05-07 09:51:48 +00:00
# endif
2020-04-10 10:30:08 +00:00
2022-02-01 19:02:46 +00:00
WLED_GLOBAL uint16_t serialBaud _INIT ( 1152 ) ; // serial baud rate, multiply by 100
2024-09-17 14:21:52 +00:00
WLED_GLOBAL bool serialCanRX _INIT ( false ) ;
WLED_GLOBAL bool serialCanTX _INIT ( false ) ;
2022-02-01 19:02:46 +00:00
2023-06-22 08:06:19 +00:00
# ifndef WLED_DISABLE_ESPNOW
2023-09-10 16:52:14 +00:00
WLED_GLOBAL bool enableESPNow _INIT ( false ) ; // global on/off for ESP-NOW
WLED_GLOBAL byte statusESPNow _INIT ( ESP_NOW_STATE_UNINIT ) ; // state of ESP-NOW stack (0 uninitialised, 1 initialised, 2 error)
WLED_GLOBAL bool useESPNowSync _INIT ( false ) ; // use ESP-NOW wireless technology for sync
WLED_GLOBAL char linked_remote [ 13 ] _INIT ( " " ) ; // MAC of ESP-NOW remote (Wiz Mote)
WLED_GLOBAL char last_signal_src [ 13 ] _INIT ( " " ) ; // last seen ESP-NOW sender
2023-06-22 08:06:19 +00:00
# endif
2020-04-10 10:30:08 +00:00
// Time CONFIG
2024-01-13 12:06:00 +00:00
# ifndef WLED_NTP_ENABLED
# define WLED_NTP_ENABLED false
# endif
# ifndef WLED_TIMEZONE
# define WLED_TIMEZONE 0
# endif
# ifndef WLED_UTC_OFFSET
# define WLED_UTC_OFFSET 0
# endif
WLED_GLOBAL bool ntpEnabled _INIT ( WLED_NTP_ENABLED ) ; // get internet time. Only required if you use clock overlays or time-activated macros
WLED_GLOBAL bool useAMPM _INIT ( false ) ; // 12h/24h clock format
WLED_GLOBAL byte currentTimezone _INIT ( WLED_TIMEZONE ) ; // Timezone ID. Refer to timezones array in wled10_ntp.ino
WLED_GLOBAL int utcOffsetSecs _INIT ( WLED_UTC_OFFSET ) ; // Seconds to offset from UTC before timzone calculation
2020-04-10 10:30:08 +00:00
2022-03-06 23:11:43 +00:00
WLED_GLOBAL byte overlayCurrent _INIT ( 0 ) ; // 0: no overlay 1: analog clock 2: was single-digit clock 3: was cronixie
2021-10-11 00:19:33 +00:00
WLED_GLOBAL byte overlayMin _INIT ( 0 ) , overlayMax _INIT ( DEFAULT_LED_COUNT - 1 ) ; // boundaries of overlay mode
2020-04-10 10:30:08 +00:00
WLED_GLOBAL byte analogClock12pixel _INIT ( 0 ) ; // The pixel in your strip where "midnight" would be
WLED_GLOBAL bool analogClockSecondsTrail _INIT ( false ) ; // Display seconds as trail of LEDs instead of a single pixel
WLED_GLOBAL bool analogClock5MinuteMarks _INIT ( false ) ; // Light pixels at every 5-minute position
2023-10-26 21:36:29 +00:00
WLED_GLOBAL bool analogClockSolidBlack _INIT ( false ) ; // Show clock overlay only if all LEDs are solid black (effect is 0 and color is black)
2020-04-10 10:30:08 +00:00
WLED_GLOBAL bool countdownMode _INIT ( false ) ; // Clock will count down towards date
WLED_GLOBAL byte countdownYear _INIT ( 20 ) , countdownMonth _INIT ( 1 ) ; // Countdown target date, year is last two digits
WLED_GLOBAL byte countdownDay _INIT ( 1 ) , countdownHour _INIT ( 0 ) ;
WLED_GLOBAL byte countdownMin _INIT ( 0 ) , countdownSec _INIT ( 0 ) ;
WLED_GLOBAL byte macroNl _INIT ( 0 ) ; // after nightlight delay over
WLED_GLOBAL byte macroCountdown _INIT ( 0 ) ;
WLED_GLOBAL byte macroAlexaOn _INIT ( 0 ) , macroAlexaOff _INIT ( 0 ) ;
2021-05-20 13:49:26 +00:00
WLED_GLOBAL byte macroButton [ WLED_MAX_BUTTONS ] _INIT ( { 0 } ) ;
WLED_GLOBAL byte macroLongPress [ WLED_MAX_BUTTONS ] _INIT ( { 0 } ) ;
WLED_GLOBAL byte macroDoublePress [ WLED_MAX_BUTTONS ] _INIT ( { 0 } ) ;
2020-04-10 10:30:08 +00:00
// Security CONFIG
WLED_GLOBAL bool otaLock _INIT ( false ) ; // prevents OTA firmware updates without password. ALWAYS enable if system exposed to any public networks
WLED_GLOBAL bool wifiLock _INIT ( false ) ; // prevents access to WiFi settings when OTA lock is enabled
WLED_GLOBAL bool aOtaEnabled _INIT ( true ) ; // ArduinoOTA allows easy updates directly from the IDE. Careful, it does not auto-disable when OTA lock is on
2022-03-01 22:37:28 +00:00
WLED_GLOBAL char settingsPIN [ 5 ] _INIT ( " " ) ; // PIN for settings pages
WLED_GLOBAL bool correctPIN _INIT ( true ) ;
WLED_GLOBAL unsigned long lastEditTime _INIT ( 0 ) ;
2020-04-10 10:30:08 +00:00
WLED_GLOBAL uint16_t userVar0 _INIT ( 0 ) , userVar1 _INIT ( 0 ) ; //available for use in usermod
// internal global variable declarations
// wifi
WLED_GLOBAL bool apActive _INIT ( false ) ;
WLED_GLOBAL bool forceReconnect _INIT ( false ) ;
2023-07-12 18:52:34 +00:00
WLED_GLOBAL unsigned long lastReconnectAttempt _INIT ( 0 ) ;
2020-04-10 10:30:08 +00:00
WLED_GLOBAL bool interfacesInited _INIT ( false ) ;
WLED_GLOBAL bool wasConnected _INIT ( false ) ;
// color
WLED_GLOBAL byte lastRandomIndex _INIT ( 0 ) ; // used to save last random color so the new one is not the same
// transitions
2024-02-06 10:06:23 +00:00
WLED_GLOBAL bool fadeTransition _INIT ( true ) ; // enable crossfading brightness/color
WLED_GLOBAL bool modeBlending _INIT ( true ) ; // enable effect blending
WLED_GLOBAL bool transitionActive _INIT ( false ) ;
WLED_GLOBAL uint16_t transitionDelay _INIT ( 750 ) ; // global transition duration
WLED_GLOBAL uint16_t transitionDelayDefault _INIT ( 750 ) ; // default transition time (stored in cfg.json)
2020-04-10 10:30:08 +00:00
WLED_GLOBAL unsigned long transitionStartTime ;
2024-02-06 10:06:23 +00:00
WLED_GLOBAL float tperLast _INIT ( 0.0f ) ; // crossfade transition progress, 0.0f - 1.0f
WLED_GLOBAL bool jsonTransitionOnce _INIT ( false ) ; // flag to override transitionDelay (playlist, JSON API: "live" & "seg":{"i"} & "tt")
WLED_GLOBAL uint8_t randomPaletteChangeTime _INIT ( 5 ) ; // amount of time [s] between random palette changes (min: 1s, max: 255s)
WLED_GLOBAL bool useHarmonicRandomPalette _INIT ( true ) ; // use *harmonic* random palette generation (nicer looking) or truly random
2020-04-10 10:30:08 +00:00
// nightlight
WLED_GLOBAL bool nightlightActive _INIT ( false ) ;
WLED_GLOBAL bool nightlightActiveOld _INIT ( false ) ;
WLED_GLOBAL uint32_t nightlightDelayMs _INIT ( 10 ) ;
WLED_GLOBAL byte nightlightDelayMinsDefault _INIT ( nightlightDelayMins ) ;
WLED_GLOBAL unsigned long nightlightStartTime ;
2024-02-09 21:15:29 +00:00
WLED_GLOBAL unsigned long lastNlUpdate ;
2020-04-10 10:30:08 +00:00
WLED_GLOBAL byte briNlT _INIT ( 0 ) ; // current nightlight brightness
WLED_GLOBAL byte colNlT [ ] _INIT_N ( ( { 0 , 0 , 0 , 0 } ) ) ; // current nightlight color
// brightness
WLED_GLOBAL unsigned long lastOnTime _INIT ( 0 ) ;
2022-03-31 19:44:11 +00:00
WLED_GLOBAL bool offMode _INIT ( ! turnOnAtBoot ) ;
2024-08-17 13:09:41 +00:00
WLED_GLOBAL byte briS _INIT ( 128 ) ; // default brightness
2022-03-31 19:44:11 +00:00
WLED_GLOBAL byte bri _INIT ( briS ) ; // global brightness (set)
2024-02-06 13:47:20 +00:00
WLED_GLOBAL byte briOld _INIT ( 0 ) ; // global brightness while in transition loop (previous iteration)
2022-03-31 19:44:11 +00:00
WLED_GLOBAL byte briT _INIT ( 0 ) ; // global brightness during transition
WLED_GLOBAL byte briLast _INIT ( 128 ) ; // brightness before turned off. Used for toggle function
2024-03-01 13:36:07 +00:00
WLED_GLOBAL byte whiteLast _INIT ( 128 ) ; // white channel before turned off. Used for toggle function in ir.cpp
2020-04-10 10:30:08 +00:00
// button
2024-03-05 15:27:28 +00:00
WLED_GLOBAL int8_t btnPin [ WLED_MAX_BUTTONS ] _INIT ( { BTNPIN } ) ;
WLED_GLOBAL byte buttonType [ WLED_MAX_BUTTONS ] _INIT ( { BTNTYPE } ) ;
2021-07-01 18:51:52 +00:00
WLED_GLOBAL bool buttonPublishMqtt _INIT ( false ) ;
2021-05-20 13:49:26 +00:00
WLED_GLOBAL bool buttonPressedBefore [ WLED_MAX_BUTTONS ] _INIT ( { false } ) ;
WLED_GLOBAL bool buttonLongPressed [ WLED_MAX_BUTTONS ] _INIT ( { false } ) ;
WLED_GLOBAL unsigned long buttonPressedTime [ WLED_MAX_BUTTONS ] _INIT ( { 0 } ) ;
WLED_GLOBAL unsigned long buttonWaitTime [ WLED_MAX_BUTTONS ] _INIT ( { 0 } ) ;
2022-11-26 22:56:55 +00:00
WLED_GLOBAL bool disablePullUp _INIT ( false ) ;
2021-05-20 13:49:26 +00:00
WLED_GLOBAL byte touchThreshold _INIT ( TOUCH_THRESHOLD ) ;
2020-04-10 10:30:08 +00:00
// notifications
2023-09-10 16:52:14 +00:00
WLED_GLOBAL bool sendNotifications _INIT ( false ) ; // master notification switch
WLED_GLOBAL bool sendNotificationsRT _INIT ( false ) ; // master notification switch (runtime)
2020-04-10 10:30:08 +00:00
WLED_GLOBAL unsigned long notificationSentTime _INIT ( 0 ) ;
2021-07-09 16:54:28 +00:00
WLED_GLOBAL byte notificationSentCallMode _INIT ( CALL_MODE_INIT ) ;
2022-10-18 23:31:23 +00:00
WLED_GLOBAL uint8_t notificationCount _INIT ( 0 ) ;
2024-08-17 13:09:41 +00:00
WLED_GLOBAL uint8_t syncGroups _INIT ( 0x01 ) ; // sync send groups this instance syncs to (bit mapped)
WLED_GLOBAL uint8_t receiveGroups _INIT ( 0x01 ) ; // sync receive groups this instance belongs to (bit mapped)
# ifdef WLED_SAVE_RAM
// this will save us 8 bytes of RAM while increasing code by ~400 bytes
typedef class Receive {
public :
union {
uint8_t Options ;
struct {
bool Brightness : 1 ;
bool Color : 1 ;
bool Effects : 1 ;
bool SegmentOptions : 1 ;
bool SegmentBounds : 1 ;
bool Direct : 1 ;
2024-09-17 14:34:38 +00:00
bool Palette : 1 ;
uint8_t reserved : 1 ;
2024-08-17 13:09:41 +00:00
} ;
} ;
Receive ( int i ) { Options = i ; }
2024-09-17 14:34:38 +00:00
Receive ( bool b , bool c , bool e , bool sO , bool sB , bool p )
: Brightness ( b )
, Color ( c )
, Effects ( e )
, SegmentOptions ( sO )
, SegmentBounds ( sB )
, Palette ( p )
{ } ;
2024-08-17 13:09:41 +00:00
} __attribute__ ( ( aligned ( 1 ) , packed ) ) receive_notification_t ;
typedef class Send {
public :
union {
uint8_t Options ;
struct {
bool Direct : 1 ;
bool Button : 1 ;
bool Alexa : 1 ;
bool Hue : 1 ;
uint8_t reserved : 4 ;
} ;
} ;
Send ( int o ) { Options = o ; }
Send ( bool d , bool b , bool a , bool h ) {
Direct = d ;
Button = b ;
Alexa = a ;
Hue = h ;
}
} __attribute__ ( ( aligned ( 1 ) , packed ) ) send_notification_t ;
2024-09-17 14:34:38 +00:00
WLED_GLOBAL receive_notification_t receiveN _INIT ( 0 b01100111 ) ;
2024-08-17 13:09:41 +00:00
WLED_GLOBAL send_notification_t notifyG _INIT ( 0 b00001111 ) ;
# define receiveNotificationBrightness receiveN.Brightness
# define receiveNotificationColor receiveN.Color
# define receiveNotificationEffects receiveN.Effects
2024-09-10 18:02:29 +00:00
# define receiveNotificationPalette receiveN.Palette
2024-08-17 13:09:41 +00:00
# define receiveSegmentOptions receiveN.SegmentOptions
# define receiveSegmentBounds receiveN.SegmentBounds
# define receiveDirect receiveN.Direct
# define notifyDirect notifyG.Direct
# define notifyButton notifyG.Button
# define notifyAlexa notifyG.Alexa
# define notifyHue notifyG.Hue
# else
WLED_GLOBAL bool receiveNotificationBrightness _INIT ( true ) ; // apply brightness from incoming notifications
WLED_GLOBAL bool receiveNotificationColor _INIT ( true ) ; // apply color
WLED_GLOBAL bool receiveNotificationEffects _INIT ( true ) ; // apply effects setup
2024-09-10 18:16:00 +00:00
WLED_GLOBAL bool receiveNotificationPalette _INIT ( true ) ; // apply palette
2024-08-17 13:09:41 +00:00
WLED_GLOBAL bool receiveSegmentOptions _INIT ( false ) ; // apply segment options
WLED_GLOBAL bool receiveSegmentBounds _INIT ( false ) ; // apply segment bounds (start, stop, offset)
WLED_GLOBAL bool receiveDirect _INIT ( true ) ; // receive UDP/Hyperion realtime
WLED_GLOBAL bool notifyDirect _INIT ( false ) ; // send notification if change via UI or HTTP API
WLED_GLOBAL bool notifyButton _INIT ( false ) ; // send if updated by button or infrared remote
WLED_GLOBAL bool notifyAlexa _INIT ( false ) ; // send notification if updated via Alexa
WLED_GLOBAL bool notifyHue _INIT ( true ) ; // send notification if Hue light changes
# endif
2020-04-10 10:30:08 +00:00
// effects
WLED_GLOBAL byte effectCurrent _INIT ( 0 ) ;
WLED_GLOBAL byte effectSpeed _INIT ( 128 ) ;
WLED_GLOBAL byte effectIntensity _INIT ( 128 ) ;
WLED_GLOBAL byte effectPalette _INIT ( 0 ) ;
2022-02-21 21:12:13 +00:00
WLED_GLOBAL bool stateChanged _INIT ( false ) ;
2020-04-10 10:30:08 +00:00
// network
2024-08-17 13:09:41 +00:00
# ifdef WLED_SAVE_RAM
// this will save us 2 bytes of RAM while increasing code by ~400 bytes
typedef class Udp {
public :
uint16_t Port ;
uint16_t Port2 ;
uint16_t RgbPort ;
struct {
uint8_t NumRetries : 5 ;
bool Connected : 1 ;
bool Connected2 : 1 ;
bool RgbConnected : 1 ;
} ;
Udp ( int p1 , int p2 , int p3 , int r , bool c1 , bool c2 , bool c3 ) {
Port = p1 ;
Port2 = p2 ;
RgbPort = p3 ;
NumRetries = r ;
Connected = c1 ;
Connected2 = c2 ;
RgbConnected = c3 ;
}
} __attribute__ ( ( aligned ( 1 ) , packed ) ) udp_port_t ;
WLED_GLOBAL udp_port_t udp _INIT_N ( ( { 21234 , 65506 , 19446 , 0 , false , false , false } ) ) ;
# define udpPort udp.Port
# define udpPort2 udp.Port2
# define udpRgbPort udp.RgbPort
# define udpNumRetries udp.NumRetries
# define udpConnected udp.Connected
# define udp2Connected udp.Connected2
# define udpRgbConnected udp.RgbConnected
# else
WLED_GLOBAL uint16_t udpPort _INIT ( 21324 ) ; // WLED notifier default port
WLED_GLOBAL uint16_t udpPort2 _INIT ( 65506 ) ; // WLED notifier supplemental port
WLED_GLOBAL uint16_t udpRgbPort _INIT ( 19446 ) ; // Hyperion port
WLED_GLOBAL uint8_t udpNumRetries _INIT ( 0 ) ; // Number of times a UDP sync message is retransmitted. Increase to increase reliability
WLED_GLOBAL bool udpConnected _INIT ( false ) ;
WLED_GLOBAL bool udp2Connected _INIT ( false ) ;
WLED_GLOBAL bool udpRgbConnected _INIT ( false ) ;
# endif
2020-04-10 10:30:08 +00:00
// ui style
WLED_GLOBAL bool showWelcomePage _INIT ( false ) ;
// hue
2024-02-09 21:15:29 +00:00
# ifndef WLED_DISABLE_HUESYNC
2020-04-10 10:30:08 +00:00
WLED_GLOBAL byte hueError _INIT ( HUE_ERROR_INACTIVE ) ;
// WLED_GLOBAL uint16_t hueFailCount _INIT(0);
WLED_GLOBAL float hueXLast _INIT ( 0 ) , hueYLast _INIT ( 0 ) ;
WLED_GLOBAL uint16_t hueHueLast _INIT ( 0 ) , hueCtLast _INIT ( 0 ) ;
WLED_GLOBAL byte hueSatLast _INIT ( 0 ) , hueBriLast _INIT ( 0 ) ;
WLED_GLOBAL unsigned long hueLastRequestSent _INIT ( 0 ) ;
WLED_GLOBAL bool hueAuthRequired _INIT ( false ) ;
WLED_GLOBAL bool hueReceived _INIT ( false ) ;
WLED_GLOBAL bool hueStoreAllowed _INIT ( false ) , hueNewKey _INIT ( false ) ;
2024-02-09 21:15:29 +00:00
# endif
2020-04-10 10:30:08 +00:00
// countdown
WLED_GLOBAL unsigned long countdownTime _INIT ( 1514764800L ) ;
WLED_GLOBAL bool countdownOverTriggered _INIT ( true ) ;
2021-12-31 13:09:48 +00:00
//timer
2021-12-25 17:46:43 +00:00
WLED_GLOBAL byte lastTimerMinute _INIT ( 0 ) ;
WLED_GLOBAL byte timerHours [ ] _INIT_N ( ( { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ) ) ;
2021-03-06 23:04:46 +00:00
WLED_GLOBAL int8_t timerMinutes [ ] _INIT_N ( ( { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ) ) ;
2021-12-25 17:46:43 +00:00
WLED_GLOBAL byte timerMacro [ ] _INIT_N ( ( { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ) ) ;
2021-12-31 13:09:48 +00:00
//weekdays to activate on, bit pattern of arr elem: 0b11111111: sun,sat,fri,thu,wed,tue,mon,validity
WLED_GLOBAL byte timerWeekday [ ] _INIT_N ( ( { 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 } ) ) ;
//upper 4 bits start, lower 4 bits end month (default 28: start month 1 and end month 12)
WLED_GLOBAL byte timerMonth [ ] _INIT_N ( ( { 28 , 28 , 28 , 28 , 28 , 28 , 28 , 28 } ) ) ;
WLED_GLOBAL byte timerDay [ ] _INIT_N ( ( { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 } ) ) ;
WLED_GLOBAL byte timerDayEnd [ ] _INIT_N ( ( { 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31 } ) ) ;
2024-05-01 17:05:26 +00:00
WLED_GLOBAL bool doAdvancePlaylist _INIT ( false ) ;
2020-04-10 10:30:08 +00:00
2021-11-16 22:20:26 +00:00
//improv
WLED_GLOBAL byte improvActive _INIT ( 0 ) ; //0: no improv packet received, 1: improv active, 2: provisioning
WLED_GLOBAL byte improvError _INIT ( 0 ) ;
2021-06-29 23:48:38 +00:00
//playlists
2021-10-07 13:41:30 +00:00
WLED_GLOBAL int16_t currentPlaylist _INIT ( - 1 ) ;
2021-10-06 17:52:21 +00:00
//still used for "PL=~" HTTP API command
WLED_GLOBAL byte presetCycCurr _INIT ( 0 ) ;
2021-11-22 20:41:04 +00:00
WLED_GLOBAL byte presetCycMin _INIT ( 1 ) ;
2022-12-15 14:50:44 +00:00
WLED_GLOBAL byte presetCycMax _INIT ( 5 ) ;
2020-11-11 22:48:14 +00:00
2020-04-10 10:30:08 +00:00
// realtime
WLED_GLOBAL byte realtimeMode _INIT ( REALTIME_MODE_INACTIVE ) ;
2020-04-29 23:52:36 +00:00
WLED_GLOBAL byte realtimeOverride _INIT ( REALTIME_OVERRIDE_NONE ) ;
2021-12-04 00:05:01 +00:00
WLED_GLOBAL IPAddress realtimeIP _INIT_N ( ( ( 0 , 0 , 0 , 0 ) ) ) ;
2020-04-10 10:30:08 +00:00
WLED_GLOBAL unsigned long realtimeTimeout _INIT ( 0 ) ;
2020-08-19 08:40:16 +00:00
WLED_GLOBAL uint8_t tpmPacketCount _INIT ( 0 ) ;
WLED_GLOBAL uint16_t tpmPayloadFrameSize _INIT ( 0 ) ;
2022-03-25 15:36:05 +00:00
WLED_GLOBAL bool useMainSegmentOnly _INIT ( false ) ;
2023-11-23 16:13:13 +00:00
WLED_GLOBAL bool realtimeRespectLedMaps _INIT ( true ) ; // Respect LED maps when receiving realtime data
2020-04-10 10:30:08 +00:00
2021-02-27 00:16:06 +00:00
WLED_GLOBAL unsigned long lastInterfaceUpdate _INIT ( 0 ) ;
2021-07-09 16:54:28 +00:00
WLED_GLOBAL byte interfaceUpdateCallMode _INIT ( CALL_MODE_INIT ) ;
2020-04-10 10:30:08 +00:00
// alexa udp
WLED_GLOBAL String escapedMac ;
# ifndef WLED_DISABLE_ALEXA
WLED_GLOBAL Espalexa espalexa ;
WLED_GLOBAL EspalexaDevice * espalexaDevice ;
# endif
// dns server
WLED_GLOBAL DNSServer dnsServer ;
// network time
2024-01-13 12:06:00 +00:00
# ifndef WLED_LAT
# define WLED_LAT 0.0f
# endif
# ifndef WLED_LON
# define WLED_LON 0.0f
# endif
2024-02-06 13:47:20 +00:00
# define NTP_NEVER 999000000L
2020-04-10 10:30:08 +00:00
WLED_GLOBAL bool ntpConnected _INIT ( false ) ;
2020-08-04 13:32:54 +00:00
WLED_GLOBAL time_t localTime _INIT ( 0 ) ;
2024-02-06 13:47:20 +00:00
WLED_GLOBAL unsigned long ntpLastSyncTime _INIT ( NTP_NEVER ) ;
WLED_GLOBAL unsigned long ntpPacketSentTime _INIT ( NTP_NEVER ) ;
2020-04-10 10:30:08 +00:00
WLED_GLOBAL IPAddress ntpServerIP ;
WLED_GLOBAL uint16_t ntpLocalPort _INIT ( 2390 ) ;
2020-04-29 23:52:36 +00:00
WLED_GLOBAL uint16_t rolloverMillis _INIT ( 0 ) ;
2024-01-13 12:06:00 +00:00
WLED_GLOBAL float longitude _INIT ( WLED_LON ) ;
WLED_GLOBAL float latitude _INIT ( WLED_LAT ) ;
2021-03-06 23:04:46 +00:00
WLED_GLOBAL time_t sunrise _INIT ( 0 ) ;
WLED_GLOBAL time_t sunset _INIT ( 0 ) ;
2021-05-24 12:34:03 +00:00
WLED_GLOBAL Toki toki _INIT ( Toki ( ) ) ;
2020-04-10 10:30:08 +00:00
2020-10-07 15:48:22 +00:00
// General filesystem
WLED_GLOBAL size_t fsBytesUsed _INIT ( 0 ) ;
WLED_GLOBAL size_t fsBytesTotal _INIT ( 0 ) ;
WLED_GLOBAL unsigned long presetsModifiedTime _INIT ( 0L ) ;
2020-10-12 23:39:34 +00:00
WLED_GLOBAL bool doCloseFile _INIT ( false ) ;
2020-10-07 15:48:22 +00:00
2020-04-10 10:30:08 +00:00
// presets
2021-10-06 16:43:12 +00:00
WLED_GLOBAL byte currentPreset _INIT ( 0 ) ;
2020-04-10 10:30:08 +00:00
WLED_GLOBAL byte errorFlag _INIT ( 0 ) ;
WLED_GLOBAL String messageHead , messageSub ;
WLED_GLOBAL byte optionType ;
2022-09-14 20:28:06 +00:00
WLED_GLOBAL bool doSerializeConfig _INIT ( false ) ; // flag to initiate saving of config
WLED_GLOBAL bool doReboot _INIT ( false ) ; // flag to initiate reboot from async handlers
2020-04-10 10:30:08 +00:00
2024-03-28 15:03:06 +00:00
WLED_GLOBAL bool psramSafe _INIT ( true ) ; // is it safe to use PSRAM (on ESP32 rev.1; compiler fix used "-mfix-esp32-psram-cache-issue")
2022-03-01 22:37:28 +00:00
// status led
# if defined(STATUSLED)
WLED_GLOBAL unsigned long ledStatusLastMillis _INIT ( 0 ) ;
WLED_GLOBAL uint8_t ledStatusType _INIT ( 0 ) ; // current status type - corresponds to number of blinks per second
WLED_GLOBAL bool ledStatusState _INIT ( false ) ; // the current LED state
# endif
2020-04-10 10:30:08 +00:00
// server library objects
WLED_GLOBAL AsyncWebServer server _INIT_N ( ( ( 80 ) ) ) ;
2020-06-26 15:28:35 +00:00
# ifdef WLED_ENABLE_WEBSOCKETS
WLED_GLOBAL AsyncWebSocket ws _INIT_N ( ( ( " /ws " ) ) ) ;
# endif
2024-02-09 21:15:29 +00:00
# ifndef WLED_DISABLE_HUESYNC
2023-01-12 19:35:34 +00:00
WLED_GLOBAL AsyncClient * hueClient _INIT ( NULL ) ;
2024-02-09 21:15:29 +00:00
# endif
2022-03-01 22:37:28 +00:00
WLED_GLOBAL AsyncWebHandler * editHandler _INIT ( nullptr ) ;
2020-04-10 10:30:08 +00:00
// udp interface objects
2020-09-27 09:43:28 +00:00
WLED_GLOBAL WiFiUDP notifierUdp , rgbUdp , notifier2Udp ;
2020-04-10 10:30:08 +00:00
WLED_GLOBAL WiFiUDP ntpUdp ;
WLED_GLOBAL ESPAsyncE131 e131 _INIT_N ( ( ( handleE131Packet ) ) ) ;
2021-10-01 19:56:54 +00:00
WLED_GLOBAL ESPAsyncE131 ddp _INIT_N ( ( ( handleE131Packet ) ) ) ;
2020-04-10 10:30:08 +00:00
WLED_GLOBAL bool e131NewData _INIT ( false ) ;
// led fx library object
2021-01-21 00:21:16 +00:00
WLED_GLOBAL BusManager busses _INIT ( BusManager ( ) ) ;
2020-04-10 10:30:08 +00:00
WLED_GLOBAL WS2812FX strip _INIT ( WS2812FX ( ) ) ;
2022-12-31 16:06:18 +00:00
WLED_GLOBAL BusConfig * busConfigs [ WLED_MAX_BUSSES + WLED_MIN_VIRTUAL_BUSSES ] _INIT ( { nullptr } ) ; //temporary, to remember values from network callback until after
2021-03-23 06:05:40 +00:00
WLED_GLOBAL bool doInitBusses _INIT ( false ) ;
2021-11-03 13:52:22 +00:00
WLED_GLOBAL int8_t loadLedmap _INIT ( - 1 ) ;
2024-06-23 12:08:18 +00:00
WLED_GLOBAL uint8_t currentLedmap _INIT ( 0 ) ;
2023-02-14 16:11:58 +00:00
# ifndef ESP8266
WLED_GLOBAL char * ledmapNames [ WLED_MAX_LEDMAPS - 1 ] _INIT_N ( ( { nullptr } ) ) ;
# endif
# if WLED_MAX_LEDMAPS>16
WLED_GLOBAL uint32_t ledMaps _INIT ( 0 ) ; // bitfield representation of available ledmaps
# else
2022-08-10 18:53:11 +00:00
WLED_GLOBAL uint16_t ledMaps _INIT ( 0 ) ; // bitfield representation of available ledmaps
2023-02-14 16:11:58 +00:00
# endif
2020-04-10 10:30:08 +00:00
2020-05-28 00:20:02 +00:00
// Usermod manager
WLED_GLOBAL UsermodManager usermods _INIT ( UsermodManager ( ) ) ;
2022-12-18 10:33:13 +00:00
// global I2C SDA pin (used for usermods)
2022-12-15 14:50:44 +00:00
# ifndef I2CSDAPIN
WLED_GLOBAL int8_t i2c_sda _INIT ( - 1 ) ;
# else
WLED_GLOBAL int8_t i2c_sda _INIT ( I2CSDAPIN ) ;
# endif
2022-12-18 10:33:13 +00:00
// global I2C SCL pin (used for usermods)
2022-12-15 14:50:44 +00:00
# ifndef I2CSCLPIN
WLED_GLOBAL int8_t i2c_scl _INIT ( - 1 ) ;
# else
WLED_GLOBAL int8_t i2c_scl _INIT ( I2CSCLPIN ) ;
# endif
2022-12-18 10:33:13 +00:00
// global SPI DATA/MOSI pin (used for usermods)
2022-12-15 14:50:44 +00:00
# ifndef SPIMOSIPIN
WLED_GLOBAL int8_t spi_mosi _INIT ( - 1 ) ;
# else
WLED_GLOBAL int8_t spi_mosi _INIT ( SPIMOSIPIN ) ;
# endif
2022-12-18 10:33:13 +00:00
// global SPI DATA/MISO pin (used for usermods)
2022-12-15 14:50:44 +00:00
# ifndef SPIMISOPIN
WLED_GLOBAL int8_t spi_miso _INIT ( - 1 ) ;
# else
WLED_GLOBAL int8_t spi_miso _INIT ( SPIMISOPIN ) ;
# endif
2022-12-18 10:33:13 +00:00
// global SPI CLOCK/SCLK pin (used for usermods)
2022-12-15 14:50:44 +00:00
# ifndef SPISCLKPIN
WLED_GLOBAL int8_t spi_sclk _INIT ( - 1 ) ;
# else
WLED_GLOBAL int8_t spi_sclk _INIT ( SPISCLKPIN ) ;
# endif
2022-08-07 14:43:29 +00:00
2021-12-04 00:05:01 +00:00
// global ArduinoJson buffer
2024-03-24 16:37:11 +00:00
# if defined(ARDUINO_ARCH_ESP32)
2023-12-21 20:30:17 +00:00
WLED_GLOBAL JsonDocument * pDoc _INIT ( nullptr ) ;
2024-08-04 18:02:05 +00:00
WLED_GLOBAL SemaphoreHandle_t jsonBufferLockMutex _INIT ( xSemaphoreCreateRecursiveMutex ( ) ) ;
2023-12-21 20:30:17 +00:00
# else
WLED_GLOBAL StaticJsonDocument < JSON_BUFFER_SIZE > gDoc ;
WLED_GLOBAL JsonDocument * pDoc _INIT ( & gDoc ) ;
# endif
2021-11-14 15:56:34 +00:00
WLED_GLOBAL volatile uint8_t jsonBufferLock _INIT ( 0 ) ;
2021-11-03 13:52:22 +00:00
2020-09-09 07:51:04 +00:00
// enable additional debug output
2022-11-06 09:58:19 +00:00
# if defined(WLED_DEBUG_HOST)
2023-02-04 22:59:28 +00:00
# include "net_debug.h"
2022-11-06 09:58:19 +00:00
// On the host side, use netcat to receive the log statements: nc -l 7868 -u
// use -D WLED_DEBUG_HOST='"192.168.xxx.xxx"' or FQDN within quotes
# define DEBUGOUT NetDebug
2022-11-10 20:50:21 +00:00
WLED_GLOBAL bool netDebugEnabled _INIT ( true ) ;
2022-11-06 09:58:19 +00:00
WLED_GLOBAL char netDebugPrintHost [ 33 ] _INIT ( WLED_DEBUG_HOST ) ;
2023-02-08 09:25:59 +00:00
# ifndef WLED_DEBUG_PORT
# define WLED_DEBUG_PORT 7868
2022-11-06 09:58:19 +00:00
# endif
2023-02-08 09:25:59 +00:00
WLED_GLOBAL int netDebugPrintPort _INIT ( WLED_DEBUG_PORT ) ;
2022-11-06 09:58:19 +00:00
# else
# define DEBUGOUT Serial
# endif
2021-08-25 05:12:03 +00:00
2020-09-09 07:51:04 +00:00
# ifdef WLED_DEBUG
# ifndef ESP8266
# include <rom/rtc.h>
# endif
2022-11-06 09:58:19 +00:00
# define DEBUG_PRINT(x) DEBUGOUT.print(x)
# define DEBUG_PRINTLN(x) DEBUGOUT.println(x)
# define DEBUG_PRINTF(x...) DEBUGOUT.printf(x)
2024-02-17 10:33:42 +00:00
# define DEBUG_PRINTF_P(x...) DEBUGOUT.printf_P(x)
2020-09-09 07:51:04 +00:00
# else
# define DEBUG_PRINT(x)
# define DEBUG_PRINTLN(x)
2021-03-07 14:33:08 +00:00
# define DEBUG_PRINTF(x...)
2024-02-17 10:33:42 +00:00
# define DEBUG_PRINTF_P(x...)
2020-09-09 07:51:04 +00:00
# endif
# ifdef WLED_DEBUG_FS
2022-11-06 09:58:19 +00:00
# define DEBUGFS_PRINT(x) DEBUGOUT.print(x)
# define DEBUGFS_PRINTLN(x) DEBUGOUT.println(x)
# define DEBUGFS_PRINTF(x...) DEBUGOUT.printf(x)
2020-09-09 07:51:04 +00:00
# else
# define DEBUGFS_PRINT(x)
# define DEBUGFS_PRINTLN(x)
2020-10-23 15:48:01 +00:00
# define DEBUGFS_PRINTF(x...)
2020-09-09 07:51:04 +00:00
# endif
2020-04-10 10:30:08 +00:00
// debug macro variable definitions
# ifdef WLED_DEBUG
WLED_GLOBAL unsigned long debugTime _INIT ( 0 ) ;
WLED_GLOBAL int lastWifiState _INIT ( 3 ) ;
WLED_GLOBAL unsigned long wifiStateChangedTime _INIT ( 0 ) ;
2024-02-09 21:15:29 +00:00
WLED_GLOBAL unsigned loops _INIT ( 0 ) ;
2020-04-10 10:30:08 +00:00
# endif
2020-11-13 17:25:13 +00:00
# ifdef ARDUINO_ARCH_ESP32
# define WLED_CONNECTED (WiFi.status() == WL_CONNECTED || ETH.localIP()[0] != 0)
# else
# define WLED_CONNECTED (WiFi.status() == WL_CONNECTED)
# endif
2020-04-10 10:30:08 +00:00
2022-11-20 14:55:38 +00:00
# ifndef WLED_AP_SSID_UNIQUE
# define WLED_SET_AP_SSID() do { \
strcpy_P ( apSSID , PSTR ( WLED_AP_SSID ) ) ; \
} while ( 0 )
# else
# define WLED_SET_AP_SSID() do { \
snprintf_P ( \
2024-02-09 21:15:29 +00:00
apSSID , \
sizeof ( apSSID ) - 1 , \
PSTR ( " %s-%s " ) , \
WLED_BRAND , \
escapedMac . c_str ( ) + 6 \
2022-11-20 14:55:38 +00:00
) ; \
} while ( 0 )
# endif
2021-10-11 12:13:34 +00:00
//macro to convert F to const
# define SET_F(x) (const char*)F(x)
2021-10-26 18:35:45 +00:00
//color mangling macros
# define RGBW32(r,g,b,w) (uint32_t((byte(w) << 24) | (byte(r) << 16) | (byte(g) << 8) | (byte(b))))
# define R(c) (byte((c) >> 16))
# define G(c) (byte((c) >> 8))
# define B(c) (byte(c))
# define W(c) (byte((c) >> 24))
2020-04-10 10:30:08 +00:00
class WLED {
public :
WLED ( ) ;
static WLED & instance ( )
{
static WLED instance ;
return instance ;
}
// boot starts here
void setup ( ) ;
void loop ( ) ;
void reset ( ) ;
void beginStrip ( ) ;
void handleConnection ( ) ;
2021-08-23 12:14:48 +00:00
bool initEthernet ( ) ; // result is informational
2020-04-10 10:30:08 +00:00
void initAP ( bool resetAP = false ) ;
void initConnection ( ) ;
void initInterfaces ( ) ;
2024-01-25 18:42:23 +00:00
int8_t findWiFi ( bool doScan = false ) ;
2023-10-25 18:27:01 +00:00
# if defined(STATUSLED)
2020-10-19 16:08:45 +00:00
void handleStatusLED ( ) ;
2023-10-25 18:27:01 +00:00
# endif
# if WLED_WATCHDOG_TIMEOUT > 0
2022-05-23 22:30:13 +00:00
void enableWatchdog ( ) ;
void disableWatchdog ( ) ;
2023-10-25 18:27:01 +00:00
# endif
2020-04-10 10:30:08 +00:00
} ;
# endif // WLED_H