From c53d02bdbee63b6278701b3556440b552c50d166 Mon Sep 17 00:00:00 2001 From: Debashish Sahu Date: Mon, 15 Oct 2018 12:09:58 -0400 Subject: [PATCH 1/4] Fix https://github.com/toblum/McLighting/issues/248 Address https://github.com/toblum/McLighting/issues/248 Commented our because # only is ment to change color and not the state --- Arduino/McLighting/request_handlers.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Arduino/McLighting/request_handlers.h b/Arduino/McLighting/request_handlers.h index cbc7f4ce..5a9f7ced 100644 --- a/Arduino/McLighting/request_handlers.h +++ b/Arduino/McLighting/request_handlers.h @@ -410,8 +410,8 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) { amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String(String("OK ") + String((char *)payload)).c_str()); #endif #ifdef ENABLE_HOMEASSISTANT - stateOn = true; - if(!ha_send_data.active()) ha_send_data.once(5, tickerSendState); + // stateOn = true; //Commented our because # only is ment to change color and not the state + if(!ha_send_data.active()) ha_send_data.once(5, tickerSendState); #endif #ifdef ENABLE_STATE_SAVE_SPIFFS if(!spiffs_save_state.active()) spiffs_save_state.once(3, tickerSpiffsSaveState); From a0680884f9e852e8bcbc986bc7a8c7c84eae0f16 Mon Sep 17 00:00:00 2001 From: Debashish Sahu Date: Mon, 5 Nov 2018 16:07:30 -0500 Subject: [PATCH 2/4] Retire NeoAnimationFX & Fix #248 * Retire NeoAnimationFX * Use DMA or UART method along with WS2812FX instead * fix #248 --- Arduino/McLighting/McLighting.ino | 60 +++++++++++++-------------- Arduino/McLighting/definitions.h | 13 +++--- Arduino/McLighting/request_handlers.h | 3 +- Arduino/McLighting/version.h | 2 +- Arduino/McLighting/version_info.ino | 5 +++ platformio.ini | 3 +- 6 files changed, 43 insertions(+), 43 deletions(-) diff --git a/Arduino/McLighting/McLighting.ino b/Arduino/McLighting/McLighting.ino index c16a9187..8cc26b4f 100644 --- a/Arduino/McLighting/McLighting.ino +++ b/Arduino/McLighting/McLighting.ino @@ -64,32 +64,6 @@ WebSocketsServer webSocket = WebSocketsServer(81); ESP8266HTTPUpdateServer httpUpdater; #endif -#ifdef USE_NEOANIMATIONFX -// *************************************************************************** -// Load libraries / Instanciate NeoAnimationFX library -// *************************************************************************** -// https://github.com/debsahu/NeoAnimationFX -#include -#define NEOMETHOD NeoPBBGRB800 - -NEOMETHOD neoStrip(NUMLEDS); -NeoAnimationFX strip(neoStrip); - -// Uses Pin RX / GPIO3 (Only pin that is supported, due to hardware limitations) -// NEOMETHOD NeoPBBGRB800 uses GRB config 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) -// NEOMETHOD NeoPBBGRB400 uses GRB config 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) -// NEOMETHOD NeoPBBRGB800 uses RGB config 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) -// NEOMETHOD NeoPBBRGB400 uses RGB config 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) - -// Uses Pin D4 / GPIO2 (Only pin that is supported, due to hardware limitations) -// NEOMETHOD NeoPBBGRBU800 uses GRB config 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) -// NEOMETHOD NeoPBBGRBU400 uses GRB config 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) -// NEOMETHOD NeoPBBRGBU800 uses RGB config 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) -// NEOMETHOD NeoPBBRGBU400 uses RGB config 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) - -#endif - -#ifdef USE_WS2812FX // *************************************************************************** // Load libraries / Instanciate WS2812FX library // *************************************************************************** @@ -109,6 +83,23 @@ WS2812FX strip = WS2812FX(NUMLEDS, PIN, NEO_GRB + NEO_KHZ800); // pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input // and minimize distance between Arduino and first pixel. Avoid connecting // on a live circuit...if you must, connect GND first. + +#ifdef USE_WS2812FX_DMA + #include + NeoEsp8266Dma800KbpsMethod dma = NeoEsp8266Dma800KbpsMethod(NUMLEDS, 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) +#endif +#ifdef USE_WS2812FX_UART + #include + NeoEsp8266Uart800KbpsMethod dma = NeoEsp8266Uart800KbpsMethod(NUMLEDS, 3); +#endif +#if defined(USE_WS2812FX_DMA) or defined(USE_WS2812FX_UART) + void DMA_Show(void) { + if(dma.IsReadyToUpdate()) { + memcpy(dma.getPixels(), strip.getPixels(), dma.getPixelsSize()); + dma.Update(); + } + } #endif // *************************************************************************** @@ -265,6 +256,10 @@ void setup() { // Setup: Neopixel // *************************************************************************** strip.init(); + #if defined(USE_WS2812FX_DMA) or defined(USE_WS2812FX_UART) + dma.Initialize(); + strip.setCustomShow(DMA_Show); + #endif strip.setBrightness(brightness); strip.setSpeed(convertSpeed(ws2812fx_speed)); //strip.setMode(FX_MODE_RAINBOW_CYCLE); @@ -511,12 +506,15 @@ void setup() { json["core_version"] = ESP.getCoreVersion(); json["cpu_freq"] = ESP.getCpuFreqMHz(); json["chip_id"] = ESP.getFlashChipId(); - #ifndef USE_NEOANIMATIONFX - json["animation_lib"] = "WS2812FX"; - json["pin"] = PIN; + #if defined(USE_WS2812FX_DMA) + json["animation_lib"] = "WS2812FX_DMA"; + json["pin"] = 3; + #elif defined(USE_WS2812FX_UART) + json["animation_lib"] = "WS2812FX_UART"; + json["pin"] = 2; #else - json["animation_lib"] = "NeoAnimationFX"; - json["pin"] = "Ignored, check NEOMETHOD"; + json["animation_lib"] = "WS2812FX"; + json["pin"] = PIN; #endif json["number_leds"] = NUMLEDS; #ifdef ENABLE_BUTTON diff --git a/Arduino/McLighting/definitions.h b/Arduino/McLighting/definitions.h index e652a471..4d682f57 100644 --- a/Arduino/McLighting/definitions.h +++ b/Arduino/McLighting/definitions.h @@ -1,5 +1,5 @@ -//#define USE_NEOANIMATIONFX // Uses NeoAnimationFX, PIN is ignored & set to RX/GPIO3 or UART method: D4/GPIO2, see: https://github.com/debsahu/NeoAnimationFX -#define USE_WS2812FX // Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX +//#define USE_WS2812FX_DMA // Uses PIN is ignored & set to RX/GPIO3 Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX +#define USE_WS2812FX_UART // Uses PIN is ignored & set to D4/GPIO2 Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX // Neopixel #define PIN D1 // PIN (14 / D5) where neopixel / WS2811 strip is attached @@ -13,16 +13,13 @@ const char HOSTNAME[] = "McLighting01"; // Friedly hostname //#define ENABLE_OTA // If defined, enable Arduino OTA code. #define ENABLE_AMQTT // If defined, enable Async MQTT code, see: https://github.com/marvinroger/async-mqtt-client //#define ENABLE_MQTT // If defined, enable MQTT client code, see: https://github.com/toblum/McLighting/wiki/MQTT-API -#define ENABLE_HOMEASSISTANT // If defined, enable Homeassistant integration, ENABLE_MQTT must be active +#define ENABLE_HOMEASSISTANT // If defined, enable Homeassistant integration, ENABLE_MQTT or ENABLE_AMQTT must be active #define ENABLE_BUTTON // If defined, enable button handling code, see: https://github.com/toblum/McLighting/wiki/Button-control //#define MQTT_HOME_ASSISTANT_SUPPORT // If defined, use AMQTT and select Tools -> IwIP Variant -> Higher Bandwidth #define ENABLE_LEGACY_ANIMATIONS -#if defined(USE_NEOANIMATIONFX) and defined(USE_WS2812FX) -#error "Cant have both NeoAnimationFX and WS2812FX enabled. Choose either one." -#endif -#if !defined(USE_NEOANIMATIONFX) and !defined(USE_WS2812FX) -#error "Need to either use NeoAnimationFX and WS2812FX mode." +#if defined(USE_WS2812FX_DMA) and defined(USE_WS2812FX_UART) +#error "Cant have both DMA and UART method." #endif #if defined(ENABLE_MQTT) and defined(ENABLE_AMQTT) #error "Cant have both PubSubClient and AsyncMQTT enabled. Choose either one." diff --git a/Arduino/McLighting/request_handlers.h b/Arduino/McLighting/request_handlers.h index 5a9f7ced..ee2b5714 100644 --- a/Arduino/McLighting/request_handlers.h +++ b/Arduino/McLighting/request_handlers.h @@ -410,7 +410,7 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) { amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String(String("OK ") + String((char *)payload)).c_str()); #endif #ifdef ENABLE_HOMEASSISTANT - // stateOn = true; //Commented our because # only is ment to change color and not the state + stateOn = true; if(!ha_send_data.active()) ha_send_data.once(5, tickerSendState); #endif #ifdef ENABLE_STATE_SAVE_SPIFFS @@ -431,6 +431,7 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) { } DBG_OUTPUT_PORT.printf("Set speed to: [%u]\n", ws2812fx_speed); #ifdef ENABLE_HOMEASSISTANT + stateOn = true; if(!ha_send_data.active()) ha_send_data.once(5, tickerSendState); #endif #ifdef ENABLE_MQTT diff --git a/Arduino/McLighting/version.h b/Arduino/McLighting/version.h index 539d5b45..b6728244 100644 --- a/Arduino/McLighting/version.h +++ b/Arduino/McLighting/version.h @@ -1 +1 @@ -#define SKETCH_VERSION "2.1.5" +#define SKETCH_VERSION "2.1.6" diff --git a/Arduino/McLighting/version_info.ino b/Arduino/McLighting/version_info.ino index 8795ebab..0a72ea98 100644 --- a/Arduino/McLighting/version_info.ino +++ b/Arduino/McLighting/version_info.ino @@ -20,4 +20,9 @@ * * 2 Oct 2018 v 2.1.5 * - Try fixing #224 HA brightness causes reboot + * + * 5 Nov 2018 v 2.1.6 + * - Retire NeoAnimationFX + * - Use DMA or UART method along with WS2812FX instead + * - fix #248 */ diff --git a/platformio.ini b/platformio.ini index 981737b4..98ef73ab 100644 --- a/platformio.ini +++ b/platformio.ini @@ -46,8 +46,7 @@ upload_resetmethod = ${common.upload_resetmethod} lib_deps = WiFiManager@0.14 AsyncMqttClient - https://github.com/bblanchon/ArduinoJson.git#v6.4.0-beta + https://github.com/bblanchon/ArduinoJson.git#v6.5.0-beta WS2812FX - https://github.com/debsahu/NeoAnimationFX NeoPixelBus WebSockets From 62ac728783f74d2963ca2873765f71b497b68dd3 Mon Sep 17 00:00:00 2001 From: Debashish Sahu Date: Tue, 6 Nov 2018 11:12:34 -0500 Subject: [PATCH 3/4] add a symbolic link to index.htm and index2.html with the respective submodule --- .gitmodules | 6 + Arduino/McLighting/data/McLightingUI | 1 + Arduino/McLighting/data/index.htm | 557 ++++++++++++++++++++++----- Arduino/McLighting/data/index2.htm | 90 +++++ clients/web/McLightingUI | 1 + 5 files changed, 561 insertions(+), 94 deletions(-) create mode 100644 .gitmodules create mode 160000 Arduino/McLighting/data/McLightingUI create mode 100644 Arduino/McLighting/data/index2.htm create mode 160000 clients/web/McLightingUI diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..e7648570 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "Arduino/McLighting/data/McLightingUI"] + path = Arduino/McLighting/data/McLightingUI + url = https://github.com/toblum/McLightingUI +[submodule "clients/web/McLightingUI"] + path = clients/web/McLightingUI + url = https://github.com/toblum/McLightingUI diff --git a/Arduino/McLighting/data/McLightingUI b/Arduino/McLighting/data/McLightingUI new file mode 160000 index 00000000..20933f32 --- /dev/null +++ b/Arduino/McLighting/data/McLightingUI @@ -0,0 +1 @@ +Subproject commit 20933f32b3bb38fd1262baf113e793b26527c30a diff --git a/Arduino/McLighting/data/index.htm b/Arduino/McLighting/data/index.htm index 6aa58cc3..365cbbda 100644 --- a/Arduino/McLighting/data/index.htm +++ b/Arduino/McLighting/data/index.htm @@ -1,97 +1,466 @@ - - - - ESP Monitor - - - - -
- - - - -
-
-
-
- + + + + + + + + + + + McLighting v2 + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Error on websocket connect.
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
pick a color
+
+
+
+
+
Auto:
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+

