Bugfixing
Bugfixing
This commit is contained in:
@@ -110,18 +110,30 @@ ESP8266HTTPUpdateServer httpUpdater;
|
|||||||
// and minimize distance between Arduino and first pixel. Avoid connecting
|
// and minimize distance between Arduino and first pixel. Avoid connecting
|
||||||
// on a live circuit...if you must, connect GND first.
|
// on a live circuit...if you must, connect GND first.
|
||||||
|
|
||||||
#ifdef USE_WS2812FX_DMA
|
#ifdef USE_WS2812FX_DMA // Uses GPIO3/RXD0/RX, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
|
||||||
#include <NeoPixelBus.h>
|
#include <NeoPixelBus.h>
|
||||||
#ifdef RGBW
|
#ifdef RGBW
|
||||||
NeoEsp8266Dma800KbpsMethod dma = NeoEsp8266Dma800KbpsMethod(NUMLEDS, 4); //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
|
NeoEsp8266Dma800KbpsMethod dma = NeoEsp8266Dma800KbpsMethod(NUMLEDS, 4); //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
|
||||||
#else
|
#else
|
||||||
NeoEsp8266Dma800KbpsMethod dma = NeoEsp8266Dma800KbpsMethod(NUMLEDS, 3); //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
|
NeoEsp8266Dma800KbpsMethod dma = NeoEsp8266Dma800KbpsMethod(NUMLEDS, 3); //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
|
||||||
#endif
|
#endif
|
||||||
//NeoEsp8266Dma400KbpsMethod dma = NeoEsp8266Dma400KbpsMethod(NUMLEDS, 3); //400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
|
//NeoEsp8266Dma400KbpsMethod dma = NeoEsp8266Dma400KbpsMethod(NUMLEDS, 3); //400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_WS2812FX_UART
|
#ifdef USE_WS2812FX_UART1 // Uses UART1: GPIO1/TXD0/TX, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
|
||||||
#include <NeoPixelBus.h>
|
#include <NeoPixelBus.h>
|
||||||
NeoEsp8266Uart800KbpsMethod dma = NeoEsp8266Uart800KbpsMethod(NUMLEDS, 3);
|
#ifdef RGBW
|
||||||
|
NeoEsp8266Uart0800KbpsMethod dma = NeoEsp8266Uart0800KbpsMethod(NUMLEDS, 4);
|
||||||
|
#else
|
||||||
|
NeoEsp8266Uart0800KbpsMethod dma = NeoEsp8266Uart0800KbpsMethod(NUMLEDS, 3);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifdef USE_WS2812FX_UART2 // Uses UART2: GPIO2/TXD1/D4, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
|
||||||
|
#include <NeoPixelBus.h>
|
||||||
|
#ifdef RGBW
|
||||||
|
NeoEsp8266Uart1800KbpsMethod dma = NeoEsp8266Uart1800KbpsMethod(NUMLEDS, 4);
|
||||||
|
#else
|
||||||
|
NeoEsp8266Uart1800KbpsMethod dma = NeoEsp8266Uart1800KbpsMethod(NUMLEDS, 3);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if defined(USE_WS2812FX_DMA) or defined(USE_WS2812FX_UART)
|
#if defined(USE_WS2812FX_DMA) or defined(USE_WS2812FX_UART)
|
||||||
void DMA_Show(void) {
|
void DMA_Show(void) {
|
||||||
@@ -649,7 +661,6 @@ DBG_OUTPUT_PORT.println("Starting....");
|
|||||||
server.send(200, "text/plain", "Formatting SPIFFS complete" );
|
server.send(200, "text/plain", "Formatting SPIFFS complete" );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
// Setup: SPIFFS Webserver handler
|
// Setup: SPIFFS Webserver handler
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
@@ -752,7 +763,7 @@ DBG_OUTPUT_PORT.println("Starting....");
|
|||||||
exit_func = true;
|
exit_func = true;
|
||||||
#endif
|
#endif
|
||||||
mode = OFF;
|
mode = OFF;
|
||||||
//getArgs();
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
mqtt_client.publish(mqtt_outtopic, String("OK =auto").c_str());
|
mqtt_client.publish(mqtt_outtopic, String("OK =auto").c_str());
|
||||||
@@ -929,7 +940,7 @@ DBG_OUTPUT_PORT.println("Starting....");
|
|||||||
server.on("/tv", []() {
|
server.on("/tv", []() {
|
||||||
exit_func = true;
|
exit_func = true;
|
||||||
mode = TV;
|
mode = TV;
|
||||||
getArgs();
|
//getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
#ifdef ENABLE_MQTT
|
#ifdef ENABLE_MQTT
|
||||||
mqtt_client.publish(mqtt_outtopic, String("OK =tv").c_str());
|
mqtt_client.publish(mqtt_outtopic, String("OK =tv").c_str());
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
//#define USE_WS2812FX_DMA // Uses PIN is ignored & set to RX/GPIO3 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_UART1 // Uses PIN is ignored & set to D4/GPIO2 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_UART2 // Uses PIN is ignored & set to TX/GPIO1 Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
|
||||||
|
|
||||||
// Neopixel
|
// Neopixel
|
||||||
#define PIN 15 // PIN (15 / D8) where neopixel / WS2811 strip is attached
|
#define PIN 3 // PIN (15 / D8) where neopixel / WS2811 strip is attached
|
||||||
#define NUMLEDS 194 // Number of leds in the strip
|
#define NUMLEDS 144 // Number of leds in the strip
|
||||||
#define BUILTIN_LED 2 // ESP-12F has the built in LED on GPIO2, see https://github.com/esp8266/Arduino/issues/2192
|
#define BUILTIN_LED 2 // ESP-12F has the built in LED on GPIO2, see https://github.com/esp8266/Arduino/issues/2192
|
||||||
#define BUTTON 14 // Input pin (14 / D5) for switching the LED strip on / off, connect this PIN to ground to trigger button.
|
#define BUTTON 14 // Input pin (14 / D5) for switching the LED strip on / off, connect this PIN to ground to trigger button.
|
||||||
#define BUTTON_GY33 12 // Input pin (12 / D6) for read color data with RGB sensor, connect this PIN to ground to trigger button.
|
#define BUTTON_GY33 12 // Input pin (12 / D6) for read color data with RGB sensor, connect this PIN to ground to trigger button.
|
||||||
@@ -18,10 +18,10 @@ const char HOSTNAME[] = "McLightingRGBW"; // Friedly hostname
|
|||||||
//#define ENABLE_MQTT // If defined, enable MQTT client code, see: https://github.com/toblum/McLighting/wiki/MQTT-API
|
//#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 or ENABLE_AMQTT 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 ENABLE_BUTTON // If defined, enable button handling code, see: https://github.com/toblum/McLighting/wiki/Button-control
|
||||||
#define ENABLE_BUTTON_GY33 // If defined, enable button handling code for GY-33 color sensor to scan color
|
//#define ENABLE_BUTTON_GY33 // If defined, enable button handling code for GY-33 color sensor to scan color
|
||||||
//#define MQTT_HOME_ASSISTANT_SUPPORT // If defined, use AMQTT and select Tools -> IwIP Variant -> Higher Bandwidth
|
//#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_LEGACY_ANIMATIONS // Dont disbale this for now
|
||||||
#define ENABLE_E131 // E1.31 implementation
|
#define ENABLE_E131 // E1.31 implementation You have to uncomment #define USE_WS2812FX_DMA
|
||||||
|
|
||||||
#ifdef ENABLE_E131
|
#ifdef ENABLE_E131
|
||||||
#define START_UNIVERSE 1 // First DMX Universe to listen for
|
#define START_UNIVERSE 1 // First DMX Universe to listen for
|
||||||
@@ -145,11 +145,13 @@ struct ledstate // Data structure to store a state of a single led
|
|||||||
|
|
||||||
typedef struct ledstate LEDState; // Define the datatype LEDState
|
typedef struct ledstate LEDState; // Define the datatype LEDState
|
||||||
LEDState ledstates[NUMLEDS]; // Get an array of led states to store the state of the whole strip
|
LEDState ledstates[NUMLEDS]; // Get an array of led states to store the state of the whole strip
|
||||||
LEDState main_color = { 0, 255, 0, 0 }; // Store the "main color" of the strip used in single color modes
|
LEDState main_color = { 255, 0, 0, 0 }; // Store the "main color" of the strip used in single color modes
|
||||||
|
|
||||||
|
|
||||||
#define ENABLE_STATE_SAVE_SPIFFS // If defined, saves state on SPIFFS
|
#define ENABLE_STATE_SAVE_SPIFFS // If defined, saves state on SPIFFS
|
||||||
//#define ENABLE_STATE_SAVE_EEPROM // If defined, save state on reboot
|
//#define ENABLE_STATE_SAVE_EEPROM // If defined, save state on reboot
|
||||||
|
|
||||||
|
char beforeauto_state[36]; // Keeps the state representation before auto mode
|
||||||
#ifdef ENABLE_STATE_SAVE_EEPROM
|
#ifdef ENABLE_STATE_SAVE_EEPROM
|
||||||
char current_state[36]; // Keeps the current state representation
|
char current_state[36]; // Keeps the current state representation
|
||||||
char last_state[36]; // Save the last state as string representation
|
char last_state[36]; // Save the last state as string representation
|
||||||
|
|||||||
@@ -54,22 +54,31 @@ void getArgs() {
|
|||||||
main_color.green = ((rgb >> 8) & 0xFF);
|
main_color.green = ((rgb >> 8) & 0xFF);
|
||||||
main_color.blue = ((rgb >> 0) & 0xFF);
|
main_color.blue = ((rgb >> 0) & 0xFF);
|
||||||
} else {
|
} else {
|
||||||
main_color.red = server.arg("r").toInt();
|
if ((server.arg("r") != "") && (server.arg("r").toInt() >= 0) && (server.arg("r").toInt() <= 255)) {
|
||||||
main_color.green = server.arg("g").toInt();
|
main_color.red = server.arg("r").toInt();
|
||||||
main_color.blue = server.arg("b").toInt();
|
}
|
||||||
main_color.white = server.arg("w").toInt();
|
if ((server.arg("g") != "") && (server.arg("g").toInt() >= 0) && (server.arg("g").toInt() <= 255)) {
|
||||||
|
main_color.green = server.arg("g").toInt();
|
||||||
|
}
|
||||||
|
if ((server.arg("b") != "") && (server.arg("b").toInt() >= 0) && (server.arg("b").toInt() <= 255)) {
|
||||||
|
main_color.blue = server.arg("b").toInt();
|
||||||
|
}
|
||||||
|
if ((server.arg("w") != "") && (server.arg("w").toInt() >= 0) && (server.arg("w").toInt() <= 255)){
|
||||||
|
main_color.white = server.arg("w").toInt();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (server.arg("s") != "") {
|
|
||||||
|
if ((server.arg("s") != "") && (server.arg("s").toInt() >= 0) && (server.arg("s").toInt() <= 255)) {
|
||||||
ws2812fx_speed = constrain(server.arg("s").toInt(), 0, 255);
|
ws2812fx_speed = constrain(server.arg("s").toInt(), 0, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server.arg("m") != "") {
|
if ((server.arg("m") != "") && (server.arg("m").toInt() >= 0) && (server.arg("m").toInt() <= strip.getModeCount())) {
|
||||||
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") != "") {
|
if ((server.arg("c") != "") && (server.arg("c").toInt() >= 0) && (server.arg("c").toInt() <= 100)) {
|
||||||
brightness = constrain((int) server.arg("c").toInt() * 2.55, 0, 255);
|
brightness = constrain((int) server.arg("c").toInt() * 2.55, 0, 255);
|
||||||
} else if (server.arg("p") != "") {
|
} else if ((server.arg("p") != "") && (server.arg("p").toInt() >= 0) && (server.arg("p").toInt() <= 255)) {
|
||||||
brightness = constrain(server.arg("p").toInt(), 0, 255);
|
brightness = constrain(server.arg("p").toInt(), 0, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,6 +172,8 @@ void handleSetSingleLED(uint8_t * mypayload, uint8_t firstChar = 0) {
|
|||||||
DBG_OUTPUT_PORT.printf("rgb.red: [%s] rgb.green: [%s] rgb.blue: [%s] rgb.white: [%s]\n", redhex, greenhex, bluehex, whitehex);
|
DBG_OUTPUT_PORT.printf("rgb.red: [%s] rgb.green: [%s] rgb.blue: [%s] rgb.white: [%s]\n", redhex, greenhex, bluehex, whitehex);
|
||||||
DBG_OUTPUT_PORT.printf("rgb.red: [%i] rgb.green: [%i] rgb.blue: [%i] rgb.white: [%i]\n", strtol(redhex, NULL, 16), strtol(greenhex, NULL, 16), strtol(bluehex, NULL, 16), strtol(whitehex, NULL, 16));
|
DBG_OUTPUT_PORT.printf("rgb.red: [%i] rgb.green: [%i] rgb.blue: [%i] rgb.white: [%i]\n", strtol(redhex, NULL, 16), strtol(greenhex, NULL, 16), strtol(bluehex, NULL, 16), strtol(whitehex, NULL, 16));
|
||||||
DBG_OUTPUT_PORT.printf("WS: Set single led [%i] to [%i] [%i] [%i] [%i] (%s)!\n", led, ledstates[led].red, ledstates[led].green, ledstates[led].blue, ledstates[led].white, mypayload);
|
DBG_OUTPUT_PORT.printf("WS: Set single led [%i] to [%i] [%i] [%i] [%i] (%s)!\n", led, ledstates[led].red, ledstates[led].green, ledstates[led].blue, ledstates[led].white, mypayload);
|
||||||
|
|
||||||
|
|
||||||
strip.setPixelColor(led, ledstates[led].red, ledstates[led].green, ledstates[led].blue, ledstates[led].white);
|
strip.setPixelColor(led, ledstates[led].red, ledstates[led].green, ledstates[led].blue, ledstates[led].white);
|
||||||
strip.show();
|
strip.show();
|
||||||
}
|
}
|
||||||
@@ -250,7 +261,6 @@ void setModeByStateString(String saved_state_string) {
|
|||||||
strip.setColor(main_color.red, main_color.green, main_color.blue, main_color.white);
|
strip.setColor(main_color.red, main_color.green, main_color.blue, main_color.white);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void handleSetNamedMode(String str_mode) {
|
void handleSetNamedMode(String str_mode) {
|
||||||
exit_func = true;
|
exit_func = true;
|
||||||
|
|
||||||
@@ -451,17 +461,19 @@ void autoTick() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void handleAutoStart() {
|
void handleAutoStart() {
|
||||||
//mode = AUTO;
|
sprintf(beforeauto_state, "STA|%2d|%3d|%3d|%3d|%3d|%3d|%3d|%3d", mode, strip.getMode(), ws2812fx_speed, brightness, main_color.red, main_color.green, main_color.blue, main_color.white);
|
||||||
|
mode = AUTO;
|
||||||
autoCount = 0;
|
autoCount = 0;
|
||||||
autoTick();
|
autoTick();
|
||||||
strip.start();
|
strip.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleAutoStop() {
|
void handleAutoStop() {
|
||||||
//mode = OFF;
|
|
||||||
autoTicker.detach();
|
autoTicker.detach();
|
||||||
strip.stop();
|
strip.stop();
|
||||||
|
setModeByStateString(beforeauto_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dbg_Prefix(bool mqtt, uint8_t num) {
|
void Dbg_Prefix(bool mqtt, uint8_t num) {
|
||||||
if (mqtt == true) {
|
if (mqtt == true) {
|
||||||
DBG_OUTPUT_PORT.print("MQTT: ");
|
DBG_OUTPUT_PORT.print("MQTT: ");
|
||||||
@@ -1074,10 +1086,14 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
uint16_t packetIdSub2 = amqttClient.subscribe((char *)mqtt_ha_state_in.c_str(), qossub);
|
uint16_t packetIdSub2 = amqttClient.subscribe((char *)mqtt_ha_state_in.c_str(), qossub);
|
||||||
DBG_OUTPUT_PORT.printf("Subscribing at QoS %d, packetId: ", qossub); DBG_OUTPUT_PORT.println(packetIdSub2);
|
DBG_OUTPUT_PORT.printf("Subscribing at QoS %d, packetId: ", qossub); DBG_OUTPUT_PORT.println(packetIdSub2);
|
||||||
#ifdef MQTT_HOME_ASSISTANT_SUPPORT
|
#ifdef MQTT_HOME_ASSISTANT_SUPPORT
|
||||||
DynamicJsonDocument jsonBuffer(JSON_ARRAY_SIZE(strip.getModeCount()) + JSON_OBJECT_SIZE(11));
|
DynamicJsonDocument jsonBuffer(JSON_ARRAY_SIZE(strip.getModeCount()) + JSON_OBJECT_SIZE(12) + 1500);
|
||||||
JsonObject json = jsonBuffer.to<JsonObject>();
|
JsonObject json = jsonBuffer.to<JsonObject>();
|
||||||
json["name"] = HOSTNAME;
|
json["name"] = HOSTNAME;
|
||||||
|
#ifdef MQTT_HOME_ASSISTANT_0_84_SUPPORT
|
||||||
|
json["schema"] = "json";
|
||||||
|
#else
|
||||||
json["platform"] = "mqtt_json";
|
json["platform"] = "mqtt_json";
|
||||||
|
#endif
|
||||||
json["state_topic"] = mqtt_ha_state_out;
|
json["state_topic"] = mqtt_ha_state_out;
|
||||||
json["command_topic"] = mqtt_ha_state_in;
|
json["command_topic"] = mqtt_ha_state_in;
|
||||||
json["on_command_type"] = "first";
|
json["on_command_type"] = "first";
|
||||||
|
|||||||
Reference in New Issue
Block a user