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/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/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/Arduino/McLighting/definitions.h b/Arduino/McLighting/definitions.h index e652a471..50360bf6 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 cbc7f4ce..ee2b5714 100644 --- a/Arduino/McLighting/request_handlers.h +++ b/Arduino/McLighting/request_handlers.h @@ -411,7 +411,7 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) { #endif #ifdef ENABLE_HOMEASSISTANT stateOn = true; - if(!ha_send_data.active()) ha_send_data.once(5, tickerSendState); + 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); @@ -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/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 diff --git a/platformio.ini b/platformio.ini index 981737b4..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 @@ -46,8 +47,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