+
+
+
+

+
+
+
+

+
+
+ +
+
+
+

+
+
+ +
+
+
+

+
+
+
+
+ +
+ + + + +
+
+ Loading animations... +
+
+
+
+
+ + + + + + + + + + \ No newline at end of file diff --git a/Arduino/McLighting/data/index2.htm b/Arduino/McLighting/data/index2.htm new file mode 100644 index 00000000..a0668e21 --- /dev/null +++ b/Arduino/McLighting/data/index2.htm @@ -0,0 +1,90 @@ +McLighting UI
\ No newline at end of file diff --git a/clients/web/McLightingUI b/clients/web/McLightingUI new file mode 160000 index 00000000..20933f32 --- /dev/null +++ b/clients/web/McLightingUI @@ -0,0 +1 @@ +Subproject commit 20933f32b3bb38fd1262baf113e793b26527c30a From ac5e873ddcf47d94452613bbbe8bd3ee47a930c1 Mon Sep 17 00:00:00 2001 From: Debashish Sahu Date: Tue, 6 Nov 2018 11:13:59 -0500 Subject: [PATCH 4/4] Disabled DMA/UART by default and SPIFFs --- Arduino/McLighting/data/McLightingUI | 1 - Arduino/McLighting/definitions.h | 2 +- platformio.ini | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) delete mode 160000 Arduino/McLighting/data/McLightingUI diff --git a/Arduino/McLighting/data/McLightingUI b/Arduino/McLighting/data/McLightingUI deleted file mode 160000 index 20933f32..00000000 --- a/Arduino/McLighting/data/McLightingUI +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 20933f32b3bb38fd1262baf113e793b26527c30a diff --git a/Arduino/McLighting/definitions.h b/Arduino/McLighting/definitions.h index 4d682f57..50360bf6 100644 --- a/Arduino/McLighting/definitions.h +++ b/Arduino/McLighting/definitions.h @@ -1,5 +1,5 @@ //#define USE_WS2812FX_DMA // Uses PIN is ignored & set to RX/GPIO3 Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX -#define USE_WS2812FX_UART // Uses PIN is ignored & set to D4/GPIO2 Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX +//#define USE_WS2812FX_UART // Uses PIN is ignored & set to D4/GPIO2 Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX // Neopixel #define PIN D1 // PIN (14 / D5) where neopixel / WS2811 strip is attached diff --git a/platformio.ini b/platformio.ini index 98ef73ab..a82deee3 100644 --- a/platformio.ini +++ b/platformio.ini @@ -10,6 +10,7 @@ [platformio] src_dir = ./Arduino/McLighting/ +data_dir = ./Arduino/McLighting/data/ env_default = nodemcuv2 description = The ESP8266 based multi-client lighting gadget