Merge remote-tracking branch 'origin/master' into flurlampe
This commit is contained in:
commit
fee53b3de0
12 changed files with 16364 additions and 247 deletions
|
@ -53,8 +53,8 @@
|
|||
#endif
|
||||
|
||||
#ifdef ARDUINOJSON_VERSION
|
||||
#if !(ARDUINOJSON_VERSION_MAJOR == 6 and ARDUINOJSON_VERSION_MINOR == 7)
|
||||
#error "Install ArduinoJson v6.7.0-beta"
|
||||
#if !(ARDUINOJSON_VERSION_MAJOR == 6 and ARDUINOJSON_VERSION_MINOR == 8)
|
||||
#error "Install ArduinoJson v6.8.0-beta"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -64,6 +64,9 @@
|
|||
ESPAsyncE131 e131(END_UNIVERSE - START_UNIVERSE + 1);
|
||||
#endif
|
||||
|
||||
#ifdef USE_HTML_MIN_GZ
|
||||
#include "html_gz.h"
|
||||
#endif
|
||||
|
||||
// ***************************************************************************
|
||||
// Instanciate HTTP(80) / WebSockets(81) Server
|
||||
|
@ -81,41 +84,66 @@ ESP8266HTTPUpdateServer httpUpdater;
|
|||
// ***************************************************************************
|
||||
// https://github.com/kitesurfer1404/WS2812FX
|
||||
#include <WS2812FX.h>
|
||||
WS2812FX strip = WS2812FX(NUMLEDS, PIN, NEO_GRB + NEO_KHZ800);
|
||||
// WS2812FX strip = WS2812FX(NUMLEDS, LED_PIN, NEO_GRB + NEO_KHZ800);
|
||||
WS2812FX* strip;
|
||||
|
||||
// Parameter 1 = number of pixels in strip
|
||||
// Parameter 2 = Arduino pin number (most are valid)
|
||||
// Parameter 3 = pixel type flags, add together as needed:
|
||||
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
|
||||
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
|
||||
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
|
||||
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
|
||||
|
||||
// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
|
||||
// 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.
|
||||
#if defined(USE_WS2812FX_DMA) or defined(USE_WS2812FX_UART1) or defined(USE_WS2812FX_UART2)
|
||||
#include <NeoPixelBus.h>
|
||||
|
||||
#ifdef USE_WS2812FX_DMA // Uses GPIO3/RXD0/RX, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
|
||||
#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)
|
||||
#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
|
||||
#include <NeoPixelBus.h>
|
||||
NeoEsp8266Uart0800KbpsMethod dma = NeoEsp8266Uart0800KbpsMethod(NUMLEDS, 3);
|
||||
#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
|
||||
#ifdef USE_WS2812FX_UART2 // Uses UART2: GPIO2/TXD1/D4, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
|
||||
#include <NeoPixelBus.h>
|
||||
NeoEsp8266Uart1800KbpsMethod dma = NeoEsp8266Uart1800KbpsMethod(NUMLEDS, 3);
|
||||
#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
|
||||
#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();
|
||||
}
|
||||
|
||||
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
|
||||
#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
|
||||
#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
|
||||
#ifdef USE_WS2812FX_UART2 // Uses UART2: GPIO2/TXD1/D4, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
|
||||
#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
|
||||
dma->Initialize();
|
||||
}
|
||||
|
||||
void DMA_Show(void) {
|
||||
if(dma->IsReadyToUpdate()) {
|
||||
memcpy(dma->getPixels(), strip->getPixels(), dma->getPixelsSize());
|
||||
dma->Update();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// ***************************************************************************
|
||||
|
@ -202,10 +230,10 @@ void configModeCallback (WiFiManager *myWiFiManager) {
|
|||
ticker.attach(0.2, tick);
|
||||
|
||||
uint16_t i;
|
||||
for (i = 0; i < strip.numPixels(); i++) {
|
||||
strip.setPixelColor(i, 0, 0, 255);
|
||||
for (i = 0; i < strip->numPixels(); i++) {
|
||||
strip->setPixelColor(i, 0, 0, 255);
|
||||
}
|
||||
strip.show();
|
||||
strip->show();
|
||||
}
|
||||
|
||||
//callback notifying us of the need to save config
|
||||
|
@ -224,6 +252,54 @@ void saveConfigCallback () {
|
|||
// ***************************************************************************
|
||||
#include "request_handlers.h"
|
||||
|
||||
#ifdef CUSTOM_WS2812FX_ANIMATIONS
|
||||
#include "custom_ws2812fx_animations.h" // Add animations in this file
|
||||
#endif
|
||||
|
||||
// function to Initialize the strip
|
||||
void initStrip(uint16_t stripSize = WS2812FXStripSettings.stripSize, neoPixelType RGBOrder = WS2812FXStripSettings.RGBOrder, uint8_t pin = WS2812FXStripSettings.pin){
|
||||
if (strip) {
|
||||
delete strip;
|
||||
WS2812FXStripSettings.stripSize = stripSize;
|
||||
WS2812FXStripSettings.RGBOrder = RGBOrder;
|
||||
WS2812FXStripSettings.pin = pin;
|
||||
}
|
||||
#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:
|
||||
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
|
||||
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
|
||||
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
|
||||
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
|
||||
|
||||
// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
|
||||
// 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.
|
||||
|
||||
strip->init();
|
||||
#if defined(USE_WS2812FX_DMA) or defined(USE_WS2812FX_UART1) or defined(USE_WS2812FX_UART2)
|
||||
initDMA(stripSize);
|
||||
strip->setCustomShow(DMA_Show);
|
||||
#endif
|
||||
strip->setBrightness(brightness);
|
||||
strip->setSpeed(convertSpeed(ws2812fx_speed));
|
||||
//strip->setMode(ws2812fx_mode);
|
||||
strip->setColor(main_color.red, main_color.green, main_color.blue);
|
||||
strip->setOptions(0, GAMMA); // We only have one WS2812FX segment, set color to human readable GAMMA correction
|
||||
#ifdef CUSTOM_WS2812FX_ANIMATIONS
|
||||
strip->setCustomMode(0, F("Fire 2012"), myCustomEffect);
|
||||
#endif
|
||||
strip->start();
|
||||
if(mode != HOLD) mode = SET_MODE;
|
||||
saveWS2812FXStripSettings.once(3, writeStripConfigFS);
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Include: Color modes
|
||||
// ***************************************************************************
|
||||
|
@ -275,16 +351,8 @@ 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);
|
||||
strip.setColor(main_color.red, main_color.green, main_color.blue);
|
||||
strip.start();
|
||||
readStripConfigFS(); // Read config from FS first
|
||||
initStrip();
|
||||
|
||||
// ***************************************************************************
|
||||
// Setup: WiFiManager
|
||||
|
@ -310,10 +378,16 @@ void setup() {
|
|||
#endif
|
||||
WiFiManagerParameter custom_mqtt_host("host", "MQTT hostname", mqtt_host, 64);
|
||||
WiFiManagerParameter custom_mqtt_port("port", "MQTT port", mqtt_port, 6);
|
||||
WiFiManagerParameter custom_mqtt_user("user", "MQTT user", mqtt_user, 32);
|
||||
WiFiManagerParameter custom_mqtt_pass("pass", "MQTT pass", mqtt_pass, 32);
|
||||
WiFiManagerParameter custom_mqtt_user("user", "MQTT user", mqtt_user, 32, " maxlength=31");
|
||||
WiFiManagerParameter custom_mqtt_pass("pass", "MQTT pass", mqtt_pass, 32, " maxlength=31 type='password'");
|
||||
#endif
|
||||
|
||||
sprintf(strip_size, "%d", WS2812FXStripSettings.stripSize);
|
||||
sprintf(led_pin, "%d", WS2812FXStripSettings.pin);
|
||||
|
||||
WiFiManagerParameter custom_strip_size("strip_size", "Number of LEDs", strip_size, 3);
|
||||
WiFiManagerParameter custom_led_pin("led_pin", "LED GPIO", led_pin, 2);
|
||||
|
||||
//Local intialization. Once its business is done, there is no need to keep it around
|
||||
WiFiManager wifiManager;
|
||||
//reset settings - for testing
|
||||
|
@ -333,6 +407,9 @@ void setup() {
|
|||
wifiManager.addParameter(&custom_mqtt_pass);
|
||||
#endif
|
||||
|
||||
wifiManager.addParameter(&custom_strip_size);
|
||||
wifiManager.addParameter(&custom_led_pin);
|
||||
|
||||
WiFi.setSleepMode(WIFI_NONE_SLEEP);
|
||||
|
||||
// Uncomment if you want to restart ESP8266 if it cannot connect to WiFi.
|
||||
|
@ -365,6 +442,16 @@ void setup() {
|
|||
strcpy(mqtt_user, custom_mqtt_user.getValue());
|
||||
strcpy(mqtt_pass, custom_mqtt_pass.getValue());
|
||||
|
||||
strcpy(strip_size, custom_strip_size.getValue());
|
||||
strcpy(led_pin, custom_led_pin.getValue());
|
||||
|
||||
if(atoi(strip_size) != WS2812FXStripSettings.stripSize)
|
||||
WS2812FXStripSettings.stripSize = atoi(strip_size);
|
||||
uint8_t pin = atoi(led_pin);
|
||||
if ((pin == 16 or pin == 5 or pin == 4 or pin == 0 or pin == 2 or pin == 14 or pin == 12 or pin == 13 or pin == 15 or pin == 3 or pin == 1) and (pin != WS2812FXStripSettings.pin) )
|
||||
WS2812FXStripSettings.pin = pin;
|
||||
initStrip();
|
||||
|
||||
//save the custom parameters to FS
|
||||
#if defined(ENABLE_STATE_SAVE_SPIFFS) and (defined(ENABLE_MQTT) or defined(ENABLE_AMQTT))
|
||||
(writeConfigFS(shouldSaveConfig)) ? DBG_OUTPUT_PORT.println("WiFiManager config FS Save success!"): DBG_OUTPUT_PORT.println("WiFiManager config FS Save failure!");
|
||||
|
@ -445,9 +532,6 @@ void setup() {
|
|||
|
||||
#ifdef ENABLE_MQTT
|
||||
if (mqtt_host != "" && atoi(mqtt_port) > 0) {
|
||||
snprintf(mqtt_intopic, sizeof mqtt_intopic, "%s/in", HOSTNAME);
|
||||
snprintf(mqtt_outtopic, sizeof mqtt_outtopic, "%s/out", HOSTNAME);
|
||||
|
||||
DBG_OUTPUT_PORT.printf("MQTT active: %s:%d\n", mqtt_host, String(mqtt_port).toInt());
|
||||
|
||||
mqtt_client.setServer(mqtt_host, atoi(mqtt_port));
|
||||
|
@ -463,6 +547,7 @@ void setup() {
|
|||
amqttClient.setServer(mqtt_host, atoi(mqtt_port));
|
||||
if (mqtt_user != "" or mqtt_pass != "") amqttClient.setCredentials(mqtt_user, mqtt_pass);
|
||||
amqttClient.setClientId(mqtt_clientid);
|
||||
amqttClient.setWill(mqtt_will_topic, 2, true, mqtt_will_payload, 0);
|
||||
|
||||
connectToMqtt();
|
||||
}
|
||||
|
@ -519,7 +604,7 @@ void setup() {
|
|||
}, handleFileUpload);
|
||||
//get heap status, analog input value and all GPIO statuses in one json call
|
||||
server.on("/esp_status", HTTP_GET, []() {
|
||||
DynamicJsonDocument jsonBuffer;
|
||||
DynamicJsonDocument jsonBuffer(JSON_OBJECT_SIZE(21) + 1500);
|
||||
JsonObject json = jsonBuffer.to<JsonObject>();
|
||||
|
||||
json["HOSTNAME"] = HOSTNAME;
|
||||
|
@ -537,12 +622,15 @@ void setup() {
|
|||
#if defined(USE_WS2812FX_DMA)
|
||||
json["animation_lib"] = "WS2812FX_DMA";
|
||||
json["pin"] = 3;
|
||||
#elif defined(USE_WS2812FX_UART)
|
||||
json["animation_lib"] = "WS2812FX_UART";
|
||||
#elif defined(USE_WS2812FX_UART1)
|
||||
json["animation_lib"] = "WS2812FX_UART1";
|
||||
json["pin"] = 1;
|
||||
#elif defined(USE_WS2812FX_UART2)
|
||||
json["animation_lib"] = "WS2812FX_UART2";
|
||||
json["pin"] = 2;
|
||||
#else
|
||||
json["animation_lib"] = "WS2812FX";
|
||||
json["pin"] = PIN;
|
||||
json["pin"] = LED_PIN;
|
||||
#endif
|
||||
json["number_leds"] = NUMLEDS;
|
||||
#ifdef ENABLE_BUTTON
|
||||
|
@ -590,6 +678,25 @@ void setup() {
|
|||
server.send(200, "application/json", json_str);
|
||||
});
|
||||
|
||||
server.on("/", HTTP_GET, [&](){
|
||||
#ifdef USE_HTML_MIN_GZ
|
||||
server.sendHeader("Content-Encoding", "gzip", true);
|
||||
server.send_P(200, PSTR("text/html"), index_htm_gz, index_htm_gz_len);
|
||||
#else
|
||||
if (!handleFileRead(server.uri()))
|
||||
handleNotFound();
|
||||
#endif
|
||||
});
|
||||
|
||||
server.on("/edit", HTTP_GET, [&](){
|
||||
#ifdef USE_HTML_MIN_GZ
|
||||
server.sendHeader("Content-Encoding", "gzip", true);
|
||||
server.send_P(200, PSTR("text/html"), edit_htm_gz, edit_htm_gz_len);
|
||||
#else
|
||||
if (!handleFileRead(server.uri()))
|
||||
handleNotFound();
|
||||
#endif
|
||||
});
|
||||
|
||||
//called when the url is not defined here
|
||||
//use it to load content from SPIFFS
|
||||
|
@ -635,7 +742,7 @@ void setup() {
|
|||
mqtt_client.publish(mqtt_outtopic, String(String("OK %") + String(brightness)).c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String(String("OK %") + String(brightness)).c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String(String("OK %") + String(brightness)).c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = true;
|
||||
|
@ -659,12 +766,12 @@ void setup() {
|
|||
if (server.arg("d").toInt() >= 0) {
|
||||
ws2812fx_speed = server.arg("d").toInt();
|
||||
ws2812fx_speed = constrain(ws2812fx_speed, 0, 255);
|
||||
strip.setSpeed(convertSpeed(ws2812fx_speed));
|
||||
strip->setSpeed(convertSpeed(ws2812fx_speed));
|
||||
#ifdef ENABLE_MQTT
|
||||
mqtt_client.publish(mqtt_outtopic, String(String("OK ?") + String(ws2812fx_speed)).c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String(String("OK ?") + String(ws2812fx_speed)).c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String(String("OK ?") + String(ws2812fx_speed)).c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
if(!ha_send_data.active()) ha_send_data.once(5, tickerSendState);
|
||||
|
@ -701,6 +808,105 @@ void setup() {
|
|||
getStatusJSON();
|
||||
});
|
||||
|
||||
server.on("/pixelconf", []() {
|
||||
|
||||
/*
|
||||
|
||||
// This will be used later when web-interface is ready and HTTP_GET will not be allowed to update the Strip Settings
|
||||
|
||||
if(server.args() == 0 and server.method() != HTTP_POST)
|
||||
{
|
||||
server.sendHeader("Access-Control-Allow-Origin", "*");
|
||||
server.send(200, "text/plain", "Only HTTP POST method is allowed and check the number of arguments!");
|
||||
return;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
bool updateStrip = false;
|
||||
if(server.hasArg("ct")){
|
||||
uint16_t pixelCt = server.arg("ct").toInt();
|
||||
if (pixelCt > 0) {
|
||||
WS2812FXStripSettings.stripSize = pixelCt;
|
||||
updateStrip = true;
|
||||
DBG_OUTPUT_PORT.printf("/pixels: Count# %d\n", pixelCt);
|
||||
}
|
||||
}
|
||||
if(server.hasArg("rgbo")){
|
||||
String RGBOrder = server.arg("rgbo");
|
||||
DBG_OUTPUT_PORT.print("/pixels: RGB Order# ");
|
||||
if (RGBOrder == "grb") {
|
||||
WS2812FXStripSettings.RGBOrder = NEO_GRB;
|
||||
updateStrip = true;
|
||||
DBG_OUTPUT_PORT.println(RGBOrder);
|
||||
} else if (RGBOrder == "gbr") {
|
||||
WS2812FXStripSettings.RGBOrder = NEO_GBR;
|
||||
updateStrip = true;
|
||||
DBG_OUTPUT_PORT.println(RGBOrder);
|
||||
} else if (RGBOrder == "rgb") {
|
||||
WS2812FXStripSettings.RGBOrder = NEO_RGB;
|
||||
updateStrip = true;
|
||||
DBG_OUTPUT_PORT.println(RGBOrder);
|
||||
} else if (RGBOrder == "rbg") {
|
||||
WS2812FXStripSettings.RGBOrder = NEO_RBG;
|
||||
updateStrip = true;
|
||||
DBG_OUTPUT_PORT.println(RGBOrder);
|
||||
} else if (RGBOrder == "brg") {
|
||||
WS2812FXStripSettings.RGBOrder = NEO_BRG;
|
||||
updateStrip = true;
|
||||
DBG_OUTPUT_PORT.println(RGBOrder);
|
||||
} else if (RGBOrder == "bgr") {
|
||||
WS2812FXStripSettings.RGBOrder = NEO_BGR;
|
||||
updateStrip = true;
|
||||
DBG_OUTPUT_PORT.println(RGBOrder);
|
||||
} else {
|
||||
DBG_OUTPUT_PORT.println("invalid input!");
|
||||
}
|
||||
}
|
||||
if(server.hasArg("pin")){
|
||||
uint8_t pin = server.arg("pin").toInt();
|
||||
DBG_OUTPUT_PORT.print("/pixels: GPIO used# ");
|
||||
#if defined(USE_WS2812FX_DMA) or defined(USE_WS2812FX_UART1) or defined(USE_WS2812FX_UART2)
|
||||
#ifdef USE_WS2812FX_DMA
|
||||
DBG_OUTPUT_PORT.println("3");
|
||||
#endif
|
||||
#ifdef USE_WS2812FX_UART1
|
||||
DBG_OUTPUT_PORT.println("2");
|
||||
#endif
|
||||
#ifdef USE_WS2812FX_UART2
|
||||
DBG_OUTPUT_PORT.println("1");
|
||||
#endif
|
||||
#else
|
||||
if (pin == 16 or pin == 5 or pin == 4 or pin == 0 or pin == 2 or pin == 14 or pin == 12 or pin == 13 or pin == 15 or pin == 3 or pin == 1) {
|
||||
WS2812FXStripSettings.pin = pin;
|
||||
updateStrip = true;
|
||||
DBG_OUTPUT_PORT.println(pin);
|
||||
} else {
|
||||
DBG_OUTPUT_PORT.println("invalid input!");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if(updateStrip)
|
||||
{
|
||||
ws2812fx_mode = strip->getMode();
|
||||
if(strip->isRunning()) strip->stop();
|
||||
initStrip();
|
||||
strip->setMode(ws2812fx_mode);
|
||||
strip->trigger();
|
||||
}
|
||||
|
||||
DynamicJsonDocument jsonBuffer(200);
|
||||
JsonObject json = jsonBuffer.to<JsonObject>();
|
||||
json["pixel_count"] = WS2812FXStripSettings.stripSize;
|
||||
json["rgb_order"] = WS2812FXStripSettings.RGBOrder;
|
||||
json["pin"] = WS2812FXStripSettings.pin;
|
||||
String json_str;
|
||||
serializeJson(json, json_str);
|
||||
server.sendHeader("Access-Control-Allow-Origin", "*");
|
||||
server.send(200, "application/json", json_str);
|
||||
});
|
||||
|
||||
server.on("/off", []() {
|
||||
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||
exit_func = true;
|
||||
|
@ -712,7 +918,7 @@ void setup() {
|
|||
mqtt_client.publish(mqtt_outtopic, String("OK =off").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =off").c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String("OK =off").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = false;
|
||||
|
@ -735,7 +941,7 @@ void setup() {
|
|||
mqtt_client.publish(mqtt_outtopic, String("OK =all").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =all").c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String("OK =all").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = true;
|
||||
|
@ -755,7 +961,7 @@ void setup() {
|
|||
mqtt_client.publish(mqtt_outtopic, String("OK =wipe").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =wipe").c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String("OK =wipe").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = true;
|
||||
|
@ -774,7 +980,7 @@ void setup() {
|
|||
mqtt_client.publish(mqtt_outtopic, String("OK =rainbow").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =rainbow").c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String("OK =rainbow").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = true;
|
||||
|
@ -793,7 +999,7 @@ void setup() {
|
|||
mqtt_client.publish(mqtt_outtopic, String("OK =rainbowCycle").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =rainbowCycle").c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String("OK =rainbowCycle").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = true;
|
||||
|
@ -812,7 +1018,7 @@ void setup() {
|
|||
mqtt_client.publish(mqtt_outtopic, String("OK =theaterchase").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =theaterchase").c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String("OK =theaterchase").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = true;
|
||||
|
@ -831,7 +1037,7 @@ void setup() {
|
|||
mqtt_client.publish(mqtt_outtopic, String("OK =twinkleRandom").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =twinkleRandom").c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String("OK =twinkleRandom").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = true;
|
||||
|
@ -850,7 +1056,7 @@ void setup() {
|
|||
mqtt_client.publish(mqtt_outtopic, String("OK =theaterchaseRainbow").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =theaterchaseRainbow").c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String("OK =theaterchaseRainbow").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = true;
|
||||
|
@ -869,7 +1075,7 @@ void setup() {
|
|||
mqtt_client.publish(mqtt_outtopic, String("OK =e131").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =131").c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String("OK =131").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = true;
|
||||
|
@ -889,7 +1095,7 @@ void setup() {
|
|||
mqtt_client.publish(mqtt_outtopic, String("OK =tv").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =tv").c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String("OK =tv").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = true;
|
||||
|
@ -913,7 +1119,7 @@ void setup() {
|
|||
mqtt_client.publish(mqtt_outtopic, String(String("OK /") + String(ws2812fx_mode)).c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String(String("OK /") + String(ws2812fx_mode)).c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String(String("OK /") + String(ws2812fx_mode)).c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = true;
|
||||
|
@ -939,7 +1145,7 @@ void setup() {
|
|||
// Choose one to begin listening for E1.31 data
|
||||
// if (e131.begin(E131_UNICAST)) // Listen via Unicast
|
||||
if (e131.begin(E131_MULTICAST, START_UNIVERSE, END_UNIVERSE)) // Listen via Multicast
|
||||
Serial.println(F("Listening for data..."));
|
||||
Serial.println(F("E1.31 mode setup complete."));
|
||||
else
|
||||
Serial.println(F("*** e131.begin failed ***"));
|
||||
#endif
|
||||
|
@ -1005,63 +1211,63 @@ void loop() {
|
|||
// Simple statemachine that handles the different modes
|
||||
if (mode == SET_MODE) {
|
||||
DBG_OUTPUT_PORT.printf("SET_MODE: %d %d\n", ws2812fx_mode, mode);
|
||||
strip.setMode(ws2812fx_mode);
|
||||
strip.trigger();
|
||||
strip->setMode(ws2812fx_mode);
|
||||
strip->trigger();
|
||||
prevmode = SET_MODE;
|
||||
mode = SETCOLOR;
|
||||
}
|
||||
if (mode == OFF) {
|
||||
if(strip.isRunning()) strip.stop(); //should clear memory
|
||||
if(strip->isRunning()) strip->stop(); //should clear memory
|
||||
// mode = HOLD;
|
||||
}
|
||||
if (mode == SETCOLOR) {
|
||||
strip.setColor(main_color.red, main_color.green, main_color.blue);
|
||||
strip.trigger();
|
||||
strip->setColor(main_color.red, main_color.green, main_color.blue);
|
||||
strip->trigger();
|
||||
mode = (prevmode == SET_MODE) ? SETSPEED : HOLD;
|
||||
}
|
||||
if (mode == SETSPEED) {
|
||||
strip.setSpeed(convertSpeed(ws2812fx_speed));
|
||||
strip.trigger();
|
||||
strip->setSpeed(convertSpeed(ws2812fx_speed));
|
||||
strip->trigger();
|
||||
mode = (prevmode == SET_MODE) ? BRIGHTNESS : HOLD;
|
||||
}
|
||||
if (mode == BRIGHTNESS) {
|
||||
strip.setBrightness(brightness);
|
||||
strip.trigger();
|
||||
strip->setBrightness(brightness);
|
||||
strip->trigger();
|
||||
if (prevmode == SET_MODE) prevmode = HOLD;
|
||||
mode = HOLD;
|
||||
}
|
||||
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||
if (mode == WIPE) {
|
||||
strip.setColor(main_color.red, main_color.green, main_color.blue);
|
||||
strip.setMode(FX_MODE_COLOR_WIPE);
|
||||
strip.trigger();
|
||||
strip->setColor(main_color.red, main_color.green, main_color.blue);
|
||||
strip->setMode(FX_MODE_COLOR_WIPE);
|
||||
strip->trigger();
|
||||
mode = HOLD;
|
||||
}
|
||||
if (mode == RAINBOW) {
|
||||
strip.setMode(FX_MODE_RAINBOW);
|
||||
strip.trigger();
|
||||
strip->setMode(FX_MODE_RAINBOW);
|
||||
strip->trigger();
|
||||
mode = HOLD;
|
||||
}
|
||||
if (mode == RAINBOWCYCLE) {
|
||||
strip.setMode(FX_MODE_RAINBOW_CYCLE);
|
||||
strip.trigger();
|
||||
strip->setMode(FX_MODE_RAINBOW_CYCLE);
|
||||
strip->trigger();
|
||||
mode = HOLD;
|
||||
}
|
||||
if (mode == THEATERCHASE) {
|
||||
strip.setColor(main_color.red, main_color.green, main_color.blue);
|
||||
strip.setMode(FX_MODE_THEATER_CHASE);
|
||||
strip.trigger();
|
||||
strip->setColor(main_color.red, main_color.green, main_color.blue);
|
||||
strip->setMode(FX_MODE_THEATER_CHASE);
|
||||
strip->trigger();
|
||||
mode = HOLD;
|
||||
}
|
||||
if (mode == TWINKLERANDOM) {
|
||||
strip.setColor(main_color.red, main_color.green, main_color.blue);
|
||||
strip.setMode(FX_MODE_TWINKLE_RANDOM);
|
||||
strip.trigger();
|
||||
strip->setColor(main_color.red, main_color.green, main_color.blue);
|
||||
strip->setMode(FX_MODE_TWINKLE_RANDOM);
|
||||
strip->trigger();
|
||||
mode = HOLD;
|
||||
}
|
||||
if (mode == THEATERCHASERAINBOW) {
|
||||
strip.setMode(FX_MODE_THEATER_CHASE_RAINBOW);
|
||||
strip.trigger();
|
||||
strip->setMode(FX_MODE_THEATER_CHASE_RAINBOW);
|
||||
strip->trigger();
|
||||
mode = HOLD;
|
||||
}
|
||||
#ifdef ENABLE_E131
|
||||
|
@ -1071,7 +1277,7 @@ void loop() {
|
|||
#endif
|
||||
#endif
|
||||
if (mode == HOLD || mode == CUSTOM) {
|
||||
if(!strip.isRunning()) strip.start();
|
||||
if(!strip->isRunning()) strip->start();
|
||||
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||
if (exit_func) {
|
||||
exit_func = false;
|
||||
|
@ -1081,7 +1287,7 @@ void loop() {
|
|||
}
|
||||
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||
if (mode == TV) {
|
||||
if(!strip.isRunning()) strip.start();
|
||||
if(!strip->isRunning()) strip->start();
|
||||
tv();
|
||||
}
|
||||
#endif
|
||||
|
@ -1092,7 +1298,7 @@ void loop() {
|
|||
#else
|
||||
if (mode != CUSTOM) {
|
||||
#endif
|
||||
strip.service();
|
||||
strip->service();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
||||
|
@ -1103,7 +1309,7 @@ void loop() {
|
|||
|
||||
#ifdef ENABLE_STATE_SAVE_EEPROM
|
||||
// Check for state changes
|
||||
sprintf(current_state, "STA|%2d|%3d|%3d|%3d|%3d|%3d|%3d", mode, strip.getMode(), ws2812fx_speed, brightness, main_color.red, main_color.green, main_color.blue);
|
||||
sprintf(current_state, "STA|%2d|%3d|%3d|%3d|%3d|%3d|%3d", mode, strip->getMode(), ws2812fx_speed, brightness, main_color.red, main_color.green, main_color.blue);
|
||||
|
||||
if (strcmp(current_state, last_state) != 0) {
|
||||
// DBG_OUTPUT_PORT.printf("STATE CHANGED: %s / %s\n", last_state, current_state);
|
||||
|
|
|
@ -25,7 +25,7 @@ void hsb2rgbAN1(uint16_t index, uint8_t sat, uint8_t bright, uint8_t myled) {
|
|||
temp[1] = temp[4] = (uint8_t)((((( (index & 255) * sat) / 255) + (sat ^ 255)) * bright) / 255);
|
||||
temp[2] = (uint8_t)(((((((index & 255) ^ 255) * sat) / 255) + (sat ^ 255)) * bright) / 255);
|
||||
|
||||
strip.setPixelColor(myled, temp[n + 2], temp[n + 1], temp[n]);
|
||||
strip->setPixelColor(myled, temp[n + 2], temp[n + 1], temp[n]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,7 +37,7 @@ void updateLed (int led, int brightness) {
|
|||
uint16_t index = (i%3 == 0) ? 400 : random(0,767);
|
||||
hsb2rgbAN1(index, 200, ledStates[i], i);
|
||||
}
|
||||
strip.show();
|
||||
strip->show();
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,7 +61,7 @@ void tv() {
|
|||
}
|
||||
if(currentMillis-previousMillis<twitch)
|
||||
{
|
||||
led=random(0, (strip.numPixels()-1));
|
||||
led=random(0, (strip->numPixels()-1));
|
||||
analogLevel=random(50,255);// set the range of the 3 pwm leds
|
||||
ledState = ledState == LOW ? HIGH: LOW; // if the LED is off turn it on and vice-versa:
|
||||
|
||||
|
@ -76,7 +76,7 @@ void tv() {
|
|||
darkTime = random(50,150);
|
||||
dipInterval = random(5,250);// cycles of flicker
|
||||
}
|
||||
//strip.show();
|
||||
//strip->show();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -85,7 +85,7 @@ void tv() {
|
|||
currentDipTime = millis();
|
||||
if (currentDipTime - dipStartTime < darkTime)
|
||||
{
|
||||
for (int i=3; i<strip.numPixels(); i++)
|
||||
for (int i=3; i<strip->numPixels(); i++)
|
||||
{
|
||||
updateLed(i, 0);
|
||||
}
|
||||
|
@ -94,6 +94,6 @@ void tv() {
|
|||
{
|
||||
timeToDip = false;
|
||||
}
|
||||
strip.show();
|
||||
strip->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
97
Arduino/McLighting/custom_ws2812fx_animations.h
Normal file
97
Arduino/McLighting/custom_ws2812fx_animations.h
Normal file
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
|
||||
Example of adding the example: https://github.com/kitesurfer1404/WS2812FX/blob/master/examples/ws2812fx_custom_FastLED/ws2812fx_custom_FastLED.ino
|
||||
as a custom effect
|
||||
|
||||
More info on how to create custom aniamtions for WS2812FX: https://github.com/kitesurfer1404/WS2812FX/blob/master/extras/WS2812FX%20Users%20Guide.md#custom-effects
|
||||
|
||||
*/
|
||||
|
||||
#include <FastLED.h> //https://github.com/FastLED/FastLED
|
||||
|
||||
|
||||
/*
|
||||
* paste in the Fire2012 code with a small edit at the end which uses the
|
||||
* setPixelColor() function to copy the color data to the ws2812fx instance.
|
||||
*/
|
||||
|
||||
// Fire2012 by Mark Kriegsman, July 2012
|
||||
// as part of "Five Elements" shown here: http://youtu.be/knWiGsmgycY
|
||||
////
|
||||
// This basic one-dimensional 'fire' simulation works roughly as follows:
|
||||
// There's a underlying array of 'heat' cells, that model the temperature
|
||||
// at each point along the line. Every cycle through the simulation,
|
||||
// four steps are performed:
|
||||
// 1) All cells cool down a little bit, losing heat to the air
|
||||
// 2) The heat from each cell drifts 'up' and diffuses a little
|
||||
// 3) Sometimes randomly new 'sparks' of heat are added at the bottom
|
||||
// 4) The heat from each cell is rendered as a color into the leds array
|
||||
// The heat-to-color mapping uses a black-body radiation approximation.
|
||||
//
|
||||
// Temperature is in arbitrary units from 0 (cold black) to 255 (white hot).
|
||||
//
|
||||
// This simulation scales it self a bit depending on NUM_LEDS; it should look
|
||||
// "OK" on anywhere from 20 to 100 LEDs without too much tweaking.
|
||||
//
|
||||
// I recommend running this simulation at anywhere from 30-100 frames per second,
|
||||
// meaning an interframe delay of about 10-35 milliseconds.
|
||||
//
|
||||
// Looks best on a high-density LED setup (60+ pixels/meter).
|
||||
//
|
||||
//
|
||||
// There are two main parameters you can play with to control the look and
|
||||
// feel of your fire: COOLING (used in step 1 above), and SPARKING (used
|
||||
// in step 3 above).
|
||||
//
|
||||
// COOLING: How much does the air cool as it rises?
|
||||
// Less cooling = taller flames. More cooling = shorter flames.
|
||||
// Default 50, suggested range 20-100
|
||||
#define COOLING 55
|
||||
|
||||
// SPARKING: What chance (out of 255) is there that a new spark will be lit?
|
||||
// Higher chance = more roaring fire. Lower chance = more flickery fire.
|
||||
// Default 120, suggested range 50-200.
|
||||
#define SPARKING 120
|
||||
|
||||
bool gReverseDirection = false;
|
||||
|
||||
void Fire2012()
|
||||
{
|
||||
// Array of temperature readings at each simulation cell
|
||||
byte heat[WS2812FXStripSettings.stripSize];
|
||||
|
||||
// Step 1. Cool down every cell a little
|
||||
for( int i = 0; i < WS2812FXStripSettings.stripSize; i++) {
|
||||
heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / WS2812FXStripSettings.stripSize) + 2));
|
||||
}
|
||||
|
||||
// Step 2. Heat from each cell drifts 'up' and diffuses a little
|
||||
for( int k= WS2812FXStripSettings.stripSize- 1; k >= 2; k--) {
|
||||
heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
|
||||
}
|
||||
|
||||
// Step 3. Randomly ignite new 'sparks' of heat near the bottom
|
||||
if( random8() < SPARKING ) {
|
||||
int y = random8(7);
|
||||
heat[y] = qadd8( heat[y], random8(160,255) );
|
||||
}
|
||||
|
||||
// Step 4. Map from heat cells to LED colors
|
||||
for( int j = 0; j < WS2812FXStripSettings.stripSize; j++) {
|
||||
CRGB color = HeatColor( heat[j]);
|
||||
int pixelnumber;
|
||||
if( gReverseDirection ) {
|
||||
pixelnumber = (WS2812FXStripSettings.stripSize-1) - j;
|
||||
} else {
|
||||
pixelnumber = j;
|
||||
}
|
||||
|
||||
strip->setPixelColor(pixelnumber, color.red, color.green, color.blue);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t myCustomEffect() {
|
||||
Fire2012();
|
||||
return (strip->getSpeed() / WS2812FXStripSettings.stripSize);
|
||||
}
|
BIN
Arduino/McLighting/data/index2.htm.gz
Normal file
BIN
Arduino/McLighting/data/index2.htm.gz
Normal file
Binary file not shown.
|
@ -1,15 +1,16 @@
|
|||
#define USE_WS2812FX_DMA // Uses PIN is ignored & set to RX/GPIO3 Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
|
||||
//#define USE_WS2812FX_UART1 // Uses PIN is ignored & set to D4/GPIO2 Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
|
||||
//#define USE_WS2812FX_UART2 // Uses PIN is ignored & set to TX/GPIO1 Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
|
||||
#define USE_WS2812FX_DMA // LED_PIN is ignored & set to RX/GPIO3 Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
|
||||
//#define USE_WS2812FX_UART1 // LED_PIN is ignored & set to D4/GPIO2 Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
|
||||
//#define USE_WS2812FX_UART2 // LED_PIN is ignored & set to TX/GPIO1 Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
|
||||
|
||||
// Neopixel
|
||||
#define PIN 3 // PIN (14 / D5) where neopixel / WS2811 strip is attached
|
||||
#define LED_PIN 3 // LED_PIN (14 / D5) where neopixel / WS2811 strip is attached
|
||||
#define NUMLEDS 30 // 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.
|
||||
#define SIMPLEINPUT 5
|
||||
|
||||
const char HOSTNAME[] = "motion1"; // Friedly hostname
|
||||
#define HOSTNAME "motion1" // Friedly hostname
|
||||
|
||||
#define HTTP_OTA // If defined, enable ESP8266HTTPUpdateServer OTA code.
|
||||
//#define ENABLE_OTA // If defined, enable Arduino OTA code.
|
||||
|
@ -21,10 +22,13 @@ const char HOSTNAME[] = "motion1"; // Friedly hostname
|
|||
//#define MQTT_HOME_ASSISTANT_SUPPORT // If defined, use AMQTT and select Tools -> IwIP Variant -> Higher Bandwidth
|
||||
#define ENABLE_LEGACY_ANIMATIONS // Dont disbale this for now
|
||||
#define ENABLE_E131 // E1.31 implementation
|
||||
#define USE_HTML_MIN_GZ //comment for using index.htm & edit.htm from SPIFFs instead of PROGMEM
|
||||
//#define CUSTOM_WS2812FX_ANIMATIONS //uncomment and put animations in "custom_ws2812fx_animations.h"
|
||||
|
||||
#ifdef ENABLE_E131
|
||||
#define START_UNIVERSE 1 // First DMX Universe to listen for
|
||||
#define END_UNIVERSE 2 // Total number of Universes to listen for, starting at UNIVERSE
|
||||
#define END_UNIVERSE 2 // Last Universe to listen for, starting at UNIVERSE
|
||||
// MUST: END_UNIVERSE >= START_UNIVERSE
|
||||
#endif
|
||||
|
||||
//#define WIFIMGR_PORTAL_TIMEOUT 180
|
||||
|
@ -37,7 +41,7 @@ const char HOSTNAME[] = "motion1"; // Friedly hostname
|
|||
#endif
|
||||
|
||||
#ifdef MQTT_HOME_ASSISTANT_SUPPORT
|
||||
#define MQTT_HOME_ASSISTANT_0_84_SUPPORT // Comment if using HA version < 0.84
|
||||
#define MQTT_HOME_ASSISTANT_0_87_SUPPORT // Comment if using HA version < 0.87
|
||||
#endif
|
||||
|
||||
#if defined(USE_WS2812FX_DMA) and defined(USE_WS2812FX_UART)
|
||||
|
@ -54,35 +58,37 @@ const char HOSTNAME[] = "motion1"; // Friedly hostname
|
|||
#endif
|
||||
|
||||
// parameters for automatically cycling favorite patterns
|
||||
uint32_t autoParams[][4] = { // color, speed, mode, duration (seconds)
|
||||
{0xff0000, 200, 1, 5.0}, // blink red for 5 seconds
|
||||
{0x00ff00, 200, 3, 10.0}, // wipe green for 10 seconds
|
||||
{0x0000ff, 200, 11, 5.0}, // dual scan blue for 5 seconds
|
||||
{0x0000ff, 200, 42, 15.0} // fireworks for 15 seconds
|
||||
uint32_t autoParams[][4] = { // color, speed, mode, duration (milliseconds)
|
||||
{0xff0000, 200, 1, 5000}, // blink red for 5 seconds
|
||||
{0x00ff00, 200, 3, 10000}, // wipe green for 10 seconds
|
||||
{0x0000ff, 200, 14, 5000}, // dual scan blue for 5 seconds
|
||||
{0x0000ff, 200, 45, 15000} // fireworks for 15 seconds
|
||||
};
|
||||
|
||||
#if defined(ENABLE_MQTT) or defined(ENABLE_AMQTT)
|
||||
|
||||
const char mqtt_will_topic[] = HOSTNAME "/status";
|
||||
const char mqtt_will_payload[] = "OFFLINE";
|
||||
const char mqtt_intopic[] = HOSTNAME "/in";
|
||||
const char mqtt_outtopic[] = HOSTNAME "/out";
|
||||
bool mqtt_lwt_boot_flag = true;
|
||||
|
||||
#ifdef ENABLE_MQTT
|
||||
#define MQTT_MAX_PACKET_SIZE 2048
|
||||
#define MQTT_MAX_PACKET_SIZE 512
|
||||
#define MQTT_MAX_RECONNECT_TRIES 4
|
||||
|
||||
int mqtt_reconnect_retries = 0;
|
||||
char mqtt_intopic[strlen(HOSTNAME) + 4 + 5]; // Topic in will be: <HOSTNAME>/in
|
||||
char mqtt_outtopic[strlen(HOSTNAME) + 5 + 5]; // Topic out will be: <HOSTNAME>/out
|
||||
uint8_t qossub = 0; // PubSubClient can sub qos 0 or 1
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_AMQTT
|
||||
String mqtt_intopic = String(HOSTNAME) + "/in";
|
||||
String mqtt_outtopic = String(HOSTNAME) + "/out";
|
||||
uint8_t qossub = 0; // AMQTT can sub qos 0 or 1 or 2
|
||||
uint8_t qospub = 0; // AMQTT can pub qos 0 or 1 or 2
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
String mqtt_ha = "home/" + String(HOSTNAME) + "_ha/";
|
||||
String mqtt_ha_state_in = mqtt_ha + "state/in";
|
||||
String mqtt_ha_state_out = mqtt_ha + "state/out";
|
||||
const char mqtt_ha_state_in[] = "home/" HOSTNAME "_ha/state/in";
|
||||
const char mqtt_ha_state_out[] = "home/" HOSTNAME "_ha/state/out";
|
||||
|
||||
const char* on_cmd = "ON";
|
||||
const char* off_cmd = "OFF";
|
||||
|
@ -96,7 +102,7 @@ uint32_t autoParams[][4] = { // color, speed, mode, duration (seconds)
|
|||
#ifdef ENABLE_MQTT_HOSTNAME_CHIPID
|
||||
char mqtt_clientid[64];
|
||||
#else
|
||||
const char* mqtt_clientid = HOSTNAME;
|
||||
const char mqtt_clientid[] = HOSTNAME;
|
||||
#endif
|
||||
|
||||
char mqtt_host[64] = "";
|
||||
|
|
15646
Arduino/McLighting/html_gz.h
Normal file
15646
Arduino/McLighting/html_gz.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -27,9 +27,9 @@ void handleE131(){
|
|||
uint16_t len = (170 + multipacketOffset > NUMLEDS) ? (NUMLEDS - multipacketOffset) : 170;
|
||||
for (uint16_t i = 0; i < len; i++){
|
||||
uint16_t j = i * 3;
|
||||
strip.setPixelColor(i + multipacketOffset, data[j], data[j + 1], data[j + 2]);
|
||||
strip->setPixelColor(i + multipacketOffset, data[j], data[j + 1], data[j + 2]);
|
||||
}
|
||||
strip.show();
|
||||
strip->show();
|
||||
checkForRequests();
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ void getArgs() {
|
|||
}
|
||||
|
||||
if (server.arg("m") != "") {
|
||||
ws2812fx_mode = constrain(server.arg("m").toInt(), 0, strip.getModeCount() - 1);
|
||||
ws2812fx_mode = constrain(server.arg("m").toInt(), 0, strip->getModeCount() - 1);
|
||||
}
|
||||
|
||||
if (server.arg("c").toInt() > 0) {
|
||||
|
@ -114,7 +114,7 @@ void handleSetMainColor(uint8_t * mypayload) {
|
|||
main_color.red = ((rgb >> 16) & 0xFF);
|
||||
main_color.green = ((rgb >> 8) & 0xFF);
|
||||
main_color.blue = ((rgb >> 0) & 0xFF);
|
||||
// strip.setColor(main_color.red, main_color.green, main_color.blue);
|
||||
// strip->setColor(main_color.red, main_color.green, main_color.blue);
|
||||
mode = SETCOLOR;
|
||||
}
|
||||
|
||||
|
@ -140,14 +140,17 @@ void handleSetSingleLED(uint8_t * mypayload, uint8_t firstChar = 0) {
|
|||
strncpy (templed, (const char *) &mypayload[firstChar], 2 );
|
||||
uint8_t led = atoi(templed);
|
||||
|
||||
DBG_OUTPUT_PORT.printf("led value: [%i]. Entry threshold: <= [%i] (=> %s)\n", led, strip.numPixels(), mypayload );
|
||||
if (led <= strip.numPixels()) {
|
||||
DBG_OUTPUT_PORT.printf("led value: [%i]. Entry threshold: <= [%i] (=> %s)\n", led, strip->numPixels(), mypayload );
|
||||
if (led <= strip->numPixels()) {
|
||||
char redhex[3];
|
||||
char greenhex[3];
|
||||
char bluehex[3];
|
||||
strncpy (redhex, (const char *) &mypayload[2 + firstChar], 2 );
|
||||
strncpy (greenhex, (const char *) &mypayload[4 + firstChar], 2 );
|
||||
strncpy (bluehex, (const char *) &mypayload[6 + firstChar], 2 );
|
||||
redhex[2] = 0x00;
|
||||
greenhex[2] = 0x00;
|
||||
bluehex[2] = 0x00;
|
||||
ledstates[led].red = strtol(redhex, NULL, 16);
|
||||
ledstates[led].green = strtol(greenhex, NULL, 16);
|
||||
ledstates[led].blue = strtol(bluehex, NULL, 16);
|
||||
|
@ -156,8 +159,8 @@ void handleSetSingleLED(uint8_t * mypayload, uint8_t firstChar = 0) {
|
|||
DBG_OUTPUT_PORT.printf("WS: Set single led [%i] to [%i] [%i] [%i] (%s)!\n", led, ledstates[led].red, ledstates[led].green, ledstates[led].blue, mypayload);
|
||||
|
||||
|
||||
strip.setPixelColor(led, ledstates[led].red, ledstates[led].green, ledstates[led].blue);
|
||||
strip.show();
|
||||
strip->setPixelColor(led, ledstates[led].red, ledstates[led].green, ledstates[led].blue);
|
||||
strip->show();
|
||||
}
|
||||
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||
exit_func = true;
|
||||
|
@ -234,10 +237,10 @@ void setModeByStateString(String saved_state_string) {
|
|||
DBG_OUTPUT_PORT.printf("main_color.green: %d\n", main_color.green);
|
||||
DBG_OUTPUT_PORT.printf("main_color.blue: %d\n", main_color.blue);
|
||||
|
||||
strip.setMode(ws2812fx_mode);
|
||||
strip.setSpeed(convertSpeed(ws2812fx_speed));
|
||||
strip.setBrightness(brightness);
|
||||
strip.setColor(main_color.red, main_color.green, main_color.blue);
|
||||
strip->setMode(ws2812fx_mode);
|
||||
strip->setSpeed(convertSpeed(ws2812fx_speed));
|
||||
strip->setBrightness(brightness);
|
||||
strip->setColor(main_color.red, main_color.green, main_color.blue);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||
|
@ -306,7 +309,7 @@ void setModeByStateString(String saved_state_string) {
|
|||
void handleE131NamedMode(String str_mode) {
|
||||
exit_func = true;
|
||||
if (str_mode.startsWith("=e131") or str_mode.startsWith("/e131")) {
|
||||
if(strip.isRunning()) strip.stop();
|
||||
if(strip->isRunning()) strip->stop();
|
||||
mode = E131;
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = true;
|
||||
|
@ -318,18 +321,18 @@ void setModeByStateString(String saved_state_string) {
|
|||
void handleSetWS2812FXMode(uint8_t * mypayload) {
|
||||
mode = SET_MODE;
|
||||
uint8_t ws2812fx_mode_tmp = (uint8_t) strtol((const char *) &mypayload[1], NULL, 10);
|
||||
ws2812fx_mode = constrain(ws2812fx_mode_tmp, 0, strip.getModeCount() - 1);
|
||||
ws2812fx_mode = constrain(ws2812fx_mode_tmp, 0, strip->getModeCount() - 1);
|
||||
}
|
||||
|
||||
String listStatusJSON(void) {
|
||||
uint8_t tmp_mode = (mode == SET_MODE) ? (uint8_t) ws2812fx_mode : strip.getMode();
|
||||
uint8_t tmp_mode = (mode == SET_MODE) ? (uint8_t) ws2812fx_mode : strip->getMode();
|
||||
|
||||
const size_t bufferSize = JSON_ARRAY_SIZE(3) + JSON_OBJECT_SIZE(6) + 500;
|
||||
DynamicJsonDocument jsonBuffer(bufferSize);
|
||||
JsonObject root = jsonBuffer.to<JsonObject>();
|
||||
root["mode"] = (uint8_t) mode;
|
||||
root["ws2812fx_mode"] = tmp_mode;
|
||||
root["ws2812fx_mode_name"] = strip.getModeName(tmp_mode);
|
||||
root["ws2812fx_mode_name"] = strip->getModeName(tmp_mode);
|
||||
root["speed"] = ws2812fx_speed;
|
||||
root["brightness"] = brightness;
|
||||
JsonArray color = root.createNestedArray("color");
|
||||
|
@ -349,7 +352,7 @@ void getStatusJSON() {
|
|||
}
|
||||
|
||||
String listModesJSON(void) {
|
||||
const size_t bufferSize = JSON_ARRAY_SIZE(strip.getModeCount()+1) + strip.getModeCount()*JSON_OBJECT_SIZE(2) + 1000;
|
||||
const size_t bufferSize = JSON_ARRAY_SIZE(strip->getModeCount()+1) + strip->getModeCount()*JSON_OBJECT_SIZE(2) + 1000;
|
||||
DynamicJsonDocument jsonBuffer(bufferSize);
|
||||
JsonArray json = jsonBuffer.to<JsonArray>();
|
||||
#ifdef ENABLE_E131
|
||||
|
@ -357,10 +360,10 @@ String listModesJSON(void) {
|
|||
objecte131["mode"] = "e131";
|
||||
objecte131["name"] = "E131";
|
||||
#endif
|
||||
for (uint8_t i = 0; i < strip.getModeCount(); i++) {
|
||||
for (uint8_t i = 0; i < strip->getModeCount(); i++) {
|
||||
JsonObject object = json.createNestedObject();
|
||||
object["mode"] = i;
|
||||
object["name"] = strip.getModeName(i);
|
||||
object["name"] = strip->getModeName(i);
|
||||
}
|
||||
JsonObject object = json.createNestedObject();
|
||||
|
||||
|
@ -422,12 +425,11 @@ Ticker autoTicker;
|
|||
int autoCount = 0;
|
||||
|
||||
void autoTick() {
|
||||
strip.setColor(autoParams[autoCount][0]);
|
||||
strip.setSpeed(convertSpeed((uint8_t)autoParams[autoCount][1]));
|
||||
strip.setMode((uint8_t)autoParams[autoCount][2]);
|
||||
autoTicker.once((float)autoParams[autoCount][3], autoTick);
|
||||
DBG_OUTPUT_PORT.print("autoTick ");
|
||||
DBG_OUTPUT_PORT.println(autoCount);
|
||||
strip->setColor(autoParams[autoCount][0]);
|
||||
strip->setSpeed(convertSpeed((uint8_t)autoParams[autoCount][1]));
|
||||
strip->setMode((uint8_t)autoParams[autoCount][2]);
|
||||
autoTicker.once_ms((uint32_t)autoParams[autoCount][3], autoTick);
|
||||
DBG_OUTPUT_PORT.printf("autoTick[%d]: {0x%06x, %d, %d, %d}\n", autoCount, autoParams[autoCount][0], (uint8_t)autoParams[autoCount][1], (uint8_t)autoParams[autoCount][2], (uint32_t)autoParams[autoCount][3]);
|
||||
|
||||
autoCount++;
|
||||
if (autoCount >= (sizeof(autoParams) / sizeof(autoParams[0]))) autoCount = 0;
|
||||
|
@ -436,12 +438,12 @@ void autoTick() {
|
|||
void handleAutoStart() {
|
||||
autoCount = 0;
|
||||
autoTick();
|
||||
strip.start();
|
||||
strip->start();
|
||||
}
|
||||
|
||||
void handleAutoStop() {
|
||||
autoTicker.detach();
|
||||
strip.stop();
|
||||
strip->stop();
|
||||
}
|
||||
|
||||
void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
||||
|
@ -459,7 +461,7 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
|||
mqtt_client.publish(mqtt_outtopic, String(String("OK ") + String((char *)payload)).c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = true;
|
||||
|
@ -490,7 +492,7 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
|||
mqtt_client.publish(mqtt_outtopic, String(String("OK ") + String((char *)payload)).c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -510,7 +512,7 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
|||
mqtt_client.publish(mqtt_outtopic, String(String("OK ") + String((char *)payload)).c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = true;
|
||||
|
@ -535,7 +537,7 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
|||
mqtt_client.publish(mqtt_outtopic, String(String("OK ") + String((char *)payload)).c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = true;
|
||||
|
@ -560,7 +562,7 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
|||
mqtt_client.publish(mqtt_outtopic, String(String("OK ") + String((char *)payload)).c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -578,7 +580,7 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
|||
mqtt_client.publish(mqtt_outtopic, String(String("OK ") + String((char *)payload)).c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -597,7 +599,7 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
|||
mqtt_client.publish(mqtt_outtopic, String(String("OK ") + String((char *)payload)).c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -622,7 +624,7 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
|||
mqtt_client.publish(mqtt_outtopic, String(String("OK ") + String((char *)payload)).c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
if(!ha_send_data.active()) ha_send_data.once(5, tickerSendState);
|
||||
|
@ -642,7 +644,7 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
|||
mqtt_client.publish(mqtt_outtopic, json.c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, json.c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, json.c_str());
|
||||
#endif
|
||||
} else {
|
||||
DBG_OUTPUT_PORT.print("WS: ");
|
||||
|
@ -669,7 +671,7 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
|||
//DBG_OUTPUT_PORT.printf("Result: %d / %d", res, json_modes.length());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, json.c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, json.c_str());
|
||||
#endif
|
||||
} else {
|
||||
DBG_OUTPUT_PORT.print("WS: ");
|
||||
|
@ -698,7 +700,7 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
|||
mqtt_client.publish(mqtt_outtopic, String(String("OK ") + String((char *)payload)).c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String(String("OK ") + String((char *)payload)).c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = true;
|
||||
|
@ -748,15 +750,13 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_LEGACY_ANIMATIONS
|
||||
void checkForRequests() {
|
||||
webSocket.loop();
|
||||
server.handleClient();
|
||||
#ifdef ENABLE_MQTT
|
||||
mqtt_client.loop();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
void checkForRequests() {
|
||||
webSocket.loop();
|
||||
server.handleClient();
|
||||
#ifdef ENABLE_MQTT
|
||||
mqtt_client.loop();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
|
@ -841,26 +841,26 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||
root["speed"] = ws2812fx_speed;
|
||||
|
||||
//char modeName[30];
|
||||
//strncpy_P(modeName, (PGM_P)strip.getModeName(strip.getMode()), sizeof(modeName)); // copy from progmem
|
||||
//strncpy_P(modeName, (PGM_P)strip->getModeName(strip->getMode()), sizeof(modeName)); // copy from progmem
|
||||
#if defined(ENABLE_E131) and defined(ENABLE_HOMEASSISTANT)
|
||||
if (mode == E131)
|
||||
root["effect"] = "E131";
|
||||
else
|
||||
root["effect"] = strip.getModeName(strip.getMode());
|
||||
root["effect"] = strip->getModeName(strip->getMode());
|
||||
#else
|
||||
root["effect"] = strip.getModeName(strip.getMode());
|
||||
root["effect"] = strip->getModeName(strip->getMode());
|
||||
#endif
|
||||
|
||||
char buffer[measureJson(root) + 1];
|
||||
serializeJson(root, buffer, sizeof(buffer));
|
||||
|
||||
#ifdef ENABLE_MQTT
|
||||
mqtt_client.publish(mqtt_ha_state_out.c_str(), buffer, true);
|
||||
DBG_OUTPUT_PORT.printf("MQTT: Send [%s]: %s\n", mqtt_ha_state_out.c_str(), buffer);
|
||||
mqtt_client.publish(mqtt_ha_state_out, buffer, true);
|
||||
DBG_OUTPUT_PORT.printf("MQTT: Send [%s]: %s\n", mqtt_ha_state_out, buffer);
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_ha_state_out.c_str(), 1, true, buffer);
|
||||
DBG_OUTPUT_PORT.printf("MQTT: Send [%s]: %s\n", mqtt_ha_state_out.c_str(), buffer);
|
||||
amqttClient.publish(mqtt_ha_state_out, 1, true, buffer);
|
||||
DBG_OUTPUT_PORT.printf("MQTT: Send [%s]: %s\n", mqtt_ha_state_out, buffer);
|
||||
#endif
|
||||
new_ha_mqtt_msg = false;
|
||||
ha_send_data.detach();
|
||||
|
@ -927,15 +927,15 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||
animation_on = true;
|
||||
String effectString = root["effect"].as<String>();
|
||||
|
||||
for (uint8_t i = 0; i < strip.getModeCount(); i++) {
|
||||
for (uint8_t i = 0; i < strip->getModeCount(); i++) {
|
||||
#if defined(ENABLE_E131) and defined(ENABLE_HOMEASSISTANT)
|
||||
if(effectString == "E131"){
|
||||
if(strip.isRunning()) strip.stop();
|
||||
if(strip->isRunning()) strip->stop();
|
||||
mode = E131;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
if(String(strip.getModeName(i)) == effectString) {
|
||||
if(String(strip->getModeName(i)) == effectString) {
|
||||
mode = SET_MODE;
|
||||
ws2812fx_mode = i;
|
||||
break;
|
||||
|
@ -965,7 +965,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||
DBG_OUTPUT_PORT.printf("MQTT: Message arrived [%s]\n", payload);
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
if (strcmp(topic, mqtt_ha_state_in.c_str()) == 0) {
|
||||
if (strcmp(topic, mqtt_ha_state_in) == 0) {
|
||||
if (!processJson((char*)payload)) {
|
||||
return;
|
||||
}
|
||||
|
@ -977,7 +977,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||
} else if (strcmp(topic, (char *)mqtt_intopic) == 0) {
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
} else if (strcmp(topic, mqtt_intopic.c_str()) == 0) {
|
||||
} else if (strcmp(topic, mqtt_intopic) == 0) {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -996,45 +996,63 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||
mqtt_reconnect_retries++;
|
||||
DBG_OUTPUT_PORT.printf("Attempting MQTT connection %d / %d ...\n", mqtt_reconnect_retries, MQTT_MAX_RECONNECT_TRIES);
|
||||
// Attempt to connect
|
||||
if (mqtt_client.connect(mqtt_clientid, mqtt_user, mqtt_pass)) {
|
||||
if (mqtt_client.connect(mqtt_clientid, mqtt_user, mqtt_pass, mqtt_will_topic, 2, true, mqtt_will_payload, true)) {
|
||||
DBG_OUTPUT_PORT.println("MQTT connected!");
|
||||
// Once connected, publish an announcement...
|
||||
char * message = new char[18 + strlen(HOSTNAME) + 1];
|
||||
char message[18 + strlen(HOSTNAME) + 1];
|
||||
strcpy(message, "McLighting ready: ");
|
||||
strcat(message, HOSTNAME);
|
||||
mqtt_client.publish(mqtt_outtopic, message);
|
||||
// ... and resubscribe
|
||||
mqtt_client.subscribe(mqtt_intopic, qossub);
|
||||
if(mqtt_lwt_boot_flag)
|
||||
{
|
||||
mqtt_client.publish(mqtt_will_topic, "ONLINE");
|
||||
//mqtt_lwt_boot_flag = false;
|
||||
}
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
ha_send_data.detach();
|
||||
mqtt_client.subscribe(mqtt_ha_state_in.c_str(), qossub);
|
||||
mqtt_client.subscribe(mqtt_ha_state_in, qossub);
|
||||
ha_send_data.once(5, tickerSendState);
|
||||
#ifdef MQTT_HOME_ASSISTANT_SUPPORT
|
||||
DynamicJsonDocument jsonBuffer(JSON_ARRAY_SIZE(strip.getModeCount()) + JSON_OBJECT_SIZE(12) + 1500);
|
||||
DynamicJsonDocument jsonBuffer(JSON_ARRAY_SIZE(strip->getModeCount()) + JSON_OBJECT_SIZE(12) + 1500);
|
||||
JsonObject json = jsonBuffer.to<JsonObject>();
|
||||
json["name"] = HOSTNAME;
|
||||
#ifdef MQTT_HOME_ASSISTANT_0_84_SUPPORT
|
||||
#ifdef MQTT_HOME_ASSISTANT_0_87_SUPPORT
|
||||
json["schema"] = "json";
|
||||
#else
|
||||
json["platform"] = "mqtt_json";
|
||||
#endif
|
||||
json["state_topic"] = mqtt_ha_state_out;
|
||||
json["command_topic"] = mqtt_ha_state_in;
|
||||
#ifndef MQTT_HOME_ASSISTANT_0_87_SUPPORT
|
||||
json["on_command_type"] = "first";
|
||||
#endif
|
||||
json["brightness"] = "true";
|
||||
json["rgb"] = "true";
|
||||
json["optimistic"] = "false";
|
||||
json["color_temp"] = "true";
|
||||
json["effect"] = "true";
|
||||
JsonArray effect_list = json.createNestedArray("effect_list");
|
||||
for (uint8_t i = 0; i < strip.getModeCount(); i++) {
|
||||
effect_list.add(strip.getModeName(i));
|
||||
for (uint8_t i = 0; i < strip->getModeCount(); i++) {
|
||||
effect_list.add(strip->getModeName(i));
|
||||
}
|
||||
#if defined(ENABLE_E131) and defined(MQTT_HOME_ASSISTANT_SUPPORT)
|
||||
effect_list.add("E131");
|
||||
#endif
|
||||
char buffer[measureJson(json) + 1];
|
||||
// Following will never work for PubSubClient as message size > 1.6kB
|
||||
// char buffer[measureJson(json) + 1];
|
||||
// serializeJson(json, buffer, sizeof(buffer));
|
||||
// mqtt_client.publish(String("homeassistant/light/" + String(HOSTNAME) + "/config").c_str(), buffer, true);
|
||||
|
||||
// Alternate way to publish large messages using PubSubClient
|
||||
unsigned int msg_len = measureJson(json) + 1;
|
||||
char buffer[msg_len];
|
||||
serializeJson(json, buffer, sizeof(buffer));
|
||||
mqtt_client.publish(String("homeassistant/light/" + String(HOSTNAME) + "/config").c_str(), buffer, true);
|
||||
DBG_OUTPUT_PORT.println(buffer);
|
||||
mqtt_client.beginPublish(String("homeassistant/light/" + String(HOSTNAME) + "/config").c_str(), msg_len-1, true);
|
||||
mqtt_client.write((const uint8_t*)buffer, msg_len-1);
|
||||
mqtt_client.endPublish();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -1084,37 +1102,45 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||
DBG_OUTPUT_PORT.println("Connected to MQTT.");
|
||||
DBG_OUTPUT_PORT.print("Session present: ");
|
||||
DBG_OUTPUT_PORT.println(sessionPresent);
|
||||
char * message = new char[18 + strlen(HOSTNAME) + 1];
|
||||
char message[18 + strlen(HOSTNAME) + 1];
|
||||
strcpy(message, "McLighting ready: ");
|
||||
strcat(message, HOSTNAME);
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, message);
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, message);
|
||||
//Subscribe
|
||||
uint16_t packetIdSub1 = amqttClient.subscribe((char *)mqtt_intopic.c_str(), qossub);
|
||||
uint16_t packetIdSub1 = amqttClient.subscribe(mqtt_intopic, qossub);
|
||||
DBG_OUTPUT_PORT.printf("Subscribing at QoS %d, packetId: ", qossub); DBG_OUTPUT_PORT.println(packetIdSub1);
|
||||
if(mqtt_lwt_boot_flag)
|
||||
{
|
||||
amqttClient.publish(mqtt_will_topic, qospub, false, "ONLINE");
|
||||
mqtt_lwt_boot_flag = false;
|
||||
}
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
ha_send_data.detach();
|
||||
uint16_t packetIdSub2 = amqttClient.subscribe((char *)mqtt_ha_state_in.c_str(), qossub);
|
||||
uint16_t packetIdSub2 = amqttClient.subscribe((char *)mqtt_ha_state_in, qossub);
|
||||
DBG_OUTPUT_PORT.printf("Subscribing at QoS %d, packetId: ", qossub); DBG_OUTPUT_PORT.println(packetIdSub2);
|
||||
ha_send_data.once(5, tickerSendState);
|
||||
#ifdef MQTT_HOME_ASSISTANT_SUPPORT
|
||||
DynamicJsonDocument jsonBuffer(JSON_ARRAY_SIZE(strip.getModeCount()) + JSON_OBJECT_SIZE(12) + 1500);
|
||||
DynamicJsonDocument jsonBuffer(JSON_ARRAY_SIZE(strip->getModeCount()) + JSON_OBJECT_SIZE(12) + 1500);
|
||||
JsonObject json = jsonBuffer.to<JsonObject>();
|
||||
json["name"] = HOSTNAME;
|
||||
#ifdef MQTT_HOME_ASSISTANT_0_84_SUPPORT
|
||||
#ifdef MQTT_HOME_ASSISTANT_0_87_SUPPORT
|
||||
json["schema"] = "json";
|
||||
#else
|
||||
json["platform"] = "mqtt_json";
|
||||
#endif
|
||||
json["state_topic"] = mqtt_ha_state_out;
|
||||
json["command_topic"] = mqtt_ha_state_in;
|
||||
#ifndef MQTT_HOME_ASSISTANT_0_87_SUPPORT
|
||||
json["on_command_type"] = "first";
|
||||
#endif
|
||||
json["brightness"] = "true";
|
||||
json["rgb"] = "true";
|
||||
json["optimistic"] = "false";
|
||||
json["color_temp"] = "true";
|
||||
json["effect"] = "true";
|
||||
JsonArray effect_list = json.createNestedArray("effect_list");
|
||||
for (uint8_t i = 0; i < strip.getModeCount(); i++) {
|
||||
effect_list.add(strip.getModeName(i));
|
||||
for (uint8_t i = 0; i < strip->getModeCount(); i++) {
|
||||
effect_list.add(strip->getModeName(i));
|
||||
}
|
||||
#if defined(ENABLE_E131) and defined(MQTT_HOME_ASSISTANT_SUPPORT)
|
||||
effect_list.add("E131");
|
||||
|
@ -1167,7 +1193,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||
mqtt_client.publish(mqtt_outtopic, String("OK =static white").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =static white").c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String("OK =static white").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = true;
|
||||
|
@ -1183,7 +1209,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||
mqtt_client.publish(mqtt_outtopic, String("OK =off").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =off").c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String("OK =off").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = false;
|
||||
|
@ -1203,7 +1229,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||
mqtt_client.publish(mqtt_outtopic, String("OK =fire flicker").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =fire flicker").c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String("OK =fire flicker").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = true;
|
||||
|
@ -1222,7 +1248,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||
mqtt_client.publish(mqtt_outtopic, String("OK =fireworks random").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_AMQTT
|
||||
amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String("OK =fireworks random").c_str());
|
||||
amqttClient.publish(mqtt_outtopic, qospub, false, String("OK =fireworks random").c_str());
|
||||
#endif
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
stateOn = true;
|
||||
|
@ -1336,7 +1362,7 @@ bool writeConfigFS(bool saveConfig){
|
|||
//FS save
|
||||
updateFS = true;
|
||||
DBG_OUTPUT_PORT.print("Saving config: ");
|
||||
DynamicJsonDocument jsonBuffer;
|
||||
DynamicJsonDocument jsonBuffer(200);
|
||||
JsonObject json = jsonBuffer.to<JsonObject>();
|
||||
json["mqtt_host"] = mqtt_host;
|
||||
json["mqtt_port"] = mqtt_port;
|
||||
|
@ -1405,10 +1431,10 @@ bool writeStateFS(){
|
|||
updateFS = true;
|
||||
//save the strip state to FS JSON
|
||||
DBG_OUTPUT_PORT.print("Saving cfg: ");
|
||||
DynamicJsonDocument jsonBuffer;
|
||||
DynamicJsonDocument jsonBuffer(JSON_OBJECT_SIZE(7)+200);
|
||||
JsonObject json = jsonBuffer.to<JsonObject>();
|
||||
json["mode"] = static_cast<int>(mode);
|
||||
json["strip_mode"] = (int) strip.getMode();
|
||||
json["strip_mode"] = (int) strip->getMode();
|
||||
json["brightness"] = brightness;
|
||||
json["speed"] = ws2812fx_speed;
|
||||
json["red"] = main_color.red;
|
||||
|
@ -1460,14 +1486,17 @@ bool readStateFS() {
|
|||
main_color.green = json["green"];
|
||||
main_color.blue = json["blue"];
|
||||
|
||||
strip.setMode(ws2812fx_mode);
|
||||
strip.setSpeed(convertSpeed(ws2812fx_speed));
|
||||
strip.setBrightness(brightness);
|
||||
strip.setColor(main_color.red, main_color.green, main_color.blue);
|
||||
#ifdef ENABLE_HOMEASSISTANT
|
||||
if(mode != OFF) stateOn = true;
|
||||
#endif
|
||||
strip->setMode(ws2812fx_mode);
|
||||
strip->setSpeed(convertSpeed(ws2812fx_speed));
|
||||
strip->setBrightness(brightness);
|
||||
strip->setColor(main_color.red, main_color.green, main_color.blue);
|
||||
|
||||
#ifdef ENABLE_E131
|
||||
if (mode == E131) {
|
||||
strip.stop();
|
||||
strip->stop();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1487,3 +1516,90 @@ bool readStateFS() {
|
|||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
//Strip Config
|
||||
char strip_size[3], led_pin[2]; //needed for WiFiManager Settings
|
||||
|
||||
struct
|
||||
{
|
||||
uint16_t stripSize = NUMLEDS;
|
||||
uint8_t RGBOrder = NEO_GRB;
|
||||
#if defined(USE_WS2812FX_DMA) or defined(USE_WS2812FX_UART1) or defined(USE_WS2812FX_UART2)
|
||||
#ifdef USE_WS2812FX_DMA
|
||||
uint8_t pin = 3;
|
||||
#endif
|
||||
#ifdef USE_WS2812FX_UART1
|
||||
uint8_t pin = 2;
|
||||
#endif
|
||||
#ifdef USE_WS2812FX_UART2
|
||||
uint8_t pin = 1;
|
||||
#endif
|
||||
#else
|
||||
uint8_t pin = LED_PIN;
|
||||
#endif
|
||||
} WS2812FXStripSettings;
|
||||
|
||||
Ticker saveWS2812FXStripSettings;
|
||||
|
||||
bool readStripConfigFS(void) {
|
||||
//read stripconfiguration from FS JSON
|
||||
updateFS = true;
|
||||
if (SPIFFS.exists("/neoconfig.json")) {
|
||||
//file exists, reading and loading
|
||||
DBG_OUTPUT_PORT.print("Reading neoconfig file... ");
|
||||
File configFile = SPIFFS.open("/neoconfig.json", "r");
|
||||
if (configFile) {
|
||||
DBG_OUTPUT_PORT.println("Opened!");
|
||||
size_t size = configFile.size();
|
||||
std::unique_ptr<char[]> buf(new char[size]);
|
||||
configFile.readBytes(buf.get(), size);
|
||||
DynamicJsonDocument jsonBuffer(JSON_OBJECT_SIZE(4)+300);
|
||||
DeserializationError error = deserializeJson(jsonBuffer, buf.get());
|
||||
DBG_OUTPUT_PORT.print("Config: ");
|
||||
if (!error) {
|
||||
DBG_OUTPUT_PORT.println(" Parsed!");
|
||||
JsonObject json = jsonBuffer.as<JsonObject>();
|
||||
serializeJson(json, DBG_OUTPUT_PORT);
|
||||
WS2812FXStripSettings.stripSize = json["pixel_pount"];
|
||||
WS2812FXStripSettings.RGBOrder = json["rgb_order"];
|
||||
WS2812FXStripSettings.pin = json["pin"];
|
||||
updateFS = false;
|
||||
return true;
|
||||
} else {
|
||||
DBG_OUTPUT_PORT.print("Failed to load json config: ");
|
||||
DBG_OUTPUT_PORT.println(error.c_str());
|
||||
}
|
||||
} else {
|
||||
DBG_OUTPUT_PORT.println("Failed to open /config.json");
|
||||
}
|
||||
} else {
|
||||
DBG_OUTPUT_PORT.println("Coudnt find config.json");
|
||||
}
|
||||
//end read
|
||||
updateFS = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
void writeStripConfigFS(void){
|
||||
updateFS = true;
|
||||
//save the strip config to FS JSON
|
||||
DBG_OUTPUT_PORT.print("Saving Strip cfg: ");
|
||||
DynamicJsonDocument jsonBuffer(JSON_OBJECT_SIZE(4)+300);
|
||||
JsonObject json = jsonBuffer.to<JsonObject>();
|
||||
json["pixel_pount"] = WS2812FXStripSettings.stripSize;
|
||||
json["rgb_order"] = WS2812FXStripSettings.RGBOrder;
|
||||
json["pin"] = WS2812FXStripSettings.pin;
|
||||
|
||||
//SPIFFS.remove("/neoconfig.json") ? DBG_OUTPUT_PORT.println("removed file") : DBG_OUTPUT_PORT.println("failed removing file");
|
||||
File configFile = SPIFFS.open("/neoconfig.json", "w");
|
||||
if (!configFile) {
|
||||
DBG_OUTPUT_PORT.println("Failed!");
|
||||
updateFS = false;
|
||||
}
|
||||
serializeJson(json, DBG_OUTPUT_PORT);
|
||||
serializeJson(json, configFile);
|
||||
DBG_OUTPUT_PORT.println();
|
||||
configFile.close();
|
||||
updateFS = false;
|
||||
//end save
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
#define SKETCH_VERSION "2.2.0"
|
||||
#define SKETCH_VERSION "2.2.3"
|
|
@ -56,7 +56,36 @@
|
|||
* 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 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)
|
||||
* - Gzipped index2.htm & edit.htm.gz(untouched), convereted to hex format using xxd -i abcd.gz > html_gz.h
|
||||
* - Pointers added for WS2812FX & NeoPixelBus
|
||||
* - new "REST API": /pixelconf?ct=xxx to change length of LED strip
|
||||
* - new "REST API": /pixelconf?rgbo=xxx to change RGB order
|
||||
* - new "REST API": /pixelconf?pin=GPIO_NO to change PIN# (Allowed GPIO values: 16/5/4/0/2/14/12/13/15/3/1)
|
||||
* - added HA 0.87 version support https://github.com/toblum/McLighting/issues/327
|
||||
* - Added alternative way to send large messages using PubSubClient
|
||||
* - Bump PIO core to 2.0.4
|
||||
* - Send HA state on MQTT connect, address https://github.com/toblum/McLighting/issues/349
|
||||
* - Add LWT for MQTT and AMQTT, address https://github.com/toblum/McLighting/issues/340
|
||||
* - Added file for custom WS2812FX animations in custom slots
|
||||
* - 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
|
||||
* - Hotfix #351
|
||||
*
|
||||
* 18 Mar 2019 v 2.2.3 (mostly bugfix)
|
||||
* - PubSubClient related bug fixed
|
||||
* - UART 1 and 0 were mixed up
|
||||
* - LWT revisit
|
||||
* - Custom mode needs index
|
||||
*/
|
||||
|
|
15
README.md
15
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.0-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.3-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.
|
||||
|
||||
|
@ -61,17 +61,20 @@ I hope I didn't miss any sources and mentioned every author. In case I forgot so
|
|||
|
||||
## Todos
|
||||
- [ ] Support multiple strips and control them separately or together [Issue](https://github.com/toblum/McLighting/issues/118)
|
||||
- [ ] Make number of pixels, MQTT and PIN configurable via front end [Issue](https://github.com/toblum/McLighting/issues/93) and [Issue](https://github.com/toblum/McLighting/issues/93)
|
||||
- [ ] Bundle webpages instead of SPIFFS [Issue](https://github.com/toblum/McLighting/issues/93)
|
||||
- [ ] Remove old / wrong EEPROM settings completely [Issue]
|
||||
- [ ] Customer profile to define segments of (in)active areas on the strip [Issue](https://github.com/toblum/McLighting/issues/37)
|
||||
- [ ] Additional clients
|
||||
- [ ] If no wifi, at least enable button mode.
|
||||
- [ ] Also enable McLighting in Wifi AP mode.
|
||||
- [ ] IR remote support [issue](https://github.com/toblum/McLightingUI/issues/3)
|
||||
- [ ] Multiple buttons/GPIO Inputs. [Issue](https://github.com/toblum/McLighting/issues/119)
|
||||
- [ ] Music visualizer / Bring back ArtNet [Issue](https://github.com/toblum/McLighting/issues/111)
|
||||
- [ ] Display version and parameters (Number of LEDs, definition settings, ..) in the web UI [Issue](https://github.com/toblum/McLighting/issues/150)
|
||||
- [ ] IR remote support [issue](https://github.com/toblum/McLightingUI/issues/3)
|
||||
- [ ] Make number of pixels, MQTT and PIN configurable via front end [Issue](https://github.com/toblum/McLighting/issues/93) and [Issue](https://github.com/toblum/McLighting/issues/272)
|
||||
- [ ] Make switching between methods: Adafruit NeoPixel, NeoPixelBus's DMA, NeoPixelBus's UART1 and NeoPixelBus's UART2 via REST API
|
||||
- [ ] Add Espalexa library support [Issue](https://github.com/toblum/McLighting/issues/348)
|
||||
- [x] Make number of pixels, RGB Order and PIN configurable via REST API
|
||||
- [x] Bundle webpages instead of SPIFFS [Issue](https://github.com/toblum/McLighting/issues/93)
|
||||
- [x] Music visualizer / Bring back ArtNet [Issue](https://github.com/toblum/McLighting/issues/111)
|
||||
- [x] Display version and parameters (Number of LEDs, definition settings, ..) in the web UI [Issue](https://github.com/toblum/McLighting/issues/150)
|
||||
- [x] MQTT support
|
||||
- [x] Save favourite effects? [Issue](https://github.com/toblum/McLighting/issues/35)(https://github.com/toblum/McLighting/issues/101)
|
||||
- [x] OTA update [Issue](https://github.com/toblum/McLighting/issues/92)
|
||||
|
|
|
@ -4,7 +4,6 @@ light:
|
|||
name: "NeoPixel LEDs"
|
||||
state_topic: "home/McLighting01_ha/state/out"
|
||||
command_topic: "home/McLighting01_ha/state/in"
|
||||
on_command_type: 'first'
|
||||
effect: true
|
||||
effect_list:
|
||||
######
|
||||
|
|
|
@ -1,13 +1,3 @@
|
|||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[platformio]
|
||||
src_dir = ./Arduino/McLighting/
|
||||
data_dir = ./Arduino/McLighting/data/
|
||||
|
@ -15,28 +5,63 @@ env_default = nodemcuv2
|
|||
description = The ESP8266 based multi-client lighting gadget
|
||||
|
||||
[common]
|
||||
# ------------------------------------------------------------------------------
|
||||
# PLATFORM:
|
||||
# !! DO NOT confuse platformio's ESP8266 development platform with Arduino core for ESP8266
|
||||
# We use Arduino Core 2.5.0 (platformIO 2.0.4) as default
|
||||
#
|
||||
# arduino core 2.3.0 = platformIO 1.5.0
|
||||
# arduino core 2.4.0 = platformIO 1.6.0
|
||||
# arduino core 2.4.1 = platformIO 1.7.3
|
||||
# arduino core 2.4.2 = platformIO 1.8.0
|
||||
# arduino core 2.5.0 = platformIO 2.0.4
|
||||
# arduino core stage = platformIO feature#stage
|
||||
# ------------------------------------------------------------------------------
|
||||
arduino_core_2_3_0 = espressif8266@1.5.0
|
||||
arduino_core_2_4_0 = espressif8266@1.6.0
|
||||
arduino_core_2_4_1 = espressif8266@1.7.3
|
||||
arduino_core_2_4_2 = espressif8266@1.8.0
|
||||
arduino_core_2_5_0 = espressif8266@2.0.4
|
||||
arduino_core_stage = https://github.com/platformio/platform-espressif8266.git#feature/stage
|
||||
|
||||
framework = arduino
|
||||
platform = espressif8266@1.8.0
|
||||
; platform = https://github.com/platformio/platform-espressif8266.git
|
||||
; platform = https://github.com/platformio/platform-espressif8266.git#feature/stage
|
||||
; platform = https://github.com/platformio/platform-espressif8266.git#develop
|
||||
; platform = ${common.arduino_core_2_4_2}
|
||||
platform = ${common.arduino_core_2_5_0}
|
||||
|
||||
build_flags =
|
||||
-DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH
|
||||
-DMQTT_MAX_PACKET_SIZE=2048 ; PubSubClient Specific flags
|
||||
-DMQTT_MAX_PACKET_SIZE=512 ; PubSubClient Specific flags
|
||||
-w ; supress all warnings
|
||||
monitor_speed = 115200
|
||||
board_build.flash_mode = qio
|
||||
board_build.flash_mode = dout
|
||||
upload_speed = 115200
|
||||
upload_resetmethod = nodemcu
|
||||
lib_deps =
|
||||
WiFiManager@0.14
|
||||
AsyncMqttClient
|
||||
https://github.com/bblanchon/ArduinoJson.git#v6.7.0-beta
|
||||
https://github.com/bblanchon/ArduinoJson.git#v6.8.0-beta
|
||||
WS2812FX
|
||||
NeoPixelBus@2.4.1
|
||||
NeoPixelBus
|
||||
WebSockets
|
||||
ESPAsyncE131
|
||||
ESPAsyncUDP
|
||||
;PubSubClient ;neede for #define ENABLE_MQTT
|
||||
;FastLED ;needed for #define CUSTOM_WS2812FX_ANIMATIONS
|
||||
targets_eum = erase, upload, monitor
|
||||
targets_um = upload, monitor
|
||||
|
||||
[env:nodemcuv2]
|
||||
board = nodemcuv2
|
||||
framework = ${common.framework}
|
||||
platform = ${common.platform}
|
||||
build_flags =
|
||||
${common.build_flags}
|
||||
-Wl,-Teagle.flash.4m3m.ld ;;;; Required for core > v2.5.0 or staging version
|
||||
monitor_speed = ${common.monitor_speed}
|
||||
upload_speed = ${common.upload_speed}
|
||||
upload_resetmethod = ${common.upload_resetmethod}
|
||||
lib_deps = ${common.lib_deps}
|
||||
; targets = ${common.targets_um}
|
||||
|
||||
[env:esp01_1m]
|
||||
board = esp01_1m
|
||||
|
@ -47,14 +72,4 @@ 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}
|
||||
platform = ${common.platform}
|
||||
build_flags = ${common.build_flags}
|
||||
monitor_speed = ${common.monitor_speed}
|
||||
upload_speed = ${common.upload_speed}
|
||||
upload_resetmethod = ${common.upload_resetmethod}
|
||||
lib_deps = ${common.lib_deps}
|
||||
lib_deps = ${common.lib_deps}
|
Loading…
Reference in a new issue