From d1c289b709f0f9137180f8ff02ad5662f363b883 Mon Sep 17 00:00:00 2001 From: Def3nder Date: Tue, 5 Nov 2019 15:52:18 +0100 Subject: [PATCH 1/9] Add Solid (analog) RGBW strip support add 4 ESP pins for driving analog/non-addressable RGBW LED strips --- wled00/NpbWrapper.h | 55 +++++++++++++++++++++++++++++++++++++++++++-- wled00/wled00.ino | 2 ++ 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/wled00/NpbWrapper.h b/wled00/NpbWrapper.h index 8e04a71e1..7adc73f23 100644 --- a/wled00/NpbWrapper.h +++ b/wled00/NpbWrapper.h @@ -20,6 +20,13 @@ #endif #endif +#ifndef WLED_DISABLE_ANALOG_LEDS + //PWM pins - PINs 5,12,13,15 are used with Magic Home LED Controller + #define RPIN 5 //R pin for analog LED strip + #define GPIN 12 //G pin for analog LED strip + #define BPIN 13 //B pin for analog LED strip + #define WPIN 15 //W pin for analog LED strip +#endif //automatically uses the right driver method for each platform #ifdef ARDUINO_ARCH_ESP32 @@ -104,15 +111,59 @@ public: #endif _pGrbw->Begin(); break; + + #ifndef WLED_DISABLE_ANALOG_LEDS + //init PWM pins - PINs 5,12,13,15 are used with Magic Home LED Controller + pinMode(RPIN, OUTPUT); + pinMode(GPIN, OUTPUT); + pinMode(BPIN, OUTPUT); + switch (_type) { + case NeoPixelType_Grb: break; + case NeoPixelType_Grbw: pinMode(WPIN, OUTPUT); break; + } + analogWriteRange(255); //same range as one RGB channel + analogWriteFreq(880); //PWM frequency proven as good for LEDs + #endif + } } +#ifndef WLED_DISABLE_ANALOG_LEDS + void SetRgbwPwm(uint8_t r, uint8_t g, uint8_t b, uint8_t w) + { + analogWrite(RPIN, r); + analogWrite(GPIN, g); + analogWrite(BPIN, b); + switch (_type) { + case NeoPixelType_Grb: break; + case NeoPixelType_Grbw: analogWrite(WPIN, w); break; + } + } +#endif + void Show() { + byte b; switch (_type) { - case NeoPixelType_Grb: _pGrb->Show(); break; - case NeoPixelType_Grbw: _pGrbw->Show(); break; + case NeoPixelType_Grb: { + _pGrb->Show(); + #ifndef WLED_DISABLE_ANALOG_LEDS + RgbColor color = _pGrb->GetPixelColor(0); + b = _pGrb->GetBrightness(); + SetRgbwPwm(color.R * b / 255, color.G * b / 255, color.B * b / 255, 0); + #endif + } + break; + case NeoPixelType_Grbw: { + _pGrbw->Show(); + #ifndef WLED_DISABLE_ANALOG_LEDS + RgbwColor colorW = _pGrbw->GetPixelColor(0); + b = _pGrbw->GetBrightness(); + SetRgbwPwm(colorW.R * b / 255, colorW.G * b / 255, colorW.B * b / 255, colorW.W * b / 255); + #endif + } + break; } } diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 21c87f40f..1f3bcd268 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -32,6 +32,8 @@ //to toggle usb serial debug (un)comment the following line //#define WLED_DEBUG +//to toggle using analog RGB or RGBW led strips (un)comment the following line +//#define WLED_DISABLE_ANALOG_LEDS //library inclusions #include From 2c70d66d4a6e10809e3335b9f61804b9c01d4445 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Wed, 18 Dec 2019 00:41:45 +0100 Subject: [PATCH 2/9] Fix TypeError (#453) --- wled00/src/dependencies/json/AsyncJson-v6.h | 19 ++++++------------- wled00/wled00.ino | 2 +- wled00/wled18_server.ino | 17 ++++++++++++++--- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/wled00/src/dependencies/json/AsyncJson-v6.h b/wled00/src/dependencies/json/AsyncJson-v6.h index 5bf87e1b1..9187a3e9d 100644 --- a/wled00/src/dependencies/json/AsyncJson-v6.h +++ b/wled00/src/dependencies/json/AsyncJson-v6.h @@ -15,7 +15,7 @@ #include "ArduinoJson-v6.h" #include -#define DYNAMYC_JSON_DOCUMENT_SIZE 8192 +#define DYNAMIC_JSON_DOCUMENT_SIZE 8192 constexpr const char* JSON_MIMETYPE = "application/json"; @@ -60,7 +60,7 @@ class AsyncJsonResponse: public AsyncAbstractResponse { public: - AsyncJsonResponse(size_t maxJsonBufferSize = DYNAMYC_JSON_DOCUMENT_SIZE, bool isArray=false) : _jsonBuffer(maxJsonBufferSize), _isValid{false} { + AsyncJsonResponse(size_t maxJsonBufferSize = DYNAMIC_JSON_DOCUMENT_SIZE, bool isArray=false) : _jsonBuffer(maxJsonBufferSize), _isValid{false} { _code = 200; _contentType = JSON_MIMETYPE; if(isArray) @@ -90,7 +90,7 @@ class AsyncJsonResponse: public AsyncAbstractResponse { } }; -typedef std::function ArJsonRequestHandlerFunction; +typedef std::function ArJsonRequestHandlerFunction; class AsyncCallbackJsonWebHandler: public AsyncWebHandler { private: @@ -103,7 +103,7 @@ protected: int _maxContentLength; public: - AsyncCallbackJsonWebHandler(const String& uri, ArJsonRequestHandlerFunction onRequest, size_t maxJsonBufferSize=DYNAMYC_JSON_DOCUMENT_SIZE) + AsyncCallbackJsonWebHandler(const String& uri, ArJsonRequestHandlerFunction onRequest, size_t maxJsonBufferSize=DYNAMIC_JSON_DOCUMENT_SIZE) : _uri(uri), _method(HTTP_POST|HTTP_PUT|HTTP_PATCH), _onRequest(onRequest), maxJsonBufferSize(maxJsonBufferSize), _maxContentLength(16384) {} void setMethod(WebRequestMethodComposite method){ _method = method; } @@ -127,15 +127,8 @@ public: virtual void handleRequest(AsyncWebServerRequest *request) override final { if(_onRequest) { if (request->_tempObject != NULL) { - - DynamicJsonDocument jsonBuffer(this->maxJsonBufferSize); - DeserializationError error = deserializeJson(jsonBuffer, (uint8_t*)(request->_tempObject)); - if(!error) { - JsonObject json = jsonBuffer.as(); - - _onRequest(request, json); - return; - } + _onRequest(request); + return; } request->send(_contentLength > _maxContentLength ? 413 : 400); } else { diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 1abf9a574..237dd80dc 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -98,7 +98,7 @@ //version code in format yymmddb (b = daily build) -#define VERSION 1912131 +#define VERSION 1912181 char versionString[] = "0.9.0-b1"; diff --git a/wled00/wled18_server.ino b/wled00/wled18_server.ino index c48d3785b..e101c997e 100644 --- a/wled00/wled18_server.ino +++ b/wled00/wled18_server.ino @@ -102,9 +102,20 @@ void initServer() serveJson(request); }); - AsyncCallbackJsonWebHandler* handler = new AsyncCallbackJsonWebHandler("/json", [](AsyncWebServerRequest *request, JsonObject root) { - if (root.isNull()){request->send(500, "application/json", "{\"error\":\"Parsing failed\"}"); return;} - if (deserializeState(root)) { serveJson(request); return; } //if JSON contains "v" (verbose response) + AsyncCallbackJsonWebHandler* handler = new AsyncCallbackJsonWebHandler("/json", [](AsyncWebServerRequest *request) { + bool verboseResponse = false; + if (1) { //scope JsonDocument so it releases its buffer + DynamicJsonDocument jsonBuffer(8192); + DeserializationError error = deserializeJson(jsonBuffer, (uint8_t*)(request->_tempObject)); + JsonObject root = jsonBuffer.as(); + if (error || root.isNull()) { + request->send(400, "application/json", "{\"error\":10}"); return; + } + verboseResponse = deserializeState(root); + } + if (verboseResponse) { //if JSON contains "v" + serveJson(request); return; + } request->send(200, "application/json", "{\"success\":true}"); }); server.addHandler(handler); From bd4d1cdd41fc4a0c376b2c44456b4bae3147bfa7 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Wed, 18 Dec 2019 00:47:24 +0100 Subject: [PATCH 3/9] Fix preset cycle --- wled00/wled00.ino | 2 +- wled00/wled19_json.ino | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 237dd80dc..9979c81aa 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -98,7 +98,7 @@ //version code in format yymmddb (b = daily build) -#define VERSION 1912181 +#define VERSION 1912182 char versionString[] = "0.9.0-b1"; diff --git a/wled00/wled19_json.ino b/wled00/wled19_json.ino index 1c5e19eb4..3e135d406 100644 --- a/wled00/wled19_json.ino +++ b/wled00/wled19_json.ino @@ -88,8 +88,8 @@ bool deserializeState(JsonObject root) int ps = root["ps"] | -1; if (ps >= 0) applyPreset(ps); - int cy = root["pl"] | -1; - presetCyclingEnabled = (cy >= 0); + int cy = root["pl"] | -2; + if (cy > -2) presetCyclingEnabled = (cy >= 0); JsonObject ccnf = root["ccnf"]; presetCycleMin = ccnf["min"] | presetCycleMin; presetCycleMax = ccnf["max"] | presetCycleMax; From c1197d06fee0c32a359d3932b959b6b1ca6c83c3 Mon Sep 17 00:00:00 2001 From: Def3nder Date: Wed, 18 Dec 2019 13:33:27 +0100 Subject: [PATCH 4/9] Changes for 4CH and 5CH LED stripes ESP32 fixes for Solid RGBW (...not implemented for ESP32 yet) Use 5CH solid RGB stripes adapt the logic to use CW and WW for different CT-values change from Opt-out to Opt-In for analog LEDs Added new boards Alexa color changes to match white values with 4Ch and 5Ch LED stripes --- platformio.ini | 59 ++++++++++++++- wled00/NpbWrapper.h | 75 ++++++++++++++----- .../dependencies/espalexa/EspalexaDevice.cpp | 17 ++++- wled00/wled00.ino | 6 +- wled00/wled12_alexa.ino | 3 +- wled00/wled14_colors.ino | 2 +- 6 files changed, 134 insertions(+), 28 deletions(-) diff --git a/platformio.ini b/platformio.ini index 16d54e3c8..e20bb4695 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,7 +11,9 @@ lib_extra_dirs = ./wled00/src ; env_default = esp01_1m ; env_default = d1_mini ; env_default = esp32dev - +; env_default = esp8285_4CH_MagicHome +; env_default = esp8285_4CH_H801 +; env_default = esp8285_5CH_H801 [common] framework = arduino @@ -57,8 +59,10 @@ arduino_core_2_4_1 = espressif8266@1.7.3 arduino_core_2_4_2 = espressif8266@1.8.0 arduino_core_2_5_0 = espressif8266@2.0.4 arduino_core_2_5_2 = espressif8266@2.2.3 +arduino_core_2_6_1 = espressif8266@2.3.0 +arduino_core_2_6_2 = espressif8266@2.3.1 arduino_core_stage = https://github.com/platformio/platform-espressif8266.git#feature/stage -platform = ${common:esp8266.arduino_core_2_5_2} +platform = ${common:esp8266.arduino_core_2_6_2} build_flags = -D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH -Wl,-Teagle.flash.4m1m.ld ;;;; Required for core > v2.5.0 or staging version 4MB Flash 3MB SPIFFs @@ -74,7 +78,7 @@ build_flags = -D WLED_DISABLE_BLYNK -D WLED_DISABLE_CRONIXIE ; -D WLED_DISABLE_HUESYNC - -D WLED_DISABLE_INFRARED + ; -D WLED_DISABLE_INFRARED [common:esp8266_512k] platform = espressif8266@1.8.0 @@ -144,6 +148,7 @@ framework = ${common.framework} build_flags = ${common.build_flags} ${common:esp8266_512k.build_flags} + -D WLED_DISABLE_INFRARED lib_deps = ${common.lib_deps_external} @@ -160,4 +165,50 @@ build_flags = lib_deps = ${common.lib_deps_external} lib_ignore = - IRremoteESP8266 \ No newline at end of file + IRremoteESP8266 + + +[env:esp8285_4CH_MagicHome] +board = esp8285 +platform = ${common:esp8266_1M.platform} +monitor_speed = ${common.monitor_speed} +upload_speed = ${common.upload_speed} +framework = ${common.framework} +build_flags = + ${common.build_flags} + ${common:esp8266_1M.build_flags} + -D WLED_DISABLE_HUESYNC + -D WLED_ENABLE_ANALOG_LEDS +lib_deps = + ${common.lib_deps_external} + +[env:esp8285_4CH_H801] +board = esp8285 +platform = ${common:esp8266.platform} +monitor_speed = ${common.monitor_speed} +upload_speed = ${common.upload_speed} +framework = ${common.framework} +build_flags = + ${common.build_flags} + ${common:esp8266_1M.build_flags} + -D WLED_DISABLE_HUESYNC + -D WLED_ENABLE_ANALOG_LEDS + -D WLED_USE_H801 +lib_deps = + ${common.lib_deps_external} + +[env:esp8285_5CH_H801] +board = esp8285 +platform = ${common:esp8266_1M.platform} +monitor_speed = ${common.monitor_speed} +upload_speed = ${common.upload_speed} +framework = ${common.framework} +build_flags = + ${common.build_flags} + ${common:esp8266_1M.build_flags} + -D WLED_DISABLE_HUESYNC + -D WLED_ENABLE_ANALOG_LEDS + -D WLED_USE_H801 + -D WLED_ENABLE_5CH_LEDS +lib_deps = + ${common.lib_deps_external} \ No newline at end of file diff --git a/wled00/NpbWrapper.h b/wled00/NpbWrapper.h index 7adc73f23..0f1c510d3 100644 --- a/wled00/NpbWrapper.h +++ b/wled00/NpbWrapper.h @@ -5,9 +5,14 @@ //PIN CONFIGURATION #define LEDPIN 2 //strip pin. Any for ESP32, gpio2 or 3 is recommended for ESP8266 (gpio2/3 are labeled D4/RX on NodeMCU and Wemos) //#define USE_APA102 // Uncomment for using APA102 LEDs. -#define BTNPIN 0 //button pin. Needs to have pullup (gpio0 recommended) -#define IR_PIN 4 //infrared pin (-1 to disable) -#define RLYPIN 12 //pin for relay, will be set HIGH if LEDs are on (-1 to disable). Also usable for standby leds, triggers,... +#ifdef WLED_USE_H801 + #define BTNPIN -1 //button pin. Needs to have pullup (gpio0 recommended) + #define IR_PIN 0 //infrared pin (-1 to disable) MagicHome: 4, H801 Wifi: 0 +#else + #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 -1 //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) #define RLYMDE 1 //mode for relay, 0: LOW if LEDs are on 1: HIGH if LEDs are on @@ -20,12 +25,21 @@ #endif #endif -#ifndef WLED_DISABLE_ANALOG_LEDS +#ifdef WLED_USE_ANALOG_LEDS + //PWM pins - PINs 15,13,12,14 (W2 = 04)are used with H801 Wifi LED Controller + #ifdef WLED_USE_H801 + #define RPIN 15 //R pin for analog LED strip + #define GPIN 13 //G pin for analog LED strip + #define BPIN 12 //B pin for analog LED strip + #define WPIN 14 //W pin for analog LED strip (W1: 14, W2: 04) + #define W2PIN 04 //W2 pin for analog LED strip + #else //PWM pins - PINs 5,12,13,15 are used with Magic Home LED Controller - #define RPIN 5 //R pin for analog LED strip - #define GPIN 12 //G pin for analog LED strip - #define BPIN 13 //B pin for analog LED strip - #define WPIN 15 //W pin for analog LED strip + #define RPIN 5 //R pin for analog LED strip + #define GPIN 12 //G pin for analog LED strip + #define BPIN 15 //B pin for analog LED strip + #define WPIN 13 //W pin for analog LED strip (W1: 14, W2: 04) + #endif #endif //automatically uses the right driver method for each platform @@ -112,14 +126,18 @@ public: _pGrbw->Begin(); break; - #ifndef WLED_DISABLE_ANALOG_LEDS + #ifdef WLED_USE_ANALOG_LEDS //init PWM pins - PINs 5,12,13,15 are used with Magic Home LED Controller pinMode(RPIN, OUTPUT); pinMode(GPIN, OUTPUT); pinMode(BPIN, OUTPUT); switch (_type) { - case NeoPixelType_Grb: break; - case NeoPixelType_Grbw: pinMode(WPIN, OUTPUT); break; + case NeoPixelType_Grb: break; + #ifdef WLED_USE_5CH_LEDS + case NeoPixelType_Grbw: pinMode(WPIN, OUTPUT); pinMode(W2PIN, OUTPUT); break; + #else + case NeoPixelType_Grbw: pinMode(WPIN, OUTPUT); break; + #endif } analogWriteRange(255); //same range as one RGB channel analogWriteFreq(880); //PWM frequency proven as good for LEDs @@ -128,15 +146,19 @@ public: } } -#ifndef WLED_DISABLE_ANALOG_LEDS - void SetRgbwPwm(uint8_t r, uint8_t g, uint8_t b, uint8_t w) +#ifdef WLED_USE_ANALOG_LEDS + void SetRgbwPwm(uint8_t r, uint8_t g, uint8_t b, uint8_t w, uint8_t w2=0) { analogWrite(RPIN, r); analogWrite(GPIN, g); analogWrite(BPIN, b); switch (_type) { - case NeoPixelType_Grb: break; - case NeoPixelType_Grbw: analogWrite(WPIN, w); break; + case NeoPixelType_Grb: break; + #ifdef WLED_USE_5CH_LEDS + case NeoPixelType_Grbw: analogWrite(WPIN, w); analogWrite(W2PIN, w2); break; + #else + case NeoPixelType_Grbw: analogWrite(WPIN, w); break; + #endif } } #endif @@ -148,7 +170,7 @@ public: { case NeoPixelType_Grb: { _pGrb->Show(); - #ifndef WLED_DISABLE_ANALOG_LEDS + #ifdef WLED_USE_ANALOG_LEDS RgbColor color = _pGrb->GetPixelColor(0); b = _pGrb->GetBrightness(); SetRgbwPwm(color.R * b / 255, color.G * b / 255, color.B * b / 255, 0); @@ -157,10 +179,27 @@ public: break; case NeoPixelType_Grbw: { _pGrbw->Show(); - #ifndef WLED_DISABLE_ANALOG_LEDS + #ifdef WLED_USE_ANALOG_LEDS RgbwColor colorW = _pGrbw->GetPixelColor(0); b = _pGrbw->GetBrightness(); - SetRgbwPwm(colorW.R * b / 255, colorW.G * b / 255, colorW.B * b / 255, colorW.W * b / 255); + // check color values for Warm / COld white mix (for RGBW) // EsplanexaDevice.cpp + #ifdef WLED_USE_5CH_LEDS + if (colorW.R == 255 & colorW.G == 255 && colorW.B == 255 && colorW.W == 255) { + SetRgbwPwm(0, 0, 0, 0, colorW.W * b / 255); + } else if (colorW.R == 127 & colorW.G == 127 && colorW.B == 127 && colorW.W == 255) { + SetRgbwPwm(0, 0, 0, colorW.W * b / 512, colorW.W * b / 255); + } else if (colorW.R == 0 & colorW.G == 0 && colorW.B == 0 && colorW.W == 255) { + SetRgbwPwm(0, 0, 0, colorW.W * b / 255, 0); + } else if (colorW.R == 130 & colorW.G == 90 && colorW.B == 0 && colorW.W == 255) { + SetRgbwPwm(0, 0, 0, colorW.W * b / 255, colorW.W * b / 512); + } else if (colorW.R == 255 & colorW.G == 153 && colorW.B == 0 && colorW.W == 255) { + SetRgbwPwm(0, 0, 0, colorW.W * b / 255, 0); + } else { // not only white colors + SetRgbwPwm(colorW.R * b / 255, colorW.G * b / 255, colorW.B * b / 255, colorW.W * b / 255); + } + #else + SetRgbwPwm(colorW.R * b / 255, colorW.G * b / 255, colorW.B * b / 255, colorW.W * b / 255); + #endif #endif } break; diff --git a/wled00/src/dependencies/espalexa/EspalexaDevice.cpp b/wled00/src/dependencies/espalexa/EspalexaDevice.cpp index 43ad6f02f..e8cff1645 100644 --- a/wled00/src/dependencies/espalexa/EspalexaDevice.cpp +++ b/wled00/src/dependencies/espalexa/EspalexaDevice.cpp @@ -110,8 +110,8 @@ uint32_t EspalexaDevice::getKelvin() uint32_t EspalexaDevice::getRGB() { if (_rgb != 0) return _rgb; //color has not changed - uint8_t rgb[3]; - float r, g, b; + byte rgb[4]{0, 0, 0, 0}; + float r, g, b, w; if (_mode == EspalexaColorMode::none) return 0; @@ -122,6 +122,15 @@ uint32_t EspalexaDevice::getRGB() float temp = 10000/ _ct; //kelvins = 1,000,000/mired (and that /100) float r, g, b; +// Cold white to warm white receiving from Alexa: _ct = 199, 234, 284, 350, 383 (from cold white to warm white) + switch (_ct) { + case 199: rgb[0]=255,rgb[1]=255,rgb[2]=255;rgb[3]=255;break; + case 234: rgb[0]=127,rgb[1]=127,rgb[2]=127;rgb[3]=255;break; + case 284: rgb[0]=0,rgb[1]=0,rgb[2]=0;rgb[3]=255;break; + case 350: rgb[0]=130,rgb[1]=90,rgb[2]=0;rgb[3]=255;break; + case 383: rgb[0]=255,rgb[1]=153,rgb[2]=0;rgb[3]=255;break; + default: { + if( temp <= 66 ){ r = 255; g = temp; @@ -143,6 +152,8 @@ uint32_t EspalexaDevice::getRGB() rgb[0] = (byte)constrain(r,0.1,255.1); rgb[1] = (byte)constrain(g,0.1,255.1); rgb[2] = (byte)constrain(b,0.1,255.1); + + } } else if (_mode == EspalexaColorMode::hs) { float h = ((float)_hue)/65535.0; @@ -216,7 +227,7 @@ uint32_t EspalexaDevice::getRGB() rgb[1] = 255.0*g; rgb[2] = 255.0*b; } - _rgb = ((rgb[0] << 16) | (rgb[1] << 8) | (rgb[2])); + _rgb = ((rgb[3] << 24) | (rgb[0] << 16) | (rgb[1] << 8) | (rgb[2])); //white value is only >0 if Alexa did provide a CT value, RGB colors will not be touched. return _rgb; } diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 1f3bcd268..de60f2020 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -33,7 +33,10 @@ //#define WLED_DEBUG //to toggle using analog RGB or RGBW led strips (un)comment the following line -//#define WLED_DISABLE_ANALOG_LEDS +//#define WLED_USE_ANALOG_LEDS + +//to toggle using 5CH analog RGBWS led strips (un)comment the following line +//#define WLED_USE_5CH_LEDS //library inclusions #include @@ -89,6 +92,7 @@ #endif #ifdef ARDUINO_ARCH_ESP32 + #undef WLED_USE_ANALOG_LEDS // Solid RGBW not implemented for ESP32 yet /*#ifndef WLED_DISABLE_INFRARED #include #endif*/ //there are issues with ESP32 infrared, so it is disabled for now diff --git a/wled00/wled12_alexa.ino b/wled00/wled12_alexa.ino index b858d2382..c3bc01ab0 100644 --- a/wled00/wled12_alexa.ino +++ b/wled00/wled12_alexa.ino @@ -62,10 +62,11 @@ void onAlexaChange(EspalexaDevice* dev) } else //color { uint32_t color = espalexaDevice->getRGB(); + col[3] = ((color >> 24) & 0xFF); // white color from Alexa is "pure white only" col[0] = ((color >> 16) & 0xFF); col[1] = ((color >> 8) & 0xFF); col[2] = (color & 0xFF); - if (useRGBW) colorRGBtoRGBW(col); + if (useRGBW && col[3] == 0) colorRGBtoRGBW(col); // do not touch white value if EspalexaDevice.cpp did set the white channel colorUpdated(10); } } diff --git a/wled00/wled14_colors.ino b/wled00/wled14_colors.ino index de57be9eb..9bedafb4b 100644 --- a/wled00/wled14_colors.ino +++ b/wled00/wled14_colors.ino @@ -158,6 +158,6 @@ void colorRGBtoRGBW(byte* rgb) //rgb to rgbw (http://codewelt.com/rgbw) float low = minf(rgb[0],minf(rgb[1],rgb[2])); float high = maxf(rgb[0],maxf(rgb[1],rgb[2])); if (high < 0.1f) return; - float sat = 255.0f * ((high - low) / high); + float sat = 100.0f * ((high - low) / high);; // maximum saturation is 100 (corrected from 255) rgb[3] = (byte)((255.0f - sat) / 255.0f * (rgb[0] + rgb[1] + rgb[2]) / 3); } From ed24f72cf9c9b82896573d14a718f3f1688a3a7c Mon Sep 17 00:00:00 2001 From: Def3nder Date: Wed, 18 Dec 2019 15:35:32 +0100 Subject: [PATCH 5/9] Changes for 4CH and 5CH LED stripes ESP32 fixes for Solid RGBW (...not implemented for ESP32 yet) Use 5CH solid RGB stripes adapt the logic to use CW and WW for different CT-values change from Opt-out to Opt-In for analog LEDs Added new boards Alexa color changes to match white values with 4Ch and 5Ch LED stripes bracket error Device definitions --- platformio.ini | 70 +++++++++++++++-- wled00/NpbWrapper.h | 75 ++++++++++++++----- .../dependencies/espalexa/EspalexaDevice.cpp | 18 ++++- wled00/wled00.ino | 6 +- wled00/wled12_alexa.ino | 3 +- wled00/wled14_colors.ino | 2 +- 6 files changed, 142 insertions(+), 32 deletions(-) diff --git a/platformio.ini b/platformio.ini index 16d54e3c8..4204910d0 100644 --- a/platformio.ini +++ b/platformio.ini @@ -4,13 +4,17 @@ [platformio] src_dir = ./wled00 data_dir = ./wled00/data -lib_extra_dirs = ./wled00/src +;lib_extra_dirs = ./wled00/src +lib_dir = ./wled00/src ; Please uncomment one of the 5 lines below to select your board ; env_default = nodemcuv2 ; env_default = esp01 ; env_default = esp01_1m ; env_default = d1_mini ; env_default = esp32dev +; env_default = esp8285_4CH_MagicHome +; env_default = esp8285_4CH_H801 +; env_default = esp8285_5CH_H801 [common] @@ -31,6 +35,7 @@ lib_deps_external = FastLED@3.3.2 NeoPixelBus@2.5.1 ESPAsyncTCP@1.2.0 + ESPAsyncUDP@697c75a025 AsyncTCP@1.0.3 Esp Async WebServer@1.2.0 #ArduinoJson@5.13.5 @@ -57,8 +62,10 @@ arduino_core_2_4_1 = espressif8266@1.7.3 arduino_core_2_4_2 = espressif8266@1.8.0 arduino_core_2_5_0 = espressif8266@2.0.4 arduino_core_2_5_2 = espressif8266@2.2.3 +arduino_core_2_6_1 = espressif8266@2.3.0 +arduino_core_2_6_2 = espressif8266@2.3.1 arduino_core_stage = https://github.com/platformio/platform-espressif8266.git#feature/stage -platform = ${common:esp8266.arduino_core_2_5_2} +platform = ${common:esp8266.arduino_core_2_6_2} build_flags = -D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH -Wl,-Teagle.flash.4m1m.ld ;;;; Required for core > v2.5.0 or staging version 4MB Flash 3MB SPIFFs @@ -74,7 +81,7 @@ build_flags = -D WLED_DISABLE_BLYNK -D WLED_DISABLE_CRONIXIE ; -D WLED_DISABLE_HUESYNC - -D WLED_DISABLE_INFRARED + ; -D WLED_DISABLE_INFRARED [common:esp8266_512k] platform = espressif8266@1.8.0 @@ -86,15 +93,15 @@ build_flags = ; -D WLED_DISABLE_ALEXA -D WLED_DISABLE_BLYNK -D WLED_DISABLE_CRONIXIE - ; -D WLED_DISABLE_HUESYNC - -D WLED_DISABLE_INFRARED + -D WLED_DISABLE_HUESYNC + ; -D WLED_DISABLE_INFRARED [common:esp32] -platform = espressif32@1.7.0 +platform = espressif32@1.11.1 build_flags = -D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH -D ARDUINO_ARCH_ESP32 - -D WLED_DISABLE_INFRARED + -D WLED_DISABLE_INFRARED # see: http://docs.platformio.org/en/latest/platforms/espressif8266.html [env:nodemcuv2] @@ -121,6 +128,51 @@ build_flags = lib_deps = ${common.lib_deps_external} +[env:esp8285_4CH_MagicHome] +board = esp8285 +platform = ${common:esp8266_1M.platform} +monitor_speed = ${common.monitor_speed} +upload_speed = ${common.upload_speed} +framework = ${common.framework} +build_flags = + ${common.build_flags} + ${common:esp8266_1M.build_flags} + -D WLED_DISABLE_HUESYNC + -D WLED_USE_ANALOG_LEDS +lib_deps = + ${common.lib_deps_external} + +[env:esp8285_4CH_H801] +board = esp8285 +platform = ${common:esp8266_1M.platform} +monitor_speed = ${common.monitor_speed} +upload_speed = ${common.upload_speed} +framework = ${common.framework} +build_flags = + ${common.build_flags} + ${common:esp8266_1M.build_flags} + -D WLED_DISABLE_HUESYNC + -D WLED_USE_ANALOG_LEDS + -D WLED_USE_H801 +lib_deps = + ${common.lib_deps_external} + +[env:esp8285_5CH_H801] +board = esp8285 +platform = ${common:esp8266_1M.platform} +monitor_speed = ${common.monitor_speed} +upload_speed = ${common.upload_speed} +framework = ${common.framework} +build_flags = + ${common.build_flags} + ${common:esp8266_1M.build_flags} + -D WLED_DISABLE_HUESYNC + -D WLED_USE_ANALOG_LEDS + -D WLED_USE_5CH_LEDS + -D WLED_USE_H801 +lib_deps = + ${common.lib_deps_external} + [env:esp01_1m] board = esp01_1m platform = ${common:esp8266_1M.platform} @@ -144,6 +196,7 @@ framework = ${common.framework} build_flags = ${common.build_flags} ${common:esp8266_512k.build_flags} + -D WLED_DISABLE_INFRARED lib_deps = ${common.lib_deps_external} @@ -160,4 +213,5 @@ build_flags = lib_deps = ${common.lib_deps_external} lib_ignore = - IRremoteESP8266 \ No newline at end of file + IRremoteESP8266 + ESPAsyncUDP \ No newline at end of file diff --git a/wled00/NpbWrapper.h b/wled00/NpbWrapper.h index 7adc73f23..0f1c510d3 100644 --- a/wled00/NpbWrapper.h +++ b/wled00/NpbWrapper.h @@ -5,9 +5,14 @@ //PIN CONFIGURATION #define LEDPIN 2 //strip pin. Any for ESP32, gpio2 or 3 is recommended for ESP8266 (gpio2/3 are labeled D4/RX on NodeMCU and Wemos) //#define USE_APA102 // Uncomment for using APA102 LEDs. -#define BTNPIN 0 //button pin. Needs to have pullup (gpio0 recommended) -#define IR_PIN 4 //infrared pin (-1 to disable) -#define RLYPIN 12 //pin for relay, will be set HIGH if LEDs are on (-1 to disable). Also usable for standby leds, triggers,... +#ifdef WLED_USE_H801 + #define BTNPIN -1 //button pin. Needs to have pullup (gpio0 recommended) + #define IR_PIN 0 //infrared pin (-1 to disable) MagicHome: 4, H801 Wifi: 0 +#else + #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 -1 //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) #define RLYMDE 1 //mode for relay, 0: LOW if LEDs are on 1: HIGH if LEDs are on @@ -20,12 +25,21 @@ #endif #endif -#ifndef WLED_DISABLE_ANALOG_LEDS +#ifdef WLED_USE_ANALOG_LEDS + //PWM pins - PINs 15,13,12,14 (W2 = 04)are used with H801 Wifi LED Controller + #ifdef WLED_USE_H801 + #define RPIN 15 //R pin for analog LED strip + #define GPIN 13 //G pin for analog LED strip + #define BPIN 12 //B pin for analog LED strip + #define WPIN 14 //W pin for analog LED strip (W1: 14, W2: 04) + #define W2PIN 04 //W2 pin for analog LED strip + #else //PWM pins - PINs 5,12,13,15 are used with Magic Home LED Controller - #define RPIN 5 //R pin for analog LED strip - #define GPIN 12 //G pin for analog LED strip - #define BPIN 13 //B pin for analog LED strip - #define WPIN 15 //W pin for analog LED strip + #define RPIN 5 //R pin for analog LED strip + #define GPIN 12 //G pin for analog LED strip + #define BPIN 15 //B pin for analog LED strip + #define WPIN 13 //W pin for analog LED strip (W1: 14, W2: 04) + #endif #endif //automatically uses the right driver method for each platform @@ -112,14 +126,18 @@ public: _pGrbw->Begin(); break; - #ifndef WLED_DISABLE_ANALOG_LEDS + #ifdef WLED_USE_ANALOG_LEDS //init PWM pins - PINs 5,12,13,15 are used with Magic Home LED Controller pinMode(RPIN, OUTPUT); pinMode(GPIN, OUTPUT); pinMode(BPIN, OUTPUT); switch (_type) { - case NeoPixelType_Grb: break; - case NeoPixelType_Grbw: pinMode(WPIN, OUTPUT); break; + case NeoPixelType_Grb: break; + #ifdef WLED_USE_5CH_LEDS + case NeoPixelType_Grbw: pinMode(WPIN, OUTPUT); pinMode(W2PIN, OUTPUT); break; + #else + case NeoPixelType_Grbw: pinMode(WPIN, OUTPUT); break; + #endif } analogWriteRange(255); //same range as one RGB channel analogWriteFreq(880); //PWM frequency proven as good for LEDs @@ -128,15 +146,19 @@ public: } } -#ifndef WLED_DISABLE_ANALOG_LEDS - void SetRgbwPwm(uint8_t r, uint8_t g, uint8_t b, uint8_t w) +#ifdef WLED_USE_ANALOG_LEDS + void SetRgbwPwm(uint8_t r, uint8_t g, uint8_t b, uint8_t w, uint8_t w2=0) { analogWrite(RPIN, r); analogWrite(GPIN, g); analogWrite(BPIN, b); switch (_type) { - case NeoPixelType_Grb: break; - case NeoPixelType_Grbw: analogWrite(WPIN, w); break; + case NeoPixelType_Grb: break; + #ifdef WLED_USE_5CH_LEDS + case NeoPixelType_Grbw: analogWrite(WPIN, w); analogWrite(W2PIN, w2); break; + #else + case NeoPixelType_Grbw: analogWrite(WPIN, w); break; + #endif } } #endif @@ -148,7 +170,7 @@ public: { case NeoPixelType_Grb: { _pGrb->Show(); - #ifndef WLED_DISABLE_ANALOG_LEDS + #ifdef WLED_USE_ANALOG_LEDS RgbColor color = _pGrb->GetPixelColor(0); b = _pGrb->GetBrightness(); SetRgbwPwm(color.R * b / 255, color.G * b / 255, color.B * b / 255, 0); @@ -157,10 +179,27 @@ public: break; case NeoPixelType_Grbw: { _pGrbw->Show(); - #ifndef WLED_DISABLE_ANALOG_LEDS + #ifdef WLED_USE_ANALOG_LEDS RgbwColor colorW = _pGrbw->GetPixelColor(0); b = _pGrbw->GetBrightness(); - SetRgbwPwm(colorW.R * b / 255, colorW.G * b / 255, colorW.B * b / 255, colorW.W * b / 255); + // check color values for Warm / COld white mix (for RGBW) // EsplanexaDevice.cpp + #ifdef WLED_USE_5CH_LEDS + if (colorW.R == 255 & colorW.G == 255 && colorW.B == 255 && colorW.W == 255) { + SetRgbwPwm(0, 0, 0, 0, colorW.W * b / 255); + } else if (colorW.R == 127 & colorW.G == 127 && colorW.B == 127 && colorW.W == 255) { + SetRgbwPwm(0, 0, 0, colorW.W * b / 512, colorW.W * b / 255); + } else if (colorW.R == 0 & colorW.G == 0 && colorW.B == 0 && colorW.W == 255) { + SetRgbwPwm(0, 0, 0, colorW.W * b / 255, 0); + } else if (colorW.R == 130 & colorW.G == 90 && colorW.B == 0 && colorW.W == 255) { + SetRgbwPwm(0, 0, 0, colorW.W * b / 255, colorW.W * b / 512); + } else if (colorW.R == 255 & colorW.G == 153 && colorW.B == 0 && colorW.W == 255) { + SetRgbwPwm(0, 0, 0, colorW.W * b / 255, 0); + } else { // not only white colors + SetRgbwPwm(colorW.R * b / 255, colorW.G * b / 255, colorW.B * b / 255, colorW.W * b / 255); + } + #else + SetRgbwPwm(colorW.R * b / 255, colorW.G * b / 255, colorW.B * b / 255, colorW.W * b / 255); + #endif #endif } break; diff --git a/wled00/src/dependencies/espalexa/EspalexaDevice.cpp b/wled00/src/dependencies/espalexa/EspalexaDevice.cpp index 43ad6f02f..df859c1d9 100644 --- a/wled00/src/dependencies/espalexa/EspalexaDevice.cpp +++ b/wled00/src/dependencies/espalexa/EspalexaDevice.cpp @@ -110,8 +110,8 @@ uint32_t EspalexaDevice::getKelvin() uint32_t EspalexaDevice::getRGB() { if (_rgb != 0) return _rgb; //color has not changed - uint8_t rgb[3]; - float r, g, b; + byte rgb[4]{0, 0, 0, 0}; + float r, g, b, w; if (_mode == EspalexaColorMode::none) return 0; @@ -122,6 +122,15 @@ uint32_t EspalexaDevice::getRGB() float temp = 10000/ _ct; //kelvins = 1,000,000/mired (and that /100) float r, g, b; +// Cold white to warm white receiving from Alexa: _ct = 199, 234, 284, 350, 383 (from cold white to warm white) + switch (_ct) { + case 199: rgb[0]=255,rgb[1]=255,rgb[2]=255;rgb[3]=255;break; + case 234: rgb[0]=127,rgb[1]=127,rgb[2]=127;rgb[3]=255;break; + case 284: rgb[0]=0,rgb[1]=0,rgb[2]=0;rgb[3]=255;break; + case 350: rgb[0]=130,rgb[1]=90,rgb[2]=0;rgb[3]=255;break; + case 383: rgb[0]=255,rgb[1]=153,rgb[2]=0;rgb[3]=255;break; + default: { + if( temp <= 66 ){ r = 255; g = temp; @@ -143,6 +152,9 @@ uint32_t EspalexaDevice::getRGB() rgb[0] = (byte)constrain(r,0.1,255.1); rgb[1] = (byte)constrain(g,0.1,255.1); rgb[2] = (byte)constrain(b,0.1,255.1); + + } + } } else if (_mode == EspalexaColorMode::hs) { float h = ((float)_hue)/65535.0; @@ -216,7 +228,7 @@ uint32_t EspalexaDevice::getRGB() rgb[1] = 255.0*g; rgb[2] = 255.0*b; } - _rgb = ((rgb[0] << 16) | (rgb[1] << 8) | (rgb[2])); + _rgb = ((rgb[3] << 24) | (rgb[0] << 16) | (rgb[1] << 8) | (rgb[2])); //white value is only >0 if Alexa did provide a CT value, RGB colors will not be touched. return _rgb; } diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 1f3bcd268..de60f2020 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -33,7 +33,10 @@ //#define WLED_DEBUG //to toggle using analog RGB or RGBW led strips (un)comment the following line -//#define WLED_DISABLE_ANALOG_LEDS +//#define WLED_USE_ANALOG_LEDS + +//to toggle using 5CH analog RGBWS led strips (un)comment the following line +//#define WLED_USE_5CH_LEDS //library inclusions #include @@ -89,6 +92,7 @@ #endif #ifdef ARDUINO_ARCH_ESP32 + #undef WLED_USE_ANALOG_LEDS // Solid RGBW not implemented for ESP32 yet /*#ifndef WLED_DISABLE_INFRARED #include #endif*/ //there are issues with ESP32 infrared, so it is disabled for now diff --git a/wled00/wled12_alexa.ino b/wled00/wled12_alexa.ino index b858d2382..c3bc01ab0 100644 --- a/wled00/wled12_alexa.ino +++ b/wled00/wled12_alexa.ino @@ -62,10 +62,11 @@ void onAlexaChange(EspalexaDevice* dev) } else //color { uint32_t color = espalexaDevice->getRGB(); + col[3] = ((color >> 24) & 0xFF); // white color from Alexa is "pure white only" col[0] = ((color >> 16) & 0xFF); col[1] = ((color >> 8) & 0xFF); col[2] = (color & 0xFF); - if (useRGBW) colorRGBtoRGBW(col); + if (useRGBW && col[3] == 0) colorRGBtoRGBW(col); // do not touch white value if EspalexaDevice.cpp did set the white channel colorUpdated(10); } } diff --git a/wled00/wled14_colors.ino b/wled00/wled14_colors.ino index de57be9eb..9bedafb4b 100644 --- a/wled00/wled14_colors.ino +++ b/wled00/wled14_colors.ino @@ -158,6 +158,6 @@ void colorRGBtoRGBW(byte* rgb) //rgb to rgbw (http://codewelt.com/rgbw) float low = minf(rgb[0],minf(rgb[1],rgb[2])); float high = maxf(rgb[0],maxf(rgb[1],rgb[2])); if (high < 0.1f) return; - float sat = 255.0f * ((high - low) / high); + float sat = 100.0f * ((high - low) / high);; // maximum saturation is 100 (corrected from 255) rgb[3] = (byte)((255.0f - sat) / 255.0f * (rgb[0] + rgb[1] + rgb[2]) / 3); } From 4c58929dd414fb834001a94f809485962349e3ee Mon Sep 17 00:00:00 2001 From: cschwinne Date: Thu, 19 Dec 2019 21:08:21 +0100 Subject: [PATCH 6/9] Fix compile --- wled00/NpbWrapper.h | 1 - wled00/wled00.ino | 10 ++-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/wled00/NpbWrapper.h b/wled00/NpbWrapper.h index fd8366187..ad841c8fb 100644 --- a/wled00/NpbWrapper.h +++ b/wled00/NpbWrapper.h @@ -37,7 +37,6 @@ #undef BTNPIN #undef IR_PIN #define IR_PIN 0 //infrared pin (-1 to disable) MagicHome: 4, H801 Wifi: 0 -#endif #else //PWM pins - PINs 5,12,13,15 are used with Magic Home LED Controller #define RPIN 5 //R pin for analog LED strip diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 930b54597..8be245c86 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -32,12 +32,6 @@ //to toggle usb serial debug (un)comment the following line //#define WLED_DEBUG -//to toggle using analog RGB or RGBW led strips (un)comment the following line -//#define WLED_USE_ANALOG_LEDS - -//to toggle using 5CH analog RGBWS led strips (un)comment the following line -//#define WLED_USE_5CH_LEDS - //library inclusions #include #ifdef ESP8266 @@ -104,8 +98,8 @@ //version code in format yymmddb (b = daily build) -#define VERSION 1912182 -char versionString[] = "0.9.0-b1"; +#define VERSION 1912191 +char versionString[] = "0.9.0-b2"; //AP and OTA default passwords (for maximum change them!) From 112ba7ac5cbfce7835975936bf2705f7545a7a84 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Thu, 19 Dec 2019 21:31:14 +0100 Subject: [PATCH 7/9] Fix compile for analog --- wled00/NpbWrapper.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/wled00/NpbWrapper.h b/wled00/NpbWrapper.h index ad841c8fb..a704e4269 100644 --- a/wled00/NpbWrapper.h +++ b/wled00/NpbWrapper.h @@ -6,8 +6,8 @@ #define LEDPIN 2 //strip pin. Any for ESP32, gpio2 or 3 is recommended for ESP8266 (gpio2/3 are labeled D4/RX on NodeMCU and Wemos) //#define USE_APA102 // Uncomment for using APA102 LEDs. //#define WLED_USE_ANALOG_LEDS //Uncomment for using "dumb" PWM controlled LEDs (see pins below, default R: gpio5, G: 12, B: 15, W: 13) -//#define WLED_USE_H801 //H801 5 channel controller. Please uncomment #define WLED_USE_ANALOG_LEDS as well -//#define WLED_USE_5CH +//#define WLED_USE_H801 //H801 controller. Please uncomment #define WLED_USE_ANALOG_LEDS as well +//#define WLED_USE_5CH //5 Channel H801 for cold and warm white #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 @@ -185,9 +185,9 @@ public: case NeoPixelType_Grb: { _pGrb->SetPixelColor(indexPixel, RgbColor(color.R,color.G,color.B)); #ifdef WLED_USE_ANALOG_LEDS - if (indexPixel != 0) return; //set analog LEDs from first pixel - b = _pGrb->GetBrightness(); - SetRgbwPwm(color.R * b / 255, color.G * b / 255, color.B * b / 255, 0); + if (indexPixel != 0) return; //set analog LEDs from first pixel + byte b = _pGrb->GetBrightness(); + SetRgbwPwm(color.R * b / 255, color.G * b / 255, color.B * b / 255, 0); #endif } break; @@ -195,7 +195,7 @@ public: _pGrbw->SetPixelColor(indexPixel, color); #ifdef WLED_USE_ANALOG_LEDS if (indexPixel != 0) return; //set analog LEDs from first pixel - b = _pGrbw->GetBrightness(); + byte b = _pGrbw->GetBrightness(); // check color values for Warm / Cold white mix (for RGBW) // EsplanexaDevice.cpp #ifdef WLED_USE_5CH_LEDS if (color.R == 255 & color.G == 255 && color.B == 255 && color.W == 255) { From 6d438545579e1e306c1cd5588937fdefcabe9526 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Thu, 19 Dec 2019 23:43:18 +0100 Subject: [PATCH 8/9] Fix PIO --- platformio.ini | 47 +---------------------------------------------- 1 file changed, 1 insertion(+), 46 deletions(-) diff --git a/platformio.ini b/platformio.ini index fe390a5da..c4cac76d1 100644 --- a/platformio.ini +++ b/platformio.ini @@ -127,51 +127,6 @@ build_flags = lib_deps = ${common.lib_deps_external} -[env:esp8285_4CH_MagicHome] -board = esp8285 -platform = ${common:esp8266_1M.platform} -monitor_speed = ${common.monitor_speed} -upload_speed = ${common.upload_speed} -framework = ${common.framework} -build_flags = - ${common.build_flags} - ${common:esp8266_1M.build_flags} - -D WLED_DISABLE_HUESYNC - -D WLED_USE_ANALOG_LEDS -lib_deps = - ${common.lib_deps_external} - -[env:esp8285_4CH_H801] -board = esp8285 -platform = ${common:esp8266_1M.platform} -monitor_speed = ${common.monitor_speed} -upload_speed = ${common.upload_speed} -framework = ${common.framework} -build_flags = - ${common.build_flags} - ${common:esp8266_1M.build_flags} - -D WLED_DISABLE_HUESYNC - -D WLED_USE_ANALOG_LEDS - -D WLED_USE_H801 -lib_deps = - ${common.lib_deps_external} - -[env:esp8285_5CH_H801] -board = esp8285 -platform = ${common:esp8266_1M.platform} -monitor_speed = ${common.monitor_speed} -upload_speed = ${common.upload_speed} -framework = ${common.framework} -build_flags = - ${common.build_flags} - ${common:esp8266_1M.build_flags} - -D WLED_DISABLE_HUESYNC - -D WLED_USE_ANALOG_LEDS - -D WLED_USE_5CH_LEDS - -D WLED_USE_H801 -lib_deps = - ${common.lib_deps_external} - [env:esp01_1m] board = esp01_1m platform = ${common:esp8266_1M.platform} @@ -231,7 +186,7 @@ lib_deps = [env:esp8285_4CH_H801] board = esp8285 -platform = ${common:esp8266.platform} +platform = ${common:esp8266_1M.platform} monitor_speed = ${common.monitor_speed} upload_speed = ${common.upload_speed} framework = ${common.framework} From 94200dd3a4bba99d2072f83a0d227ceb9dc6ed05 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Sat, 21 Dec 2019 03:17:54 +0100 Subject: [PATCH 9/9] Fixed effects (#466) --- wled00/FX.cpp | 50 +++++++++++++++++++++++++--------------- wled00/wled00.ino | 4 ++-- wled00/wled18_server.ino | 2 +- 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index fc13c60d9..82ec2cf45 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -151,7 +151,7 @@ uint16_t WS2812FX::color_wipe(bool rev, bool useRandomColors) { uint32_t col1 = useRandomColors? color_wheel(SEGENV.aux1) : SEGCOLOR(1); for (uint16_t i = SEGMENT.start; i < SEGMENT.stop; i++) { - uint16_t index = (rev && back)? SEGMENT.stop -1 -i : i; + uint16_t index = (rev && back)? SEGMENT.stop -1 -i +SEGMENT.start : i; uint32_t col0 = useRandomColors? color_wheel(SEGENV.aux0) : color_from_palette(index, true, PALETTE_SOLID_WRAP, 0); if (i - SEGMENT.start < ledIndex) @@ -729,33 +729,40 @@ uint16_t WS2812FX::mode_colorful(void) { cols[3] = 0x0077F0F0; for (uint8_t i = 4; i < 7; i++) cols[i] = cols[i-4]; } - int i = SEGMENT.start; - for (i; i < SEGMENT.stop ; i+=4) + + uint32_t cycleTime = 50 + (15 * (uint32_t)(255 - SEGMENT.speed)); + uint32_t it = now / cycleTime; + if (it != SEGENV.step) { - setPixelColor(i, cols[SEGENV.step]); - setPixelColor(i+1, cols[SEGENV.step+1]); - setPixelColor(i+2, cols[SEGENV.step+2]); - setPixelColor(i+3, cols[SEGENV.step+3]); + if (SEGMENT.speed > 0) SEGENV.aux0++; + if (SEGENV.aux0 > 3) SEGENV.aux0 = 0; + SEGENV.step = it; + } + + uint16_t i = SEGMENT.start; + for (i; i < SEGMENT.stop -3; i+=4) + { + setPixelColor(i, cols[SEGENV.aux0]); + setPixelColor(i+1, cols[SEGENV.aux0+1]); + setPixelColor(i+2, cols[SEGENV.aux0+2]); + setPixelColor(i+3, cols[SEGENV.aux0+3]); } - i+=4; if(i < SEGMENT.stop) { - setPixelColor(i, cols[SEGENV.step]); + setPixelColor(i, cols[SEGENV.aux0]); if(i+1 < SEGMENT.stop) { - setPixelColor(i+1, cols[SEGENV.step+1]); + setPixelColor(i+1, cols[SEGENV.aux0+1]); if(i+2 < SEGMENT.stop) { - setPixelColor(i+2, cols[SEGENV.step+2]); + setPixelColor(i+2, cols[SEGENV.aux0+2]); } } } - if (SEGMENT.speed > 0) SEGENV.step++; //static if lowest speed - if (SEGENV.step >3) SEGENV.step = 0; - return 50 + (15 * (uint32_t)(255 - SEGMENT.speed)); + return FRAMETIME; } @@ -768,7 +775,7 @@ uint16_t WS2812FX::mode_traffic_light(void) { uint32_t mdelay = 500; for (int i = SEGMENT.start; i < SEGMENT.stop-2 ; i+=3) { - switch (SEGENV.step) + switch (SEGENV.aux0) { case 0: setPixelColor(i, 0x00FF0000); mdelay = 150 + (100 * (uint32_t)(255 - SEGMENT.speed));break; case 1: setPixelColor(i, 0x00FF0000); mdelay = 150 + (20 * (uint32_t)(255 - SEGMENT.speed)); setPixelColor(i+1, 0x00EECC00); break; @@ -777,9 +784,14 @@ uint16_t WS2812FX::mode_traffic_light(void) { } } - SEGENV.step++; - if (SEGENV.step >3) SEGENV.step = 0; - return mdelay; + if (now - SEGENV.step > mdelay) + { + SEGENV.aux0++; + if (SEGENV.aux0 > 3) SEGENV.aux0 = 0; + SEGENV.step = now; + } + + return FRAMETIME; } @@ -1074,7 +1086,7 @@ uint16_t WS2812FX::gradient_base(bool loading) { } per = val/brd; if (per >1.0) per = 1.0; - setPixelColor(SEGMENT.start + i, color_blend(SEGCOLOR(0), color_from_palette(SEGMENT.start + i, true, PALETTE_SOLID_WRAP, 1), per*255)); + setPixelColor(i, color_blend(SEGCOLOR(0), color_from_palette(i, true, PALETTE_SOLID_WRAP, 1), per*255)); } SEGENV.step++; diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 8be245c86..34403ee37 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -3,7 +3,7 @@ */ /* * @title WLED project sketch - * @version 0.9.0-b1 + * @version 0.9.0-b2 * @author Christian Schwinne */ @@ -98,7 +98,7 @@ //version code in format yymmddb (b = daily build) -#define VERSION 1912191 +#define VERSION 1912211 char versionString[] = "0.9.0-b2"; diff --git a/wled00/wled18_server.ino b/wled00/wled18_server.ino index e101c997e..f7162d3e5 100644 --- a/wled00/wled18_server.ino +++ b/wled00/wled18_server.ino @@ -104,7 +104,7 @@ void initServer() AsyncCallbackJsonWebHandler* handler = new AsyncCallbackJsonWebHandler("/json", [](AsyncWebServerRequest *request) { bool verboseResponse = false; - if (1) { //scope JsonDocument so it releases its buffer + { //scope JsonDocument so it releases its buffer DynamicJsonDocument jsonBuffer(8192); DeserializationError error = deserializeJson(jsonBuffer, (uint8_t*)(request->_tempObject)); JsonObject root = jsonBuffer.as();