diff --git a/CHANGELOG.md b/CHANGELOG.md index 8df63ff8e..d92a1966a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ### Development versions after 0.9.1 release +#### Build 2004061 + +- Fixed RBG and BGR getPixelColor (#825) +- Improved formatting + #### Build 2004060 - Consolidated global variables in wled.h diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index de89a430e..69b8c88a1 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -412,8 +412,8 @@ uint32_t WS2812FX::getPixelColor(uint16_t i) case 0: return ((col.W << 24) | (col.G << 8) | (col.R << 16) | (col.B)); //0 = GRB, default case 1: return ((col.W << 24) | (col.R << 8) | (col.G << 16) | (col.B)); //1 = RGB, common for WS2811 case 2: return ((col.W << 24) | (col.B << 8) | (col.R << 16) | (col.G)); //2 = BRG - case 3: return ((col.W << 24) | (col.R << 8) | (col.B << 16) | (col.G)); //3 = RBG - case 4: return ((col.W << 24) | (col.B << 8) | (col.G << 16) | (col.R)); //4 = BGR + case 3: return ((col.W << 24) | (col.B << 8) | (col.G << 16) | (col.R)); //3 = RBG + case 4: return ((col.W << 24) | (col.R << 8) | (col.B << 16) | (col.G)); //4 = BGR case 5: return ((col.W << 24) | (col.G << 8) | (col.B << 16) | (col.R)); //5 = GBR } return 0; diff --git a/wled00/const.h b/wled00/const.h index ef19e51be..173d7e7d5 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -1,6 +1,10 @@ #ifndef WLED_CONST_H #define WLED_CONST_H +/* + * Readability defines and their associated numerical values + compile-time constants + */ + //Defaults #define DEFAULT_CLIENT_SSID "Your_Network" #define DEFAULT_AP_PASS "wled1234" diff --git a/wled00/func_declare.h b/wled00/fcn_declare.h similarity index 99% rename from wled00/func_declare.h rename to wled00/fcn_declare.h index db3cb4bc4..c0826d6aa 100644 --- a/wled00/func_declare.h +++ b/wled00/fcn_declare.h @@ -1,5 +1,5 @@ -#ifndef WLED_FUNC_DECLARE_H -#define WLED_FUNC_DECLARE_H +#ifndef WLED_FCN_DECLARE_H +#define WLED_FCN_DECLARE_H #include #include "src/dependencies/espalexa/EspalexaDevice.h" #include "src/dependencies/e131/ESPAsyncE131.h" diff --git a/wled00/html_other.h b/wled00/html_other.h index e27c64dde..ce36cff48 100644 --- a/wled00/html_other.h +++ b/wled00/html_other.h @@ -1,5 +1,5 @@ /* - * Various pages + * Various web pages */ //USER HTML HERE (/u subpage) diff --git a/wled00/html_settings.h b/wled00/html_settings.h index 284d9b30f..e2d94f973 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -1,6 +1,6 @@ /* - Settings html -*/ + * Settings html + */ //common CSS of settings pages const char PAGE_settingsCss[] PROGMEM = R"=====()====="; diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 701b98e31..b68723bb0 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -2,6 +2,10 @@ #include "wled.h" #include +/* + * Main WLED class implementation. Mostly initialization and connection logic + */ + WLED::WLED() { } diff --git a/wled00/wled.h b/wled00/wled.h index 0c6d31147..6f4b2cb00 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2004060 +#define VERSION 2004061 // ESP8266-01 (blue) got too little storage space to work with all features of WLED. To use it, you must use ESP8266 Arduino Core v2.4.2 and the setting 512K(No SPIFFS). @@ -81,7 +81,7 @@ #include "src/dependencies/json/AsyncJson-v6.h" #include "src/dependencies/json/ArduinoJson-v6.h" -#include "func_declare.h" +#include "fcn_declare.h" #include "html_ui.h" #include "html_settings.h" #include "html_other.h" @@ -128,6 +128,12 @@ #define DEBUG_PRINTF(x) #endif +// 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 # define WLED_GLOBAL extern # define _INIT(x) @@ -170,13 +176,13 @@ WLED_GLOBAL bool noWifiSleep _INIT(false); // disabling // LED CONFIG WLED_GLOBAL uint16_t ledCount _INIT(30); // overcurrent prevented by ABL -WLED_GLOBAL bool useRGBW _INIT(false); // SK6812 strips can contain an extra White channel +WLED_GLOBAL bool useRGBW _INIT(false); // SK6812 strips can contain an extra White channel 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 +WLED_GLOBAL byte bootPreset _INIT(0); // save preset to load after power-up -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 briS _INIT(128); // default brightness +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 briS _INIT(128); // default brightness WLED_GLOBAL byte nightlightTargetBri _INIT(0); // brightness after nightlight is over WLED_GLOBAL byte nightlightDelayMins _INIT(60); @@ -189,52 +195,52 @@ WLED_GLOBAL bool skipFirstLed _INIT(false); // ignore first LED in strip 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 -WLED_GLOBAL char serverDescription[33] _INIT("WLED"); // Name of module -WLED_GLOBAL bool syncToggleReceive _INIT(false); // UIs which only have a single button for sync should toggle send+receive if this is true, only send otherwise +WLED_GLOBAL char serverDescription[33] _INIT("WLED"); // Name of module +WLED_GLOBAL bool syncToggleReceive _INIT(false); // UIs which only have a single button for sync should toggle send+receive if this is true, only send otherwise // Sync CONFIG -WLED_GLOBAL bool buttonEnabled _INIT(true); -WLED_GLOBAL byte irEnabled _INIT(0); // Infrared receiver +WLED_GLOBAL bool buttonEnabled _INIT(true); +WLED_GLOBAL byte irEnabled _INIT(0); // Infrared receiver -WLED_GLOBAL uint16_t udpPort _INIT(21324); // WLED notifier default port -WLED_GLOBAL uint16_t udpRgbPort _INIT(19446); // Hyperion port +WLED_GLOBAL uint16_t udpPort _INIT(21324); // WLED notifier default port +WLED_GLOBAL uint16_t udpRgbPort _INIT(19446); // Hyperion port -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 -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 notifyMacro _INIT(false); // send notification for macro -WLED_GLOBAL bool notifyHue _INIT(true); // send notification if Hue light changes -WLED_GLOBAL bool notifyTwice _INIT(false); // notifications use UDP: enable if devices don't sync reliably +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 +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 notifyMacro _INIT(false); // send notification for macro +WLED_GLOBAL bool notifyHue _INIT(true); // send notification if Hue light changes +WLED_GLOBAL bool notifyTwice _INIT(false); // notifications use UDP: enable if devices don't sync reliably -WLED_GLOBAL bool alexaEnabled _INIT(true); // enable device discovery by Amazon Echo -WLED_GLOBAL char alexaInvocationName[33] _INIT("Light"); // speech control name of device. Choose something voice-to-text can understand +WLED_GLOBAL bool alexaEnabled _INIT(true); // enable device discovery by Amazon Echo +WLED_GLOBAL char alexaInvocationName[33] _INIT("Light"); // speech control name of device. Choose something voice-to-text can understand -WLED_GLOBAL char blynkApiKey[36] _INIT(""); // Auth token for Blynk server. If empty, no connection will be made +WLED_GLOBAL char blynkApiKey[36] _INIT(""); // Auth token for Blynk server. If empty, no connection will be made -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 receiveDirect _INIT(true); // receive UDP realtime -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 +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 receiveDirect _INIT(true); // receive UDP realtime +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 -WLED_GLOBAL uint16_t e131Universe _INIT(1); // settings for E1.31 (sACN) protocol (only DMX_MODE_MULTIPLE_* can span over consequtive universes) -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] -WLED_GLOBAL byte DMXOldDimmer _INIT(0); // only update brightness on change -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 +WLED_GLOBAL uint16_t e131Universe _INIT(1); // settings for E1.31 (sACN) protocol (only DMX_MODE_MULTIPLE_* can span over consequtive universes) +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] +WLED_GLOBAL byte DMXOldDimmer _INIT(0); // only update brightness on change +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 WLED_GLOBAL bool mqttEnabled _INIT(false); -WLED_GLOBAL char mqttDeviceTopic[33] _INIT(""); // main MQTT topic (individual per device, default is wled/mac) -WLED_GLOBAL char mqttGroupTopic[33] _INIT("wled/all"); // second MQTT topic (for example to group devices) -WLED_GLOBAL char mqttServer[33] _INIT(""); // both domains and IPs should work (no SSL) -WLED_GLOBAL char mqttUser[41] _INIT(""); // optional: username for MQTT auth -WLED_GLOBAL char mqttPass[41] _INIT(""); // optional: password for MQTT auth -WLED_GLOBAL char mqttClientID[41] _INIT(""); // override the client ID +WLED_GLOBAL char mqttDeviceTopic[33] _INIT(""); // main MQTT topic (individual per device, default is wled/mac) +WLED_GLOBAL char mqttGroupTopic[33] _INIT("wled/all"); // second MQTT topic (for example to group devices) +WLED_GLOBAL char mqttServer[33] _INIT(""); // both domains and IPs should work (no SSL) +WLED_GLOBAL char mqttUser[41] _INIT(""); // optional: username for MQTT auth +WLED_GLOBAL char mqttPass[41] _INIT(""); // optional: password for MQTT auth +WLED_GLOBAL char mqttClientID[41] _INIT(""); // override the client ID WLED_GLOBAL uint16_t mqttPort _INIT(1883); WLED_GLOBAL bool huePollingEnabled _INIT(false); // poll hue bridge for light state @@ -255,30 +261,30 @@ WLED_GLOBAL int utcOffsetSecs _INIT(0); // Seconds to offset from UTC WLED_GLOBAL byte overlayDefault _INIT(0); // 0: no overlay 1: analog clock 2: single-digit clocl 3: cronixie WLED_GLOBAL byte overlayMin _INIT(0), overlayMax _INIT(ledCount - 1); // boundaries of overlay mode -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 +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 WLED_GLOBAL char cronixieDisplay[7] _INIT("HHMMSS"); // Cronixie Display mask. See wled13_cronixie.ino WLED_GLOBAL bool cronixieBacklight _INIT(true); // Allow digits to be back-illuminated 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 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 macroBoot _INIT(0); // macro loaded after startup -WLED_GLOBAL byte macroNl _INIT(0); // after nightlight delay over +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); WLED_GLOBAL byte macroButton _INIT(0), macroLongPress _INIT(0), macroDoublePress _INIT(0); // 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 +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 -WLED_GLOBAL uint16_t userVar0 _INIT(0), userVar1 _INIT(0); +WLED_GLOBAL uint16_t userVar0 _INIT(0), userVar1 _INIT(0); //available for use in usermod #ifdef WLED_ENABLE_DMX // dmx CONFIG diff --git a/wled00/wled00.ino b/wled00/wled00.ino index f806e5b34..866543ab9 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -1,5 +1,14 @@ /* - * Arduino IDE compatibility file. + * WLED Arduino IDE compatibility file. + * + * Where has everything gone? + * + * In April 2020, the project's structure underwent a major change. + * Global variables are now found in file "wled.h" + * Global function declarations are found in "fcn_declare.h" + * + * Usermod compatibility: Existing wled06_usermod.ino mods should continue to work. Delete usermod.cpp. + * New usermods should use usermod.cpp instead. */ #include "wled.h"