Update to 3.1.0.BETA7

* Version Bump to 3.1.0.BETA7
 * small API changes
 * work to solve heap problems
This commit is contained in:
bpohvoodoo
2020-02-02 16:07:52 +01:00
parent 09a1b078f6
commit cac526215d
15 changed files with 1927 additions and 1869 deletions
+52 -51
View File
@@ -15,11 +15,11 @@
#include <ESP8266WebServer.h>
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
#include <FS.h>
#include <ESP8266mDNS.h>
#include <WebSockets.h> //https://github.com/Links2004/arduinoWebSockets
#include <WebSocketsServer.h>
#if defined(ENABLE_BUTTON_GY33)
// ***************************************************************************
// Load libraries for GY33 and initialize color sensor
@@ -39,7 +39,7 @@
WiFiClient espClient;
PubSubClient * mqtt_client;
#endif
#if ENABLE_MQTT == 1
// ***************************************************************************
// Load libraries for Amqtt
@@ -76,7 +76,7 @@
#endif
#if defined(USE_HTML_MIN_GZ)
#include "htm_index_gz.h"
#include "htm_index_gz.h"
#include "htm_edit_gz.h"
#include "html_material_icons.h"
#endif
@@ -112,45 +112,45 @@ WS2812FX * strip = NULL;
#include <NeoPixelBus.h>
#if USE_WS2812FX_DMA == 0 // Uses GPIO3/RXD0/RX, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
#if !defined(LED_TYPE_WS2811)
#if !defined(LED_TYPE_WS2811)
NeoPixelBus<NeoRgbwFeature, NeoEsp8266Dma800KbpsMethod> * dma = NULL ; //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
#else
NeoPixelBus<NeoRgbwFeature, NeoEsp8266Dma400KbpsMethod> * dma = NULL; //400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
#endif
#endif
#if USE_WS2812FX_DMA == 1 // Uses UART1: GPIO1/TXD0/TX, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
#if !defined(LED_TYPE_WS2811)
#if !defined(LED_TYPE_WS2811)
NeoPixelBus<NeoRgbwFeature, NeoEsp8266Uart0800KbpsMethod> * dma = NULL; //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
#else
NeoPixelBus<NeoRgbwFeature, NeoEsp8266Uart0400KbpsMethod> * dma = NULL; //400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
#endif
#endif
#if USE_WS2812FX_DMA == 2 // Uses UART2: GPIO2/TXD1/D4, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
#if !defined(LED_TYPE_WS2811)
#if !defined(LED_TYPE_WS2811)
NeoPixelBus<NeoRgbwFeature, NeoEsp8266Uart1800KbpsMethod> * dma = NULL; //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
#else
NeoPixelBus<NeoRgbwFeature, NeoEsp8266Uart1400KbpsMethod> * dma = NULL; //400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
#endif
#endif
void initDMA(uint16_t stripSize = NUMLEDS){
if (dma != NULL) { delete(dma); }
#if USE_WS2812FX_DMA == 0 // Uses GPIO3/RXD0/RX, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
#if !defined(LED_TYPE_WS2811)
#if !defined(LED_TYPE_WS2811)
dma = new NeoPixelBus<NeoRgbwFeature, NeoEsp8266Dma800KbpsMethod>(stripSize); //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
#else
dma = new NeoPixelBus<NeoRgbwFeature, NeoEsp8266Dma400KbpsMethod>(stripSize); //400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
#endif
#endif
#if USE_WS2812FX_DMA == 1 // Uses UART1: GPIO1/TXD0/TX, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
#if !defined(LED_TYPE_WS2811)
#if !defined(LED_TYPE_WS2811)
dma = new NeoPixelBus<NeoRgbwFeature, NeoEsp8266Uart0800KbpsMethod>(stripSize); //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
#else
dma = new NeoPixelBus<NeoRgbwFeature, NeoEsp8266Uart0400KbpsMethod>(stripSize); //400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
#endif
#endif
#if USE_WS2812FX_DMA == 2 // Uses UART2: GPIO2/TXD1/D4, more info: https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
#if !defined(LED_TYPE_WS2811)
#if !defined(LED_TYPE_WS2811)
dma = new NeoPixelBus<NeoRgbwFeature, NeoEsp8266Uart1800KbpsMethod>(stripSize); //800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
#else
dma = new NeoPixelBus<NeoRgbwFeature, NeoEsp8266Uart1400KbpsMethod>(stripSize); //400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
@@ -285,7 +285,7 @@ void initMqtt() {
mqtt_client->setServer(mqtt_host, mqtt_port);
mqtt_client->setCallback(onMqttMessage);
#endif
#if ENABLE_MQTT == 1
#if ENABLE_MQTT == 1
DBG_OUTPUT_PORT.printf("AMQTT active: %s:%d\r\n", mqtt_host, mqtt_port);
mqtt_client->onConnect(onMqttConnect);
mqtt_client->onDisconnect(onMqttDisconnect);
@@ -329,7 +329,7 @@ void setup() {
#endif
#if defined(POWER_SUPPLY)
pinMode(POWER_SUPPLY, OUTPUT); // output to control external power supply
pinMode(POWER_SUPPLY, OUTPUT); // output to control external power supply
#endif
// start ticker with 0.5 because we start in AP mode and try to connect
@@ -398,7 +398,7 @@ void setup() {
wifiManager.setAPCallback(configModeCallback);
//set config save notify callback
wifiManager.setSaveConfigCallback(saveConfigCallback);
wifiManager.addParameter(&custom_hostname);
#if defined(ENABLE_MQTT)
//add all your parameters here
@@ -413,16 +413,16 @@ void setup() {
#endif
wifiManager.addParameter(&custom_rgbOrder);
wifiManager.addParameter(&custom_fxoptions);
WiFi.setSleepMode(WIFI_NONE_SLEEP);
// Uncomment if you want to restart ESP8266 if it cannot connect to WiFi.
// Value in brackets is in seconds that WiFiManger waits until restart
#if defined(WIFIMGR_PORTAL_TIMEOUT)
wifiManager.setConfigPortalTimeout(WIFIMGR_PORTAL_TIMEOUT);
#endif
// Order is: IP, Gateway and Subnet
// Order is: IP, Gateway and Subnet
#if defined(WIFIMGR_SET_MANUAL_IP)
wifiManager.setSTAStaticIPConfig(IPAddress(_ip[0], _ip[1], _ip[2], _ip[3]), IPAddress(_gw[0], _gw[1], _gw[2], _gw[3]), IPAddress(_sn[0], _sn[1], _sn[2], _sn[3]));
#endif
@@ -437,7 +437,7 @@ void setup() {
//ESP.reset(); //Will be removed when upgrading to standalone offline McLightingUI version
//delay(1000); //Will be removed when upgrading to standalone offline McLightingUI version
}
//save the custom parameters to FS/EEPROM
#if defined(ENABLE_STATE_SAVE)
strcpy(HOSTNAME, custom_hostname.getValue());
@@ -460,7 +460,7 @@ void setup() {
(writeConfigFS(updateConfig)) ? DBG_OUTPUT_PORT.println("WiFiManager config FS Save success!"): DBG_OUTPUT_PORT.println("WiFiManager config FS Save failure!");
}
#endif
//if you get here you have connected to the WiFi
DBG_OUTPUT_PORT.println("connected...yeey :)");
ticker.detach();
@@ -484,11 +484,11 @@ void setup() {
// No authentication by default
// ArduinoOTA.setPassword("admin");
// Password can be set with it's md5 value as well
// MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
// ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");
ArduinoOTA.onStart([]() {
DBG_OUTPUT_PORT.println("Arduino OTA: Start updating");
});
@@ -506,7 +506,7 @@ void setup() {
else if (error == OTA_RECEIVE_ERROR) DBG_OUTPUT_PORT.println("Arduino OTA: Receive Failed");
else if (error == OTA_END_ERROR) DBG_OUTPUT_PORT.println("Arduino OTA: End Failed");
});
ArduinoOTA.begin();
DBG_OUTPUT_PORT.println("");
#endif
@@ -523,7 +523,7 @@ void setup() {
wifiConnectHandler = WiFi.onStationModeGotIP(onWifiConnect);
wifiDisconnectHandler = WiFi.onStationModeDisconnected(onWifiDisconnect);
#endif
// ***************************************************************************
// Setup: MDNS responder
// ***************************************************************************
@@ -557,7 +557,7 @@ void setup() {
if (mdns_result) {
MDNS.addService("http", "tcp", 80);
}
#if defined(ENABLE_BUTTON_GY33)
tcs.setConfig(MCU_LED_06, MCU_WHITE_ON);
// delay(2000);
@@ -583,7 +583,7 @@ void loop() {
#if defined(ENABLE_BUTTON_GY33)
button_gy33();
#endif
#endif
server.handleClient();
webSocket.loop();
@@ -604,7 +604,7 @@ void loop() {
WiFi.disconnect();
WiFi.setSleepMode(WIFI_NONE_SLEEP);
WiFi.mode(WIFI_STA);
WiFi.hostname(HOSTNAME);
WiFi.hostname(HOSTNAME);
WiFi.begin();
} else {
if ((strlen(mqtt_host) != 0) && (mqtt_port != 0) && (mqtt_reconnect_retries < MQTT_MAX_RECONNECT_TRIES)) {
@@ -625,10 +625,10 @@ void loop() {
if (new_ha_mqtt_msg) sendState();
#endif
#endif
// ***************************************************************************
// Simple statemachine that handles the different modes
// ***************************************************************************
// ***************************************************************************
if ((State.mode == OFF) && ((strip->getBrightness() == 0) || !Config.transEffect)) {
if(strip->isRunning()) {
@@ -652,7 +652,7 @@ void loop() {
}
}
}
if (State.mode == OFF) {
if (prevmode != State.mode) {
#if defined(ENABLE_MQTT)
@@ -661,17 +661,17 @@ void loop() {
#if defined(POWER_SUPPLY)
digitalWrite(POWER_SUPPLY, !POWER_ON); // power off -> external power supply
#endif
if (Config.transEffect) {
if (Config.transEffect) {
brightness_trans = 0;
}
}
}
}
#if defined(POWER_SUPPLY)
if (State.mode != OFF) {
if (prevmode != State.mode) {digitalWrite(POWER_SUPPLY, POWER_ON); } // power on -> external power supply
}
#endif
#endif
if (State.mode == SET) {
State.mode = HOLD;
// Segment
@@ -680,7 +680,7 @@ void loop() {
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK Ss%i", State.segment);
#endif
//prevsegment = State.segment;
}
}
// Mode
if (segState.mode[State.segment] != fx_mode) {
segState.mode[State.segment] = fx_mode;
@@ -714,20 +714,20 @@ void loop() {
}
prevmode = SET;
}
if ((State.mode == HOLD) || ((State.mode == OFF) && (strip->getBrightness() > 0) && Config.transEffect)) {
if ((State.mode == HOLD) || ((State.mode == OFF) && (strip->getBrightness() > 0) && Config.transEffect)) {
if(!strip->isRunning()) strip->start();
strip->service();
for (uint8_t i = 0; i < Config.segments; i++) {
if (segState.mode[i] == FX_MODE_CUSTOM_0) { handleAutoPlay(i); }
if (segState.mode[i] == FX_MODE_CUSTOM_3) {
if (segState.mode[i] == FX_MODE_CUSTOM_3) {
if (strip->getSpeed(i) > SPEED_MIN) {
strip->setSpeed(i, SPEED_MIN);
}
}
}
}
if (prevmode != State.mode) {
if (segState.mode[prevsegment] != FX_MODE_CUSTOM_0) {
convertColors();
@@ -739,7 +739,7 @@ void loop() {
}
strip->setSpeed(prevsegment, convertSpeed(fx_speed));
}
//strip->setBrightness(brightness_actual);
//strip->setBrightness(brightness_actual);
#if defined(ENABLE_MQTT)
#if ENABLE_MQTT == 0
mqtt_client->publish(mqtt_outtopic, mqtt_buf);
@@ -748,13 +748,14 @@ void loop() {
mqtt_client->publish(mqtt_outtopic, qospub, false, mqtt_buf);
#endif
#if defined(ENABLE_HOMEASSISTANT)
if(!ha_send_data.active()) ha_send_data.once(3, tickerSendState);
if(ha_send_data.active()) ha_send_data.detach();
ha_send_data.once(5, tickerSendState);
#endif
#endif
}
prevmode = State.mode;
#if defined(ENABLE_STATE_SAVE)
if (updateState){
(writeStateFS(updateState)) ? DBG_OUTPUT_PORT.println("State FS Save Success!") : DBG_OUTPUT_PORT.println("State FS Save failure!");
@@ -766,7 +767,7 @@ void loop() {
(writeConfigFS(updateConfig)) ? DBG_OUTPUT_PORT.println("Config FS Save success!"): DBG_OUTPUT_PORT.println("Config FS Save failure!");
}
#endif
// Async color transition
if ((segState.mode[prevsegment] != FX_MODE_CUSTOM_0) && (memcmp(hexcolors_trans, strip->getColors(prevsegment), sizeof(hexcolors_trans)) != 0)) {
if (Config.transEffect) {
@@ -799,10 +800,10 @@ void loop() {
if (speedFadeDelay <= millis()) {
//DBG_OUTPUT_PORT.print("Speed trans actual: ");
if (fx_speed < segState.speed[prevsegment]) {
fx_speed++;
fx_speed++;
}
if (fx_speed > segState.speed[prevsegment]) {
fx_speed--;
fx_speed--;
}
//DBG_OUTPUT_PORT.println(fx_speed);
speedFadeDelay = millis() + TRANS_DELAY;
@@ -817,16 +818,16 @@ void loop() {
if (State.mode == HOLD) strip->trigger();
}
}
// Async brightness transition
if (strip->getBrightness() != brightness_trans) {
if (Config.transEffect) {
if(brightnessFadeDelay <= millis()) {
if (strip->getBrightness() < brightness_trans) {
strip->increaseBrightness(1);
strip->increaseBrightness(1);
}
if (strip->getBrightness() > brightness_trans) {
strip->decreaseBrightness(1);
strip->decreaseBrightness(1);
}
brightnessFadeDelay = millis() + TRANS_DELAY;
if (State.mode == HOLD) strip->trigger();
@@ -841,10 +842,10 @@ void loop() {
if (prevsegment != State.segment) {
DBG_OUTPUT_PORT.println("Segment not equal");
//if ((segState.mode[State.segment] == FX_MODE_CUSTOM_0) || (segState.mode[State.segment] == FX_MODE_CUSTOM_2) || (segState.mode[prevsegment] == FX_MODE_CUSTOM_0)) {
if ((segState.mode[State.segment] == FX_MODE_CUSTOM_0) || (segState.mode[prevsegment] == FX_MODE_CUSTOM_0)) {
if ((segState.mode[State.segment] == FX_MODE_CUSTOM_0) || (segState.mode[prevsegment] == FX_MODE_CUSTOM_0)) {
fx_speed = segState.speed[State.segment];
DBG_OUTPUT_PORT.printf("Switched segment from: %i to %i", prevsegment, State.segment);
prevsegment = State.segment;
prevsegment = State.segment;
} else if ((memcmp(hexcolors_trans, strip->getColors(prevsegment), sizeof(hexcolors_trans)) == 0) && (fx_speed == segState.speed[prevsegment])) {
memcpy(hexcolors_trans, segState.colors[State.segment], sizeof(hexcolors_trans));
fx_speed = segState.speed[State.segment];
@@ -853,7 +854,7 @@ void loop() {
}
}
#if defined(ENABLE_REMOTE)
handleRemote();
#endif
+10 -10
View File
@@ -1038,23 +1038,23 @@ uint16_t WS2812FX::mode_sparkle(void) {
/*
* Lights all LEDs in the color. Flashes single white pixels randomly.
* Lights all LEDs in the color. Flashes white pixels randomly.
* Inspired by www.tweaking4all.com/hardware/arduino/arduino-led-strip-effects/
*/
uint16_t WS2812FX::mode_flash_sparkle(void) {
if(SEGMENT_RUNTIME.counter_mode_call == 0) {
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
setPixelColor(i, SEGMENT.colors[0]);
}
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
setPixelColor(i, SEGMENT.colors[0]);
}
setPixelColor(SEGMENT.start + SEGMENT_RUNTIME.aux_param3, SEGMENT.colors[0]);
if(random8(5) == 0) {
SEGMENT_RUNTIME.aux_param3 = random16(SEGMENT_LENGTH); // aux_param3 stores the random led index
setPixelColor(SEGMENT.start + SEGMENT_RUNTIME.aux_param3, WHITE);
uint8_t size = 1 << SIZE_OPTION;
uint16_t index = SEGMENT.start + random16(SEGMENT_LENGTH - size);
for(uint8_t j=0; j<size; j++) {
setPixelColor(index + j, WHITE);
}
return 20;
}
}
return SEGMENT.speed;
}
+5
View File
@@ -5,6 +5,11 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="mobile-web-app-capable" content="yes">
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Wed, 01 Jan 2020 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<style>
Binary file not shown.
+13 -12
View File
@@ -4,14 +4,14 @@
#define MAXLEDS 384 // due to memory limit of esp8266 at the moment only 384 leds are supported in DMA Mode. More can crash if mqtt is used.
#else
#define MAXLEDS 4096
#endif
#endif
// Neopixel
#define LED_PIN 3 // PIN (15 / D8) where neopixel / WS2811 strip is attached; is configurable, if USE_WS2812FX_DMA is not defined. Just for the start
#define NUMLEDS 50 // Number of leds in the; is configurable just for the start
#define NUMLEDS 50 // Number of leds in the; is configurable just for the start
#define RGBORDER "GRBW" // RGBOrder; is configurable just for the start
#define FX_OPTIONS 48 // ws2812fx Options 48 = SIZE_SMALL + FADE_MEDIUM is configurable just for the start; for WS2812FX setSegment OPTIONS, see: https://github.com/kitesurfer1404/WS2812FX/blob/master/extras/WS2812FX%20Users%20Guide.md
//#define LED_TYPE_WS2811 // Uncomment, if LED type uses 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
#define LED_BUILTIN 2 // ESP-12F has the built in LED on GPIO2, see https://github.com/esp8266/Arduino/issues/2192
#define LED_BUILTIN 2 // ESP-12F has the built in LED on GPIO2, see https://github.com/esp8266/Arduino/issues/2192
char HOSTNAME[65] = "McLightingRGBW"; // Friedly hostname is configurable just for the start. Hostname should not contain spaces as this can break Home Assistant discovery if used.
#define ENABLE_OTA 1 // If defined, enable Arduino OTA code. If set to 0 enable Arduino OTA code, if set to 1 enable ESP8266HTTPUpdateServer OTA code.
@@ -20,22 +20,23 @@ char HOSTNAME[65] = "McLightingRGBW"; // Friedly hostname is configurable just
//#define ENABLE_MQTT_INCLUDE_IP // uncomment/comment to add the IP-adress to the MQTT message
#define ENABLE_HOMEASSISTANT // If defined, enable Homeassistant integration, ENABLE_MQTT must be active
#define MQTT_HOME_ASSISTANT_SUPPORT // If defined, use AMQTT and select Tools -> IwIP Variant -> Higher Bandwidth
//#define DISABLE_MQTT_OUT_ON_MQTT_IN // If defined, McLighting will not send back MQTT-out on MQTT-in regarding issue #67, does not change anything at the moment
//#define ENABLE_BUTTON 14 // If defined, enable button handling code, see: https://github.com/toblum/McLighting/wiki/Button-control, the value defines the input pin (14 / D5) for switching the LED strip on / off, connect this PIN to ground to trigger button.
#define ENABLE_BUTTON 14 // If defined, enable button handling code, see: https://github.com/toblum/McLighting/wiki/Button-control, the value defines the input pin (14 / D5) for switching the LED strip on / off, connect this PIN to ground to trigger button.
//#define ENABLE_BUTTON_GY33 12 // If defined, enable button handling code for GY-33 color sensor to scan color. The value defines the input pin (12 / D6) for read color data with RGB sensor, connect this PIN to ground to trigger button.
//#define POWER_SUPPLY 12 // PIN (12 / D6) If defined, enable output to control external power supply
#if defined(POWER_SUPPLY)
#define POWER_ON HIGH // Define the output state to turn on the power supply, either HIGH or LOW. Opposite will be uses for power off.
#endif
#define ENABLE_REMOTE 13 // If defined, enable Remote Control via TSOP31238. The value defines the input pin (13 / D7) for TSOP31238 Out
#endif
//#define ENABLE_REMOTE 13 // If defined, enable Remote Control via TSOP31238. The value defines the input pin (13 / D7) for TSOP31238 Out
#if defined(ENABLE_BUTTON_GY33)
#define GAMMA 2.5 // Gamma correction for GY-33 sensor
#endif
#define ENABLE_STATE_SAVE // If defined, load saved state on reboot and save state on SPIFFS
#define ENABLE_STATE_SAVE // If defined, load saved state on reboot and save state on SPIFFS
#define CUSTOM_WS2812FX_ANIMATIONS // uncomment and put animations in "custom_ws2812fx_animations.h"
#define CUSTOM_WS2812FX_ANIMATIONS // uncomment and put animations in "custom_ws2812fx_animations.h"
#define USE_HTML_MIN_GZ // uncomment for using index.htm & edit.htm from PROGMEM instead of SPIFFS
#define TRANS_COLOR_DELAY 5 // Delay for color transition
@@ -74,7 +75,7 @@ uint8_t prevsegment = 0;
#endif
#if defined(MQTT_HOME_ASSISTANT_SUPPORT)
#define MQTT_HOME_ASSISTANT_0_87_SUPPORT // Comment if using HA version < 0.87
#define MQTT_HOME_ASSISTANT_0_87_SUPPORT // Comment if using HA version < 0.87
#endif
#if defined(USE_WS2812FX_DMA) && (USE_WS2812FX_DMA < 0 || USE_WS2812FX_DMA > 2)
@@ -155,7 +156,7 @@ struct {
uint8_t mode[10] = {}; // Global variable for storing the WS2812FX mode to set for each segment
uint8_t speed[10] = {}; // Global variable for storing the speed for effects --> smaller == slower
uint32_t colors[10][3] = {}; // 2 dim. Color array for setting colors of WS2812FX
uint8_t options = FX_OPTIONS;
uint8_t options = FX_OPTIONS;
} segState;
// List of all color modes
@@ -187,11 +188,11 @@ struct {
#endif
bool transEffect = false;
} Config;
uint8_t fx_speed = 196; // Global variable for storing the speed for effects while fading --> smaller == slower
uint8_t fx_mode = 0;
uint8_t brightness_trans = 0; // Global variable for storing the brightness before change
uint32_t hexcolors_trans[3] = {}; // Color array of colors of WS2812FX before fading
uint32_t hexcolors_trans[3] = {}; // Color array of colors of WS2812FX before fading
struct ledstate // Data structure to store a state of a single led
{
uint8_t red;
+13 -8
View File
@@ -2,6 +2,11 @@
bool readSegmentStateFS(uint8_t _seg);
// End Prototypes
void getACK(char *buffer) {
server.sendHeader("Access-Control-Allow-Origin", "*");
server.send(200, "text/plain", buffer );
}
// Call convertColors whenever main_color, back_color or xtra_color changes.
void convertColors() {
hexcolors_trans[0] = (uint32_t)(main_color.white << 24) | (main_color.red << 16) | (main_color.green << 8) | main_color.blue;
@@ -28,7 +33,7 @@ uint16_t convertSpeed(uint8_t _mcl_speed) {
} else if (_mcl_speed < 200) {
_fx_speed = 1550 - ((_mcl_speed-149) * 25);
} else {
_fx_speed = 280 - ((_mcl_speed-199) * 5);
_fx_speed = 280 - ((_mcl_speed-199) * 5);
}
_fx_speed = constrain(_fx_speed, SPEED_MIN, SPEED_MAX);
return _fx_speed;
@@ -50,7 +55,7 @@ uint16_t convertSpeed(uint8_t _mcl_speed) {
return _mcl_speed;
}*/
bool checkPin(uint8_t pin) {
bool checkPin(uint8_t pin) {
#if defined(USE_WS2812FX_DMA)
#if USE_WS2812FX_DMA == 0
pin = 3;
@@ -168,10 +173,10 @@ void initStrip(uint16_t _stripSize = Config.stripSize, uint8_t _num_segments = C
strcpy(Config.RGBOrder, _RGBOrder);
Config.pin = _pin;
}
if (ledstates != NULL) {
delete(ledstates);
}
}
ledstates = new uint8_t [_stripSize];
#if !defined(LED_TYPE_WS2811)
@@ -222,19 +227,19 @@ void initStrip(uint16_t _stripSize = Config.stripSize, uint8_t _num_segments = C
strip->setCustomMode(5, F("Gradient"), handleGradient);
DBG_OUTPUT_PORT.print("Number of Segments: ");
DBG_OUTPUT_PORT.println(strip->getNumSegments());
if (e131 != NULL) { delete(e131); }
e131 = new ESPAsyncE131(END_UNIVERSE - START_UNIVERSE + 1);
float universe_leds = 170.0; // a universe has only 512 (0..511) channels: 3*170 or 4*128 <= 512
if (strstr(Config.RGBOrder, "W") != NULL) {
//universe_leds = 128.0;
}
float float_enduni = _stripSize/universe_leds;
float float_enduni = _stripSize/universe_leds;
uint8_t END_UNIVERSE = _stripSize/universe_leds;
if (float_enduni > END_UNIVERSE) {
END_UNIVERSE = END_UNIVERSE +1;
}
// if (e131.begin(E131_UNICAST)) // Listen via Unicast
if (e131->begin(E131_MULTICAST, START_UNIVERSE, END_UNIVERSE)) {// Listen via Multicast
DBG_OUTPUT_PORT.println(F("Listening for data..."));
@@ -295,7 +300,7 @@ uint8_t convertColorsFade(uint8_t _seg) {
DBG_OUTPUT_PORT.println("Color transistion aborted. Restarting...!");
trans_cnt = 1;
}
return calculateColorTransitionSteps(_seg);
return calculateColorTransitionSteps(_seg);
} else {
return 0;
}
File diff suppressed because it is too large Load Diff
+70 -61
View File
@@ -7,7 +7,7 @@
bool handleSetMainColor(uint8_t * mypayload) {
// decode rgb data
uint32_t rgb = (uint32_t) strtoul((const char *) &mypayload[1], NULL, 16);
if (rgb != segState.colors[State.segment][0]) {
if (rgb != segState.colors[State.segment][0]) {
main_color.white = ((rgb >> 24) & 0xFF);
main_color.red = ((rgb >> 16) & 0xFF);
main_color.green = ((rgb >> 8) & 0xFF);
@@ -20,7 +20,7 @@ bool handleSetMainColor(uint8_t * mypayload) {
bool handleSetBackColor(uint8_t * mypayload) {
// decode rgb data
uint32_t rgb = (uint32_t) strtoul((const char *) &mypayload[2], NULL, 16);
if (rgb != segState.colors[State.segment][1]) {
if (rgb != segState.colors[State.segment][1]) {
back_color.white = ((rgb >> 24) & 0xFF);
back_color.red = ((rgb >> 16) & 0xFF);
back_color.green = ((rgb >> 8) & 0xFF);
@@ -32,7 +32,7 @@ bool handleSetBackColor(uint8_t * mypayload) {
bool handleSetXtraColor(uint8_t * mypayload) {
// decode rgb data
uint32_t rgb = (uint32_t) strtoul((const char *) &mypayload[3], NULL, 16);
if (rgb != segState.colors[State.segment][2]) {
if (rgb != segState.colors[State.segment][2]) {
xtra_color.white = ((rgb >> 24) & 0xFF);
xtra_color.red = ((rgb >> 16) & 0xFF);
xtra_color.green = ((rgb >> 8) & 0xFF);
@@ -116,7 +116,7 @@ void handleSetDifferentColors(uint8_t * mypayload) {
void handleRangeDifferentColors(uint8_t * mypayload) {
uint8_t* nextCommand = 0;
nextCommand = (uint8_t*) strtok((char*) mypayload, "R");
// While there is a range to process R00010010<0000ff00>
// While there is a range to process R00010010<0000ff00>
while (nextCommand) {
// Loop for each LED.
@@ -189,7 +189,7 @@ bool setModeByStateString(String saved_state_string) {
return true;
} else {
DBG_OUTPUT_PORT.println("Saved state not found!");
return false;
return false;
}
return false;
}
@@ -206,7 +206,7 @@ void handleSetWS2812FXMode(uint8_t * mypayload) {
if (strcmp((char *) &mypayload[1], "on") == 0) {
State.mode = SET;
}
}
}
}
// ***************************************************************************
@@ -249,11 +249,11 @@ void handleNotFound() {
}
// ***************************************************************************
// Functions and variables
// Functions and variables
// ***************************************************************************
void Dbg_Prefix(bool _mqtt, uint8_t _num) {
if (_mqtt == true) {
DBG_OUTPUT_PORT.print("MQTT: ");
DBG_OUTPUT_PORT.print("MQTT: ");
} else {
DBG_OUTPUT_PORT.print("WS: ");
webSocket.sendTXT(_num, "OK");
@@ -314,7 +314,7 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
Dbg_Prefix(mqtt, num);
DBG_OUTPUT_PORT.printf("Set segment options to: [%u]\r\n", segState.options);
}
}
}
char * buffer = listSegmentStateJSON(State.segment);
if (mqtt == true) {
DBG_OUTPUT_PORT.print("MQTT: ");
@@ -330,7 +330,7 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
DBG_OUTPUT_PORT.print("WS: ");
webSocket.sendTXT(num, "OK");
webSocket.sendTXT(num, buffer);
}
}
}
// / ==> Set WS2812 mode.
if (_payload[0] == '/') {
@@ -340,7 +340,7 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
Dbg_Prefix(mqtt, num);
DBG_OUTPUT_PORT.printf("Set WS2812 mode: [%s]\r\n", _payload);
}
}
}
// # ==> Set main color - ## ==> Set 2nd color - ### ==> Set 3rd color
if (_payload[0] == '#') {
if (_payload[2] == '#') {
@@ -432,12 +432,14 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
}
#if defined(ENABLE_STATE_SAVE)
if (_updateState) {
if(!save_state.active()) save_state.once(3, tickerSaveState);
if(save_state.active()) save_state.detach();
save_state.once(3, tickerSaveState);
}
if (_updateSegState) {
State.mode = SET;
if(!save_seg_state.active()) save_seg_state.once(3, tickerSaveSegmentState);
if(save_seg_state.active()) save_seg_state.detach();
save_seg_state.once(3, tickerSaveSegmentState);
}
_updateState = false;
_updateSegState = false;
@@ -467,12 +469,12 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
Config.stripSize = constrain(atoi(tmp_count), 1, MAXLEDS);
_updateStrip = true;
}
if (_payload[2] == 'r') {
if (_payload[2] == 'r') {
char _rgbOrder[5];
snprintf(_rgbOrder, sizeof(_rgbOrder), "%s", &_payload[3]);
_rgbOrder[4] = 0x00;
checkRGBOrder(_rgbOrder);
_updateStrip=true;
_updateStrip=true;
}
#if !defined(USE_WS2812FX_DMA)
if (_payload[2] == 'p') {
@@ -482,10 +484,10 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
checkPin(atoi(tmp_pin));
_updateStrip = true;
}
#endif
#endif
}
if (_updateStrip){
initStrip();
initStrip();
}
if (_payload[1] == 'h') {
snprintf(HOSTNAME, sizeof(HOSTNAME), "%s", &_payload[2]);
@@ -515,12 +517,12 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
snprintf(mqtt_pass, sizeof(mqtt_pass), "%s", &_payload[3]);
mqtt_pass[sizeof(mqtt_pass) - 1] = 0x00;
_updateConfig = true;
}
}
}
if (_updateConfig) {
initMqtt();
}
#endif
}
#endif
if (_payload[1] == 'e') {
char _transEffect[2];
snprintf(_transEffect, sizeof(_transEffect), "%s", &_payload[2]);
@@ -528,7 +530,7 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
Config.transEffect = atoi(_transEffect);
_updateConfig = true;
}
char * buffer = listConfigJSON();
if (mqtt == true) {
DBG_OUTPUT_PORT.print("MQTT: ");
@@ -544,13 +546,15 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
DBG_OUTPUT_PORT.print("WS: ");
webSocket.sendTXT(num, "OK");
webSocket.sendTXT(num, buffer);
}
}
#if defined(ENABLE_STATE_SAVE)
if (_updateStrip || _updateConfig) {
if(!save_conf.active()) save_conf.once(3, tickerSaveConfig);
if(save_conf.active()) save_conf.detach();
save_conf.once(3, tickerSaveConfig);
}
if (_updateState) {
if(!save_state.active()) save_state.once(3, tickerSaveState);
if(save_state.active()) save_state.detach();
save_state.once(3, tickerSaveState);
}
#endif
_updateStrip = false;
@@ -559,7 +563,7 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
DBG_OUTPUT_PORT.printf("Get status info: %s\r\n", buffer);
free (buffer);
}
// $ ==> Get status Info.
if (_payload[0] == '$') {
char * buffer = listStateJSONfull();
@@ -581,22 +585,22 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
DBG_OUTPUT_PORT.printf("Get status info: %s\r\n", buffer);
free (buffer);
}
// ~ ==> Get WS2812 modes.
if (_payload[0] == '~') {
char * buffer = listModesJSON();
if (mqtt == true) {
DBG_OUTPUT_PORT.print("MQTT: ");
DBG_OUTPUT_PORT.print("MQTT: ");
#if defined(ENABLE_MQTT)
#if ENABLE_MQTT == 0
uint16_t msg_len = strlen(buffer) + 1;
mqtt_client->beginPublish(mqtt_outtopic, msg_len, true);
mqtt_client->write((const uint8_t*)buffer, msg_len);
mqtt_client->endPublish();
mqtt_client->endPublish();
#endif
#if ENABLE_MQTT == 1
mqtt_client->publish(mqtt_outtopic, qospub, false, buffer);
#endif
#endif
#endif
} else {
DBG_OUTPUT_PORT.print("WS: ");
@@ -707,7 +711,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
DynamicJsonDocument jsonBuffer(bufferSize);
JsonObject root = jsonBuffer.to<JsonObject>();
root["state"] = (State.mode != OFF) ? on_cmd : off_cmd;
#if defined(ENABLE_MQTT_INCLUDE_IP)
#if defined(ENABLE_MQTT_INCLUDE_IP)
root["ip"] = WiFi.localIP().toString();
#endif
root["segment"] = State.segment;
@@ -769,7 +773,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
}
//DBG_OUTPUT_PORT.println("JSON ParseObject() done!");
JsonObject root = jsonBuffer.as<JsonObject>();
if (root.containsKey("state")) {
const char* state_in = root["state"];
if (strcmp(state_in, on_cmd) == 0) {
@@ -788,10 +792,10 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
if (prevsegment != json_segment) {
prevsegment = State.segment;
State.segment = json_segment;
getSegmentParams(State.segment);
getSegmentParams(State.segment);
State.mode = SET;
_updateState = true;
}
}
}
if (root.containsKey("color")) {
JsonObject color = root["color"];
@@ -809,7 +813,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
if (color.containsKey("w3")) { xtra_color.white = (uint8_t) color["w3"]; }
_updateSegState = true;
}
if (root.containsKey("white_value")) {
uint8_t json_white_value = constrain((uint8_t) root["white_value"], 0, 255);
if (json_white_value != main_color.white) {
@@ -817,7 +821,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
_updateSegState = true;
}
}
if (root.containsKey("speed")) {
uint8_t _fx_speed = constrain((uint8_t) root["speed"], 0, 255);
if (_fx_speed != segState.speed[State.segment]) {
@@ -863,11 +867,13 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
}
#if defined(ENABLE_STATE_SAVE)
if (_updateState) {
if(!save_state.active()) save_state.once(3, tickerSaveState);
if(save_state.active()) save_state.detach();
save_state.once(3, tickerSaveState);
}
if (_updateSegState) {
State.mode = SET;
if(!save_seg_state.active()) save_seg_state.once(3, tickerSaveSegmentState);
if(save_seg_state.active()) save_seg_state.detach();
save_seg_state.once(3, tickerSaveSegmentState);
}
#endif
_updateState = false;
@@ -880,7 +886,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
#if ENABLE_MQTT == 0
void onMqttMessage(char* topic, byte* payload_in, uint16_t length) {
#endif
#if ENABLE_MQTT == 1
void onMqttMessage(char* topic, char* payload_in, AsyncMqttClientMessageProperties properties, size_t length, size_t index, size_t total) {
#endif
@@ -888,14 +894,15 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
memcpy(payload, payload_in, length);
payload[length] = 0;
DBG_OUTPUT_PORT.printf("MQTT: Recieved [%s]: %s\r\n", topic, payload);
#if defined(ENABLE_HOMEASSISTANT)
if (strcmp(topic, mqtt_ha_state_in) == 0) {
if (!processJson((char*)payload)) {
return;
}
if(!ha_send_data.active()) ha_send_data.once(5, tickerSendState);
} else if (strcmp(topic, mqtt_intopic) == 0) {
if(ha_send_data.active()) ha_send_data.detach();
ha_send_data.once(5, tickerSendState);
} else if (strcmp(topic, mqtt_intopic) == 0) {
#endif
checkpayload(payload, true);
@@ -994,7 +1001,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
DBG_OUTPUT_PORT.println("Re-connecting to Wi-Fi...");
WiFi.setSleepMode(WIFI_NONE_SLEEP);
WiFi.mode(WIFI_STA);
WiFi.hostname(HOSTNAME);
WiFi.hostname(HOSTNAME);
WiFi.begin();
}
@@ -1159,7 +1166,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
}
}
#endif
#if defined(ENABLE_BUTTON_GY33)
void shortKeyPress_gy33() {
DBG_OUTPUT_PORT.printf("Short GY-33 button press\r\n");
@@ -1169,18 +1176,18 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
uint8_t r, g, b, col, conf;
tcs.getData(&r, &g, &b, &col, &conf);
DBG_OUTPUT_PORT.printf("Colors: R: [%d] G: [%d] B: [%d] Color: [%d] Conf: [%d]\r\n", (int)r, (int)g, (int)b, (int)col, (int)conf);
main_color.red = (pow((r/255.0), GAMMA)*255); main_color.green = (pow((g/255.0), GAMMA)*255); main_color.blue = (pow((b/255.0), GAMMA)*255);main_color.white = 0;
main_color.red = (pow((r/255.0), GAMMA)*255); main_color.green = (pow((g/255.0), GAMMA)*255); main_color.blue = (pow((b/255.0), GAMMA)*255);main_color.white = 0;
State.mode = SET;
}
// called when button is kept pressed for less than 2 seconds
void mediumKeyPress_gy33() {
void mediumKeyPress_gy33() {
tcs.setConfig(MCU_LED_03, MCU_WHITE_OFF);
}
// called when button is kept pressed for 2 seconds or more
void longKeyPress_gy33() {
tcs.setConfig(MCU_LED_OFF, MCU_WHITE_OFF);
tcs.setConfig(MCU_LED_OFF, MCU_WHITE_OFF);
}
void button_gy33() {
@@ -1273,7 +1280,7 @@ void handleRemote() {
}
}
}
if ((segState.mode[State.segment] < FX_MODE_CUSTOM_0) || (segState.mode[State.segment] > FX_MODE_CUSTOM_4)) {
if ((segState.mode[State.segment] < FX_MODE_CUSTOM_0) || (segState.mode[State.segment] > FX_MODE_CUSTOM_4)) {
if (results.value == rmt_commands[RED_UP]) { //Red Up
last_remote_cmd = results.value;
if (selected_color == 1) {
@@ -1300,7 +1307,7 @@ void handleRemote() {
if (selected_color == 1) {
if (main_color.red - chng >= 0) {
main_color.red = main_color.red - chng;
_updateSegState = true;
_updateSegState = true;
}
}
if (selected_color == 2) {
@@ -1342,7 +1349,7 @@ void handleRemote() {
if (selected_color == 1) {
if (main_color.green - chng >= 0) {
main_color.green = main_color.green - chng;;
_updateSegState = true;
_updateSegState = true;
}
}
if (selected_color == 2) {
@@ -1384,7 +1391,7 @@ void handleRemote() {
if (selected_color == 1) {
if (main_color.blue - chng >= 0) {
main_color.blue = main_color.blue - chng;
_updateSegState = true;
_updateSegState = true;
}
}
if (selected_color == 2) {
@@ -1426,7 +1433,7 @@ void handleRemote() {
if (selected_color == 1) {
if (main_color.white - chng >= 0) {
main_color.white = main_color.white - chng;
_updateSegState = true;
_updateSegState = true;
}
}
if (selected_color == 2) {
@@ -1445,11 +1452,11 @@ void handleRemote() {
if (results.value == rmt_commands[COL_M]) { // Select Main Color
last_remote_cmd = 0;
selected_color = 1;
}
}
if (results.value == rmt_commands[COL_B]) { // Select Back Color
last_remote_cmd = 0;
selected_color = 2;
}
}
if (results.value == rmt_commands[COL_X]) { // Select Extra Color
last_remote_cmd = 0;
selected_color = 3;
@@ -1481,17 +1488,17 @@ void handleRemote() {
fx_mode = FX_MODE_CUSTOM_2;
_updateSegState = true;
}
#endif
#endif
if (results.value == rmt_commands[CUST_2]) { // Select Custom Mode 2
last_remote_cmd = 0;
fx_mode = FX_MODE_RAINBOW_CYCLE;
_updateSegState = true;
}
}
if (results.value == rmt_commands[CUST_3]) { // Select Custom Mode 3
last_remote_cmd = 0;
fx_mode = FX_MODE_FIRE_FLICKER;
_updateSegState = true;
}
}
if (results.value == rmt_commands[SEG_UP]) { // Select segment up
last_remote_cmd = 0;
if ((State.segment < Config.segments - 1) && (State.mode == HOLD)) {
@@ -1499,7 +1506,7 @@ void handleRemote() {
State.segment = State.segment + 1;
getSegmentParams(State.segment);
}
_updateSegState = true;
_updateSegState = true;
}
if (results.value == rmt_commands[SEG_DOWN]) { // Select segment down
last_remote_cmd = 0;
@@ -1509,16 +1516,18 @@ void handleRemote() {
getSegmentParams(State.segment);
}
_updateSegState = true;
}
}
irrecv.resume(); // Receive the next value
}
#if defined(ENABLE_STATE_SAVE)
if (_updateState) {
if(!save_state.active()) save_state.once(3, tickerSaveState);
if(save_state.active()) save_state.detach();
save_state.once(3, tickerSaveState);
}
if (_updateSegState) {
State.mode = SET;
if(!save_seg_state.active()) save_seg_state.once(3, tickerSaveSegmentState);
if(save_seg_state.active()) save_seg_state.detach();
save_seg_state.once(3, tickerSaveSegmentState);
}
#endif
_updateState = false;
+32 -16
View File
@@ -136,17 +136,27 @@ server.on("/get_switch", []() {
});
server.on("/get_color", []() {
char rgbcolor[10];
snprintf(rgbcolor, sizeof(rgbcolor), "%02X%02X%02X%02X", main_color.white, main_color.red, main_color.green, main_color.blue);
char rgbcolor[7];
snprintf(rgbcolor, sizeof(rgbcolor), "%02X%02X%02X", main_color.red, main_color.green, main_color.blue);
rgbcolor[sizeof(rgbcolor) - 1] = 0x00;
server.sendHeader("Access-Control-Allow-Origin", "*");
server.send(200, "text/plain", rgbcolor );
server.send(200, "text/plain", rgbcolor);
DBG_OUTPUT_PORT.print("/get_color: ");
DBG_OUTPUT_PORT.println(rgbcolor);
});
server.on("/get_color1", []() {
char rgbcolor[9];
snprintf(rgbcolor, sizeof(rgbcolor), "%02X%02X%02X%02X", main_color.white, main_color.red, main_color.green, main_color.blue);
rgbcolor[sizeof(rgbcolor) - 1] = 0x00;
server.sendHeader("Access-Control-Allow-Origin", "*");
server.send(200, "text/plain", rgbcolor );
DBG_OUTPUT_PORT.print("/get_color1: ");
DBG_OUTPUT_PORT.println(rgbcolor);
});
server.on("/get_color2", []() {
char rgbcolor[10];
char rgbcolor[9];
snprintf(rgbcolor, sizeof(rgbcolor), "%02X%02X%02X%02X", back_color.white, back_color.red, back_color.green, back_color.blue);
rgbcolor[sizeof(rgbcolor) - 1] = 0x00;
server.sendHeader("Access-Control-Allow-Origin", "*");
@@ -156,7 +166,7 @@ server.on("/get_color2", []() {
});
server.on("/get_color3", []() {
char rgbcolor[10];
char rgbcolor[9];
snprintf(rgbcolor, sizeof(rgbcolor), "%02X%02X%02X%02X", xtra_color.white, xtra_color.red, xtra_color.green, xtra_color.blue);
rgbcolor[sizeof(rgbcolor) - 1] = 0x00;
server.sendHeader("Access-Control-Allow-Origin", "*");
@@ -294,10 +304,12 @@ server.on("/config", []() {
#if defined(ENABLE_STATE_SAVE)
if (_updateStrip || _updateConfig) {
if(!save_conf.active()) save_conf.once(3, tickerSaveConfig);
if(save_conf.active()) save_conf.detach();
save_conf.once(3, tickerSaveConfig);
}
if (_updateState) {
if(!save_state.active()) save_state.once(3, tickerSaveState);
if(save_state.active()) save_state.detach();
save_state.once(3, tickerSaveState);
}
#endif
_updateStrip = false;
@@ -308,21 +320,23 @@ server.on("/config", []() {
server.on("/off", []() {
if (State.mode == OFF) { State.mode = SET; } else { State.mode = OFF; };
getStateJSON();
getACK("OK");
#if defined(ENABLE_STATE_SAVE)
if(!save_state.active()) save_state.once(3, tickerSaveState);
if(save_state.active()) save_state.detach();
save_state.once(3, tickerSaveState);
#endif
});
server.on("/on", []() {
if (prevmode == OFF) {
State.mode = SET;
getStateJSON();
getACK("OK");
#if defined(ENABLE_STATE_SAVE)
if(!save_state.active()) save_state.once(3, tickerSaveState);
if(save_state.active()) save_state.detach();
save_state.once(3, tickerSaveState);
#endif
} else {
getStateJSON();
getACK("NOK");
}
});
@@ -482,16 +496,18 @@ server.on("/set", []() {
State.mode = SET;
_updateState = true;
}
DBG_OUTPUT_PORT.printf("Get Args: %s\r\n", listStateJSONfull());
getStateJSON();
//DBG_OUTPUT_PORT.printf("Get Args: %s\r\n", listStateJSONfull()); //possibly causing heap problems
getACK("OK");
#if defined(ENABLE_STATE_SAVE)
if (_updateState) {
if(!save_state.active()) save_state.once(3, tickerSaveState);
if(save_state.active()) save_state.detach();
save_state.once(3, tickerSaveState);
}
if (_updateSegState) {
State.mode = SET;
if(!save_seg_state.active()) save_seg_state.once(3, tickerSaveSegmentState);
if(save_seg_state.active()) save_seg_state.detach();
save_seg_state.once(3, tickerSaveSegmentState);
}
#endif
_updateState = false;
+3
View File
@@ -70,6 +70,9 @@ bool handleFileRead(String path) {
path += ".gz";
File file = SPIFFS.open(path, "r");
server.sendHeader("Access-Control-Allow-Origin", "*");
server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
server.sendHeader("Pragma", "no-cache");
server.sendHeader("Expires", "-1");
size_t sent = server.streamFile(file, contentType);
file.close();
return true;
+1 -1
View File
@@ -1 +1 @@
#define SKETCH_VERSION "3.1.0.BETA6"
#define SKETCH_VERSION "3.1.0.BETA7"
+5
View File
@@ -247,4 +247,9 @@
* known problems:
* Homeassistant will allways use active segment
* E1.31 is only working for one segment at the moment
*
* 27 January
* Version Bump to 3.1.0.BETA7
* small API changes
* work to solve heap problems
*/