Retire NeoAnimationFX & Fix

* Retire NeoAnimationFX
* Use DMA or UART method along with WS2812FX instead
* fix 
This commit is contained in:
Debashish Sahu 2018-11-05 16:07:30 -05:00
parent c53d02bdbe
commit a0680884f9
6 changed files with 43 additions and 43 deletions

View file

@ -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 <NeoAnimationFX.h>
#define NEOMETHOD NeoPBBGRB800
NEOMETHOD neoStrip(NUMLEDS);
NeoAnimationFX<NEOMETHOD> 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 <NeoPixelBus.h>
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 <NeoPixelBus.h>
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

View file

@ -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."

View file

@ -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

View file

@ -1 +1 @@
#define SKETCH_VERSION "2.1.5"
#define SKETCH_VERSION "2.1.6"

View file

@ -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
*/

View file

@ -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