From 6f188d455ada0de1ff11a04155f04cfb0e84f2c5 Mon Sep 17 00:00:00 2001 From: Debashish Sahu Date: Thu, 7 Mar 2019 12:49:30 -0500 Subject: [PATCH 1/4] WS2811 DMA - Added Settings for WS2811 --- Arduino/McLighting/McLighting.ino | 43 +++++++++++++++++++++++------ Arduino/McLighting/definitions.h | 1 + Arduino/McLighting/version.h | 2 +- Arduino/McLighting/version_info.ino | 7 +++-- platformio.ini | 26 ++++++++--------- 5 files changed, 55 insertions(+), 24 deletions(-) diff --git a/Arduino/McLighting/McLighting.ino b/Arduino/McLighting/McLighting.ino index b17f83a..37ad8d4 100644 --- a/Arduino/McLighting/McLighting.ino +++ b/Arduino/McLighting/McLighting.ino @@ -91,26 +91,49 @@ WS2812FX* strip; #include #ifdef USE_WS2812FX_DMA // Uses GPIO3/RXD0/RX, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods - NeoEsp8266Dma800KbpsMethod* dma; + #ifndef LED_TYPE_WS2811 + NeoEsp8266Dma800KbpsMethod* dma; //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) + #else + NeoEsp8266Dma400KbpsMethod* dma; //400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) + #endif #endif #ifdef USE_WS2812FX_UART1 // Uses UART1: GPIO1/TXD0/TX, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods - NeoEsp8266Uart0800KbpsMethod* dma; + #ifndef LED_TYPE_WS2811 + NeoEsp8266Uart0800KbpsMethod* dma; //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) + #else + NeoEsp8266Uart0400KbpsMethod* dma; //400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) + #endif #endif #ifdef USE_WS2812FX_UART2 // Uses UART2: GPIO2/TXD1/D4, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods - NeoEsp8266Uart1800KbpsMethod* dma; + #ifndef LED_TYPE_WS2811 + NeoEsp8266Uart1800KbpsMethod* dma; //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) + #else + NeoEsp8266Uart1400KbpsMethod* dma; //400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) + #endif #endif void initDMA(uint16_t stripSize = NUMLEDS){ if (dma) delete dma; #ifdef USE_WS2812FX_DMA // Uses GPIO3/RXD0/RX, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods - dma = new NeoEsp8266Dma800KbpsMethod(stripSize, 3); //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) - //NeoEsp8266Dma400KbpsMethod dma = NeoEsp8266Dma400KbpsMethod(NUMLEDS, 3); //400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) + #ifndef LED_TYPE_WS2811 + dma = new NeoEsp8266Dma800KbpsMethod(stripSize, 3); //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) + #else + dma = new NeoEsp8266Dma400KbpsMethod(stripSize, 3); //400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) + #endif #endif #ifdef USE_WS2812FX_UART1 // Uses UART1: GPIO1/TXD0/TX, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods - dma = new NeoEsp8266Uart0800KbpsMethod(stripSize, 3); + #ifndef LED_TYPE_WS2811 + dma = new NeoEsp8266Uart0800KbpsMethod(stripSize, 3); //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) + #else + dma = new NeoEsp8266Uart0400KbpsMethod(stripSize, 3); //400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) + #endif #endif #ifdef USE_WS2812FX_UART2 // Uses UART2: GPIO2/TXD1/D4, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods - dma = new NeoEsp8266Uart1800KbpsMethod(stripSize, 3); + #ifndef LED_TYPE_WS2811 + dma = new NeoEsp8266Uart1800KbpsMethod(stripSize, 3); //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) + #else + dma = new NeoEsp8266Uart1400KbpsMethod(stripSize, 3); //400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) + #endif #endif dma->Initialize(); } @@ -241,7 +264,11 @@ void initStrip(uint16_t stripSize = WS2812FXStripSettings.stripSize, neoPixelTyp WS2812FXStripSettings.RGBOrder = RGBOrder; WS2812FXStripSettings.pin = pin; } - strip = new WS2812FX(stripSize, pin, RGBOrder + NEO_KHZ800); + #ifndef LED_TYPE_WS2811 + strip = new WS2812FX(stripSize, pin, RGBOrder + NEO_KHZ800); + #else + strip = new WS2812FX(stripSize, pin, RGBOrder + NEO_KHZ400); + #endif // Parameter 1 = number of pixels in strip // Parameter 2 = Arduino pin number (most are valid) // Parameter 3 = pixel type flags, add together as needed: diff --git a/Arduino/McLighting/definitions.h b/Arduino/McLighting/definitions.h index 5f6c7a5..e90a14f 100644 --- a/Arduino/McLighting/definitions.h +++ b/Arduino/McLighting/definitions.h @@ -5,6 +5,7 @@ // Neopixel #define LED_PIN 14 // LED_PIN (14 / D5) where neopixel / WS2811 strip is attached #define NUMLEDS 24 // Number of leds in the strip +#define LED_TYPE_WS2811 // Uncomment if LED type uses 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) #define BUILTIN_LED 2 // ESP-12F has the built in LED on GPIO2, see https://github.com/esp8266/Arduino/issues/2192 #define BUTTON 4 // Input pin (4 / D2) for switching the LED strip on / off, connect this PIN to ground to trigger button. diff --git a/Arduino/McLighting/version.h b/Arduino/McLighting/version.h index ce383bd..08832bb 100644 --- a/Arduino/McLighting/version.h +++ b/Arduino/McLighting/version.h @@ -1 +1 @@ -#define SKETCH_VERSION "2.2.1" \ No newline at end of file +#define SKETCH_VERSION "2.2.2" \ No newline at end of file diff --git a/Arduino/McLighting/version_info.ino b/Arduino/McLighting/version_info.ino index 2b2fbb1..1b7a7b0 100644 --- a/Arduino/McLighting/version_info.ino +++ b/Arduino/McLighting/version_info.ino @@ -56,11 +56,11 @@ * 23 Dec 2018 v 2.2.0 * - Add E1.31 mode to getModes(), no need to change McLightingUI * - * 6 Jan 2018 v 2.2.0 + * 6 Jan 2019 v 2.2.0 * - fix webserver not responding when E1.31 is mode is acivated: do a webserver.loop() for every 1.31 packet * - HA E1.31 mode added * - * 24 Jan 2018 v 2.2.1 + * 24 Jan 2019 v 2.2.1 * - checkForRequests() is vital for e131 mode, remove from #ifdef ENABLE_LEGACY_ANIMATIONS * - Minor fixes related to NeoPixelBus UART methods * - Modify platformio.ini for future bump to esp8266-arduino v2.5.0 (shamelessly stolen settings from espurna project) @@ -78,4 +78,7 @@ * - Rename varaibles to be char instead of String * - Added LED pixel count and PIN settings to WiFiManager * - Gamma correction to LEDs + * + * 7 Mar 2019 v 2.2.2 + * - Add compiler flag for WS2811 strips #define LED_TYPE_WS2811 */ diff --git a/platformio.ini b/platformio.ini index fee5b1f..d3dc3c1 100644 --- a/platformio.ini +++ b/platformio.ini @@ -41,7 +41,7 @@ lib_deps = AsyncMqttClient https://github.com/bblanchon/ArduinoJson.git#v6.8.0-beta WS2812FX - NeoPixelBus@2.4.2 + NeoPixelBus WebSockets ESPAsyncE131 ESPAsyncUDP @@ -50,17 +50,6 @@ lib_deps = targets_eum = erase, upload, monitor targets_um = upload, monitor -[env:esp01_1m] -board = esp01_1m -framework = ${common.framework} -platform = ${common.platform} -build_flags = ${common.build_flags} -D D1=2 -monitor_speed = ${common.monitor_speed} -upload_speed = ${common.upload_speed} -upload_resetmethod = ${common.upload_resetmethod} -board_build.flash_mode = dout -lib_deps = ${common.lib_deps} - [env:nodemcuv2] board = nodemcuv2 framework = ${common.framework} @@ -72,4 +61,15 @@ monitor_speed = ${common.monitor_speed} upload_speed = ${common.upload_speed} upload_resetmethod = ${common.upload_resetmethod} lib_deps = ${common.lib_deps} -; targets = ${common.targets_um} \ No newline at end of file +; targets = ${common.targets_um} + +[env:esp01_1m] +board = esp01_1m +framework = ${common.framework} +platform = ${common.platform} +build_flags = ${common.build_flags} -D D1=2 +monitor_speed = ${common.monitor_speed} +upload_speed = ${common.upload_speed} +upload_resetmethod = ${common.upload_resetmethod} +board_build.flash_mode = dout +lib_deps = ${common.lib_deps} \ No newline at end of file From fa918443c4063d418e25698b695b18549fd4beb0 Mon Sep 17 00:00:00 2001 From: Debashish Sahu Date: Thu, 7 Mar 2019 12:50:22 -0500 Subject: [PATCH 2/4] Update definitions.h #define LED_TYPE_WS2811 disbaled by default --- Arduino/McLighting/definitions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Arduino/McLighting/definitions.h b/Arduino/McLighting/definitions.h index e90a14f..dc02cc5 100644 --- a/Arduino/McLighting/definitions.h +++ b/Arduino/McLighting/definitions.h @@ -5,7 +5,7 @@ // Neopixel #define LED_PIN 14 // LED_PIN (14 / D5) where neopixel / WS2811 strip is attached #define NUMLEDS 24 // Number of leds in the strip -#define LED_TYPE_WS2811 // Uncomment if LED type uses 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) +//#define LED_TYPE_WS2811 // Uncomment if LED type uses 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) #define BUILTIN_LED 2 // ESP-12F has the built in LED on GPIO2, see https://github.com/esp8266/Arduino/issues/2192 #define BUTTON 4 // Input pin (4 / D2) for switching the LED strip on / off, connect this PIN to ground to trigger button. From 1b6cf691821f476e7518d48b310693669320dd9a Mon Sep 17 00:00:00 2001 From: Debashish Sahu Date: Fri, 8 Mar 2019 10:59:36 -0500 Subject: [PATCH 3/4] hotfix #351 - hotfix #351 --- Arduino/McLighting/McLighting.ino | 2 +- Arduino/McLighting/request_handlers.h | 4 +++- README.md | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Arduino/McLighting/McLighting.ino b/Arduino/McLighting/McLighting.ino index 37ad8d4..89a63ae 100644 --- a/Arduino/McLighting/McLighting.ino +++ b/Arduino/McLighting/McLighting.ino @@ -889,7 +889,7 @@ void setup() { DynamicJsonDocument jsonBuffer(200); JsonObject json = jsonBuffer.to(); - json["pixel_pount"] = WS2812FXStripSettings.stripSize; + json["pixel_count"] = WS2812FXStripSettings.stripSize; json["rgb_order"] = WS2812FXStripSettings.RGBOrder; json["pin"] = WS2812FXStripSettings.pin; String json_str; diff --git a/Arduino/McLighting/request_handlers.h b/Arduino/McLighting/request_handlers.h index 4ba7210..4f0f445 100644 --- a/Arduino/McLighting/request_handlers.h +++ b/Arduino/McLighting/request_handlers.h @@ -1412,7 +1412,9 @@ bool readStateFS() { main_color.green = json["green"]; main_color.blue = json["blue"]; - if(mode != OFF) stateOn = true; + #ifdef ENABLE_HOMEASSISTANT + if(mode != OFF) stateOn = true; + #endif strip->setMode(ws2812fx_mode); strip->setSpeed(convertSpeed(ws2812fx_speed)); strip->setBrightness(brightness); diff --git a/README.md b/README.md index a95aec5..73b89d5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # McLighting v2 - The ESP8266 based multi-client lighting gadget -[![Gitter](https://badges.gitter.im/mclighting/Lobby.svg)](https://gitter.im/mclighting/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Build Status](https://travis-ci.com/toblum/McLighting.svg?branch=master)](https://travis-ci.com/toblum/McLighting) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![version](https://img.shields.io/badge/version-v2.2.1-blue.svg)](https://github.com/toblum/McLighting/blob/master/Arduino/McLighting/version.h) +[![Gitter](https://badges.gitter.im/mclighting/Lobby.svg)](https://gitter.im/mclighting/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Build Status](https://travis-ci.com/toblum/McLighting.svg?branch=master)](https://travis-ci.com/toblum/McLighting) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![version](https://img.shields.io/badge/version-v2.2.2-blue.svg)](https://github.com/toblum/McLighting/blob/master/Arduino/McLighting/version.h) McLighting (the multi-client lighting gadget) is a very cheap internet-controllable lighting solution based on the famous ESP8266 microcontroller and WS2811/2812 led strips. It features among other things a web-interface, a REST-API and a websocket connector. From 5aebe40d09b363ecf6e949545adb2791bff0a586 Mon Sep 17 00:00:00 2001 From: Debashish Sahu Date: Fri, 8 Mar 2019 11:01:09 -0500 Subject: [PATCH 4/4] Update version_info.ino --- Arduino/McLighting/version_info.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/Arduino/McLighting/version_info.ino b/Arduino/McLighting/version_info.ino index 1b7a7b0..2764ee5 100644 --- a/Arduino/McLighting/version_info.ino +++ b/Arduino/McLighting/version_info.ino @@ -81,4 +81,5 @@ * * 7 Mar 2019 v 2.2.2 * - Add compiler flag for WS2811 strips #define LED_TYPE_WS2811 + * - Hotfix #351 */