3.1.0.ALPHA1
This commit is contained in:
@@ -14,9 +14,6 @@
|
|||||||
#include <WiFiClient.h>
|
#include <WiFiClient.h>
|
||||||
#include <ESP8266mDNS.h>
|
#include <ESP8266mDNS.h>
|
||||||
#include <FS.h>
|
#include <FS.h>
|
||||||
#if ENABLE_STATE_SAVE == 0
|
|
||||||
#include <EEPROM.h>
|
|
||||||
#endif
|
|
||||||
#include <WebSockets.h> //https://github.com/Links2004/arduinoWebSockets
|
#include <WebSockets.h> //https://github.com/Links2004/arduinoWebSockets
|
||||||
#include <WebSocketsServer.h>
|
#include <WebSocketsServer.h>
|
||||||
|
|
||||||
@@ -299,7 +296,12 @@ void initStrip(uint16_t stripSize = WS2812FXStripSettings.stripSize, char RGBOrd
|
|||||||
strip->setCustomShow(DMA_Show);
|
strip->setCustomShow(DMA_Show);
|
||||||
#endif
|
#endif
|
||||||
//parameters: index, start, stop, mode, color, speed, options
|
//parameters: index, start, stop, mode, color, speed, options
|
||||||
strip->setSegment(selected_segment, 0, stripSize - 1, ws2812fx_mode, hex_colors_trans, convertSpeed(ws2812fx_speed), fxoptions);
|
for (uint8_t seg=0; seg < num_segments; seg++) {
|
||||||
|
(readStateSegmentFS(seg)) ? DBG_OUTPUT_PORT.println("Segment state config FS read Success!") : DBG_OUTPUT_PORT.println("Segment state config FS read failure!");
|
||||||
|
strip->setSegment(seg, seg_start, seg_stop , ws2812fx_mode, hex_colors_trans, convertSpeed(ws2812fx_speed), fxoptions);
|
||||||
|
}
|
||||||
|
//strip->setSegment(0, 0, (stripSize - 1)/2, ws2812fx_mode, hex_colors_trans, convertSpeed(ws2812fx_speed), fxoptions);
|
||||||
|
//strip->setSegment(1, ((stripSize - 1)/2) + 1, (stripSize - 1), ws2812fx_mode, hex_colors_trans, convertSpeed(ws2812fx_speed), fxoptions);
|
||||||
strip->setCustomMode(0, F("Autoplay"), myCustomEffect0);
|
strip->setCustomMode(0, F("Autoplay"), myCustomEffect0);
|
||||||
strip->setCustomMode(1, F("Custom WS"), myCustomEffect1);
|
strip->setCustomMode(1, F("Custom WS"), myCustomEffect1);
|
||||||
#if defined(CUSTOM_WS2812FX_ANIMATIONS)
|
#if defined(CUSTOM_WS2812FX_ANIMATIONS)
|
||||||
@@ -308,6 +310,8 @@ void initStrip(uint16_t stripSize = WS2812FXStripSettings.stripSize, char RGBOrd
|
|||||||
strip->setCustomMode(4, F("Fire 2012"), myCustomEffect4);
|
strip->setCustomMode(4, F("Fire 2012"), myCustomEffect4);
|
||||||
strip->setCustomMode(5, F("Gradient"), myCustomEffect5);
|
strip->setCustomMode(5, F("Gradient"), myCustomEffect5);
|
||||||
gReverseDirection = (WS2812FXStripSettings.fxoptions & 128);
|
gReverseDirection = (WS2812FXStripSettings.fxoptions & 128);
|
||||||
|
DBG_OUTPUT_PORT.print("Number of Segments: ");
|
||||||
|
DBG_OUTPUT_PORT.println(strip->getNumSegments());
|
||||||
|
|
||||||
if (e131 != NULL) { delete(e131); }
|
if (e131 != NULL) { delete(e131); }
|
||||||
e131 = new ESPAsyncE131(END_UNIVERSE - START_UNIVERSE + 1);
|
e131 = new ESPAsyncE131(END_UNIVERSE - START_UNIVERSE + 1);
|
||||||
@@ -394,9 +398,6 @@ void setup() {
|
|||||||
delay(500);
|
delay(500);
|
||||||
DBG_OUTPUT_PORT.println("");
|
DBG_OUTPUT_PORT.println("");
|
||||||
DBG_OUTPUT_PORT.println("Starting...Main Setup");
|
DBG_OUTPUT_PORT.println("Starting...Main Setup");
|
||||||
#if ENABLE_STATE_SAVE == 0
|
|
||||||
EEPROM.begin(512);
|
|
||||||
#endif
|
|
||||||
// set builtin led pin as output
|
// set builtin led pin as output
|
||||||
pinMode(LED_BUILTIN, OUTPUT);
|
pinMode(LED_BUILTIN, OUTPUT);
|
||||||
// button pin setup
|
// button pin setup
|
||||||
@@ -444,16 +445,9 @@ void setup() {
|
|||||||
|
|
||||||
#if defined(ENABLE_STATE_SAVE)
|
#if defined(ENABLE_STATE_SAVE)
|
||||||
//Strip Config
|
//Strip Config
|
||||||
#if ENABLE_STATE_SAVE == 1
|
(readConfigFS()) ? DBG_OUTPUT_PORT.println("WiFiManager config FS read success!"): DBG_OUTPUT_PORT.println("WiFiManager config FS Read failure!");
|
||||||
(readConfigFS()) ? DBG_OUTPUT_PORT.println("WiFiManager config FS read success!"): DBG_OUTPUT_PORT.println("WiFiManager config FS Read failure!");
|
delay(250);
|
||||||
delay(250);
|
(readStateFS()) ? DBG_OUTPUT_PORT.println("Strip state config FS read Success!") : DBG_OUTPUT_PORT.println("Strip state config FS read failure!");
|
||||||
(readStateFS()) ? DBG_OUTPUT_PORT.println("Strip state config FS read Success!") : DBG_OUTPUT_PORT.println("Strip state config FS read failure!");
|
|
||||||
#endif
|
|
||||||
#if ENABLE_STATE_SAVE == 0
|
|
||||||
(setConfByConfString(readEEPROM(0, 222)))? DBG_OUTPUT_PORT.println("WiFiManager config EEPROM read success!"): DBG_OUTPUT_PORT.println("WiFiManager config EEPROM Read failure!");
|
|
||||||
delay(250);
|
|
||||||
(setModeByStateString(readEEPROM(256, 66)))? DBG_OUTPUT_PORT.println("Strip state config EEPROM read Success!") : DBG_OUTPUT_PORT.println("Strip state config EEPROM read failure!");
|
|
||||||
#endif
|
|
||||||
char tmp_strip_size[6], tmp_fxoptions[5], tmp_rgbOrder[5]; //needed tempararily for WiFiManager Settings
|
char tmp_strip_size[6], tmp_fxoptions[5], tmp_rgbOrder[5]; //needed tempararily for WiFiManager Settings
|
||||||
WiFiManagerParameter custom_hostname("hostname", "Hostname", HOSTNAME, 64, " maxlength=64");
|
WiFiManagerParameter custom_hostname("hostname", "Hostname", HOSTNAME, 64, " maxlength=64");
|
||||||
#if defined(ENABLE_MQTT)
|
#if defined(ENABLE_MQTT)
|
||||||
@@ -547,22 +541,7 @@ void setup() {
|
|||||||
checkRGBOrder(tmp_rgbOrder);
|
checkRGBOrder(tmp_rgbOrder);
|
||||||
WS2812FXStripSettings.fxoptions = atoi(custom_fxoptions.getValue());
|
WS2812FXStripSettings.fxoptions = atoi(custom_fxoptions.getValue());
|
||||||
if (updateConfig) {
|
if (updateConfig) {
|
||||||
#if ENABLE_STATE_SAVE == 1
|
(writeConfigFS(updateConfig)) ? DBG_OUTPUT_PORT.println("WiFiManager config FS Save success!"): DBG_OUTPUT_PORT.println("WiFiManager config FS Save failure!");
|
||||||
(writeConfigFS(updateConfig)) ? DBG_OUTPUT_PORT.println("WiFiManager config FS Save success!"): DBG_OUTPUT_PORT.println("WiFiManager config FS Save failure!");
|
|
||||||
#endif
|
|
||||||
#if ENABLE_STATE_SAVE == 0
|
|
||||||
char last_conf[225];
|
|
||||||
DBG_OUTPUT_PORT.println("Saving WiFiManager config");
|
|
||||||
#if defined(ENABLE_MQTT)
|
|
||||||
snprintf(last_conf, sizeof(last_conf), "CNF|%64s|%64s|%5d|%32s|%32s|%4d|%2d|%4s|%3d|%1d", HOSTNAME, mqtt_host, mqtt_port, mqtt_user, mqtt_pass, WS2812FXStripSettings.stripSize, WS2812FXStripSettings.pin, WS2812FXStripSettings.RGBOrder, WS2812FXStripSettings.fxoptions, transEffect);
|
|
||||||
#else
|
|
||||||
snprintf(last_conf, sizeof(last_conf), "CNF|%64s|%64s|%5d|%32s|%32s|%4d|%2d|%4s|%3d|%1d", HOSTNAME, "", "", "", "", WS2812FXStripSettings.stripSize, WS2812FXStripSettings.pin, WS2812FXStripSettings.RGBOrder, WS2812FXStripSettings.fxoptions, transEffect);
|
|
||||||
#endif
|
|
||||||
last_conf[sizeof(last_conf)] = 0x00;
|
|
||||||
writeEEPROM(0, 224, last_conf);
|
|
||||||
EEPROM.commit();
|
|
||||||
updateConfig = false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -775,15 +754,22 @@ void loop() {
|
|||||||
|
|
||||||
if (mode == SET) {
|
if (mode == SET) {
|
||||||
mode = HOLD;
|
mode = HOLD;
|
||||||
|
// Segment
|
||||||
|
if (prevsegment != segment) {
|
||||||
|
#if defined(ENABLE_MQTT)
|
||||||
|
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK S%i", segment);
|
||||||
|
#endif
|
||||||
|
prevsegment = segment;
|
||||||
|
}
|
||||||
// Mode
|
// Mode
|
||||||
if (ws2812fx_mode != strip->getMode(selected_segment)) { // SET_MODE
|
if (ws2812fx_mode != strip->getMode(segment)) {
|
||||||
#if defined(ENABLE_MQTT)
|
#if defined(ENABLE_MQTT)
|
||||||
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK /%i", ws2812fx_mode);
|
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK /%i", ws2812fx_mode);
|
||||||
#endif
|
#endif
|
||||||
strip->strip_off();
|
strip->strip_off();
|
||||||
autoCount = 0;
|
autoCount = 0;
|
||||||
autoDelay = 0;
|
autoDelay = 0;
|
||||||
strip->setMode(selected_segment, ws2812fx_mode);
|
strip->setMode(segment, ws2812fx_mode);
|
||||||
}
|
}
|
||||||
//Color
|
//Color
|
||||||
/*if (memcmp(hex_colors_trans, strip->getColors(selected_segment), sizeof(hex_colors_trans)) != 0) {
|
/*if (memcmp(hex_colors_trans, strip->getColors(selected_segment), sizeof(hex_colors_trans)) != 0) {
|
||||||
@@ -808,12 +794,11 @@ void loop() {
|
|||||||
|
|
||||||
if (prevmode != mode) {
|
if (prevmode != mode) {
|
||||||
convertColors();
|
convertColors();
|
||||||
if (memcmp(hex_colors_trans, strip->getColors(selected_segment), sizeof(hex_colors_trans)) != 0) {
|
if (memcmp(hex_colors_trans, strip->getColors(segment), sizeof(hex_colors_trans)) != 0) {
|
||||||
DBG_OUTPUT_PORT.println("Colors not equal!");
|
|
||||||
convertColorsFade();
|
convertColorsFade();
|
||||||
trans_cnt = 1;
|
trans_cnt = 1;
|
||||||
}
|
}
|
||||||
strip->setSpeed(selected_segment, convertSpeed(ws2812fx_speed_actual));
|
strip->setSpeed(segment, convertSpeed(ws2812fx_speed_actual));
|
||||||
//strip->setBrightness(brightness_actual);
|
//strip->setBrightness(brightness_actual);
|
||||||
if (prevmode != INIT_STRIP) { // do not save if INIT_STRIP mode was set
|
if (prevmode != INIT_STRIP) { // do not save if INIT_STRIP mode was set
|
||||||
#if defined(ENABLE_STATE_SAVE)
|
#if defined(ENABLE_STATE_SAVE)
|
||||||
@@ -836,33 +821,10 @@ void loop() {
|
|||||||
}
|
}
|
||||||
#if defined(ENABLE_STATE_SAVE)
|
#if defined(ENABLE_STATE_SAVE)
|
||||||
if (updateState){
|
if (updateState){
|
||||||
#if ENABLE_STATE_SAVE == 1
|
|
||||||
(writeStateFS(updateState)) ? DBG_OUTPUT_PORT.println(" State FS Save Success!") : DBG_OUTPUT_PORT.println("State FS Save failure!");
|
(writeStateFS(updateState)) ? DBG_OUTPUT_PORT.println(" State FS Save Success!") : DBG_OUTPUT_PORT.println("State FS Save failure!");
|
||||||
#endif
|
|
||||||
#if ENABLE_STATE_SAVE == 0
|
|
||||||
writeEEPROM(384, 66, last_state); // 384 --> last_state (reserved 66 bytes)
|
|
||||||
EEPROM.commit();
|
|
||||||
updateState = false;
|
|
||||||
settings_save_state.detach();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (updateConfig) {
|
if (updateConfig) {
|
||||||
#if ENABLE_STATE_SAVE == 1
|
|
||||||
(writeConfigFS(updateConfig)) ? DBG_OUTPUT_PORT.println("Config FS Save success!"): DBG_OUTPUT_PORT.println("Config FS Save failure!");
|
(writeConfigFS(updateConfig)) ? DBG_OUTPUT_PORT.println("Config FS Save success!"): DBG_OUTPUT_PORT.println("Config FS Save failure!");
|
||||||
#endif
|
|
||||||
#if ENABLE_STATE_SAVE == 0
|
|
||||||
char last_conf[225];
|
|
||||||
#if defined(ENABLE_MQTT)
|
|
||||||
snprintf(last_conf, sizeof(last_conf), "CNF|%64s|%64s|%5d|%32s|%32s|%4d|%2d|%4s|%3d|%1d", HOSTNAME, mqtt_host, mqtt_port, mqtt_user, mqtt_pass, WS2812FXStripSettings.stripSize, WS2812FXStripSettings.pin, WS2812FXStripSettings.RGBOrder, WS2812FXStripSettings.fxoptions, transEffect);
|
|
||||||
#else
|
|
||||||
snprintf(last_conf, sizeof(last_conf), "CNF|%64s|%64s|%5d|%32s|%32s|%4d|%2d|%4s|%3d|%1d", HOSTNAME, "", "", "", "", WS2812FXStripSettings.stripSize, WS2812FXStripSettings.pin, WS2812FXStripSettings.RGBOrder, WS2812FXStripSettings.fxoptions, transEffect);
|
|
||||||
#endif
|
|
||||||
last_conf[sizeof(last_conf) - 1] = 0x00;
|
|
||||||
writeEEPROM(0, 224, last_conf);
|
|
||||||
EEPROM.commit();
|
|
||||||
updateConfig = false;
|
|
||||||
settings_save_conf.detach();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -875,7 +837,7 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Async color transition
|
// Async color transition
|
||||||
if (memcmp(hex_colors_trans, strip->getColors(selected_segment), sizeof(hex_colors_trans)) != 0) {
|
if (memcmp(hex_colors_trans, strip->getColors(segment), sizeof(hex_colors_trans)) != 0) {
|
||||||
if (transEffect) {
|
if (transEffect) {
|
||||||
if ((trans_cnt > 0) && (trans_cnt < trans_cnt_max)) {
|
if ((trans_cnt > 0) && (trans_cnt < trans_cnt_max)) {
|
||||||
if (colorFadeDelay <= millis()) {
|
if (colorFadeDelay <= millis()) {
|
||||||
@@ -883,21 +845,21 @@ void loop() {
|
|||||||
hex_colors_actual[0] = trans(hex_colors_trans[0], hex_colors[0], trans_cnt);
|
hex_colors_actual[0] = trans(hex_colors_trans[0], hex_colors[0], trans_cnt);
|
||||||
hex_colors_actual[1] = trans(hex_colors_trans[1], hex_colors[1], trans_cnt);
|
hex_colors_actual[1] = trans(hex_colors_trans[1], hex_colors[1], trans_cnt);
|
||||||
hex_colors_actual[2] = trans(hex_colors_trans[2], hex_colors[2], trans_cnt);
|
hex_colors_actual[2] = trans(hex_colors_trans[2], hex_colors[2], trans_cnt);
|
||||||
strip->setColors(selected_segment, hex_colors_actual);
|
strip->setColors(prevsegment, hex_colors_actual);
|
||||||
trans_cnt++;
|
trans_cnt++;
|
||||||
colorFadeDelay = millis() + TRANS_COLOR_DELAY;
|
colorFadeDelay = millis() + TRANS_COLOR_DELAY;
|
||||||
if (mode == HOLD) strip->trigger();
|
if (mode == HOLD) strip->trigger();
|
||||||
}
|
}
|
||||||
} else if (trans_cnt >= trans_cnt_max) {
|
} else if (trans_cnt >= trans_cnt_max) {
|
||||||
memcpy(hex_colors, hex_colors_trans, sizeof(hex_colors_trans));
|
memcpy(hex_colors, hex_colors_trans, sizeof(hex_colors_trans));
|
||||||
strip->setColors(selected_segment, hex_colors);
|
strip->setColors(prevsegment, hex_colors);
|
||||||
if (mode == HOLD) strip->trigger();
|
if (mode == HOLD) strip->trigger();
|
||||||
trans_cnt = 0;
|
trans_cnt = 0;
|
||||||
DBG_OUTPUT_PORT.println("Color transition finished!");
|
DBG_OUTPUT_PORT.println("Color transition finished!");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
memcpy(hex_colors, hex_colors_trans, sizeof(hex_colors_trans));
|
memcpy(hex_colors, hex_colors_trans, sizeof(hex_colors_trans));
|
||||||
strip->setColors(selected_segment, hex_colors);
|
strip->setColors(prevsegment, hex_colors);
|
||||||
if (mode == HOLD) strip->trigger();
|
if (mode == HOLD) strip->trigger();
|
||||||
trans_cnt = 0;
|
trans_cnt = 0;
|
||||||
}
|
}
|
||||||
@@ -917,12 +879,12 @@ void loop() {
|
|||||||
ws2812fx_speed_actual--;
|
ws2812fx_speed_actual--;
|
||||||
}
|
}
|
||||||
speedFadeDelay = millis() + TRANS_DELAY;
|
speedFadeDelay = millis() + TRANS_DELAY;
|
||||||
strip->setSpeed(selected_segment, convertSpeed(ws2812fx_speed_actual));
|
strip->setSpeed(prevsegment, convertSpeed(ws2812fx_speed_actual));
|
||||||
if (mode == HOLD) strip->trigger();
|
if (mode == HOLD) strip->trigger();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ws2812fx_speed_actual = ws2812fx_speed;
|
ws2812fx_speed_actual = ws2812fx_speed;
|
||||||
strip->setSpeed(selected_segment, convertSpeed(ws2812fx_speed_actual));
|
strip->setSpeed(prevsegment, convertSpeed(ws2812fx_speed_actual));
|
||||||
if (mode == HOLD) strip->trigger();
|
if (mode == HOLD) strip->trigger();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -942,11 +904,19 @@ void loop() {
|
|||||||
strip->trigger();
|
strip->trigger();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
strip->setBrightness(brightness);
|
brightness_trans = brightness;
|
||||||
|
strip->setBrightness(brightness_trans);
|
||||||
if (mode == HOLD) strip->trigger();
|
if (mode == HOLD) strip->trigger();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* // Segment change only if color and speed transitions are finished, because they are segment specific
|
||||||
|
if (prevsegment != segment) {
|
||||||
|
if ((memcmp(hex_colors_trans, strip->getColors(segment), sizeof(hex_colors_trans)) == 0) && (ws2812fx_speed_actual == ws2812fx_speed)) {
|
||||||
|
segment = prevsegment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
prevmode = mode;
|
prevmode = mode;
|
||||||
|
|
||||||
#if defined(ENABLE_REMOTE)
|
#if defined(ENABLE_REMOTE)
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ char HOSTNAME[65] = "McLightingRGBW"; // Friedly hostname is configurable just
|
|||||||
#endif
|
#endif
|
||||||
#define ENABLE_REMOTE 13 // If defined, enable Remote Control via TSOP31238. The value defines the input pin (13 / D7) for TSOP31238 Out
|
#define ENABLE_REMOTE 13 // If defined, enable Remote Control via TSOP31238. The value defines the input pin (13 / D7) for TSOP31238 Out
|
||||||
|
|
||||||
#define ENABLE_STATE_SAVE 1 // If defined, load saved state on reboot and save state. If set to 0 from EEPROM, if set to 1 from 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 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
|
#define TRANS_COLOR_DELAY 5 // Delay for color transition
|
||||||
#define TRANS_DELAY 10 // Delay for brightness and speed transition
|
#define TRANS_DELAY 10 // Delay for brightness and speed transition
|
||||||
@@ -49,7 +49,12 @@ unsigned long speedFadeDelay = 0;
|
|||||||
uint8_t END_UNIVERSE = START_UNIVERSE; // Total number of Universes to listen for, starting at UNIVERSE
|
uint8_t END_UNIVERSE = START_UNIVERSE; // Total number of Universes to listen for, starting at UNIVERSE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
uint8_t selected_segment = 0;
|
uint8_t num_segments = 1;
|
||||||
|
uint8_t segment = 0;
|
||||||
|
uint16_t seg_start = 0;
|
||||||
|
uint16_t seg_stop = NUMLEDS - 1;
|
||||||
|
uint8_t prevsegment = 0;
|
||||||
|
|
||||||
#if defined(ENABLE_REMOTE)
|
#if defined(ENABLE_REMOTE)
|
||||||
uint8_t selected_color = 1;
|
uint8_t selected_color = 1;
|
||||||
uint64_t last_remote_cmd;
|
uint64_t last_remote_cmd;
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ void handleAutoPlay() {
|
|||||||
hex_colors[0] = autoParams[autoCount][0];
|
hex_colors[0] = autoParams[autoCount][0];
|
||||||
hex_colors[1] = autoParams[autoCount][1];
|
hex_colors[1] = autoParams[autoCount][1];
|
||||||
hex_colors[2] = autoParams[autoCount][2];
|
hex_colors[2] = autoParams[autoCount][2];
|
||||||
strip->setColors(selected_segment, hex_colors);
|
strip->setColors(segment, hex_colors);
|
||||||
strip->setSpeed(selected_segment, convertSpeed((uint8_t)autoParams[autoCount][3]));
|
strip->setSpeed(segment, convertSpeed((uint8_t)autoParams[autoCount][3]));
|
||||||
strip->setMode(selected_segment, (uint8_t)autoParams[autoCount][4]);
|
strip->setMode(segment, (uint8_t)autoParams[autoCount][4]);
|
||||||
strip->trigger();
|
strip->trigger();
|
||||||
autoDelay = millis() + (uint32_t)autoParams[autoCount][5];
|
autoDelay = millis() + (uint32_t)autoParams[autoCount][5];
|
||||||
DBG_OUTPUT_PORT.print("autoTick ");
|
DBG_OUTPUT_PORT.print("autoTick ");
|
||||||
@@ -237,7 +237,7 @@ void Gradient() {
|
|||||||
} else {
|
} else {
|
||||||
pixelnumber = j;
|
pixelnumber = j;
|
||||||
}
|
}
|
||||||
color = trans(strip->getColors(selected_segment)[1], strip->getColors(selected_segment)[0], (j*255)/(WS2812FXStripSettings.stripSize - 1));
|
color = trans(strip->getColors(segment)[1], strip->getColors(segment)[0], (j*255)/(WS2812FXStripSettings.stripSize - 1));
|
||||||
strip->setPixelColor(pixelnumber, ((color >> 16) & 0xFF), ((color >> 8) & 0xFF), ((color >> 0) & 0xFF), ((color >> 24) & 0xFF));
|
strip->setPixelColor(pixelnumber, ((color >> 16) & 0xFF), ((color >> 8) & 0xFF), ((color >> 0) & 0xFF), ((color >> 24) & 0xFF));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -245,31 +245,31 @@ void Gradient() {
|
|||||||
|
|
||||||
uint16_t myCustomEffect0() {
|
uint16_t myCustomEffect0() {
|
||||||
handleAuto();
|
handleAuto();
|
||||||
return (strip->getSpeed() / WS2812FXStripSettings.stripSize);
|
return (strip->getSpeed(segment) / WS2812FXStripSettings.stripSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t myCustomEffect1() {
|
uint16_t myCustomEffect1() {
|
||||||
handleCustomWS();
|
handleCustomWS();
|
||||||
return (strip->getSpeed() / WS2812FXStripSettings.stripSize);
|
return (strip->getSpeed(segment) / WS2812FXStripSettings.stripSize);
|
||||||
}
|
}
|
||||||
#if defined(CUSTOM_WS2812FX_ANIMATIONS)
|
#if defined(CUSTOM_WS2812FX_ANIMATIONS)
|
||||||
uint16_t myCustomEffect2() {
|
uint16_t myCustomEffect2() {
|
||||||
handleTV();
|
handleTV();
|
||||||
return (strip->getSpeed() / WS2812FXStripSettings.stripSize);
|
return (strip->getSpeed(segment) / WS2812FXStripSettings.stripSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t myCustomEffect3() {
|
uint16_t myCustomEffect3() {
|
||||||
handleE131();
|
handleE131();
|
||||||
return (strip->getSpeed() / WS2812FXStripSettings.stripSize);
|
return (strip->getSpeed(segment) / WS2812FXStripSettings.stripSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t myCustomEffect4() {
|
uint16_t myCustomEffect4() {
|
||||||
Fire2012();
|
Fire2012();
|
||||||
return (strip->getSpeed() / WS2812FXStripSettings.stripSize);
|
return (strip->getSpeed(segment) / WS2812FXStripSettings.stripSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t myCustomEffect5() {
|
uint16_t myCustomEffect5() {
|
||||||
Gradient();
|
Gradient();
|
||||||
return (strip->getSpeed() / WS2812FXStripSettings.stripSize);
|
return (strip->getSpeed(segment) / WS2812FXStripSettings.stripSize);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -17,6 +17,31 @@ void convertColors() {
|
|||||||
hex_colors_trans[2] = (uint32_t)(xtra_color.white << 24) | (xtra_color.red << 16) | (xtra_color.green << 8) | xtra_color.blue;
|
hex_colors_trans[2] = (uint32_t)(xtra_color.white << 24) | (xtra_color.red << 16) | (xtra_color.green << 8) | xtra_color.blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t* convertColors2(uint8_t w, uint8_t r, uint8_t g, uint8_t b, uint8_t w2, uint8_t r2, uint8_t g2, uint8_t b2, uint8_t w3, uint8_t r3, uint8_t g3, uint8_t b3) {
|
||||||
|
uint32_t hexcolors[3] = {};
|
||||||
|
hexcolors[0] = (uint32_t)(w << 24) | (r << 16) | (g << 8) | b;
|
||||||
|
hexcolors[1] = (uint32_t)(w2 << 24) | (r2 << 16) | (g2 << 8) | b2;
|
||||||
|
hexcolors[2] = (uint32_t)(w3 << 24) | (r3 << 16) | (g3 << 8) | b3;
|
||||||
|
return hexcolors;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void getSegmentParams(uint8_t seg) {
|
||||||
|
ws2812fx_mode = strip->getMode(seg);
|
||||||
|
main_color.white = ((strip->getColors(seg)[0] >> 24) & 0xFF);
|
||||||
|
main_color.red = ((strip->getColors(seg)[0] >> 16) & 0xFF);
|
||||||
|
main_color.green = ((strip->getColors(seg)[0] >> 8) & 0xFF);
|
||||||
|
main_color.blue = ((strip->getColors(seg)[0]) & 0xFF);
|
||||||
|
back_color.white = ((strip->getColors(seg)[1] >> 24) & 0xFF);
|
||||||
|
back_color.red = ((strip->getColors(seg)[1] >> 16) & 0xFF);
|
||||||
|
back_color.green = ((strip->getColors(seg)[1] >> 8) & 0xFF);
|
||||||
|
back_color.blue = ((strip->getColors(seg)[1]) & 0xFF);
|
||||||
|
xtra_color.white = ((strip->getColors(seg)[2] >> 24) & 0xFF);
|
||||||
|
xtra_color.red = ((strip->getColors(seg)[2] >> 16) & 0xFF);
|
||||||
|
xtra_color.green = ((strip->getColors(seg)[2] >> 8) & 0xFF);
|
||||||
|
xtra_color.blue = ((strip->getColors(seg)[2] >> 0) & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
void calculateColorTransitionSteps() {
|
void calculateColorTransitionSteps() {
|
||||||
//compare all colors and calculate steps
|
//compare all colors and calculate steps
|
||||||
trans_cnt_max = 0;
|
trans_cnt_max = 0;
|
||||||
@@ -33,7 +58,7 @@ void calculateColorTransitionSteps() {
|
|||||||
void convertColorsFade() {
|
void convertColorsFade() {
|
||||||
if (transEffect) {
|
if (transEffect) {
|
||||||
if (trans_cnt > 1) {
|
if (trans_cnt > 1) {
|
||||||
memcpy(hex_colors, strip->getColors(selected_segment), sizeof(hex_colors));
|
memcpy(hex_colors, strip->getColors(segment), sizeof(hex_colors));
|
||||||
DBG_OUTPUT_PORT.println("Color transistion aborted. Restarting...!");
|
DBG_OUTPUT_PORT.println("Color transistion aborted. Restarting...!");
|
||||||
trans_cnt = 1;
|
trans_cnt = 1;
|
||||||
}
|
}
|
||||||
@@ -43,6 +68,13 @@ void convertColorsFade() {
|
|||||||
|
|
||||||
void getArgs() {
|
void getArgs() {
|
||||||
if (mode == SET) {
|
if (mode == SET) {
|
||||||
|
// Segment
|
||||||
|
if ((server.arg("seg") != "") && (server.arg("seg").toInt() >= 0) && (server.arg("seg").toInt() <= MAX_NUM_SEGMENTS)) {
|
||||||
|
prevsegment = segment;
|
||||||
|
segment = server.arg("seg").toInt();
|
||||||
|
getSegmentParams(segment);
|
||||||
|
memcpy(hex_colors_trans, hex_colors, sizeof(hex_colors_trans));
|
||||||
|
}
|
||||||
//color wrgb
|
//color wrgb
|
||||||
if (server.arg("rgb") != "") {
|
if (server.arg("rgb") != "") {
|
||||||
uint32_t rgb = (uint32_t) strtoul(server.arg("rgb").c_str(), NULL, 16);
|
uint32_t rgb = (uint32_t) strtoul(server.arg("rgb").c_str(), NULL, 16);
|
||||||
@@ -131,7 +163,6 @@ void getArgs() {
|
|||||||
brightness = constrain(server.arg("p").toInt(), 0, 255);
|
brightness = constrain(server.arg("p").toInt(), 0, 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG_OUTPUT_PORT.printf("Get Args: %s\r\n", listStatusJSON());
|
DBG_OUTPUT_PORT.printf("Get Args: %s\r\n", listStatusJSON());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,7 +335,6 @@ bool checkPin(uint8_t pin) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
neoPixelType checkRGBOrder(char rgbOrder[5]) {
|
neoPixelType checkRGBOrder(char rgbOrder[5]) {
|
||||||
for( uint8_t i=0 ; i < sizeof(rgbOrder) ; ++i ) rgbOrder[i] = toupper(rgbOrder[i]) ;
|
for( uint8_t i=0 ; i < sizeof(rgbOrder) ; ++i ) rgbOrder[i] = toupper(rgbOrder[i]) ;
|
||||||
DBG_OUTPUT_PORT.printf("Checking RGB Order: %s ...", rgbOrder);
|
DBG_OUTPUT_PORT.printf("Checking RGB Order: %s ...", rgbOrder);
|
||||||
@@ -385,31 +415,6 @@ neoPixelType checkRGBOrder(char rgbOrder[5]) {
|
|||||||
return returnOrder;
|
return returnOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool setConfByConfString(String saved_conf_string) {
|
|
||||||
if (getValue(saved_conf_string, '|', 0) == "CNF") {
|
|
||||||
DBG_OUTPUT_PORT.printf("Parsed conf: %s\r\n", saved_conf_string.c_str());
|
|
||||||
getValue(saved_conf_string, '|', 1).toCharArray(HOSTNAME, 64);
|
|
||||||
#if defined(ENABLE_MQTT)
|
|
||||||
getValue(saved_conf_string, '|', 2).toCharArray(mqtt_host, 64);
|
|
||||||
mqtt_port = getValue(saved_conf_string, '|', 3).toInt();
|
|
||||||
getValue(saved_conf_string, '|', 4).toCharArray(mqtt_user, 32);
|
|
||||||
getValue(saved_conf_string, '|', 5).toCharArray(mqtt_pass, 32);
|
|
||||||
#endif
|
|
||||||
WS2812FXStripSettings.stripSize = constrain(getValue(saved_conf_string, '|', 6).toInt(), 1, MAXLEDS);
|
|
||||||
checkPin(getValue(saved_conf_string, '|', 7).toInt());
|
|
||||||
char tmp_rgbOrder[5];
|
|
||||||
getValue(saved_conf_string, '|', 8).toCharArray(tmp_rgbOrder, 4);
|
|
||||||
checkRGBOrder(tmp_rgbOrder);
|
|
||||||
WS2812FXStripSettings.fxoptions = constrain(((getValue(saved_conf_string, '|', 9).toInt()>>1)<<1), 0, 255);
|
|
||||||
transEffect = getValue(saved_conf_string, '|', 10).toInt();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
DBG_OUTPUT_PORT.println("Saved conf not found!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool setModeByStateString(String saved_state_string) {
|
bool setModeByStateString(String saved_state_string) {
|
||||||
if (getValue(saved_state_string, '|', 0) == "STA") {
|
if (getValue(saved_state_string, '|', 0) == "STA") {
|
||||||
DBG_OUTPUT_PORT.printf("Parsed state: %s\r\n", saved_state_string.c_str());
|
DBG_OUTPUT_PORT.printf("Parsed state: %s\r\n", saved_state_string.c_str());
|
||||||
@@ -472,15 +477,14 @@ void handleSetWS2812FXMode(uint8_t * mypayload) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char * listStatusJSON() {
|
char * listStatusJSONorg() {
|
||||||
const size_t bufferSize = JSON_ARRAY_SIZE(12) + JSON_OBJECT_SIZE(6) + 500;
|
const size_t bufferSize = JSON_ARRAY_SIZE(13) + JSON_OBJECT_SIZE(6) + 500;
|
||||||
DynamicJsonDocument jsonBuffer(bufferSize);
|
DynamicJsonDocument jsonBuffer(bufferSize);
|
||||||
JsonObject root = jsonBuffer.to<JsonObject>();
|
JsonObject root = jsonBuffer.to<JsonObject>();
|
||||||
|
root["segment"] = segment;
|
||||||
root["mode"] = (uint8_t) mode;
|
root["mode"] = (uint8_t) mode;
|
||||||
root["ws2812fx_mode"] = ws2812fx_mode;
|
root["ws2812fx_mode"] = ws2812fx_mode;
|
||||||
root["ws2812fx_mode_name"] = strip->getModeName(ws2812fx_mode);
|
root["ws2812fx_mode_name"] = strip->getModeName(ws2812fx_mode);
|
||||||
//root["ws2812fx_mode"] = tmp_mode;
|
|
||||||
//root["ws2812fx_mode_name"] = strip->getModeName(tmp_mode);
|
|
||||||
root["speed"] = ws2812fx_speed;
|
root["speed"] = ws2812fx_speed;
|
||||||
root["brightness"] = brightness;
|
root["brightness"] = brightness;
|
||||||
JsonArray color = root.createNestedArray("color");
|
JsonArray color = root.createNestedArray("color");
|
||||||
@@ -503,8 +507,53 @@ char * listStatusJSON() {
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char * listStatusJSON() {
|
||||||
|
const size_t bufferSize = JSON_OBJECT_SIZE(3) + 25;
|
||||||
|
DynamicJsonDocument jsonBuffer(bufferSize);
|
||||||
|
JsonObject root = jsonBuffer.to<JsonObject>();
|
||||||
|
root["segment"] = segment;
|
||||||
|
root["mode"] = (uint8_t) mode;
|
||||||
|
root["brightness"] = brightness;
|
||||||
|
uint16_t msg_len = measureJson(root) + 1;
|
||||||
|
char * buffer = (char *) malloc(msg_len);
|
||||||
|
serializeJson(root, buffer, msg_len);
|
||||||
|
jsonBuffer.clear();
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
char * listSegmentStatusJSON(uint8_t seg) {
|
||||||
|
const size_t bufferSize = JSON_ARRAY_SIZE(12) + JSON_OBJECT_SIZE(7) + 100;
|
||||||
|
DynamicJsonDocument jsonBuffer(bufferSize);
|
||||||
|
JsonObject root = jsonBuffer.to<JsonObject>();
|
||||||
|
root["segment"] = seg;
|
||||||
|
root["start"] = strip->getSegment(seg)->start;
|
||||||
|
root["stop"] = strip->getSegment(seg)->stop;
|
||||||
|
root["ws2812fx_mode"] = strip->getMode(seg);
|
||||||
|
root["ws2812fx_mode_name"] = strip->getModeName(strip->getMode(seg));
|
||||||
|
root["speed"] = ws2812fx_speed;
|
||||||
|
getSegmentParams(seg);
|
||||||
|
JsonArray color = root.createNestedArray("color");
|
||||||
|
color.add((strip->getColors(seg)[0] >> 24) & 0xFF);
|
||||||
|
color.add((strip->getColors(seg)[0] >> 16) & 0xFF);
|
||||||
|
color.add((strip->getColors(seg)[0] >> 8) & 0xFF);
|
||||||
|
color.add((strip->getColors(seg)[0]) & 0xFF);
|
||||||
|
color.add((strip->getColors(seg)[1] >> 24) & 0xFF);
|
||||||
|
color.add((strip->getColors(seg)[1] >> 16) & 0xFF);
|
||||||
|
color.add((strip->getColors(seg)[1] >> 8) & 0xFF);
|
||||||
|
color.add((strip->getColors(seg)[1]) & 0xFF);
|
||||||
|
color.add((strip->getColors(seg)[2] >> 24) & 0xFF);
|
||||||
|
color.add((strip->getColors(seg)[2] >> 16) & 0xFF);
|
||||||
|
color.add((strip->getColors(seg)[2] >> 8) & 0xFF);
|
||||||
|
color.add((strip->getColors(seg)[2]) & 0xFF);
|
||||||
|
uint16_t msg_len = measureJson(root) + 1;
|
||||||
|
char * buffer = (char *) malloc(msg_len);
|
||||||
|
serializeJson(root, buffer, msg_len);
|
||||||
|
jsonBuffer.clear();
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
void getStatusJSON() {
|
void getStatusJSON() {
|
||||||
char * buffer = listStatusJSON();
|
char * buffer = listStatusJSONorg();
|
||||||
server.sendHeader("Access-Control-Allow-Origin", "*");
|
server.sendHeader("Access-Control-Allow-Origin", "*");
|
||||||
server.send ( 200, "application/json", buffer);
|
server.send ( 200, "application/json", buffer);
|
||||||
free (buffer);
|
free (buffer);
|
||||||
@@ -512,9 +561,9 @@ void getStatusJSON() {
|
|||||||
|
|
||||||
char * listConfigJSON() {
|
char * listConfigJSON() {
|
||||||
#if defined(ENABLE_MQTT)
|
#if defined(ENABLE_MQTT)
|
||||||
const size_t bufferSize = JSON_OBJECT_SIZE(9) + 500;
|
const size_t bufferSize = JSON_OBJECT_SIZE(10) + 500;
|
||||||
#else
|
#else
|
||||||
const size_t bufferSize = JSON_OBJECT_SIZE(5) + 150;
|
const size_t bufferSize = JSON_OBJECT_SIZE(6) + 150;
|
||||||
#endif
|
#endif
|
||||||
DynamicJsonDocument jsonBuffer(bufferSize);
|
DynamicJsonDocument jsonBuffer(bufferSize);
|
||||||
JsonObject root = jsonBuffer.to<JsonObject>();
|
JsonObject root = jsonBuffer.to<JsonObject>();
|
||||||
@@ -525,6 +574,7 @@ char * listConfigJSON() {
|
|||||||
root["mqtt_user"] = mqtt_user;
|
root["mqtt_user"] = mqtt_user;
|
||||||
root["mqtt_pass"] = mqtt_pass;
|
root["mqtt_pass"] = mqtt_pass;
|
||||||
#endif
|
#endif
|
||||||
|
root["num_seg"] = num_segments;
|
||||||
root["ws_cnt"] = WS2812FXStripSettings.stripSize;
|
root["ws_cnt"] = WS2812FXStripSettings.stripSize;
|
||||||
root["ws_rgbo"] = WS2812FXStripSettings.RGBOrder;
|
root["ws_rgbo"] = WS2812FXStripSettings.RGBOrder;
|
||||||
root["ws_pin"] = WS2812FXStripSettings.pin;
|
root["ws_pin"] = WS2812FXStripSettings.pin;
|
||||||
@@ -545,7 +595,7 @@ void getConfigJSON() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
char * listModesJSON() {
|
char * listModesJSON() {
|
||||||
const size_t bufferSize = JSON_ARRAY_SIZE(strip->getModeCount() + 3) + (strip->getModeCount() + 3)*JSON_OBJECT_SIZE(2) + 2000;
|
const size_t bufferSize = JSON_ARRAY_SIZE(strip->getModeCount() + 1) + (strip->getModeCount() + 1)*JSON_OBJECT_SIZE(2) + 2000;
|
||||||
DynamicJsonDocument jsonBuffer(bufferSize);
|
DynamicJsonDocument jsonBuffer(bufferSize);
|
||||||
JsonArray root = jsonBuffer.to<JsonArray>();
|
JsonArray root = jsonBuffer.to<JsonArray>();
|
||||||
JsonObject objectoff = root.createNestedObject();
|
JsonObject objectoff = root.createNestedObject();
|
||||||
@@ -622,6 +672,18 @@ void Dbg_Prefix(bool mqtt, uint8_t num) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
||||||
|
// Select segment
|
||||||
|
if (payload[0] == 'S') {
|
||||||
|
uint8_t seg = (uint8_t) strtol((const char *) &payload[1], NULL, 10);
|
||||||
|
prevsegment = segment;
|
||||||
|
segment = constrain(seg, 0, MAX_NUM_SEGMENTS);
|
||||||
|
getSegmentParams(segment);
|
||||||
|
memcpy(hex_colors_trans, hex_colors, sizeof(hex_colors_trans));
|
||||||
|
mode = SET;
|
||||||
|
Dbg_Prefix(mqtt, num);
|
||||||
|
DBG_OUTPUT_PORT.printf("Set segment to: [%u]\r\n", segment);
|
||||||
|
}
|
||||||
|
|
||||||
// # ==> Set main color - ## ==> Set 2nd color - ### ==> Set 3rd color
|
// # ==> Set main color - ## ==> Set 2nd color - ### ==> Set 3rd color
|
||||||
if (payload[0] == '#') {
|
if (payload[0] == '#') {
|
||||||
#if defined(ENABLE_MQTT)
|
#if defined(ENABLE_MQTT)
|
||||||
@@ -696,7 +758,7 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
|||||||
|
|
||||||
// $ ==> Get status Info.
|
// $ ==> Get status Info.
|
||||||
if (payload[0] == '$') {
|
if (payload[0] == '$') {
|
||||||
char * buffer = listStatusJSON();
|
char * buffer = listStatusJSONorg();
|
||||||
if (mqtt == true) {
|
if (mqtt == true) {
|
||||||
DBG_OUTPUT_PORT.print("MQTT: ");
|
DBG_OUTPUT_PORT.print("MQTT: ");
|
||||||
#if defined(ENABLE_MQTT)
|
#if defined(ENABLE_MQTT)
|
||||||
@@ -722,6 +784,13 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
|||||||
bool updateStrip = false;
|
bool updateStrip = false;
|
||||||
bool updateConf = false;
|
bool updateConf = false;
|
||||||
if (payload[1] == 's') {
|
if (payload[1] == 's') {
|
||||||
|
if (payload[2] == 's') {
|
||||||
|
char tmp_segments[3];
|
||||||
|
snprintf(tmp_segments, sizeof(tmp_segments), "%s", &payload[3]);
|
||||||
|
tmp_segments[2] = 0x00;
|
||||||
|
num_segments = constrain(atoi(tmp_segments), 1, MAX_NUM_SEGMENTS - 1);
|
||||||
|
updateStrip = true;
|
||||||
|
}
|
||||||
if (payload[2] == 'c') {
|
if (payload[2] == 'c') {
|
||||||
char tmp_count[6];
|
char tmp_count[6];
|
||||||
snprintf(tmp_count, sizeof(tmp_count), "%s", &payload[3]);
|
snprintf(tmp_count, sizeof(tmp_count), "%s", &payload[3]);
|
||||||
@@ -1441,203 +1510,239 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
updateConfig = true;
|
updateConfig = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_STATE_SAVE == 0
|
// Write configuration to FS JSON
|
||||||
// ***************************************************************************
|
bool writeConfigFS(bool saveConfig){
|
||||||
// EEPROM helper
|
if (saveConfig) {
|
||||||
// ***************************************************************************
|
//FS save
|
||||||
String readEEPROM(uint16_t offset, uint16_t len) {
|
DBG_OUTPUT_PORT.println("Saving config: ");
|
||||||
String res = "";
|
File configFile = SPIFFS.open("/config.json", "w");
|
||||||
for (uint16_t i = 0; i < len; ++i)
|
if (!configFile) {
|
||||||
{
|
DBG_OUTPUT_PORT.println("Failed!");
|
||||||
res += char(EEPROM.read(i + offset));
|
|
||||||
//DBG_OUTPUT_PORT.println(char(EEPROM.read(i + offset)));
|
|
||||||
}
|
|
||||||
DBG_OUTPUT_PORT.printf("readEEPROM(): %s\r\n", res.c_str());
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeEEPROM(uint16_t offset, uint16_t len, String value) {
|
|
||||||
DBG_OUTPUT_PORT.printf("writeEEPROM(): %s\r\n", value.c_str());
|
|
||||||
for (uint16_t i = 0; i < len; ++i)
|
|
||||||
{
|
|
||||||
if (i < value.length()) {
|
|
||||||
EEPROM.write(i + offset, value[i]);
|
|
||||||
} else {
|
|
||||||
EEPROM.write(i + offset, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if ENABLE_STATE_SAVE == 1
|
|
||||||
// Write configuration to FS JSON
|
|
||||||
bool writeConfigFS(bool saveConfig){
|
|
||||||
if (saveConfig) {
|
|
||||||
//FS save
|
|
||||||
DBG_OUTPUT_PORT.println("Saving config: ");
|
|
||||||
File configFile = SPIFFS.open("/config.json", "w");
|
|
||||||
if (!configFile) {
|
|
||||||
DBG_OUTPUT_PORT.println("Failed!");
|
|
||||||
settings_save_conf.detach();
|
|
||||||
updateConfig = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
DBG_OUTPUT_PORT.println(listConfigJSON());
|
|
||||||
configFile.print(listConfigJSON());
|
|
||||||
configFile.close();
|
|
||||||
settings_save_conf.detach();
|
settings_save_conf.detach();
|
||||||
updateConfig = false;
|
updateConfig = false;
|
||||||
return true;
|
|
||||||
//end save
|
|
||||||
} else {
|
|
||||||
DBG_OUTPUT_PORT.println("SaveConfig is false!");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
DBG_OUTPUT_PORT.println(listConfigJSON());
|
||||||
|
configFile.print(listConfigJSON());
|
||||||
// Read search_str to FS
|
configFile.close();
|
||||||
bool readConfigFS() {
|
settings_save_conf.detach();
|
||||||
//read configuration from FS JSON
|
updateConfig = false;
|
||||||
if (SPIFFS.exists("/config.json")) {
|
return true;
|
||||||
//file exists, reading and loading
|
//end save
|
||||||
DBG_OUTPUT_PORT.print("Reading config file... ");
|
} else {
|
||||||
File configFile = SPIFFS.open("/config.json", "r");
|
DBG_OUTPUT_PORT.println("SaveConfig is false!");
|
||||||
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);
|
|
||||||
configFile.close();
|
|
||||||
#if defined(ENABLE_MQTT)
|
|
||||||
const size_t bufferSize = JSON_OBJECT_SIZE(5) + 500;
|
|
||||||
#else
|
|
||||||
const size_t bufferSize = JSON_OBJECT_SIZE(1) + 150;
|
|
||||||
#endif
|
|
||||||
DynamicJsonDocument jsonBuffer(bufferSize);
|
|
||||||
DeserializationError error = deserializeJson(jsonBuffer, buf.get());
|
|
||||||
DBG_OUTPUT_PORT.print("Config: ");
|
|
||||||
if (!error) {
|
|
||||||
DBG_OUTPUT_PORT.println("Parsed!");
|
|
||||||
JsonObject root = jsonBuffer.as<JsonObject>();
|
|
||||||
serializeJson(root, DBG_OUTPUT_PORT);
|
|
||||||
DBG_OUTPUT_PORT.println("");
|
|
||||||
strcpy(HOSTNAME, root["hostname"]);
|
|
||||||
#if defined(ENABLE_MQTT)
|
|
||||||
strcpy(mqtt_host, root["mqtt_host"]);
|
|
||||||
mqtt_port = root["mqtt_port"].as<uint16_t>();
|
|
||||||
strcpy(mqtt_user, root["mqtt_user"]);
|
|
||||||
strcpy(mqtt_pass, root["mqtt_pass"]);
|
|
||||||
#endif
|
|
||||||
WS2812FXStripSettings.stripSize = constrain(root["ws_cnt"].as<uint16_t>(), 1, MAXLEDS);
|
|
||||||
char tmp_rgbOrder[5];
|
|
||||||
strcpy(tmp_rgbOrder, root["ws_rgbo"]);
|
|
||||||
checkRGBOrder(tmp_rgbOrder);
|
|
||||||
uint8_t temp_pin;
|
|
||||||
checkPin((uint8_t) root["ws_pin"]);
|
|
||||||
WS2812FXStripSettings.fxoptions = constrain(root["ws_fxopt"].as<uint8_t>(), 0, 255) & 0xFE;
|
|
||||||
transEffect = root["transEffect"].as<bool>();
|
|
||||||
jsonBuffer.clear();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
DBG_OUTPUT_PORT.print("Failed to load json config: ");
|
|
||||||
DBG_OUTPUT_PORT.println(error.c_str());
|
|
||||||
jsonBuffer.clear();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
DBG_OUTPUT_PORT.println("Failed to open /config.json");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
DBG_OUTPUT_PORT.println("Coudnt find config.json");
|
|
||||||
writeConfigFS(true);
|
|
||||||
}
|
|
||||||
//end read
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read search_str to FS
|
||||||
|
bool readConfigFS() {
|
||||||
|
//read configuration from FS JSON
|
||||||
|
if (SPIFFS.exists("/config.json")) {
|
||||||
|
//file exists, reading and loading
|
||||||
|
DBG_OUTPUT_PORT.print("Reading config file... ");
|
||||||
|
File configFile = SPIFFS.open("/config.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);
|
||||||
|
configFile.close();
|
||||||
|
#if defined(ENABLE_MQTT)
|
||||||
|
const size_t bufferSize = JSON_OBJECT_SIZE(5) + 500;
|
||||||
|
#else
|
||||||
|
const size_t bufferSize = JSON_OBJECT_SIZE(1) + 150;
|
||||||
|
#endif
|
||||||
|
DynamicJsonDocument jsonBuffer(bufferSize);
|
||||||
|
DeserializationError error = deserializeJson(jsonBuffer, buf.get());
|
||||||
|
DBG_OUTPUT_PORT.print("Config: ");
|
||||||
|
if (!error) {
|
||||||
|
DBG_OUTPUT_PORT.println("Parsed!");
|
||||||
|
JsonObject root = jsonBuffer.as<JsonObject>();
|
||||||
|
serializeJson(root, DBG_OUTPUT_PORT);
|
||||||
|
DBG_OUTPUT_PORT.println("");
|
||||||
|
strcpy(HOSTNAME, root["hostname"]);
|
||||||
|
#if defined(ENABLE_MQTT)
|
||||||
|
strcpy(mqtt_host, root["mqtt_host"]);
|
||||||
|
mqtt_port = root["mqtt_port"].as<uint16_t>();
|
||||||
|
strcpy(mqtt_user, root["mqtt_user"]);
|
||||||
|
strcpy(mqtt_pass, root["mqtt_pass"]);
|
||||||
|
#endif
|
||||||
|
num_segments = constrain(root["num_seg"].as<uint8_t>(), 1, MAX_NUM_SEGMENTS - 1);
|
||||||
|
WS2812FXStripSettings.stripSize = constrain(root["ws_cnt"].as<uint16_t>(), 1, MAXLEDS);
|
||||||
|
char tmp_rgbOrder[5];
|
||||||
|
strcpy(tmp_rgbOrder, root["ws_rgbo"]);
|
||||||
|
checkRGBOrder(tmp_rgbOrder);
|
||||||
|
uint8_t temp_pin;
|
||||||
|
checkPin((uint8_t) root["ws_pin"]);
|
||||||
|
WS2812FXStripSettings.fxoptions = constrain(root["ws_fxopt"].as<uint8_t>(), 0, 255) & 0xFE;
|
||||||
|
transEffect = root["transEffect"].as<bool>();
|
||||||
|
jsonBuffer.clear();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
DBG_OUTPUT_PORT.print("Failed to load json config: ");
|
||||||
|
DBG_OUTPUT_PORT.println(error.c_str());
|
||||||
|
jsonBuffer.clear();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DBG_OUTPUT_PORT.println("Failed to open /config.json");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DBG_OUTPUT_PORT.println("Coudnt find config.json");
|
||||||
|
writeConfigFS(true);
|
||||||
|
}
|
||||||
|
//end read
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool writeStateFS(bool saveConfig){
|
bool writeStateFS(bool saveConfig){
|
||||||
if (saveConfig) {
|
if (saveConfig) {
|
||||||
//save the strip state to FS JSON
|
//save the strip state to FS JSON
|
||||||
DBG_OUTPUT_PORT.print("Saving state: ");
|
DBG_OUTPUT_PORT.print("Saving state: ");
|
||||||
//SPIFFS.remove("/stripstate.json") ? DBG_OUTPUT_PORT.println("removed file") : DBG_OUTPUT_PORT.println("failed removing file");
|
//SPIFFS.remove("/stripstate.json") ? DBG_OUTPUT_PORT.println("removed file") : DBG_OUTPUT_PORT.println("failed removing file");
|
||||||
File configFile = SPIFFS.open("/stripstate.json", "w");
|
File configFile = SPIFFS.open("/stripstate.json", "w");
|
||||||
|
if (!configFile) {
|
||||||
|
DBG_OUTPUT_PORT.println("Failed!");
|
||||||
|
settings_save_state.detach();
|
||||||
|
updateState = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
DBG_OUTPUT_PORT.println(listStatusJSON());
|
||||||
|
configFile.print(listStatusJSON());
|
||||||
|
configFile.close();
|
||||||
|
char filename[28];
|
||||||
|
for (uint8_t seg=0; seg < num_segments; seg++) {
|
||||||
|
snprintf(filename, 28, "/stripstate_segment_%02i.json", seg);
|
||||||
|
filename[27] = 0x00;
|
||||||
|
File configFile = SPIFFS.open(filename, "w");
|
||||||
if (!configFile) {
|
if (!configFile) {
|
||||||
DBG_OUTPUT_PORT.println("Failed!");
|
DBG_OUTPUT_PORT.println("Failed!");
|
||||||
settings_save_state.detach();
|
settings_save_state.detach();
|
||||||
updateState = false;
|
updateState = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
DBG_OUTPUT_PORT.println(listStatusJSON());
|
DBG_OUTPUT_PORT.println(listSegmentStatusJSON(seg));
|
||||||
configFile.print(listStatusJSON());
|
configFile.print(listSegmentStatusJSON(seg));
|
||||||
configFile.close();
|
configFile.close();
|
||||||
settings_save_state.detach();
|
}
|
||||||
updateState = false;
|
settings_save_state.detach();
|
||||||
return true;
|
updateState = false;
|
||||||
//end save
|
return true;
|
||||||
} else {
|
//end save
|
||||||
DBG_OUTPUT_PORT.println("SaveStateConfig is false!");
|
} else {
|
||||||
return false;
|
DBG_OUTPUT_PORT.println("SaveStateConfig is false!");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool readStateFS() {
|
|
||||||
//read strip state from FS JSON
|
|
||||||
//if (resetsettings) { SPIFFS.begin(); SPIFFS.remove("/config.json"); SPIFFS.format(); delay(1000);}
|
|
||||||
if (SPIFFS.exists("/stripstate.json")) {
|
|
||||||
//file exists, reading and loading
|
|
||||||
DBG_OUTPUT_PORT.print("Reading state file... ");
|
|
||||||
File configFile = SPIFFS.open("/stripstate.json", "r");
|
|
||||||
if (configFile) {
|
|
||||||
DBG_OUTPUT_PORT.println("Opened!");
|
|
||||||
size_t size = configFile.size();
|
|
||||||
// Allocate a buffer to store contents of the file.
|
|
||||||
std::unique_ptr<char[]> buf(new char[size]);
|
|
||||||
configFile.readBytes(buf.get(), size);
|
|
||||||
configFile.close();
|
|
||||||
const size_t bufferSize = JSON_OBJECT_SIZE(5) + JSON_ARRAY_SIZE(12) + 500;
|
|
||||||
DynamicJsonDocument jsonBuffer(bufferSize);
|
|
||||||
DeserializationError error = deserializeJson(jsonBuffer, buf.get());
|
|
||||||
DBG_OUTPUT_PORT.print("Config: ");
|
|
||||||
if (!error) {
|
|
||||||
DBG_OUTPUT_PORT.print("Parsed");
|
|
||||||
JsonObject root = jsonBuffer.as<JsonObject>();
|
|
||||||
serializeJson(root, DBG_OUTPUT_PORT);
|
|
||||||
DBG_OUTPUT_PORT.println("");
|
|
||||||
mode = static_cast<MODE>(root["mode"].as<uint8_t>());
|
|
||||||
ws2812fx_mode = root["ws2812fx_mode"].as<uint8_t>();
|
|
||||||
ws2812fx_speed = root["speed"].as<uint8_t>();
|
|
||||||
brightness = root["brightness"];
|
|
||||||
main_color.white = root["color"][0].as<uint8_t>();
|
|
||||||
main_color.red = root["color"][1].as<uint8_t>();
|
|
||||||
main_color.green = root["color"][2].as<uint8_t>();
|
|
||||||
main_color.blue = root["color"][3].as<uint8_t>();
|
|
||||||
back_color.white = root["color"][4].as<uint8_t>();
|
|
||||||
back_color.red = root["color"][5].as<uint8_t>();
|
|
||||||
back_color.green = root["color"][6].as<uint8_t>();
|
|
||||||
back_color.blue = root["color"][7].as<uint8_t>();
|
|
||||||
xtra_color.white = root["color"][8].as<uint8_t>();
|
|
||||||
xtra_color.red = root["color"][9].as<uint8_t>();
|
|
||||||
xtra_color.green = root["color"][10].as<uint8_t>();
|
|
||||||
xtra_color.blue = root["color"][11].as<uint8_t>();
|
|
||||||
convertColors();
|
|
||||||
jsonBuffer.clear();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
DBG_OUTPUT_PORT.print("Failed to load json config: ");
|
|
||||||
DBG_OUTPUT_PORT.println(error.c_str());
|
|
||||||
jsonBuffer.clear();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
DBG_OUTPUT_PORT.println("Failed to open \"/stripstate.json\"");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
DBG_OUTPUT_PORT.println("Couldn't find \"/stripstate.json\"");
|
|
||||||
writeStateFS(true);
|
|
||||||
}
|
|
||||||
//end read
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
|
||||||
|
bool readStateFS() {
|
||||||
|
//read strip state from FS JSON
|
||||||
|
if (SPIFFS.exists("/stripstate.json")) {
|
||||||
|
//file exists, reading and loading
|
||||||
|
DBG_OUTPUT_PORT.print("Reading state file... ");
|
||||||
|
File configFile = SPIFFS.open("/stripstate.json", "r");
|
||||||
|
if (configFile) {
|
||||||
|
DBG_OUTPUT_PORT.println("Opened!");
|
||||||
|
size_t size = configFile.size();
|
||||||
|
// Allocate a buffer to store contents of the file.
|
||||||
|
std::unique_ptr<char[]> buf(new char[size]);
|
||||||
|
configFile.readBytes(buf.get(), size);
|
||||||
|
configFile.close();
|
||||||
|
const size_t bufferSize = JSON_OBJECT_SIZE(5) + JSON_ARRAY_SIZE(12) + 500;
|
||||||
|
DynamicJsonDocument jsonBuffer(bufferSize);
|
||||||
|
DeserializationError error = deserializeJson(jsonBuffer, buf.get());
|
||||||
|
DBG_OUTPUT_PORT.print("Config: ");
|
||||||
|
if (!error) {
|
||||||
|
DBG_OUTPUT_PORT.print("Parsed");
|
||||||
|
JsonObject root = jsonBuffer.as<JsonObject>();
|
||||||
|
serializeJson(root, DBG_OUTPUT_PORT);
|
||||||
|
DBG_OUTPUT_PORT.println("");
|
||||||
|
segment = root["segment"];
|
||||||
|
mode = static_cast<MODE>(root["mode"].as<uint8_t>());
|
||||||
|
brightness = root["brightness"];
|
||||||
|
jsonBuffer.clear();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
DBG_OUTPUT_PORT.print("Failed to load json config: ");
|
||||||
|
DBG_OUTPUT_PORT.println(error.c_str());
|
||||||
|
jsonBuffer.clear();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DBG_OUTPUT_PORT.println("Failed to open \"/stripstate.json\"");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DBG_OUTPUT_PORT.println("Couldn't find \"/stripstate.json\"");
|
||||||
|
writeStateFS(true);
|
||||||
|
}
|
||||||
|
//end read
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool readStateSegmentFS(uint8_t seg) {
|
||||||
|
//read strip state from FS JSON
|
||||||
|
char filename[28];
|
||||||
|
snprintf(filename, 28, "/stripstate_segment_%02i.json", seg);
|
||||||
|
filename[27] = 0x00;
|
||||||
|
if (SPIFFS.exists(filename)) {
|
||||||
|
//file exists, reading and loading
|
||||||
|
DBG_OUTPUT_PORT.printf("Reading segmentstate file: %s\r\n", filename);
|
||||||
|
File configFile = SPIFFS.open(filename, "r");
|
||||||
|
if (configFile) {
|
||||||
|
DBG_OUTPUT_PORT.println("Opened!");
|
||||||
|
size_t size = configFile.size();
|
||||||
|
// Allocate a buffer to store contents of the file.
|
||||||
|
std::unique_ptr<char[]> buf(new char[size]);
|
||||||
|
configFile.readBytes(buf.get(), size);
|
||||||
|
configFile.close();
|
||||||
|
const size_t bufferSize = JSON_OBJECT_SIZE(5) + JSON_ARRAY_SIZE(12) + 500;
|
||||||
|
DynamicJsonDocument jsonBuffer(bufferSize);
|
||||||
|
DeserializationError error = deserializeJson(jsonBuffer, buf.get());
|
||||||
|
DBG_OUTPUT_PORT.print("Config: ");
|
||||||
|
if (!error) {
|
||||||
|
DBG_OUTPUT_PORT.print("Parsed");
|
||||||
|
JsonObject root = jsonBuffer.as<JsonObject>();
|
||||||
|
serializeJson(root, DBG_OUTPUT_PORT);
|
||||||
|
DBG_OUTPUT_PORT.println("");
|
||||||
|
seg_start = root["start"].as<uint16_t>();
|
||||||
|
seg_stop = root["stop"].as<uint16_t>();
|
||||||
|
ws2812fx_mode = root["ws2812fx_mode"].as<uint8_t>();
|
||||||
|
ws2812fx_speed = root["speed"].as<uint8_t>();
|
||||||
|
main_color.white = root["color"][0].as<uint8_t>();
|
||||||
|
main_color.red = root["color"][1].as<uint8_t>();
|
||||||
|
main_color.green = root["color"][2].as<uint8_t>();
|
||||||
|
main_color.blue = root["color"][3].as<uint8_t>();
|
||||||
|
back_color.white = root["color"][4].as<uint8_t>();
|
||||||
|
back_color.red = root["color"][5].as<uint8_t>();
|
||||||
|
back_color.green = root["color"][6].as<uint8_t>();
|
||||||
|
back_color.blue = root["color"][7].as<uint8_t>();
|
||||||
|
xtra_color.white = root["color"][8].as<uint8_t>();
|
||||||
|
xtra_color.red = root["color"][9].as<uint8_t>();
|
||||||
|
xtra_color.green = root["color"][10].as<uint8_t>();
|
||||||
|
xtra_color.blue = root["color"][11].as<uint8_t>();
|
||||||
|
convertColors();
|
||||||
|
jsonBuffer.clear();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
DBG_OUTPUT_PORT.print("Failed to load json config: ");
|
||||||
|
DBG_OUTPUT_PORT.println(error.c_str());
|
||||||
|
jsonBuffer.clear();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DBG_OUTPUT_PORT.printf("Failed to open \"/%s\"\r\n", filename);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DBG_OUTPUT_PORT.printf("Couldn't find \"/%s\"", filename);
|
||||||
|
writeStateFS(true);
|
||||||
|
}
|
||||||
|
//end read
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(ENABLE_REMOTE)
|
#if defined(ENABLE_REMOTE)
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
// Request handler for IR remote support
|
// Request handler for IR remote support
|
||||||
|
|||||||
@@ -129,12 +129,7 @@
|
|||||||
root["ota"] = "OFF";
|
root["ota"] = "OFF";
|
||||||
#endif
|
#endif
|
||||||
#if defined(ENABLE_STATE_SAVE)
|
#if defined(ENABLE_STATE_SAVE)
|
||||||
#if ENABLE_STATE_SAVE == 1
|
root["state_save"] = "SPIFFS";
|
||||||
root["state_save"] = "SPIFFS";
|
|
||||||
#endif
|
|
||||||
#if ENABLE_STATE_SAVE == 0
|
|
||||||
root["state_save"] = "EEPROM";
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
root["state_save"] = "OFF";
|
root["state_save"] = "OFF";
|
||||||
#endif
|
#endif
|
||||||
@@ -256,6 +251,11 @@
|
|||||||
|
|
||||||
bool updateStrip = false;
|
bool updateStrip = false;
|
||||||
bool updateConf = false;
|
bool updateConf = false;
|
||||||
|
if(server.hasArg("ws_seg")){
|
||||||
|
uint8_t wsseg = server.arg("ws_seg").toInt();
|
||||||
|
num_segments = constrain(wsseg, 1, MAX_NUM_SEGMENTS - 1);
|
||||||
|
updateStrip = true;
|
||||||
|
}
|
||||||
if(server.hasArg("ws_cnt")){
|
if(server.hasArg("ws_cnt")){
|
||||||
uint16_t pixelCt = server.arg("ws_cnt").toInt();
|
uint16_t pixelCt = server.arg("ws_cnt").toInt();
|
||||||
if (pixelCt > 0) {
|
if (pixelCt > 0) {
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
char * listStatusJSON2() {
|
||||||
|
const size_t bufferSize = 10*JSON_ARRAY_SIZE(12) + 10*JSON_OBJECT_SIZE(4) + JSON_OBJECT_SIZE(12) + 600;
|
||||||
|
DynamicJsonDocument jsonBuffer(bufferSize);
|
||||||
|
JsonObject root = jsonBuffer.to<JsonObject>();
|
||||||
|
root["mode"] = (uint8_t) mode;
|
||||||
|
root["brightness"] = brightness;
|
||||||
|
for(uint8_t i=0; i<10; i++) {
|
||||||
|
char int2char[3];
|
||||||
|
itoa(i, int2char, 10);
|
||||||
|
JsonObject segments = root.createNestedObject(int2char);
|
||||||
|
segments["ws2812fx_mode"] = strip->getMode(i);
|
||||||
|
segments["ws2812fx_mode_name"] = strip->getModeName(strip->getMode(i));
|
||||||
|
segments["speed"] = ws2812fx_speed;
|
||||||
|
JsonArray color = segments.createNestedArray("color");
|
||||||
|
color.add(main_color.white);
|
||||||
|
color.add(main_color.red);
|
||||||
|
color.add(main_color.green);
|
||||||
|
color.add(main_color.blue);
|
||||||
|
color.add(back_color.white);
|
||||||
|
color.add(back_color.red);
|
||||||
|
color.add(back_color.green);
|
||||||
|
color.add(back_color.blue);
|
||||||
|
color.add(xtra_color.white);
|
||||||
|
color.add(xtra_color.red);
|
||||||
|
color.add(xtra_color.green);
|
||||||
|
color.add(xtra_color.blue);
|
||||||
|
}
|
||||||
|
uint16_t msg_len = measureJson(root) + 1;
|
||||||
|
char * buffer = (char *) malloc(msg_len);
|
||||||
|
serializeJson(root, buffer, msg_len);
|
||||||
|
jsonBuffer.clear();
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
@@ -188,4 +188,11 @@
|
|||||||
* Version Bump to 3.0.0.BETA1
|
* Version Bump to 3.0.0.BETA1
|
||||||
* further code changes
|
* further code changes
|
||||||
* bugfixes
|
* bugfixes
|
||||||
|
*
|
||||||
|
* 30 September 2019
|
||||||
|
* Version Bump to 3.1.0.ALPHA1
|
||||||
|
* further code changes
|
||||||
|
* removal of saving to EEPROM
|
||||||
|
* first integration of multi segments
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user