* Added support for NeoAnimationFX (USE_NEOANIMATIONFX)
* Better scaling for speed
This commit is contained in:
debsahu 2018-03-29 23:49:18 -04:00
parent e3060fa7ee
commit 4dc09f37c9
3 changed files with 32 additions and 3 deletions

View file

@ -59,6 +59,25 @@ 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)
#endif
#ifdef USE_WS2812FX
// ***************************************************************************
// Load libraries / Instanciate WS2812FX library
// ***************************************************************************
@ -78,7 +97,7 @@ 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.
#endif
// ***************************************************************************
// Load library "ticker" for blinking status led

View file

@ -1,3 +1,6 @@
//#define USE_NEOANIMATIONFX // Uses NeoAnimationFX, PIN is ignored & set to RX/GPIO3
#define USE_WS2812FX // Uses WS2812FX
// Neopixel
#define PIN 14 // PIN (14 / D5) where neopixel / WS2811 strip is attached
#define NUMLEDS 300 // Number of leds in the strip
@ -13,6 +16,12 @@ const char HOSTNAME[] = "McLighting01"; // Friedly hostname
#define ENABLE_HOMEASSISTANT // If defined, enable Homeassistant integration, ENABLE_MQTT must be active
#define ENABLE_BUTTON // If defined, enable button handling code, see: https://github.com/toblum/McLighting/wiki/Button-control
#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."
#endif
#if defined(ENABLE_MQTT) and defined(ENABLE_AMQTT)
#error "Cant have both PubSubClient and AsyncMQTT enabled. Choose either one."
#endif

View file

@ -51,8 +51,9 @@ void getArgs() {
}
long convertSpeed(int mcl_speed) {
long ws2812_speed = mcl_speed * 256;
uint16_t convertSpeed(uint8_t mcl_speed) {
//long ws2812_speed = mcl_speed * 256;
uint16_t ws2812_speed = 61760 * (exp(0.0002336 * mcl_speed) - exp(-0.03181 * mcl_speed));
ws2812_speed = SPEED_MAX - ws2812_speed;
if (ws2812_speed < SPEED_MIN) {
ws2812_speed = SPEED_MIN;