Version Bump to 3.0.0.ALPHA1
* removed LEGACY_ANIMATIONS * removed old Custom Animations from beginning of list. * added Custom Animation 'AutoPlay' with number 56 * added Custom Animation 'Custom WS' with number 57 * added Custom Animation 'TV' with number 58 * added Custom Animation 'E1.31' with number 59 * moved Custom Animation 'Fire2012' to number 60 * moved Custom Animation 'Gradients' to number 61 * REST-API changes (will be documented soon)
This commit is contained in:
+140
-178
@@ -59,7 +59,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ENABLE_E131)
|
#if defined(CUSTOM_WS2812FX_ANIMATIONS)
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
// Load libraries for E131 support
|
// Load libraries for E131 support
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
@@ -106,7 +106,7 @@ WebSocketsServer webSocket = WebSocketsServer(81);
|
|||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
// Load and instanciate WS2812FX library
|
// Load and instanciate WS2812FX library
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
#include <WS2812FX.h> // https://github.com/kitesurfer1404/WS2812FX
|
#include "WS2812FX.h" // https://github.com/kitesurfer1404/WS2812FX
|
||||||
WS2812FX * strip = NULL;
|
WS2812FX * strip = NULL;
|
||||||
|
|
||||||
#if defined(USE_WS2812FX_DMA)
|
#if defined(USE_WS2812FX_DMA)
|
||||||
@@ -250,19 +250,10 @@ void saveConfigCallback () {
|
|||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
#include "request_handlers.h"
|
#include "request_handlers.h"
|
||||||
|
|
||||||
#if defined(ENABLE_TV)
|
|
||||||
// ***************************************************************************
|
|
||||||
// Include: TV mode
|
|
||||||
// ***************************************************************************
|
|
||||||
#include "mode_tv.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CUSTOM_WS2812FX_ANIMATIONS)
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
// Include: Custom animations
|
// Include: Custom animations
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
#include "mode_custom_ws2812fx_animations.h" // Add animations in this file
|
#include "mode_custom_ws2812fx_animations.h" // Add animations in this file
|
||||||
#endif
|
|
||||||
|
|
||||||
// function to Initialize the strip
|
// function to Initialize the strip
|
||||||
void initStrip(uint16_t stripSize = WS2812FXStripSettings.stripSize, char RGBOrder[5] = WS2812FXStripSettings.RGBOrder, uint8_t pin = WS2812FXStripSettings.pin, uint8_t fxoptions = WS2812FXStripSettings.fxoptions ){
|
void initStrip(uint16_t stripSize = WS2812FXStripSettings.stripSize, char RGBOrder[5] = WS2812FXStripSettings.RGBOrder, uint8_t pin = WS2812FXStripSettings.pin, uint8_t fxoptions = WS2812FXStripSettings.fxoptions ){
|
||||||
@@ -279,9 +270,7 @@ void initStrip(uint16_t stripSize = WS2812FXStripSettings.stripSize, char RGBOrd
|
|||||||
WS2812FXStripSettings.pin = pin;
|
WS2812FXStripSettings.pin = pin;
|
||||||
WS2812FXStripSettings.fxoptions = fxoptions;
|
WS2812FXStripSettings.fxoptions = fxoptions;
|
||||||
}
|
}
|
||||||
#if defined(ENABLE_E131)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
if (ledstates != NULL) {
|
if (ledstates != NULL) {
|
||||||
delete(ledstates);
|
delete(ledstates);
|
||||||
}
|
}
|
||||||
@@ -310,13 +299,16 @@ 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(0, 0, stripSize - 1, ws2812fx_mode, hex_colors, convertSpeed(ws2812fx_speed), fxoptions);
|
strip->setSegment(selected_segment, 0, stripSize - 1, ws2812fx_mode, hex_colors_trans, convertSpeed(ws2812fx_speed), fxoptions);
|
||||||
|
strip->setCustomMode(0, F("Autoplay"), myCustomEffect0);
|
||||||
|
strip->setCustomMode(1, F("Custom WS"), myCustomEffect1);
|
||||||
#if defined(CUSTOM_WS2812FX_ANIMATIONS)
|
#if defined(CUSTOM_WS2812FX_ANIMATIONS)
|
||||||
strip->setCustomMode(0, F("Fire 2012"), myCustomEffect0);
|
strip->setCustomMode(2, F("TV"), myCustomEffect2);
|
||||||
strip->setCustomMode(1, F("Gradient"), myCustomEffect1);
|
strip->setCustomMode(3, F("E1.31"), myCustomEffect3);
|
||||||
|
strip->setCustomMode(4, F("Fire 2012"), myCustomEffect4);
|
||||||
|
strip->setCustomMode(5, F("Gradient"), myCustomEffect5);
|
||||||
gReverseDirection = (WS2812FXStripSettings.fxoptions & 128);
|
gReverseDirection = (WS2812FXStripSettings.fxoptions & 128);
|
||||||
#endif
|
|
||||||
#if defined(ENABLE_E131)
|
|
||||||
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);
|
||||||
float universe_leds = 170.0; // a universe has only 512 (0..511) channels: 3*170 or 4*128 <= 512
|
float universe_leds = 170.0; // a universe has only 512 (0..511) channels: 3*170 or 4*128 <= 512
|
||||||
@@ -559,15 +551,15 @@ void setup() {
|
|||||||
(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
|
#endif
|
||||||
#if ENABLE_STATE_SAVE == 0
|
#if ENABLE_STATE_SAVE == 0
|
||||||
char last_conf[223];
|
char last_conf[225];
|
||||||
DBG_OUTPUT_PORT.println("Saving WiFiManager config");
|
DBG_OUTPUT_PORT.println("Saving WiFiManager config");
|
||||||
#if defined(ENABLE_MQTT)
|
#if defined(ENABLE_MQTT)
|
||||||
snprintf(last_conf, sizeof(last_conf), "CNF|%64s|%64s|%5d|%32s|%32s|%4d|%2d|%4s|%3d", HOSTNAME, mqtt_host, mqtt_port, mqtt_user, mqtt_pass, WS2812FXStripSettings.stripSize, WS2812FXStripSettings.pin, WS2812FXStripSettings.RGBOrder, WS2812FXStripSettings.fxoptions);
|
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
|
#else
|
||||||
snprintf(last_conf, sizeof(last_conf), "CNF|%64s|%64s|%5d|%32s|%32s|%4d|%2d|%4s|%3d", HOSTNAME, "", "", "", "", WS2812FXStripSettings.stripSize, WS2812FXStripSettings.pin, WS2812FXStripSettings.RGBOrder, WS2812FXStripSettings.fxoptions);
|
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
|
#endif
|
||||||
last_conf[sizeof(last_conf)] = 0x00;
|
last_conf[sizeof(last_conf)] = 0x00;
|
||||||
writeEEPROM(0, 222, last_conf);
|
writeEEPROM(0, 224, last_conf);
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
updateConfig = false;
|
updateConfig = false;
|
||||||
#endif
|
#endif
|
||||||
@@ -681,9 +673,12 @@ void setup() {
|
|||||||
#endif
|
#endif
|
||||||
snprintf(last_state, sizeof(last_state), "STA|%2d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d", mode, ws2812fx_mode, ws2812fx_speed, brightness, main_color.red, main_color.green, main_color.blue, main_color.white, back_color.red, back_color.green, back_color.blue, back_color.white, xtra_color.red, xtra_color.green, xtra_color.blue,xtra_color.white);
|
snprintf(last_state, sizeof(last_state), "STA|%2d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|%3d", mode, ws2812fx_mode, ws2812fx_speed, brightness, main_color.red, main_color.green, main_color.blue, main_color.white, back_color.red, back_color.green, back_color.blue, back_color.white, xtra_color.red, xtra_color.green, xtra_color.blue,xtra_color.white);
|
||||||
last_state[sizeof(last_state)]= 0x00;
|
last_state[sizeof(last_state)]= 0x00;
|
||||||
DBG_OUTPUT_PORT.println("finished Main Setup!");
|
ws2812fx_speed_actual = ws2812fx_speed;
|
||||||
|
brightness_trans = brightness;
|
||||||
|
memcpy(hex_colors, hex_colors_trans, sizeof(hex_colors_trans));
|
||||||
initStrip();
|
initStrip();
|
||||||
|
strip->setBrightness(0);
|
||||||
|
DBG_OUTPUT_PORT.println("finished Main Setup!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
@@ -741,81 +736,38 @@ void loop() {
|
|||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
// Simple statemachine that handles the different modes
|
// Simple statemachine that handles the different modes
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
if ((mode != OFF) && (mode != TV) && (mode != E131)) { // strip->start() is only needed for modes with WS2812FX functionality
|
if ((mode == OFF) && ((strip->getBrightness() == 0) || !transEffect)) {
|
||||||
if(!strip->isRunning()) strip->start();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (((mode == OFF) && (brightness_actual == 0)) || (mode == TV) || (mode == E131)) {
|
|
||||||
if(strip->isRunning()) {
|
if(strip->isRunning()) {
|
||||||
strip->strip_off(); // Workaround: to be shure,
|
strip->strip_off(); // Workaround: to be shure,
|
||||||
delay(10); // that strip is really off. Sometimes strip->stop isn't enought
|
delay(10); // that strip is really off. Sometimes strip->stop isn't enought
|
||||||
strip->stop(); // should clear memory
|
strip->stop(); // should clear memory
|
||||||
|
autoCount = 0;
|
||||||
|
autoDelay = 0;
|
||||||
} else {
|
} else {
|
||||||
if (prevmode != mode) { // Start temporarily to clear strip
|
if (prevmode != mode) { // Start temporarily to clear strip
|
||||||
strip->start();
|
strip->start();
|
||||||
strip->strip_off(); // Workaround: to be shure,
|
strip->strip_off(); // Workaround: to be shure,
|
||||||
delay(10); // that strip is really off. Sometimes strip->stop isn't enought
|
delay(10); // that strip is really off. Sometimes strip->stop isn't enought
|
||||||
strip->stop(); // should clear memory
|
strip->stop(); // should clear memory
|
||||||
|
autoCount = 0;
|
||||||
|
autoDelay = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (( mode == AUTO) || (mode == HOLD) || ((mode == OFF) && (brightness !=0))) {
|
|
||||||
strip->service(); // strip->service() is only needed for modes with WS2812FX functionality
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((prevmode == AUTO) && (mode != AUTO)) {
|
|
||||||
handleAutoStop(); // stop auto mode
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mode == OFF) {
|
if (mode == OFF) {
|
||||||
if (prevmode != mode) {
|
if (prevmode != mode) {
|
||||||
#if defined(ENABLE_MQTT)
|
#if defined(ENABLE_MQTT)
|
||||||
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK =off", "");
|
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK =off", "");
|
||||||
#endif
|
#endif
|
||||||
if (fadeEffect) {
|
if (transEffect) {
|
||||||
brightness_fade = 0;
|
brightness_trans = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode == AUTO) {
|
|
||||||
if (prevmode != mode) {
|
|
||||||
brightness_fade = brightness;
|
|
||||||
handleAutoStart();
|
|
||||||
#if defined(ENABLE_MQTT)
|
|
||||||
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK =auto", "");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(ENABLE_TV)
|
|
||||||
if (mode == TV) {
|
|
||||||
if (prevmode != mode) {
|
|
||||||
brightness_fade = brightness;
|
|
||||||
#if defined(ENABLE_MQTT)
|
|
||||||
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK =tv", "");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
handleTV();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ENABLE_E131)
|
|
||||||
if (mode == E131) {
|
|
||||||
if (prevmode != mode) {
|
|
||||||
brightness_fade = brightness;
|
|
||||||
#if defined(ENABLE_MQTT)
|
|
||||||
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK =e131", "");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
handleE131();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (mode == INIT_STRIP) {
|
if (mode == INIT_STRIP) {
|
||||||
mode = prevmode;
|
mode = prevmode;
|
||||||
//ws2812fx_mode = strip->getMode();
|
|
||||||
strip->strip_off();
|
strip->strip_off();
|
||||||
delay(10);
|
delay(10);
|
||||||
if(strip->isRunning()) strip->stop();
|
if(strip->isRunning()) strip->stop();
|
||||||
@@ -823,58 +775,34 @@ void loop() {
|
|||||||
prevmode = INIT_STRIP;
|
prevmode = INIT_STRIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode == SET_ALL) {
|
if (mode == SET) {
|
||||||
mode = prevmode;
|
mode = HOLD;
|
||||||
if ((prevmode == OFF) || (prevmode == AUTO) || (prevmode == TV) || (prevmode == E131)) {
|
if (ws2812fx_mode != strip->getMode(selected_segment)) { // SET_MODE
|
||||||
setModeByStateString(last_state);
|
|
||||||
}
|
|
||||||
#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->setMode(ws2812fx_mode);
|
strip->strip_off();
|
||||||
if (fade_cnt==0) { fade_cnt=1; }
|
autoCount = 0;
|
||||||
if (!fadeEffect) { fade_cnt=255; }
|
autoDelay = 0;
|
||||||
brightness_fade = brightness;
|
strip->setMode(selected_segment, ws2812fx_mode);
|
||||||
convertColors();
|
}
|
||||||
prevmode = SET_ALL;
|
if (strip->getBrightness() != brightness) {
|
||||||
|
#if defined(ENABLE_MQTT)
|
||||||
|
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK %%%i", brightness);
|
||||||
|
#endif
|
||||||
|
brightness_trans = brightness;
|
||||||
|
}
|
||||||
|
prevmode = SET;
|
||||||
strip->trigger();
|
strip->trigger();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode == SET_MODE) {
|
/*if (mode == SET) {
|
||||||
mode = HOLD;
|
mode = HOLD;
|
||||||
#if defined(ENABLE_MQTT)
|
if (trans_cnt==0) { trans_cnt=1; }
|
||||||
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK /%i", ws2812fx_mode);
|
if (!transEffect) { trans_cnt=255; }
|
||||||
#endif
|
convertColorsFade();
|
||||||
strip->setMode(ws2812fx_mode);
|
prevmode = SET;
|
||||||
brightness_fade = brightness;
|
}*/
|
||||||
prevmode = SET_MODE;
|
|
||||||
strip->trigger();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mode == SET_COLOR) {
|
|
||||||
if (fade_cnt==0) { fade_cnt=1; }
|
|
||||||
if (!fadeEffect) { fade_cnt=255; }
|
|
||||||
convertColors();
|
|
||||||
mode = prevmode;
|
|
||||||
prevmode = SET_COLOR;
|
|
||||||
}
|
|
||||||
// Async color transition
|
|
||||||
if ((fade_cnt > 0) && (fade_cnt < 254)) {
|
|
||||||
if ((fadeEffect) && (colorFadeDelay <= millis())) {
|
|
||||||
hex_colors_actual[0] = fade(hex_colors[0], hex_colors_mem[0], fade_cnt);
|
|
||||||
hex_colors_actual[1] = fade(hex_colors[1], hex_colors_mem[1], fade_cnt);
|
|
||||||
hex_colors_actual[2] = fade(hex_colors[2], hex_colors_mem[2], fade_cnt);
|
|
||||||
fade_cnt++;
|
|
||||||
colorFadeDelay = millis() + FADE_COLOR_DELAY;
|
|
||||||
strip->setColors(0, hex_colors_actual);
|
|
||||||
if ((mode == HOLD) && ((ws2812fx_mode != 1) && (ws2812fx_mode != 2) && (ws2812fx_mode != 8) && (ws2812fx_mode != 9) &&(ws2812fx_mode != 10) && (ws2812fx_mode != 15))) strip->trigger();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fade_cnt >= 254) {
|
|
||||||
strip->setColors(0, hex_colors);
|
|
||||||
if (mode == HOLD) strip->trigger();
|
|
||||||
fade_cnt = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mode == SET_SPEED) {
|
if (mode == SET_SPEED) {
|
||||||
#if defined(ENABLE_MQTT)
|
#if defined(ENABLE_MQTT)
|
||||||
@@ -883,57 +811,17 @@ void loop() {
|
|||||||
mode = prevmode;
|
mode = prevmode;
|
||||||
prevmode = SET_SPEED;
|
prevmode = SET_SPEED;
|
||||||
}
|
}
|
||||||
// Async speed transition
|
|
||||||
if (ws2812fx_speed_actual != ws2812fx_speed) {
|
|
||||||
if (fadeEffect) {
|
|
||||||
if (speedFadeDelay <= millis()) {
|
|
||||||
if (ws2812fx_speed_actual < ws2812fx_speed) {
|
|
||||||
ws2812fx_speed_actual++;
|
|
||||||
}
|
|
||||||
if (ws2812fx_speed_actual > ws2812fx_speed) {
|
|
||||||
ws2812fx_speed_actual--;
|
|
||||||
}
|
|
||||||
speedFadeDelay = millis() + FADE_DELAY;
|
|
||||||
strip->setSpeed(convertSpeed(ws2812fx_speed_actual));
|
|
||||||
if ((mode == HOLD) && ((ws2812fx_mode != 1) && (ws2812fx_mode != 2) && (ws2812fx_mode != 8) && (ws2812fx_mode != 9) &&(ws2812fx_mode != 10) && (ws2812fx_mode != 15))) strip->trigger();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ws2812fx_speed_actual = ws2812fx_speed;
|
|
||||||
strip->setSpeed(ws2812fx_speed);
|
|
||||||
if (mode == HOLD) strip->trigger();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mode == SET_BRIGHTNESS) {
|
|
||||||
#if defined(ENABLE_MQTT)
|
|
||||||
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK %%%i", brightness);
|
|
||||||
#endif
|
|
||||||
brightness_fade = brightness;
|
|
||||||
mode = prevmode;
|
|
||||||
prevmode = SET_BRIGHTNESS;
|
|
||||||
}
|
|
||||||
// Async brightness transition
|
|
||||||
if (brightness_actual != brightness_fade) {
|
|
||||||
if (fadeEffect) {
|
|
||||||
if(brightnessFadeDelay <= millis()) {
|
|
||||||
if (brightness_actual < brightness_fade) {
|
|
||||||
brightness_actual++;
|
|
||||||
}
|
|
||||||
if (brightness_actual > brightness_fade) {
|
|
||||||
brightness_actual--;
|
|
||||||
}
|
|
||||||
brightnessFadeDelay = millis() + FADE_DELAY;
|
|
||||||
strip->setBrightness(brightness_actual);
|
|
||||||
if ((mode == HOLD) && ((ws2812fx_mode != 1) && (ws2812fx_mode != 2) && (ws2812fx_mode != 8) && (ws2812fx_mode != 9) &&(ws2812fx_mode != 10) && (ws2812fx_mode != 15))) strip->trigger();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
brightness_actual = brightness;
|
|
||||||
strip->setBrightness(brightness_actual);
|
|
||||||
if (mode == HOLD) strip->trigger();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prevmode != mode) {
|
if (prevmode != mode) {
|
||||||
|
convertColors();
|
||||||
|
if (memcmp(hex_colors_trans, strip->getColors(selected_segment), sizeof(hex_colors_trans)) != 0) {
|
||||||
|
DBG_OUTPUT_PORT.println("Colors not equal!");
|
||||||
|
if (trans_cnt==0) { trans_cnt=1; }
|
||||||
|
if (!transEffect) { trans_cnt=255; }
|
||||||
|
convertColorsFade();
|
||||||
|
}
|
||||||
|
strip->setSpeed(selected_segment, convertSpeed(ws2812fx_speed_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)
|
||||||
if(!settings_save_state.active()) settings_save_state.once(3, tickerSaveState);
|
if(!settings_save_state.active()) settings_save_state.once(3, tickerSaveState);
|
||||||
@@ -970,21 +858,95 @@ void loop() {
|
|||||||
(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
|
#endif
|
||||||
#if ENABLE_STATE_SAVE == 0
|
#if ENABLE_STATE_SAVE == 0
|
||||||
char last_conf[223];
|
char last_conf[225];
|
||||||
#if defined(ENABLE_MQTT)
|
#if defined(ENABLE_MQTT)
|
||||||
snprintf(last_conf, sizeof(last_conf), "CNF|%64s|%64s|%5d|%32s|%32s|%4d|%2d|%4s|%3d", HOSTNAME, mqtt_host, mqtt_port, mqtt_user, mqtt_pass, WS2812FXStripSettings.stripSize, WS2812FXStripSettings.pin, WS2812FXStripSettings.RGBOrder, WS2812FXStripSettings.fxoptions);
|
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
|
#else
|
||||||
snprintf(last_conf, sizeof(last_conf), "CNF|%64s|%64s|%5d|%32s|%32s|%4d|%2d|%4s|%3d", HOSTNAME, "", "", "", "", WS2812FXStripSettings.stripSize, WS2812FXStripSettings.pin, WS2812FXStripSettings.RGBOrder, WS2812FXStripSettings.fxoptions);
|
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
|
#endif
|
||||||
last_conf[sizeof(last_conf) - 1] = 0x00;
|
last_conf[sizeof(last_conf) - 1] = 0x00;
|
||||||
writeEEPROM(0, 222, last_conf);
|
writeEEPROM(0, 224, last_conf);
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
updateConfig = false;
|
updateConfig = false;
|
||||||
settings_save_conf.detach();
|
settings_save_conf.detach();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if ((mode == HOLD) || ((mode == OFF) && ((strip->getBrightness() == 0) || !transEffect))) {
|
||||||
|
if (ws2812fx_mode == FX_MODE_CUSTOM_0) {
|
||||||
|
handleAutoPlay();
|
||||||
|
}
|
||||||
|
if(!strip->isRunning()) strip->start();
|
||||||
|
strip->service();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Async color transition
|
||||||
|
if ((trans_cnt > 0) && (trans_cnt < 255)) {
|
||||||
|
uint32_t hex_colors_actual[3] = {};
|
||||||
|
if ((transEffect) && (colorFadeDelay <= millis())) {
|
||||||
|
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[2] = trans(hex_colors_trans[2], hex_colors[2], trans_cnt);
|
||||||
|
strip->setColors(selected_segment, hex_colors_actual);
|
||||||
|
trans_cnt++;
|
||||||
|
colorFadeDelay = millis() + TRANS_COLOR_DELAY;
|
||||||
|
if (mode == HOLD) strip->trigger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (trans_cnt > 254) {
|
||||||
|
memcpy(hex_colors, hex_colors_trans, sizeof(hex_colors_trans));
|
||||||
|
strip->setColors(selected_segment, hex_colors);
|
||||||
|
if (mode == HOLD) strip->trigger();
|
||||||
|
trans_cnt = 0;
|
||||||
|
DBG_OUTPUT_PORT.println("Color transition finished!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Async speed transition
|
||||||
|
if (ws2812fx_speed_actual != ws2812fx_speed) {
|
||||||
|
if (transEffect) {
|
||||||
|
if (speedFadeDelay <= millis()) {
|
||||||
|
DBG_OUTPUT_PORT.println("Speed actual: ");
|
||||||
|
DBG_OUTPUT_PORT.println(ws2812fx_speed_actual);
|
||||||
|
DBG_OUTPUT_PORT.println(convertSpeed(ws2812fx_speed_actual));
|
||||||
|
DBG_OUTPUT_PORT.println(unconvertSpeed(convertSpeed(ws2812fx_speed_actual)));
|
||||||
|
if (ws2812fx_speed_actual < ws2812fx_speed) {
|
||||||
|
ws2812fx_speed_actual++;
|
||||||
|
}
|
||||||
|
if (ws2812fx_speed_actual > ws2812fx_speed) {
|
||||||
|
ws2812fx_speed_actual--;
|
||||||
|
}
|
||||||
|
speedFadeDelay = millis() + TRANS_DELAY;
|
||||||
|
strip->setSpeed(selected_segment, convertSpeed(ws2812fx_speed_actual));
|
||||||
|
if (mode == HOLD) strip->trigger();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ws2812fx_speed_actual = ws2812fx_speed;
|
||||||
|
strip->setSpeed(selected_segment, convertSpeed(ws2812fx_speed_actual));
|
||||||
|
if (mode == HOLD) strip->trigger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Async brightness transition
|
||||||
|
if (strip->getBrightness() != brightness_trans) {
|
||||||
|
if (transEffect) {
|
||||||
|
if(brightnessFadeDelay <= millis()) {
|
||||||
|
if (strip->getBrightness() < brightness_trans) {
|
||||||
|
strip->increaseBrightness(1);
|
||||||
|
}
|
||||||
|
if (strip->getBrightness() > brightness_trans) {
|
||||||
|
strip->decreaseBrightness(1);
|
||||||
|
}
|
||||||
|
brightnessFadeDelay = millis() + TRANS_DELAY;
|
||||||
|
//if (mode == HOLD) strip->trigger();
|
||||||
|
strip->trigger();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
strip->setBrightness(brightness);
|
||||||
|
if (mode == HOLD) strip->trigger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
prevmode = mode;
|
prevmode = mode;
|
||||||
|
|
||||||
#if defined(ENABLE_REMOTE)
|
#if defined(ENABLE_REMOTE)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,650 @@
|
|||||||
|
/*
|
||||||
|
WS2812FX.h - Library for WS2812 LED effects.
|
||||||
|
|
||||||
|
Harm Aldick - 2016
|
||||||
|
www.aldick.org
|
||||||
|
FEATURES
|
||||||
|
* A lot of blinken modes and counting
|
||||||
|
* WS2812FX can be used as drop-in replacement for Adafruit NeoPixel Library
|
||||||
|
NOTES
|
||||||
|
* Uses the Adafruit NeoPixel library. Get it here:
|
||||||
|
https://github.com/adafruit/Adafruit_NeoPixel
|
||||||
|
LICENSE
|
||||||
|
The MIT License (MIT)
|
||||||
|
Copyright (c) 2016 Harm Aldick
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
CHANGELOG
|
||||||
|
2016-05-28 Initial beta release
|
||||||
|
2016-06-03 Code cleanup, minor improvements, new modes
|
||||||
|
2016-06-04 2 new fx, fixed setColor (now also resets _mode_color)
|
||||||
|
2017-02-02 added external trigger functionality (e.g. for sound-to-light)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef WS2812FX_h
|
||||||
|
#define WS2812FX_h
|
||||||
|
|
||||||
|
#define FSH(x) (__FlashStringHelper*)(x)
|
||||||
|
|
||||||
|
#include <Adafruit_NeoPixel.h>
|
||||||
|
|
||||||
|
#define DEFAULT_BRIGHTNESS (uint8_t)50
|
||||||
|
#define DEFAULT_MODE (uint8_t)0
|
||||||
|
#define DEFAULT_SPEED (uint16_t)1000
|
||||||
|
#define DEFAULT_COLOR (uint32_t)0xFF0000
|
||||||
|
|
||||||
|
#if defined(ESP8266) || defined(ESP32)
|
||||||
|
//#pragma message("Compiling for ESP")
|
||||||
|
#define SPEED_MIN (uint16_t)2
|
||||||
|
#else
|
||||||
|
//#pragma message("Compiling for Arduino")
|
||||||
|
#define SPEED_MIN (uint16_t)10
|
||||||
|
#endif
|
||||||
|
#define SPEED_MAX (uint16_t)65535
|
||||||
|
|
||||||
|
#define BRIGHTNESS_MIN (uint8_t)0
|
||||||
|
#define BRIGHTNESS_MAX (uint8_t)255
|
||||||
|
|
||||||
|
/* each segment uses 36 bytes of SRAM memory, so if you're application fails because of
|
||||||
|
insufficient memory, decreasing MAX_NUM_SEGMENTS may help */
|
||||||
|
#define MAX_NUM_SEGMENTS 10
|
||||||
|
#define NUM_COLORS 3 /* number of colors per segment */
|
||||||
|
#define MAX_CUSTOM_MODES 10
|
||||||
|
#define SEGMENT _segments[_segment_index]
|
||||||
|
#define SEGMENT_RUNTIME _segment_runtimes[_segment_index]
|
||||||
|
#define SEGMENT_LENGTH (SEGMENT.stop - SEGMENT.start + 1)
|
||||||
|
|
||||||
|
// some common colors
|
||||||
|
#define RED (uint32_t)0xFF0000
|
||||||
|
#define GREEN (uint32_t)0x00FF00
|
||||||
|
#define BLUE (uint32_t)0x0000FF
|
||||||
|
#define WHITE (uint32_t)0xFFFFFF
|
||||||
|
#define BLACK (uint32_t)0x000000
|
||||||
|
#define YELLOW (uint32_t)0xFFFF00
|
||||||
|
#define CYAN (uint32_t)0x00FFFF
|
||||||
|
#define MAGENTA (uint32_t)0xFF00FF
|
||||||
|
#define PURPLE (uint32_t)0x400080
|
||||||
|
#define ORANGE (uint32_t)0xFF3000
|
||||||
|
#define PINK (uint32_t)0xFF1493
|
||||||
|
#define ULTRAWHITE (uint32_t)0xFFFFFFFF
|
||||||
|
#define DARK(c) (uint32_t)((c >> 4) & 0x0f0f0f0f)
|
||||||
|
|
||||||
|
// segment options
|
||||||
|
// bit 7: reverse animation
|
||||||
|
// bits 4-6: fade rate (0-7)
|
||||||
|
// bit 3: gamma correction
|
||||||
|
// bits 1-2: size
|
||||||
|
// bits 0: TBD
|
||||||
|
#define NO_OPTIONS (uint8_t)B00000000
|
||||||
|
#define REVERSE (uint8_t)B10000000
|
||||||
|
#define IS_REVERSE ((SEGMENT.options & REVERSE) == REVERSE)
|
||||||
|
#define FADE_XFAST (uint8_t)B00010000
|
||||||
|
#define FADE_FAST (uint8_t)B00100000
|
||||||
|
#define FADE_MEDIUM (uint8_t)B00110000
|
||||||
|
#define FADE_SLOW (uint8_t)B01000000
|
||||||
|
#define FADE_XSLOW (uint8_t)B01010000
|
||||||
|
#define FADE_XXSLOW (uint8_t)B01100000
|
||||||
|
#define FADE_GLACIAL (uint8_t)B01110000
|
||||||
|
#define FADE_RATE ((SEGMENT.options >> 4) & 7)
|
||||||
|
#define GAMMA (uint8_t)B00001000
|
||||||
|
#define IS_GAMMA ((SEGMENT.options & GAMMA) == GAMMA)
|
||||||
|
#define SIZE_SMALL (uint8_t)B00000000
|
||||||
|
#define SIZE_MEDIUM (uint8_t)B00000010
|
||||||
|
#define SIZE_LARGE (uint8_t)B00000100
|
||||||
|
#define SIZE_XLARGE (uint8_t)B00000110
|
||||||
|
#define SIZE_OPTION ((SEGMENT.options >> 1) & 3)
|
||||||
|
|
||||||
|
// segment runtime options (aux_param2)
|
||||||
|
#define FRAME (uint8_t)B10000000
|
||||||
|
#define SET_FRAME (SEGMENT_RUNTIME.aux_param2 |= FRAME)
|
||||||
|
#define CLR_FRAME (SEGMENT_RUNTIME.aux_param2 &= ~FRAME)
|
||||||
|
#define CYCLE (uint8_t)B01000000
|
||||||
|
#define SET_CYCLE (SEGMENT_RUNTIME.aux_param2 |= CYCLE)
|
||||||
|
#define CLR_CYCLE (SEGMENT_RUNTIME.aux_param2 &= ~CYCLE)
|
||||||
|
|
||||||
|
#define MODE_COUNT (sizeof(_names)/sizeof(_names[0]))
|
||||||
|
|
||||||
|
#define FX_MODE_STATIC 0
|
||||||
|
#define FX_MODE_BLINK 1
|
||||||
|
#define FX_MODE_BREATH 2
|
||||||
|
#define FX_MODE_COLOR_WIPE 3
|
||||||
|
#define FX_MODE_COLOR_WIPE_INV 4
|
||||||
|
#define FX_MODE_COLOR_WIPE_REV 5
|
||||||
|
#define FX_MODE_COLOR_WIPE_REV_INV 6
|
||||||
|
#define FX_MODE_COLOR_WIPE_RANDOM 7
|
||||||
|
#define FX_MODE_RANDOM_COLOR 8
|
||||||
|
#define FX_MODE_SINGLE_DYNAMIC 9
|
||||||
|
#define FX_MODE_MULTI_DYNAMIC 10
|
||||||
|
#define FX_MODE_RAINBOW 11
|
||||||
|
#define FX_MODE_RAINBOW_CYCLE 12
|
||||||
|
#define FX_MODE_SCAN 13
|
||||||
|
#define FX_MODE_DUAL_SCAN 14
|
||||||
|
#define FX_MODE_FADE 15
|
||||||
|
#define FX_MODE_THEATER_CHASE 16
|
||||||
|
#define FX_MODE_THEATER_CHASE_RAINBOW 17
|
||||||
|
#define FX_MODE_RUNNING_LIGHTS 18
|
||||||
|
#define FX_MODE_TWINKLE 19
|
||||||
|
#define FX_MODE_TWINKLE_RANDOM 20
|
||||||
|
#define FX_MODE_TWINKLE_FADE 21
|
||||||
|
#define FX_MODE_TWINKLE_FADE_RANDOM 22
|
||||||
|
#define FX_MODE_SPARKLE 23
|
||||||
|
#define FX_MODE_FLASH_SPARKLE 24
|
||||||
|
#define FX_MODE_HYPER_SPARKLE 25
|
||||||
|
#define FX_MODE_STROBE 26
|
||||||
|
#define FX_MODE_STROBE_RAINBOW 27
|
||||||
|
#define FX_MODE_MULTI_STROBE 28
|
||||||
|
#define FX_MODE_BLINK_RAINBOW 29
|
||||||
|
#define FX_MODE_CHASE_WHITE 30
|
||||||
|
#define FX_MODE_CHASE_COLOR 31
|
||||||
|
#define FX_MODE_CHASE_RANDOM 32
|
||||||
|
#define FX_MODE_CHASE_RAINBOW 33
|
||||||
|
#define FX_MODE_CHASE_FLASH 34
|
||||||
|
#define FX_MODE_CHASE_FLASH_RANDOM 35
|
||||||
|
#define FX_MODE_CHASE_RAINBOW_WHITE 36
|
||||||
|
#define FX_MODE_CHASE_BLACKOUT 37
|
||||||
|
#define FX_MODE_CHASE_BLACKOUT_RAINBOW 38
|
||||||
|
#define FX_MODE_COLOR_SWEEP_RANDOM 39
|
||||||
|
#define FX_MODE_RUNNING_COLOR 40
|
||||||
|
#define FX_MODE_RUNNING_RED_BLUE 41
|
||||||
|
#define FX_MODE_RUNNING_RANDOM 42
|
||||||
|
#define FX_MODE_LARSON_SCANNER 43
|
||||||
|
#define FX_MODE_COMET 44
|
||||||
|
#define FX_MODE_FIREWORKS 45
|
||||||
|
#define FX_MODE_FIREWORKS_RANDOM 46
|
||||||
|
#define FX_MODE_MERRY_CHRISTMAS 47
|
||||||
|
#define FX_MODE_FIRE_FLICKER 48
|
||||||
|
#define FX_MODE_FIRE_FLICKER_SOFT 49
|
||||||
|
#define FX_MODE_FIRE_FLICKER_INTENSE 50
|
||||||
|
#define FX_MODE_CIRCUS_COMBUSTUS 51
|
||||||
|
#define FX_MODE_HALLOWEEN 52
|
||||||
|
#define FX_MODE_BICOLOR_CHASE 53
|
||||||
|
#define FX_MODE_TRICOLOR_CHASE 54
|
||||||
|
#define FX_MODE_ICU 55
|
||||||
|
#define FX_MODE_CUSTOM 56 // keep this for backward compatiblity
|
||||||
|
#define FX_MODE_CUSTOM_0 56 // custom modes need to go at the end
|
||||||
|
#define FX_MODE_CUSTOM_1 57
|
||||||
|
#define FX_MODE_CUSTOM_2 58
|
||||||
|
#define FX_MODE_CUSTOM_3 59
|
||||||
|
#define FX_MODE_CUSTOM_4 60
|
||||||
|
#define FX_MODE_CUSTOM_5 61
|
||||||
|
#define FX_MODE_CUSTOM_6 62
|
||||||
|
#define FX_MODE_CUSTOM_7 63
|
||||||
|
#define FX_MODE_CUSTOM_8 64
|
||||||
|
#define FX_MODE_CUSTOM_9 65
|
||||||
|
|
||||||
|
// create GLOBAL names to allow WS2812FX to compile with sketches and other libs that store strings
|
||||||
|
// in PROGMEM (get rid of the "section type conflict with __c" errors once and for all. Amen.)
|
||||||
|
const char name_0[] PROGMEM = "Static";
|
||||||
|
const char name_1[] PROGMEM = "Blink";
|
||||||
|
const char name_2[] PROGMEM = "Breath";
|
||||||
|
const char name_3[] PROGMEM = "Color Wipe";
|
||||||
|
const char name_4[] PROGMEM = "Color Wipe Inverse";
|
||||||
|
const char name_5[] PROGMEM = "Color Wipe Reverse";
|
||||||
|
const char name_6[] PROGMEM = "Color Wipe Reverse Inverse";
|
||||||
|
const char name_7[] PROGMEM = "Color Wipe Random";
|
||||||
|
const char name_8[] PROGMEM = "Random Color";
|
||||||
|
const char name_9[] PROGMEM = "Single Dynamic";
|
||||||
|
const char name_10[] PROGMEM = "Multi Dynamic";
|
||||||
|
const char name_11[] PROGMEM = "Rainbow";
|
||||||
|
const char name_12[] PROGMEM = "Rainbow Cycle";
|
||||||
|
const char name_13[] PROGMEM = "Scan";
|
||||||
|
const char name_14[] PROGMEM = "Dual Scan";
|
||||||
|
const char name_15[] PROGMEM = "Fade";
|
||||||
|
const char name_16[] PROGMEM = "Theater Chase";
|
||||||
|
const char name_17[] PROGMEM = "Theater Chase Rainbow";
|
||||||
|
const char name_18[] PROGMEM = "Running Lights";
|
||||||
|
const char name_19[] PROGMEM = "Twinkle";
|
||||||
|
const char name_20[] PROGMEM = "Twinkle Random";
|
||||||
|
const char name_21[] PROGMEM = "Twinkle Fade";
|
||||||
|
const char name_22[] PROGMEM = "Twinkle Fade Random";
|
||||||
|
const char name_23[] PROGMEM = "Sparkle";
|
||||||
|
const char name_24[] PROGMEM = "Flash Sparkle";
|
||||||
|
const char name_25[] PROGMEM = "Hyper Sparkle";
|
||||||
|
const char name_26[] PROGMEM = "Strobe";
|
||||||
|
const char name_27[] PROGMEM = "Strobe Rainbow";
|
||||||
|
const char name_28[] PROGMEM = "Multi Strobe";
|
||||||
|
const char name_29[] PROGMEM = "Blink Rainbow";
|
||||||
|
const char name_30[] PROGMEM = "Chase White";
|
||||||
|
const char name_31[] PROGMEM = "Chase Color";
|
||||||
|
const char name_32[] PROGMEM = "Chase Random";
|
||||||
|
const char name_33[] PROGMEM = "Chase Rainbow";
|
||||||
|
const char name_34[] PROGMEM = "Chase Flash";
|
||||||
|
const char name_35[] PROGMEM = "Chase Flash Random";
|
||||||
|
const char name_36[] PROGMEM = "Chase Rainbow White";
|
||||||
|
const char name_37[] PROGMEM = "Chase Blackout";
|
||||||
|
const char name_38[] PROGMEM = "Chase Blackout Rainbow";
|
||||||
|
const char name_39[] PROGMEM = "Color Sweep Random";
|
||||||
|
const char name_40[] PROGMEM = "Running Color";
|
||||||
|
const char name_41[] PROGMEM = "Running Red Blue";
|
||||||
|
const char name_42[] PROGMEM = "Running Random";
|
||||||
|
const char name_43[] PROGMEM = "Larson Scanner";
|
||||||
|
const char name_44[] PROGMEM = "Comet";
|
||||||
|
const char name_45[] PROGMEM = "Fireworks";
|
||||||
|
const char name_46[] PROGMEM = "Fireworks Random";
|
||||||
|
const char name_47[] PROGMEM = "Merry Christmas";
|
||||||
|
const char name_48[] PROGMEM = "Fire Flicker";
|
||||||
|
const char name_49[] PROGMEM = "Fire Flicker (soft)";
|
||||||
|
const char name_50[] PROGMEM = "Fire Flicker (intense)";
|
||||||
|
const char name_51[] PROGMEM = "Circus Combustus";
|
||||||
|
const char name_52[] PROGMEM = "Halloween";
|
||||||
|
const char name_53[] PROGMEM = "Bicolor Chase";
|
||||||
|
const char name_54[] PROGMEM = "Tricolor Chase";
|
||||||
|
const char name_55[] PROGMEM = "ICU";
|
||||||
|
const char name_56[] PROGMEM = "Custom 0"; // custom modes need to go at the end
|
||||||
|
const char name_57[] PROGMEM = "Custom 1";
|
||||||
|
const char name_58[] PROGMEM = "Custom 2";
|
||||||
|
const char name_59[] PROGMEM = "Custom 3";
|
||||||
|
const char name_60[] PROGMEM = "Custom 4";
|
||||||
|
const char name_61[] PROGMEM = "Custom 5";
|
||||||
|
const char name_62[] PROGMEM = "Custom 6";
|
||||||
|
const char name_63[] PROGMEM = "Custom 7";
|
||||||
|
const char name_64[] PROGMEM = "Custom 8";
|
||||||
|
const char name_65[] PROGMEM = "Custom 9";
|
||||||
|
|
||||||
|
static const __FlashStringHelper* _names[] = {
|
||||||
|
FSH(name_0),
|
||||||
|
FSH(name_1),
|
||||||
|
FSH(name_2),
|
||||||
|
FSH(name_3),
|
||||||
|
FSH(name_4),
|
||||||
|
FSH(name_5),
|
||||||
|
FSH(name_6),
|
||||||
|
FSH(name_7),
|
||||||
|
FSH(name_8),
|
||||||
|
FSH(name_9),
|
||||||
|
FSH(name_10),
|
||||||
|
FSH(name_11),
|
||||||
|
FSH(name_12),
|
||||||
|
FSH(name_13),
|
||||||
|
FSH(name_14),
|
||||||
|
FSH(name_15),
|
||||||
|
FSH(name_16),
|
||||||
|
FSH(name_17),
|
||||||
|
FSH(name_18),
|
||||||
|
FSH(name_19),
|
||||||
|
FSH(name_20),
|
||||||
|
FSH(name_21),
|
||||||
|
FSH(name_22),
|
||||||
|
FSH(name_23),
|
||||||
|
FSH(name_24),
|
||||||
|
FSH(name_25),
|
||||||
|
FSH(name_26),
|
||||||
|
FSH(name_27),
|
||||||
|
FSH(name_28),
|
||||||
|
FSH(name_29),
|
||||||
|
FSH(name_30),
|
||||||
|
FSH(name_31),
|
||||||
|
FSH(name_32),
|
||||||
|
FSH(name_33),
|
||||||
|
FSH(name_34),
|
||||||
|
FSH(name_35),
|
||||||
|
FSH(name_36),
|
||||||
|
FSH(name_37),
|
||||||
|
FSH(name_38),
|
||||||
|
FSH(name_39),
|
||||||
|
FSH(name_40),
|
||||||
|
FSH(name_41),
|
||||||
|
FSH(name_42),
|
||||||
|
FSH(name_43),
|
||||||
|
FSH(name_44),
|
||||||
|
FSH(name_45),
|
||||||
|
FSH(name_46),
|
||||||
|
FSH(name_47),
|
||||||
|
FSH(name_48),
|
||||||
|
FSH(name_49),
|
||||||
|
FSH(name_50),
|
||||||
|
FSH(name_51),
|
||||||
|
FSH(name_52),
|
||||||
|
FSH(name_53),
|
||||||
|
FSH(name_54),
|
||||||
|
FSH(name_55),
|
||||||
|
FSH(name_56),
|
||||||
|
FSH(name_57),
|
||||||
|
FSH(name_58),
|
||||||
|
FSH(name_59),
|
||||||
|
FSH(name_60),
|
||||||
|
FSH(name_61),
|
||||||
|
FSH(name_62),
|
||||||
|
FSH(name_63),
|
||||||
|
FSH(name_64),
|
||||||
|
FSH(name_65)
|
||||||
|
};
|
||||||
|
|
||||||
|
class WS2812FX : public Adafruit_NeoPixel {
|
||||||
|
|
||||||
|
typedef uint16_t (WS2812FX::*mode_ptr)(void);
|
||||||
|
|
||||||
|
// segment parameters
|
||||||
|
public:
|
||||||
|
typedef struct Segment { // 20 bytes
|
||||||
|
uint16_t start;
|
||||||
|
uint16_t stop;
|
||||||
|
uint16_t speed;
|
||||||
|
uint8_t mode;
|
||||||
|
uint8_t options;
|
||||||
|
uint32_t colors[NUM_COLORS];
|
||||||
|
} segment;
|
||||||
|
|
||||||
|
// segment runtime parameters
|
||||||
|
typedef struct Segment_runtime { // 16 bytes
|
||||||
|
unsigned long next_time;
|
||||||
|
uint32_t counter_mode_step;
|
||||||
|
uint32_t counter_mode_call;
|
||||||
|
uint8_t aux_param; // auxilary param (usually stores a color_wheel index)
|
||||||
|
uint8_t aux_param2; // auxilary param (usually stores bitwise options)
|
||||||
|
uint16_t aux_param3; // auxilary param (usually stores a segment index)
|
||||||
|
} segment_runtime;
|
||||||
|
|
||||||
|
WS2812FX(uint16_t n, uint8_t p, neoPixelType t) : Adafruit_NeoPixel(n, p, t) {
|
||||||
|
_mode[FX_MODE_STATIC] = &WS2812FX::mode_static;
|
||||||
|
_mode[FX_MODE_BLINK] = &WS2812FX::mode_blink;
|
||||||
|
_mode[FX_MODE_COLOR_WIPE] = &WS2812FX::mode_color_wipe;
|
||||||
|
_mode[FX_MODE_COLOR_WIPE_INV] = &WS2812FX::mode_color_wipe_inv;
|
||||||
|
_mode[FX_MODE_COLOR_WIPE_REV] = &WS2812FX::mode_color_wipe_rev;
|
||||||
|
_mode[FX_MODE_COLOR_WIPE_REV_INV] = &WS2812FX::mode_color_wipe_rev_inv;
|
||||||
|
_mode[FX_MODE_COLOR_WIPE_RANDOM] = &WS2812FX::mode_color_wipe_random;
|
||||||
|
_mode[FX_MODE_RANDOM_COLOR] = &WS2812FX::mode_random_color;
|
||||||
|
_mode[FX_MODE_SINGLE_DYNAMIC] = &WS2812FX::mode_single_dynamic;
|
||||||
|
_mode[FX_MODE_MULTI_DYNAMIC] = &WS2812FX::mode_multi_dynamic;
|
||||||
|
_mode[FX_MODE_RAINBOW] = &WS2812FX::mode_rainbow;
|
||||||
|
_mode[FX_MODE_RAINBOW_CYCLE] = &WS2812FX::mode_rainbow_cycle;
|
||||||
|
_mode[FX_MODE_SCAN] = &WS2812FX::mode_scan;
|
||||||
|
_mode[FX_MODE_DUAL_SCAN] = &WS2812FX::mode_dual_scan;
|
||||||
|
_mode[FX_MODE_FADE] = &WS2812FX::mode_fade;
|
||||||
|
_mode[FX_MODE_THEATER_CHASE] = &WS2812FX::mode_theater_chase;
|
||||||
|
_mode[FX_MODE_THEATER_CHASE_RAINBOW] = &WS2812FX::mode_theater_chase_rainbow;
|
||||||
|
_mode[FX_MODE_TWINKLE] = &WS2812FX::mode_twinkle;
|
||||||
|
_mode[FX_MODE_TWINKLE_RANDOM] = &WS2812FX::mode_twinkle_random;
|
||||||
|
_mode[FX_MODE_TWINKLE_FADE] = &WS2812FX::mode_twinkle_fade;
|
||||||
|
_mode[FX_MODE_TWINKLE_FADE_RANDOM] = &WS2812FX::mode_twinkle_fade_random;
|
||||||
|
_mode[FX_MODE_SPARKLE] = &WS2812FX::mode_sparkle;
|
||||||
|
_mode[FX_MODE_FLASH_SPARKLE] = &WS2812FX::mode_flash_sparkle;
|
||||||
|
_mode[FX_MODE_HYPER_SPARKLE] = &WS2812FX::mode_hyper_sparkle;
|
||||||
|
_mode[FX_MODE_STROBE] = &WS2812FX::mode_strobe;
|
||||||
|
_mode[FX_MODE_STROBE_RAINBOW] = &WS2812FX::mode_strobe_rainbow;
|
||||||
|
_mode[FX_MODE_MULTI_STROBE] = &WS2812FX::mode_multi_strobe;
|
||||||
|
_mode[FX_MODE_BLINK_RAINBOW] = &WS2812FX::mode_blink_rainbow;
|
||||||
|
_mode[FX_MODE_CHASE_WHITE] = &WS2812FX::mode_chase_white;
|
||||||
|
_mode[FX_MODE_CHASE_COLOR] = &WS2812FX::mode_chase_color;
|
||||||
|
_mode[FX_MODE_CHASE_RANDOM] = &WS2812FX::mode_chase_random;
|
||||||
|
_mode[FX_MODE_CHASE_RAINBOW] = &WS2812FX::mode_chase_rainbow;
|
||||||
|
_mode[FX_MODE_CHASE_FLASH] = &WS2812FX::mode_chase_flash;
|
||||||
|
_mode[FX_MODE_CHASE_FLASH_RANDOM] = &WS2812FX::mode_chase_flash_random;
|
||||||
|
_mode[FX_MODE_CHASE_RAINBOW_WHITE] = &WS2812FX::mode_chase_rainbow_white;
|
||||||
|
_mode[FX_MODE_CHASE_BLACKOUT] = &WS2812FX::mode_chase_blackout;
|
||||||
|
_mode[FX_MODE_CHASE_BLACKOUT_RAINBOW] = &WS2812FX::mode_chase_blackout_rainbow;
|
||||||
|
_mode[FX_MODE_COLOR_SWEEP_RANDOM] = &WS2812FX::mode_color_sweep_random;
|
||||||
|
_mode[FX_MODE_RUNNING_COLOR] = &WS2812FX::mode_running_color;
|
||||||
|
_mode[FX_MODE_RUNNING_RED_BLUE] = &WS2812FX::mode_running_red_blue;
|
||||||
|
_mode[FX_MODE_RUNNING_RANDOM] = &WS2812FX::mode_running_random;
|
||||||
|
_mode[FX_MODE_LARSON_SCANNER] = &WS2812FX::mode_larson_scanner;
|
||||||
|
_mode[FX_MODE_COMET] = &WS2812FX::mode_comet;
|
||||||
|
_mode[FX_MODE_FIREWORKS] = &WS2812FX::mode_fireworks;
|
||||||
|
_mode[FX_MODE_FIREWORKS_RANDOM] = &WS2812FX::mode_fireworks_random;
|
||||||
|
_mode[FX_MODE_MERRY_CHRISTMAS] = &WS2812FX::mode_merry_christmas;
|
||||||
|
_mode[FX_MODE_FIRE_FLICKER] = &WS2812FX::mode_fire_flicker;
|
||||||
|
_mode[FX_MODE_FIRE_FLICKER_SOFT] = &WS2812FX::mode_fire_flicker_soft;
|
||||||
|
_mode[FX_MODE_FIRE_FLICKER_INTENSE] = &WS2812FX::mode_fire_flicker_intense;
|
||||||
|
_mode[FX_MODE_CIRCUS_COMBUSTUS] = &WS2812FX::mode_circus_combustus;
|
||||||
|
_mode[FX_MODE_HALLOWEEN] = &WS2812FX::mode_halloween;
|
||||||
|
_mode[FX_MODE_BICOLOR_CHASE] = &WS2812FX::mode_bicolor_chase;
|
||||||
|
_mode[FX_MODE_TRICOLOR_CHASE] = &WS2812FX::mode_tricolor_chase;
|
||||||
|
// if flash memory is constrained (I'm looking at you Arduino Nano), replace modes
|
||||||
|
// that use a lot of flash with mode_static (reduces flash footprint by about 2100 bytes)
|
||||||
|
#ifdef REDUCED_MODES
|
||||||
|
_mode[FX_MODE_BREATH] = &WS2812FX::mode_static;
|
||||||
|
_mode[FX_MODE_RUNNING_LIGHTS] = &WS2812FX::mode_static;
|
||||||
|
_mode[FX_MODE_ICU] = &WS2812FX::mode_static;
|
||||||
|
#else
|
||||||
|
_mode[FX_MODE_BREATH] = &WS2812FX::mode_breath;
|
||||||
|
_mode[FX_MODE_RUNNING_LIGHTS] = &WS2812FX::mode_running_lights;
|
||||||
|
_mode[FX_MODE_ICU] = &WS2812FX::mode_icu;
|
||||||
|
#endif
|
||||||
|
_mode[FX_MODE_CUSTOM_0] = &WS2812FX::mode_custom_0;
|
||||||
|
_mode[FX_MODE_CUSTOM_1] = &WS2812FX::mode_custom_1;
|
||||||
|
_mode[FX_MODE_CUSTOM_2] = &WS2812FX::mode_custom_2;
|
||||||
|
_mode[FX_MODE_CUSTOM_3] = &WS2812FX::mode_custom_3;
|
||||||
|
_mode[FX_MODE_CUSTOM_4] = &WS2812FX::mode_custom_4;
|
||||||
|
_mode[FX_MODE_CUSTOM_5] = &WS2812FX::mode_custom_5;
|
||||||
|
_mode[FX_MODE_CUSTOM_6] = &WS2812FX::mode_custom_6;
|
||||||
|
_mode[FX_MODE_CUSTOM_7] = &WS2812FX::mode_custom_7;
|
||||||
|
_mode[FX_MODE_CUSTOM_8] = &WS2812FX::mode_custom_8;
|
||||||
|
_mode[FX_MODE_CUSTOM_9] = &WS2812FX::mode_custom_9;
|
||||||
|
|
||||||
|
brightness = DEFAULT_BRIGHTNESS + 1; // Adafruit_NeoPixel internally offsets brightness by 1
|
||||||
|
_running = false;
|
||||||
|
_num_segments = 1;
|
||||||
|
_segments[0].mode = DEFAULT_MODE;
|
||||||
|
_segments[0].colors[0] = DEFAULT_COLOR;
|
||||||
|
_segments[0].start = 0;
|
||||||
|
_segments[0].stop = n - 1;
|
||||||
|
_segments[0].speed = DEFAULT_SPEED;
|
||||||
|
resetSegmentRuntimes();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
// timer(void),
|
||||||
|
init(void),
|
||||||
|
service(void),
|
||||||
|
start(void),
|
||||||
|
stop(void),
|
||||||
|
pause(void),
|
||||||
|
resume(void),
|
||||||
|
strip_off(void),
|
||||||
|
fade_out(void),
|
||||||
|
fade_out(uint32_t),
|
||||||
|
setMode(uint8_t m),
|
||||||
|
setMode(uint8_t seg, uint8_t m),
|
||||||
|
setOptions(uint8_t seg, uint8_t o),
|
||||||
|
setCustomMode(uint16_t (*p)()),
|
||||||
|
setCustomShow(void (*p)()),
|
||||||
|
setSpeed(uint16_t s),
|
||||||
|
setSpeed(uint8_t seg, uint16_t s),
|
||||||
|
increaseSpeed(uint8_t s),
|
||||||
|
decreaseSpeed(uint8_t s),
|
||||||
|
setColor(uint8_t r, uint8_t g, uint8_t b),
|
||||||
|
setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t w),
|
||||||
|
setColor(uint32_t c),
|
||||||
|
setColor(uint8_t seg, uint32_t c),
|
||||||
|
setColors(uint8_t seg, uint32_t* c),
|
||||||
|
setBrightness(uint8_t b),
|
||||||
|
increaseBrightness(uint8_t s),
|
||||||
|
decreaseBrightness(uint8_t s),
|
||||||
|
setLength(uint16_t b),
|
||||||
|
increaseLength(uint16_t s),
|
||||||
|
decreaseLength(uint16_t s),
|
||||||
|
trigger(void),
|
||||||
|
setNumSegments(uint8_t n),
|
||||||
|
setSegment(uint8_t n, uint16_t start, uint16_t stop, uint8_t mode, uint32_t color, uint16_t speed, bool reverse),
|
||||||
|
setSegment(uint8_t n, uint16_t start, uint16_t stop, uint8_t mode, uint32_t color, uint16_t speed, uint8_t options),
|
||||||
|
setSegment(uint8_t n, uint16_t start, uint16_t stop, uint8_t mode, const uint32_t colors[], uint16_t speed, bool reverse),
|
||||||
|
setSegment(uint8_t n, uint16_t start, uint16_t stop, uint8_t mode, const uint32_t colors[], uint16_t speed, uint8_t options),
|
||||||
|
resetSegments(),
|
||||||
|
resetSegmentRuntimes(),
|
||||||
|
resetSegmentRuntime(uint8_t),
|
||||||
|
setPixelColor(uint16_t n, uint32_t c),
|
||||||
|
setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b),
|
||||||
|
setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w),
|
||||||
|
copyPixels(uint16_t d, uint16_t s, uint16_t c),
|
||||||
|
show(void);
|
||||||
|
|
||||||
|
boolean
|
||||||
|
isRunning(void),
|
||||||
|
isTriggered(void),
|
||||||
|
isFrame(void),
|
||||||
|
isFrame(uint8_t),
|
||||||
|
isCycle(void),
|
||||||
|
isCycle(uint8_t);
|
||||||
|
|
||||||
|
uint8_t
|
||||||
|
random8(void),
|
||||||
|
random8(uint8_t),
|
||||||
|
getMode(void),
|
||||||
|
getMode(uint8_t),
|
||||||
|
getModeCount(void),
|
||||||
|
setCustomMode(const __FlashStringHelper* name, uint16_t (*p)()),
|
||||||
|
setCustomMode(uint8_t i, const __FlashStringHelper* name, uint16_t (*p)()),
|
||||||
|
getNumSegments(void),
|
||||||
|
get_random_wheel_index(uint8_t),
|
||||||
|
getOptions(uint8_t),
|
||||||
|
getNumBytesPerPixel(void);
|
||||||
|
|
||||||
|
uint16_t
|
||||||
|
random16(void),
|
||||||
|
random16(uint16_t),
|
||||||
|
getSpeed(void),
|
||||||
|
getSpeed(uint8_t),
|
||||||
|
getLength(void),
|
||||||
|
getNumBytes(void);
|
||||||
|
|
||||||
|
uint32_t
|
||||||
|
color_wheel(uint8_t),
|
||||||
|
getColor(void),
|
||||||
|
getColor(uint8_t),
|
||||||
|
intensitySum(void);
|
||||||
|
|
||||||
|
uint32_t* getColors(uint8_t);
|
||||||
|
uint32_t* intensitySums(void);
|
||||||
|
|
||||||
|
const __FlashStringHelper* getModeName(uint8_t m);
|
||||||
|
|
||||||
|
WS2812FX::Segment* getSegment(void);
|
||||||
|
|
||||||
|
WS2812FX::Segment* getSegment(uint8_t);
|
||||||
|
|
||||||
|
WS2812FX::Segment* getSegments(void);
|
||||||
|
|
||||||
|
WS2812FX::Segment_runtime* getSegmentRuntime(void);
|
||||||
|
|
||||||
|
WS2812FX::Segment_runtime* getSegmentRuntime(uint8_t);
|
||||||
|
|
||||||
|
WS2812FX::Segment_runtime* getSegmentRuntimes(void);
|
||||||
|
|
||||||
|
// mode helper functions
|
||||||
|
uint16_t
|
||||||
|
blink(uint32_t, uint32_t, bool strobe),
|
||||||
|
color_wipe(uint32_t, uint32_t, bool),
|
||||||
|
twinkle(uint32_t, uint32_t),
|
||||||
|
twinkle_fade(uint32_t),
|
||||||
|
chase(uint32_t, uint32_t, uint32_t),
|
||||||
|
running(uint32_t, uint32_t),
|
||||||
|
fireworks(uint32_t),
|
||||||
|
fire_flicker(int),
|
||||||
|
tricolor_chase(uint32_t, uint32_t, uint32_t),
|
||||||
|
scan(uint32_t, uint32_t, bool);
|
||||||
|
uint32_t
|
||||||
|
color_blend(uint32_t, uint32_t, uint8_t);
|
||||||
|
|
||||||
|
// builtin modes
|
||||||
|
uint16_t
|
||||||
|
mode_static(void),
|
||||||
|
mode_blink(void),
|
||||||
|
mode_blink_rainbow(void),
|
||||||
|
mode_strobe(void),
|
||||||
|
mode_strobe_rainbow(void),
|
||||||
|
mode_color_wipe(void),
|
||||||
|
mode_color_wipe_inv(void),
|
||||||
|
mode_color_wipe_rev(void),
|
||||||
|
mode_color_wipe_rev_inv(void),
|
||||||
|
mode_color_wipe_random(void),
|
||||||
|
mode_color_sweep_random(void),
|
||||||
|
mode_random_color(void),
|
||||||
|
mode_single_dynamic(void),
|
||||||
|
mode_multi_dynamic(void),
|
||||||
|
mode_breath(void),
|
||||||
|
mode_fade(void),
|
||||||
|
mode_scan(void),
|
||||||
|
mode_dual_scan(void),
|
||||||
|
mode_theater_chase(void),
|
||||||
|
mode_theater_chase_rainbow(void),
|
||||||
|
mode_rainbow(void),
|
||||||
|
mode_rainbow_cycle(void),
|
||||||
|
mode_running_lights(void),
|
||||||
|
mode_twinkle(void),
|
||||||
|
mode_twinkle_random(void),
|
||||||
|
mode_twinkle_fade(void),
|
||||||
|
mode_twinkle_fade_random(void),
|
||||||
|
mode_sparkle(void),
|
||||||
|
mode_flash_sparkle(void),
|
||||||
|
mode_hyper_sparkle(void),
|
||||||
|
mode_multi_strobe(void),
|
||||||
|
mode_chase_white(void),
|
||||||
|
mode_chase_color(void),
|
||||||
|
mode_chase_random(void),
|
||||||
|
mode_chase_rainbow(void),
|
||||||
|
mode_chase_flash(void),
|
||||||
|
mode_chase_flash_random(void),
|
||||||
|
mode_chase_rainbow_white(void),
|
||||||
|
mode_chase_blackout(void),
|
||||||
|
mode_chase_blackout_rainbow(void),
|
||||||
|
mode_running_color(void),
|
||||||
|
mode_running_red_blue(void),
|
||||||
|
mode_running_random(void),
|
||||||
|
mode_larson_scanner(void),
|
||||||
|
mode_comet(void),
|
||||||
|
mode_fireworks(void),
|
||||||
|
mode_fireworks_random(void),
|
||||||
|
mode_merry_christmas(void),
|
||||||
|
mode_halloween(void),
|
||||||
|
mode_fire_flicker(void),
|
||||||
|
mode_fire_flicker_soft(void),
|
||||||
|
mode_fire_flicker_intense(void),
|
||||||
|
mode_circus_combustus(void),
|
||||||
|
mode_bicolor_chase(void),
|
||||||
|
mode_tricolor_chase(void),
|
||||||
|
mode_icu(void),
|
||||||
|
mode_custom_0(void),
|
||||||
|
mode_custom_1(void),
|
||||||
|
mode_custom_2(void),
|
||||||
|
mode_custom_3(void),
|
||||||
|
mode_custom_4(void),
|
||||||
|
mode_custom_5(void),
|
||||||
|
mode_custom_6(void),
|
||||||
|
mode_custom_7(void),
|
||||||
|
mode_custom_8(void),
|
||||||
|
mode_custom_9(void);
|
||||||
|
private:
|
||||||
|
uint16_t _rand16seed;
|
||||||
|
uint16_t (*customModes[MAX_CUSTOM_MODES])(void) {
|
||||||
|
[]{ return (uint16_t)1000; },
|
||||||
|
[]{ return (uint16_t)1000; },
|
||||||
|
[]{ return (uint16_t)1000; },
|
||||||
|
[]{ return (uint16_t)1000; },
|
||||||
|
[]{ return (uint16_t)1000; },
|
||||||
|
[]{ return (uint16_t)1000; },
|
||||||
|
[]{ return (uint16_t)1000; },
|
||||||
|
[]{ return (uint16_t)1000; },
|
||||||
|
[]{ return (uint16_t)1000; },
|
||||||
|
[]{ return (uint16_t)1000; }
|
||||||
|
};
|
||||||
|
void (*customShow)(void) = NULL;
|
||||||
|
|
||||||
|
boolean
|
||||||
|
_running,
|
||||||
|
_triggered;
|
||||||
|
|
||||||
|
mode_ptr _mode[MODE_COUNT]; // SRAM footprint: 4 bytes per element
|
||||||
|
|
||||||
|
uint8_t _segment_index = 0;
|
||||||
|
uint8_t _num_segments = 1;
|
||||||
|
segment _segments[MAX_NUM_SEGMENTS] = { // SRAM footprint: 20 bytes per element
|
||||||
|
// start, stop, speed, mode, options, color[]
|
||||||
|
{ 0, 7, DEFAULT_SPEED, FX_MODE_STATIC, NO_OPTIONS, {DEFAULT_COLOR}}
|
||||||
|
};
|
||||||
|
segment_runtime _segment_runtimes[MAX_NUM_SEGMENTS]; // SRAM footprint: 16 bytes per element
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 4.4 KiB |
@@ -0,0 +1,674 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>SPIFFS Editor</title>
|
||||||
|
<style type="text/css" media="screen">
|
||||||
|
.contextMenu {
|
||||||
|
z-index: 300;
|
||||||
|
position: absolute;
|
||||||
|
left: 5px;
|
||||||
|
border: 1px solid #444;
|
||||||
|
background-color: #F5F5F5;
|
||||||
|
display: none;
|
||||||
|
box-shadow: 0 0 10px rgba( 0, 0, 0, .4 );
|
||||||
|
font-size: 12px;
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-weight:bold;
|
||||||
|
}
|
||||||
|
.contextMenu ul {
|
||||||
|
list-style: none;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.contextMenu li {
|
||||||
|
position: relative;
|
||||||
|
min-width: 60px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.contextMenu span {
|
||||||
|
color: #444;
|
||||||
|
display: inline-block;
|
||||||
|
padding: 6px;
|
||||||
|
}
|
||||||
|
.contextMenu li:hover { background: #444; }
|
||||||
|
.contextMenu li:hover span { color: #EEE; }
|
||||||
|
|
||||||
|
.css-treeview ul, .css-treeview li {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.css-treeview input {
|
||||||
|
position: absolute;
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.css-treeview {
|
||||||
|
font: normal 11px Verdana, Arial, Sans-serif;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.css-treeview span {
|
||||||
|
color: #00f;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.css-treeview span:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.css-treeview input + label + ul {
|
||||||
|
margin: 0 0 0 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.css-treeview input ~ ul {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.css-treeview label, .css-treeview label::before {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.css-treeview input:disabled + label {
|
||||||
|
cursor: default;
|
||||||
|
opacity: .6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.css-treeview input:checked:not(:disabled) ~ ul {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.css-treeview label, .css-treeview label::before {
|
||||||
|
background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAACgCAYAAAAFOewUAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAApxJREFUeNrslM1u00AQgGdthyalFFOK+ClIIKQKyqUVQvTEE3DmAhLwAhU8QZoH4A2Q2gMSFace4MCtJ8SPBFwAkRuiHKpA6sRN/Lu7zG5i14kctaUqRGhGXnu9O/Pt7MzsMiklvF+9t2kWTDvyIrAsA0aKRRi1T0C/hJ4LUbt5/8rNpWVlp8RSr9J40b48fxFaTQ9+ft8EZ6MJYb0Ok+dnYGpmPgXwKIAvLx8vYXc5GdMAQJgQEkpjRTh36TS2U+DWW/D17WuYgm8pwJyY1npZsZKOxImOV1I/h4+O6vEg5GCZBpgmA6hX8wHKUHDRBXQYicQ4rlc3Tf0VMs8DHBS864F2YFspjgUYjKX/Az3gsdQd2eeBHwmdGWXHcgBGSkZXOXohcEXebRoQcAgjqediNY+AVyu3Z3sAKqfKoGMsewBeEIOPgQxxPJIjcGH6qtL/0AdADzKGnuuD+2tLK7Q8DhHHbOBW+KEzcHLuYc82MkEUekLiwuvVH+guQBQzOG4XdAb8EOcRcqQvDkY2iCLuxECJ43JobMXoutqGgDa2T7UqLKwt9KRyuxKVByqVXXqIoCCUCAqhUOioTWC7G4TQEOD0APy2/7G2Xpu1J4+lxeQ4TXBbITDpoVelRN/BVFbwu5oMMJUBhoXy5tmdRcMwymP2OLQaLjx9/vnBo6V3K6izATmSnMa0Dq7ferIohJhr1p01zrlz49rZF4OMs8JkX23vVQzYp+wbYGV/KpXKjvspl8tsIKCrMNAYFxj2GKS5ZWxg4ewKsJfaGMIY5KXqPz8LBBj6+yDvVP79+yDp/9F9oIx3OisHWwe7Oal0HxCAAAQgAAEIQAACEIAABCAAAQhAAAIQgAAEIAABCEAAAhCAAAQgwD8E/BZgAP0qhKj3rXO7AAAAAElFTkSuQmCC") no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
.css-treeview label, .css-treeview span, .css-treeview label::before {
|
||||||
|
display: inline-block;
|
||||||
|
height: 16px;
|
||||||
|
line-height: 16px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.css-treeview label {
|
||||||
|
background-position: 18px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.css-treeview label::before {
|
||||||
|
content: "";
|
||||||
|
width: 16px;
|
||||||
|
margin: 0 22px 0 0;
|
||||||
|
vertical-align: middle;
|
||||||
|
background-position: 0 -32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.css-treeview input:checked + label::before {
|
||||||
|
background-position: 0 -16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* webkit adjacent element selector bugfix */
|
||||||
|
@media screen and (-webkit-min-device-pixel-ratio:0)
|
||||||
|
{
|
||||||
|
.css-treeview{
|
||||||
|
-webkit-animation: webkit-adjacent-element-selector-bugfix infinite 1s;
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes webkit-adjacent-element-selector-bugfix
|
||||||
|
{
|
||||||
|
from {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#uploader {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
left: 0;
|
||||||
|
height:28px;
|
||||||
|
line-height: 24px;
|
||||||
|
padding-left: 10px;
|
||||||
|
background-color: #444;
|
||||||
|
color:#EEE;
|
||||||
|
}
|
||||||
|
#tree {
|
||||||
|
position: absolute;
|
||||||
|
top: 28px;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
width:200px;
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
#editor, #preview {
|
||||||
|
position: absolute;
|
||||||
|
top: 28px;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 200px;
|
||||||
|
}
|
||||||
|
#preview {
|
||||||
|
background-color: #EEE;
|
||||||
|
padding:5px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
function createFileUploader(element, tree, editor){
|
||||||
|
var xmlHttp;
|
||||||
|
var input = document.createElement("input");
|
||||||
|
input.type = "file";
|
||||||
|
input.multiple = false;
|
||||||
|
input.name = "data";
|
||||||
|
document.getElementById(element).appendChild(input);
|
||||||
|
var path = document.createElement("input");
|
||||||
|
path.id = "upload-path";
|
||||||
|
path.type = "text";
|
||||||
|
path.name = "path";
|
||||||
|
path.defaultValue = "/";
|
||||||
|
document.getElementById(element).appendChild(path);
|
||||||
|
var button = document.createElement("button");
|
||||||
|
button.innerHTML = 'Upload';
|
||||||
|
document.getElementById(element).appendChild(button);
|
||||||
|
var mkdir = document.createElement("button");
|
||||||
|
mkdir.innerHTML = 'MkDir';
|
||||||
|
document.getElementById(element).appendChild(mkdir);
|
||||||
|
var mkfile = document.createElement("button");
|
||||||
|
mkfile.innerHTML = 'MkFile';
|
||||||
|
document.getElementById(element).appendChild(mkfile);
|
||||||
|
|
||||||
|
function httpPostProcessRequest(){
|
||||||
|
if (xmlHttp.readyState == 4){
|
||||||
|
if(xmlHttp.status != 200) alert("ERROR["+xmlHttp.status+"]: "+xmlHttp.responseText);
|
||||||
|
else {
|
||||||
|
tree.refreshPath(path.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function createPath(p){
|
||||||
|
xmlHttp = new XMLHttpRequest();
|
||||||
|
xmlHttp.onreadystatechange = httpPostProcessRequest;
|
||||||
|
var formData = new FormData();
|
||||||
|
formData.append("path", p);
|
||||||
|
xmlHttp.open("PUT", "/edit");
|
||||||
|
xmlHttp.send(formData);
|
||||||
|
}
|
||||||
|
|
||||||
|
mkfile.onclick = function(e){
|
||||||
|
if(path.value.indexOf(".") === -1) return;
|
||||||
|
createPath(path.value);
|
||||||
|
editor.loadUrl(path.value);
|
||||||
|
};
|
||||||
|
mkdir.onclick = function(e){
|
||||||
|
if(path.value.length < 2) return;
|
||||||
|
var dir = path.value
|
||||||
|
if(dir.indexOf(".") !== -1){
|
||||||
|
if(dir.lastIndexOf("/") === 0) return;
|
||||||
|
dir = dir.substring(0, dir.lastIndexOf("/"));
|
||||||
|
}
|
||||||
|
createPath(dir);
|
||||||
|
};
|
||||||
|
button.onclick = function(e){
|
||||||
|
if(input.files.length === 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
xmlHttp = new XMLHttpRequest();
|
||||||
|
xmlHttp.onreadystatechange = httpPostProcessRequest;
|
||||||
|
var formData = new FormData();
|
||||||
|
formData.append("data", input.files[0], path.value);
|
||||||
|
xmlHttp.open("POST", "/edit");
|
||||||
|
xmlHttp.send(formData);
|
||||||
|
}
|
||||||
|
input.onchange = function(e){
|
||||||
|
if(input.files.length === 0) return;
|
||||||
|
var filename = input.files[0].name;
|
||||||
|
var ext = /(?:\.([^.]+))?$/.exec(filename)[1];
|
||||||
|
var name = /(.*)\.[^.]+$/.exec(filename)[1];
|
||||||
|
if(typeof name !== undefined){
|
||||||
|
if(name.length > 8) name = name.substring(0, 8);
|
||||||
|
filename = name;
|
||||||
|
}
|
||||||
|
if(typeof ext !== undefined){
|
||||||
|
if(ext === "html") ext = "htm";
|
||||||
|
else if(ext === "jpeg") ext = "jpg";
|
||||||
|
filename = filename + "." + ext;
|
||||||
|
}
|
||||||
|
if(path.value === "/" || path.value.lastIndexOf("/") === 0){
|
||||||
|
path.value = "/"+filename;
|
||||||
|
} else {
|
||||||
|
path.value = path.value.substring(0, path.value.lastIndexOf("/")+1)+filename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createTree(element, editor){
|
||||||
|
var preview = document.getElementById("preview");
|
||||||
|
var treeRoot = document.createElement("div");
|
||||||
|
treeRoot.className = "css-treeview";
|
||||||
|
document.getElementById(element).appendChild(treeRoot);
|
||||||
|
|
||||||
|
function loadDownload(path){
|
||||||
|
document.getElementById('download-frame').src = path+"?download=true";
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadPreview(path){
|
||||||
|
document.getElementById("editor").style.display = "none";
|
||||||
|
preview.style.display = "block";
|
||||||
|
preview.innerHTML = '<img src="'+path+'" style="max-width:100%; max-height:100%; margin:auto; display:block;" />';
|
||||||
|
}
|
||||||
|
|
||||||
|
function fillFolderMenu(el, path){
|
||||||
|
var list = document.createElement("ul");
|
||||||
|
el.appendChild(list);
|
||||||
|
var action = document.createElement("li");
|
||||||
|
list.appendChild(action);
|
||||||
|
var isChecked = document.getElementById(path).checked;
|
||||||
|
var expnd = document.createElement("li");
|
||||||
|
list.appendChild(expnd);
|
||||||
|
if(isChecked){
|
||||||
|
expnd.innerHTML = "<span>Collapse</span>";
|
||||||
|
expnd.onclick = function(e){
|
||||||
|
document.getElementById(path).checked = false;
|
||||||
|
if(document.body.getElementsByClassName('contextMenu').length > 0) document.body.removeChild(el);
|
||||||
|
};
|
||||||
|
var refrsh = document.createElement("li");
|
||||||
|
list.appendChild(refrsh);
|
||||||
|
refrsh.innerHTML = "<span>Refresh</span>";
|
||||||
|
refrsh.onclick = function(e){
|
||||||
|
var leaf = document.getElementById(path).parentNode;
|
||||||
|
if(leaf.childNodes.length == 3) leaf.removeChild(leaf.childNodes[2]);
|
||||||
|
httpGet(leaf, path);
|
||||||
|
if(document.body.getElementsByClassName('contextMenu').length > 0) document.body.removeChild(el);
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
expnd.innerHTML = "<span>Expand</span>";
|
||||||
|
expnd.onclick = function(e){
|
||||||
|
document.getElementById(path).checked = true;
|
||||||
|
var leaf = document.getElementById(path).parentNode;
|
||||||
|
if(leaf.childNodes.length == 3) leaf.removeChild(leaf.childNodes[2]);
|
||||||
|
httpGet(leaf, path);
|
||||||
|
if(document.body.getElementsByClassName('contextMenu').length > 0) document.body.removeChild(el);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
var upload = document.createElement("li");
|
||||||
|
list.appendChild(upload);
|
||||||
|
upload.innerHTML = "<span>Upload</span>";
|
||||||
|
upload.onclick = function(e){
|
||||||
|
var pathEl = document.getElementById("upload-path");
|
||||||
|
if(pathEl){
|
||||||
|
var subPath = pathEl.value;
|
||||||
|
if(subPath.lastIndexOf("/") < 1) pathEl.value = path+subPath;
|
||||||
|
else pathEl.value = path.substring(subPath.lastIndexOf("/"))+subPath;
|
||||||
|
}
|
||||||
|
if(document.body.getElementsByClassName('contextMenu').length > 0) document.body.removeChild(el);
|
||||||
|
};
|
||||||
|
var delFile = document.createElement("li");
|
||||||
|
list.appendChild(delFile);
|
||||||
|
delFile.innerHTML = "<span>Delete</span>";
|
||||||
|
delFile.onclick = function(e){
|
||||||
|
httpDelete(path);
|
||||||
|
if(document.body.getElementsByClassName('contextMenu').length > 0) document.body.removeChild(el);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function fillFileMenu(el, path){
|
||||||
|
var list = document.createElement("ul");
|
||||||
|
el.appendChild(list);
|
||||||
|
var action = document.createElement("li");
|
||||||
|
list.appendChild(action);
|
||||||
|
if(isTextFile(path)){
|
||||||
|
action.innerHTML = "<span>Edit</span>";
|
||||||
|
action.onclick = function(e){
|
||||||
|
editor.loadUrl(path);
|
||||||
|
if(document.body.getElementsByClassName('contextMenu').length > 0) document.body.removeChild(el);
|
||||||
|
};
|
||||||
|
} else if(isImageFile(path)){
|
||||||
|
action.innerHTML = "<span>Preview</span>";
|
||||||
|
action.onclick = function(e){
|
||||||
|
loadPreview(path);
|
||||||
|
if(document.body.getElementsByClassName('contextMenu').length > 0) document.body.removeChild(el);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
var download = document.createElement("li");
|
||||||
|
list.appendChild(download);
|
||||||
|
download.innerHTML = "<span>Download</span>";
|
||||||
|
download.onclick = function(e){
|
||||||
|
loadDownload(path);
|
||||||
|
if(document.body.getElementsByClassName('contextMenu').length > 0) document.body.removeChild(el);
|
||||||
|
};
|
||||||
|
var delFile = document.createElement("li");
|
||||||
|
list.appendChild(delFile);
|
||||||
|
delFile.innerHTML = "<span>Delete</span>";
|
||||||
|
delFile.onclick = function(e){
|
||||||
|
httpDelete(path);
|
||||||
|
if(document.body.getElementsByClassName('contextMenu').length > 0) document.body.removeChild(el);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function showContextMenu(e, path, isfile){
|
||||||
|
var divContext = document.createElement("div");
|
||||||
|
var scrollTop = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
|
||||||
|
var scrollLeft = document.body.scrollLeft ? document.body.scrollLeft : document.documentElement.scrollLeft;
|
||||||
|
var left = e.clientX + scrollLeft;
|
||||||
|
var top = e.clientY + scrollTop;
|
||||||
|
divContext.className = 'contextMenu';
|
||||||
|
divContext.style.display = 'block';
|
||||||
|
divContext.style.left = left + 'px';
|
||||||
|
divContext.style.top = top + 'px';
|
||||||
|
if(isfile) fillFileMenu(divContext, path);
|
||||||
|
else fillFolderMenu(divContext, path);
|
||||||
|
document.body.appendChild(divContext);
|
||||||
|
var width = divContext.offsetWidth;
|
||||||
|
var height = divContext.offsetHeight;
|
||||||
|
divContext.onmouseout = function(e){
|
||||||
|
if(e.clientX < left || e.clientX > (left + width) || e.clientY < top || e.clientY > (top + height)){
|
||||||
|
if(document.body.getElementsByClassName('contextMenu').length > 0) document.body.removeChild(divContext);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function createTreeLeaf(path, name, size){
|
||||||
|
var leaf = document.createElement("li");
|
||||||
|
leaf.id = (((path == "/")?"":path)+"/"+name).toLowerCase();
|
||||||
|
var label = document.createElement("span");
|
||||||
|
label.textContent = name.toLowerCase();
|
||||||
|
leaf.appendChild(label);
|
||||||
|
leaf.onclick = function(e){
|
||||||
|
if(isTextFile(leaf.id)){
|
||||||
|
editor.loadUrl(leaf.id);
|
||||||
|
} else if(isImageFile(leaf.id)){
|
||||||
|
loadPreview(leaf.id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
leaf.oncontextmenu = function(e){
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
showContextMenu(e, leaf.id, true);
|
||||||
|
};
|
||||||
|
return leaf;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createTreeBranch(path, name, disabled){
|
||||||
|
var leaf = document.createElement("li");
|
||||||
|
var check = document.createElement("input");
|
||||||
|
check.type = "checkbox";
|
||||||
|
check.id = (((path == "/")?"":path)+"/"+name).toLowerCase();
|
||||||
|
if(typeof disabled !== "undefined" && disabled) check.disabled = "disabled";
|
||||||
|
leaf.appendChild(check);
|
||||||
|
var label = document.createElement("label");
|
||||||
|
label.for = check.id;
|
||||||
|
label.textContent = name.toLowerCase();
|
||||||
|
leaf.appendChild(label);
|
||||||
|
check.onchange = function(e){
|
||||||
|
if(check.checked){
|
||||||
|
if(leaf.childNodes.length == 3) leaf.removeChild(leaf.childNodes[2]);
|
||||||
|
httpGet(leaf, check.id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
label.onclick = function(e){
|
||||||
|
if(!check.checked){
|
||||||
|
check.checked = true;
|
||||||
|
if(leaf.childNodes.length == 3) leaf.removeChild(leaf.childNodes[2]);
|
||||||
|
httpGet(leaf, check.id);
|
||||||
|
} else {
|
||||||
|
check.checked = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
leaf.oncontextmenu = function(e){
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
showContextMenu(e, check.id, false);
|
||||||
|
}
|
||||||
|
return leaf;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addList(parent, path, items){
|
||||||
|
var list = document.createElement("ul");
|
||||||
|
parent.appendChild(list);
|
||||||
|
var ll = items.length;
|
||||||
|
for(var i = 0; i < ll; i++){
|
||||||
|
var item = items[i];
|
||||||
|
var itemEl;
|
||||||
|
if(item.type === "file"){
|
||||||
|
itemEl = createTreeLeaf(path, item.name, item.size);
|
||||||
|
} else {
|
||||||
|
itemEl = createTreeBranch(path, item.name);
|
||||||
|
}
|
||||||
|
list.appendChild(itemEl);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function isTextFile(path){
|
||||||
|
var ext = /(?:\.([^.]+))?$/.exec(path)[1];
|
||||||
|
if(typeof ext !== undefined){
|
||||||
|
switch(ext){
|
||||||
|
case "txt":
|
||||||
|
case "htm":
|
||||||
|
case "html":
|
||||||
|
case "js":
|
||||||
|
case "json":
|
||||||
|
case "c":
|
||||||
|
case "h":
|
||||||
|
case "cpp":
|
||||||
|
case "css":
|
||||||
|
case "xml":
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isImageFile(path){
|
||||||
|
var ext = /(?:\.([^.]+))?$/.exec(path)[1];
|
||||||
|
if(typeof ext !== undefined){
|
||||||
|
switch(ext){
|
||||||
|
case "png":
|
||||||
|
case "jpg":
|
||||||
|
case "gif":
|
||||||
|
case "ico":
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.refreshPath = function(path){
|
||||||
|
if(path.lastIndexOf('/') < 1){
|
||||||
|
path = '/';
|
||||||
|
treeRoot.removeChild(treeRoot.childNodes[0]);
|
||||||
|
httpGet(treeRoot, "/");
|
||||||
|
} else {
|
||||||
|
path = path.substring(0, path.lastIndexOf('/'));
|
||||||
|
var leaf = document.getElementById(path).parentNode;
|
||||||
|
if(leaf.childNodes.length == 3) leaf.removeChild(leaf.childNodes[2]);
|
||||||
|
httpGet(leaf, path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function delCb(path){
|
||||||
|
return function(){
|
||||||
|
if (xmlHttp.readyState == 4){
|
||||||
|
if(xmlHttp.status != 200){
|
||||||
|
alert("ERROR["+xmlHttp.status+"]: "+xmlHttp.responseText);
|
||||||
|
} else {
|
||||||
|
if(path.lastIndexOf('/') < 1){
|
||||||
|
path = '/';
|
||||||
|
treeRoot.removeChild(treeRoot.childNodes[0]);
|
||||||
|
httpGet(treeRoot, "/");
|
||||||
|
} else {
|
||||||
|
path = path.substring(0, path.lastIndexOf('/'));
|
||||||
|
var leaf = document.getElementById(path).parentNode;
|
||||||
|
if(leaf.childNodes.length == 3) leaf.removeChild(leaf.childNodes[2]);
|
||||||
|
httpGet(leaf, path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function httpDelete(filename){
|
||||||
|
xmlHttp = new XMLHttpRequest();
|
||||||
|
xmlHttp.onreadystatechange = delCb(filename);
|
||||||
|
var formData = new FormData();
|
||||||
|
formData.append("path", filename);
|
||||||
|
xmlHttp.open("DELETE", "/edit");
|
||||||
|
xmlHttp.send(formData);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCb(parent, path){
|
||||||
|
return function(){
|
||||||
|
if (xmlHttp.readyState == 4){
|
||||||
|
//clear loading
|
||||||
|
if(xmlHttp.status == 200) addList(parent, path, JSON.parse(xmlHttp.responseText));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function httpGet(parent, path){
|
||||||
|
xmlHttp = new XMLHttpRequest(parent, path);
|
||||||
|
xmlHttp.onreadystatechange = getCb(parent, path);
|
||||||
|
xmlHttp.open("GET", "/list?dir="+path, true);
|
||||||
|
xmlHttp.send(null);
|
||||||
|
//start loading
|
||||||
|
}
|
||||||
|
|
||||||
|
httpGet(treeRoot, "/");
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createEditor(element, file, lang, theme, type){
|
||||||
|
function getLangFromFilename(filename){
|
||||||
|
var lang = "plain";
|
||||||
|
var ext = /(?:\.([^.]+))?$/.exec(filename)[1];
|
||||||
|
if(typeof ext !== undefined){
|
||||||
|
switch(ext){
|
||||||
|
case "txt": lang = "plain"; break;
|
||||||
|
case "htm": lang = "html"; break;
|
||||||
|
case "js": lang = "javascript"; break;
|
||||||
|
case "c": lang = "c_cpp"; break;
|
||||||
|
case "cpp": lang = "c_cpp"; break;
|
||||||
|
case "css":
|
||||||
|
case "scss":
|
||||||
|
case "php":
|
||||||
|
case "html":
|
||||||
|
case "json":
|
||||||
|
case "xml":
|
||||||
|
lang = ext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lang;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(typeof file === "undefined") file = "/index.htm";
|
||||||
|
|
||||||
|
if(typeof lang === "undefined"){
|
||||||
|
lang = getLangFromFilename(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(typeof theme === "undefined") theme = "textmate";
|
||||||
|
|
||||||
|
if(typeof type === "undefined"){
|
||||||
|
type = "text/"+lang;
|
||||||
|
if(lang === "c_cpp") type = "text/plain";
|
||||||
|
}
|
||||||
|
|
||||||
|
var xmlHttp = null;
|
||||||
|
var editor = ace.edit(element);
|
||||||
|
|
||||||
|
//post
|
||||||
|
function httpPostProcessRequest(){
|
||||||
|
if (xmlHttp.readyState == 4){
|
||||||
|
if(xmlHttp.status != 200) alert("ERROR["+xmlHttp.status+"]: "+xmlHttp.responseText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function httpPost(filename, data, type){
|
||||||
|
xmlHttp = new XMLHttpRequest();
|
||||||
|
xmlHttp.onreadystatechange = httpPostProcessRequest;
|
||||||
|
var formData = new FormData();
|
||||||
|
formData.append("data", new Blob([data], { type: type }), filename);
|
||||||
|
xmlHttp.open("POST", "/edit");
|
||||||
|
xmlHttp.send(formData);
|
||||||
|
}
|
||||||
|
//get
|
||||||
|
function httpGetProcessRequest(){
|
||||||
|
if (xmlHttp.readyState == 4){
|
||||||
|
document.getElementById("preview").style.display = "none";
|
||||||
|
document.getElementById("editor").style.display = "block";
|
||||||
|
if(xmlHttp.status == 200) editor.setValue(xmlHttp.responseText);
|
||||||
|
else editor.setValue("");
|
||||||
|
editor.clearSelection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function httpGet(theUrl){
|
||||||
|
xmlHttp = new XMLHttpRequest();
|
||||||
|
xmlHttp.onreadystatechange = httpGetProcessRequest;
|
||||||
|
xmlHttp.open("GET", theUrl, true);
|
||||||
|
xmlHttp.send(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(lang !== "plain") editor.getSession().setMode("ace/mode/"+lang);
|
||||||
|
editor.setTheme("ace/theme/"+theme);
|
||||||
|
editor.$blockScrolling = Infinity;
|
||||||
|
editor.getSession().setUseSoftTabs(true);
|
||||||
|
editor.getSession().setTabSize(2);
|
||||||
|
editor.setHighlightActiveLine(true);
|
||||||
|
editor.setShowPrintMargin(false);
|
||||||
|
editor.commands.addCommand({
|
||||||
|
name: 'saveCommand',
|
||||||
|
bindKey: {win: 'Ctrl-S', mac: 'Command-S'},
|
||||||
|
exec: function(editor) {
|
||||||
|
httpPost(file, editor.getValue()+"", type);
|
||||||
|
},
|
||||||
|
readOnly: false
|
||||||
|
});
|
||||||
|
editor.commands.addCommand({
|
||||||
|
name: 'undoCommand',
|
||||||
|
bindKey: {win: 'Ctrl-Z', mac: 'Command-Z'},
|
||||||
|
exec: function(editor) {
|
||||||
|
editor.getSession().getUndoManager().undo(false);
|
||||||
|
},
|
||||||
|
readOnly: false
|
||||||
|
});
|
||||||
|
editor.commands.addCommand({
|
||||||
|
name: 'redoCommand',
|
||||||
|
bindKey: {win: 'Ctrl-Shift-Z', mac: 'Command-Shift-Z'},
|
||||||
|
exec: function(editor) {
|
||||||
|
editor.getSession().getUndoManager().redo(false);
|
||||||
|
},
|
||||||
|
readOnly: false
|
||||||
|
});
|
||||||
|
httpGet(file);
|
||||||
|
editor.loadUrl = function(filename){
|
||||||
|
file = filename;
|
||||||
|
lang = getLangFromFilename(file);
|
||||||
|
type = "text/"+lang;
|
||||||
|
if(lang !== "plain") editor.getSession().setMode("ace/mode/"+lang);
|
||||||
|
httpGet(file);
|
||||||
|
}
|
||||||
|
return editor;
|
||||||
|
}
|
||||||
|
function onBodyLoad(){
|
||||||
|
var vars = {};
|
||||||
|
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { vars[key] = value; });
|
||||||
|
var editor = createEditor("editor", vars.file, vars.lang, vars.theme);
|
||||||
|
var tree = createTree("tree", editor);
|
||||||
|
createFileUploader("uploader", tree, editor);
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.9/ace.js" type="text/javascript" charset="utf-8"></script>
|
||||||
|
</head>
|
||||||
|
<body onload="onBodyLoad();">
|
||||||
|
<div id="uploader"></div>
|
||||||
|
<div id="tree"></div>
|
||||||
|
<div id="editor"></div>
|
||||||
|
<div id="preview" style="display:none;"></div>
|
||||||
|
<iframe id=download-frame style='display:none;'></iframe>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 34 KiB |
+2533
-91
File diff suppressed because one or more lines are too long
Binary file not shown.
@@ -29,28 +29,26 @@ char HOSTNAME[65] = "McLightingRGBW"; // Friedly hostname is configurable just
|
|||||||
|
|
||||||
#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 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_LEGACY_ANIMATIONS // Enable Legacy Animations
|
|
||||||
#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 ENABLE_E131 // E1.31 implementation You have to uncomment #define USE_WS2812FX_DMA and set it to 0
|
|
||||||
#define ENABLE_TV // Enable TV Animation
|
|
||||||
#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 FADE_COLOR_DELAY 5 // Delay for color transition
|
#define TRANS_COLOR_DELAY 5 // Delay for color transition
|
||||||
#define FADE_DELAY 10 // Delay for brightness and speed transition
|
#define TRANS_DELAY 10 // Delay for brightness and speed transition
|
||||||
|
|
||||||
bool fadeEffect = true; // Experimental: Enable transitions of color, brightness and speed. It does not work properly for all effects.
|
bool transEffect = false; // Experimental: Enable transitions of color, brightness and speed. It does not work properly for all effects.
|
||||||
uint8_t fade_cnt = 0;
|
bool transEffectOverride = false;
|
||||||
|
uint8_t trans_cnt = 0;
|
||||||
unsigned long colorFadeDelay = 0;
|
unsigned long colorFadeDelay = 0;
|
||||||
unsigned long brightnessFadeDelay = 0;
|
unsigned long brightnessFadeDelay = 0;
|
||||||
unsigned long speedFadeDelay = 0;
|
unsigned long speedFadeDelay = 0;
|
||||||
|
|
||||||
#if defined(ENABLE_E131)
|
#if defined(CUSTOM_WS2812FX_ANIMATIONS)
|
||||||
#define MULTICAST false
|
#define MULTICAST false
|
||||||
#define START_UNIVERSE 1 // First DMX Universe to listen for
|
#define START_UNIVERSE 1 // First DMX Universe to listen for
|
||||||
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;
|
||||||
#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;
|
||||||
@@ -142,20 +140,20 @@ uint32_t autoParams[][6] = { // main_color, back_color, xtra_color, speed, mod
|
|||||||
#define DBG_OUTPUT_PORT Serial // Set debug output port
|
#define DBG_OUTPUT_PORT Serial // Set debug output port
|
||||||
|
|
||||||
// List of all color modes
|
// List of all color modes
|
||||||
enum MODE {OFF, AUTO, TV, E131, CUSTOM, HOLD, SET_ALL, SET_MODE, SET_COLOR, SET_SPEED, SET_BRIGHTNESS, INIT_STRIP};
|
enum MODE {OFF, HOLD, SET, SET_SPEED, INIT_STRIP};
|
||||||
MODE mode = SET_ALL; // Standard mode that is active when software starts
|
MODE mode = SET; // Standard mode that is active when software starts
|
||||||
MODE prevmode = INIT_STRIP;
|
MODE prevmode = HOLD; // Do not change
|
||||||
|
|
||||||
|
uint8_t autoCount = 0; // Global variable for storing the counter for automated playback
|
||||||
|
long autoDelay = 0; // Global variable for storing the time to next auto effect
|
||||||
uint8_t ws2812fx_speed = 196; // Global variable for storing the speed for effects --> smaller == slower
|
uint8_t ws2812fx_speed = 196; // Global variable for storing the speed for effects --> smaller == slower
|
||||||
uint8_t ws2812fx_speed_actual = 196; // Global variable for storing the speed for effects while fading --> smaller == slower
|
uint8_t ws2812fx_speed_actual = 196; // Global variable for storing the speed for effects while fading --> smaller == slower
|
||||||
uint8_t brightness = 196; // Global variable for storing the brightness (255 == 100%)
|
uint8_t brightness = 196; // Global variable for storing the brightness (255 == 100%)
|
||||||
uint8_t brightness_actual = 0; // Global variable for storing the brightness while fadeing (255 == 100%)
|
uint8_t brightness_trans = 0; // Global variable for storing the brightness before change
|
||||||
uint8_t brightness_fade = 0; // Global variable for storing the brightness before change
|
uint8_t ws2812fx_mode = 0; // Global variable for storing the WS2812FX mode to set
|
||||||
uint8_t ws2812fx_mode = 0; // Global variable for storing the WS2812FX modes
|
|
||||||
|
|
||||||
uint32_t hex_colors[3] = {}; // Color array for setting colors of WS2812FX
|
uint32_t hex_colors[3] = {}; // Color array for setting colors of WS2812FX
|
||||||
uint32_t hex_colors_actual[3] = {}; // Color array for actual colors of WS2812FX while fading
|
uint32_t hex_colors_trans[3] = {}; // Color array of colors of WS2812FX before fading
|
||||||
uint32_t hex_colors_mem[3] = {}; // Color array of colors of WS2812FX before fading
|
|
||||||
struct ledstate // Data structure to store a state of a single led
|
struct ledstate // Data structure to store a state of a single led
|
||||||
{
|
{
|
||||||
uint8_t red;
|
uint8_t red;
|
||||||
@@ -177,7 +175,7 @@ bool updateState = false;
|
|||||||
// Button handling
|
// Button handling
|
||||||
|
|
||||||
#if defined(ENABLE_BUTTON)
|
#if defined(ENABLE_BUTTON)
|
||||||
//#define BTN_MODE_SHORT "STA|mo|fxm| h| s| r1| g1| b1| w1| r2| g2| b2| w2| r3| g3| b3| w3" // Example
|
//#define BTN_MODE_SHORT "STA|mo|fxm| b| s| r1| g1| b1| w1| r2| g2| b2| w2| r3| g3| b3| w3" // Example
|
||||||
#define BTN_MODE_SHORT "STA| 5| 0|255|196| 0| 0| 0|255| 0| 0| 0| 0| 0| 0| 0| 0" // Static white
|
#define BTN_MODE_SHORT "STA| 5| 0|255|196| 0| 0| 0|255| 0| 0| 0| 0| 0| 0| 0| 0" // Static white
|
||||||
#define BTN_MODE_MEDIUM "STA| 5| 48|200|196|255|102| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0" // Fire flicker
|
#define BTN_MODE_MEDIUM "STA| 5| 48|200|196|255|102| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0" // Fire flicker
|
||||||
#define BTN_MODE_LONG "STA| 5| 46|200|196|255|102| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0" // Fireworks random
|
#define BTN_MODE_LONG "STA| 5| 46|200|196|255|102| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0" // Fireworks random
|
||||||
|
|||||||
+1648
-1666
File diff suppressed because it is too large
Load Diff
@@ -7,8 +7,151 @@ More info on how to create custom aniamtions for WS2812FX: https://github.com/ki
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <FastLED.h> //https://github.com/FastLED/FastLED
|
// ***************************************************************************
|
||||||
|
// Functions and variables for automatic cycling
|
||||||
|
// ***************************************************************************
|
||||||
|
|
||||||
|
void handleAutoPlay() {
|
||||||
|
if (autoDelay <= millis()) {
|
||||||
|
hex_colors[0] = autoParams[autoCount][0];
|
||||||
|
hex_colors[1] = autoParams[autoCount][1];
|
||||||
|
hex_colors[2] = autoParams[autoCount][2];
|
||||||
|
strip->setColors(selected_segment, hex_colors);
|
||||||
|
strip->setSpeed(selected_segment, convertSpeed((uint8_t)autoParams[autoCount][3]));
|
||||||
|
strip->setMode(selected_segment, (uint8_t)autoParams[autoCount][4]);
|
||||||
|
strip->trigger();
|
||||||
|
autoDelay = millis() + (uint32_t)autoParams[autoCount][5];
|
||||||
|
DBG_OUTPUT_PORT.print("autoTick ");
|
||||||
|
DBG_OUTPUT_PORT.printf("autoTick[%d]: {0x%08x, 0x%08x, 0x%08x, %d, %d, %d}\r\n", autoCount, hex_colors[0], hex_colors[1], hex_colors[2], autoParams[autoCount][3], autoParams[autoCount][4], autoParams[autoCount][5]);
|
||||||
|
|
||||||
|
autoCount++;
|
||||||
|
if (autoCount >= (sizeof(autoParams) / sizeof(autoParams[0]))) autoCount = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleAuto() {
|
||||||
|
// Dummy function
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleCustomWS() {
|
||||||
|
// Dummy function
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(CUSTOM_WS2812FX_ANIMATIONS)
|
||||||
|
// ***************************************************************************
|
||||||
|
// TV mode
|
||||||
|
// ***************************************************************************
|
||||||
|
|
||||||
|
uint8_t dipInterval = 10;
|
||||||
|
uint16_t darkTime = 250;
|
||||||
|
unsigned long currentDipTime;
|
||||||
|
unsigned long dipStartTime;
|
||||||
|
unsigned long currentMillis;
|
||||||
|
uint8_t ledState = LOW;
|
||||||
|
long previousMillis = 0;
|
||||||
|
uint16_t led = 5;
|
||||||
|
uint16_t interv = 2000;
|
||||||
|
uint8_t twitch = 50;
|
||||||
|
uint8_t dipCount = 0;
|
||||||
|
boolean timeToDip = false;
|
||||||
|
|
||||||
|
|
||||||
|
void hsb2rgbAN1(uint16_t index, uint8_t sat, uint8_t bright, uint16_t led) {
|
||||||
|
// Source: https://blog.adafruit.com/2012/03/14/constant-brightness-hsb-to-rgb-algorithm/
|
||||||
|
uint8_t temp[5], n = (index >> 8) % 3;
|
||||||
|
temp[0] = temp[3] = (uint8_t)(( (sat ^ 255) * bright) / 255);
|
||||||
|
temp[1] = temp[4] = (uint8_t)((((( (index & 255) * sat) / 255) + (sat ^ 255)) * bright) / 255);
|
||||||
|
temp[2] = (uint8_t)(((((((index & 255) ^ 255) * sat) / 255) + (sat ^ 255)) * bright) / 255);
|
||||||
|
strip->setPixelColor(led, temp[n + 2], temp[n + 1], temp[n], 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void updateLed (uint16_t led, uint8_t brightness) {
|
||||||
|
ledstates[led] = brightness;
|
||||||
|
for (uint16_t i=0; i<WS2812FXStripSettings.stripSize; i++) {
|
||||||
|
uint16_t index = (i%3 == 0) ? 400 : random(0,767);
|
||||||
|
hsb2rgbAN1(index, 200, ledstates[i], i);
|
||||||
|
}
|
||||||
|
//strip->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// See: http://forum.mysensors.org/topic/85/phoneytv-for-vera-is-here/13
|
||||||
|
void handleTV() {
|
||||||
|
if (timeToDip == false) {
|
||||||
|
currentMillis = millis();
|
||||||
|
if(currentMillis-previousMillis > interv) {
|
||||||
|
previousMillis = currentMillis;
|
||||||
|
//interv = random(750,4001);//Adjusts the interval for more/less frequent random light changes
|
||||||
|
interv = random(1000-(ws2812fx_speed*2),5001-(ws2812fx_speed*8));
|
||||||
|
twitch = random(40,100);// Twitch provides motion effect but can be a bit much if too high
|
||||||
|
dipCount = dipCount++;
|
||||||
|
}
|
||||||
|
if(currentMillis-previousMillis<twitch) {
|
||||||
|
led=random(0, WS2812FXStripSettings.stripSize - 1);
|
||||||
|
ledState = ledState == LOW ? HIGH: LOW; // if the LED is off turn it on and vice-versa:
|
||||||
|
updateLed(led, (ledState) ? 255 : 0);
|
||||||
|
if (dipCount > dipInterval) {
|
||||||
|
DBG_OUTPUT_PORT.println("dip");
|
||||||
|
timeToDip = true;
|
||||||
|
dipCount = 0;
|
||||||
|
dipStartTime = millis();
|
||||||
|
darkTime = random(50,150);
|
||||||
|
dipInterval = random(5,250);// cycles of flicker
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DBG_OUTPUT_PORT.println("Dip Time");
|
||||||
|
currentDipTime = millis();
|
||||||
|
if (currentDipTime - dipStartTime < darkTime) {
|
||||||
|
for (uint16_t i=3; i<WS2812FXStripSettings.stripSize; i++) {
|
||||||
|
updateLed(i, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
timeToDip = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleE131(){
|
||||||
|
if (!e131->isEmpty())
|
||||||
|
{
|
||||||
|
e131_packet_t packet;
|
||||||
|
e131->pull(&packet); // Pull packet from ring buffer
|
||||||
|
|
||||||
|
uint16_t universe = htons(packet.universe);
|
||||||
|
uint8_t *data = packet.property_values + 1;
|
||||||
|
|
||||||
|
if (universe < START_UNIVERSE || universe > END_UNIVERSE) return; //async will take care about filling the buffer
|
||||||
|
|
||||||
|
// Serial.printf("Universe %u / %u Channels | Packet#: %u / Errors: %u / CH1: %u\n",
|
||||||
|
// htons(packet.universe), // The Universe for this packet
|
||||||
|
// htons(packet.property_value_count) - 1, // Start code is ignored, we're interested in dimmer data
|
||||||
|
// e131.stats.num_packets, // Packet counter
|
||||||
|
// e131.stats.packet_errors, // Packet error counter
|
||||||
|
// packet.property_values[1]); // Dimmer data for Channel 1
|
||||||
|
/* #if defined(RGBW)
|
||||||
|
uint16_t multipacketOffset = (universe - START_UNIVERSE) * 128; //if more than 128 LEDs * 4 colors = 512 channels, client will send in next higher universe
|
||||||
|
if (NUMLEDS <= multipacketOffset) return;
|
||||||
|
uint16_t len = (128 + multipacketOffset > WS2812FXStripSettings.stripSize) ? (WS2812FXStripSettings.stripSize - multipacketOffset) : 128;
|
||||||
|
#else*/
|
||||||
|
uint16_t multipacketOffset = (universe - START_UNIVERSE) * 170; //if more than 170 LEDs * 3 colors = 510 channels, client will send in next higher universe
|
||||||
|
if (WS2812FXStripSettings.stripSize <= multipacketOffset) return;
|
||||||
|
uint16_t len = (170 + multipacketOffset > WS2812FXStripSettings.stripSize) ? (WS2812FXStripSettings.stripSize - multipacketOffset) : 170;
|
||||||
|
/* #endif */
|
||||||
|
for (uint16_t i = 0; i < len; i++){
|
||||||
|
uint16_t j = i * 3;
|
||||||
|
/* #if defined(RGBW)
|
||||||
|
strip->setPixelColor(i + multipacketOffset, data[j], data[j + 1], data[j + 2], data[j + 3]);
|
||||||
|
#else */
|
||||||
|
strip->setPixelColor(i + multipacketOffset, data[j], data[j + 1], data[j + 2], 0);
|
||||||
|
/* #endif */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include <FastLED.h> //https://github.com/FastLED/FastLED
|
||||||
/*
|
/*
|
||||||
* paste in the Fire2012 code with a small edit at the end which uses the
|
* paste in the Fire2012 code with a small edit at the end which uses the
|
||||||
* setPixelColor() function to copy the color data to the ws2812fx instance.
|
* setPixelColor() function to copy the color data to the ws2812fx instance.
|
||||||
@@ -95,17 +238,39 @@ void Gradient() {
|
|||||||
} else {
|
} else {
|
||||||
pixelnumber = j;
|
pixelnumber = j;
|
||||||
}
|
}
|
||||||
color = fade(hex_colors_actual[1], hex_colors_actual[0], (j*255)/(WS2812FXStripSettings.stripSize - 1));
|
color = trans(strip->getColors(selected_segment)[1], strip->getColors(selected_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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
uint16_t myCustomEffect0() {
|
uint16_t myCustomEffect0() {
|
||||||
Fire2012();
|
handleAuto();
|
||||||
return (strip->getSpeed() / WS2812FXStripSettings.stripSize);
|
return (strip->getSpeed() / WS2812FXStripSettings.stripSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t myCustomEffect1() {
|
uint16_t myCustomEffect1() {
|
||||||
|
handleCustomWS();
|
||||||
|
return (strip->getSpeed() / WS2812FXStripSettings.stripSize);
|
||||||
|
}
|
||||||
|
#if defined(CUSTOM_WS2812FX_ANIMATIONS)
|
||||||
|
uint16_t myCustomEffect2() {
|
||||||
|
handleTV();
|
||||||
|
return (strip->getSpeed() / WS2812FXStripSettings.stripSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t myCustomEffect3() {
|
||||||
|
handleE131();
|
||||||
|
return (strip->getSpeed() / WS2812FXStripSettings.stripSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t myCustomEffect4() {
|
||||||
|
Fire2012();
|
||||||
|
return (strip->getSpeed() / WS2812FXStripSettings.stripSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t myCustomEffect5() {
|
||||||
Gradient();
|
Gradient();
|
||||||
return (strip->getSpeed() / WS2812FXStripSettings.stripSize);
|
return (strip->getSpeed() / WS2812FXStripSettings.stripSize);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -1,77 +0,0 @@
|
|||||||
// ***************************************************************************
|
|
||||||
// TV mode
|
|
||||||
// ***************************************************************************
|
|
||||||
|
|
||||||
uint8_t dipInterval = 10;
|
|
||||||
uint16_t darkTime = 250;
|
|
||||||
unsigned long currentDipTime;
|
|
||||||
unsigned long dipStartTime;
|
|
||||||
unsigned long currentMillis;
|
|
||||||
uint8_t ledState = LOW;
|
|
||||||
long previousMillis = 0;
|
|
||||||
uint16_t led = 5;
|
|
||||||
uint16_t interv = 2000;
|
|
||||||
uint8_t twitch = 50;
|
|
||||||
uint8_t dipCount = 0;
|
|
||||||
uint8_t analogLevel = 100;
|
|
||||||
boolean timeToDip = false;
|
|
||||||
|
|
||||||
|
|
||||||
void hsb2rgbAN1(uint16_t index, uint8_t sat, uint8_t bright, uint8_t myled) {
|
|
||||||
// Source: https://blog.adafruit.com/2012/03/14/constant-brightness-hsb-to-rgb-algorithm/
|
|
||||||
uint8_t temp[5], n = (index >> 8) % 3;
|
|
||||||
temp[0] = temp[3] = (uint8_t)(( (sat ^ 255) * bright) / 255);
|
|
||||||
temp[1] = temp[4] = (uint8_t)((((( (index & 255) * sat) / 255) + (sat ^ 255)) * bright) / 255);
|
|
||||||
temp[2] = (uint8_t)(((((((index & 255) ^ 255) * sat) / 255) + (sat ^ 255)) * bright) / 255);
|
|
||||||
strip->setPixelColor(myled, temp[n + 2], temp[n + 1], temp[n], 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void updateLed (uint16_t led, uint8_t brightness) {
|
|
||||||
ledstates[led] = brightness;
|
|
||||||
for (uint16_t i=0; i<WS2812FXStripSettings.stripSize; i++) {
|
|
||||||
uint16_t index = (i%3 == 0) ? 400 : random(0,767);
|
|
||||||
hsb2rgbAN1(index, 200, ledstates[i], i);
|
|
||||||
}
|
|
||||||
strip->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// See: http://forum.mysensors.org/topic/85/phoneytv-for-vera-is-here/13
|
|
||||||
void handleTV() {
|
|
||||||
if (timeToDip == false) {
|
|
||||||
currentMillis = millis();
|
|
||||||
if(currentMillis-previousMillis > interv) {
|
|
||||||
previousMillis = currentMillis;
|
|
||||||
//interv = random(750,4001);//Adjusts the interval for more/less frequent random light changes
|
|
||||||
interv = random(1000-(ws2812fx_speed*2),5001-(ws2812fx_speed*8));
|
|
||||||
twitch = random(40,100);// Twitch provides motion effect but can be a bit much if too high
|
|
||||||
dipCount = dipCount++;
|
|
||||||
}
|
|
||||||
if(currentMillis-previousMillis<twitch) {
|
|
||||||
led=random(0, WS2812FXStripSettings.stripSize - 1);
|
|
||||||
analogLevel=random(50,255);// set the range of the 3 pwm leds
|
|
||||||
ledState = ledState == LOW ? HIGH: LOW; // if the LED is off turn it on and vice-versa:
|
|
||||||
updateLed(led, (ledState) ? 255 : 0);
|
|
||||||
if (dipCount > dipInterval) {
|
|
||||||
DBG_OUTPUT_PORT.println("dip");
|
|
||||||
timeToDip = true;
|
|
||||||
dipCount = 0;
|
|
||||||
dipStartTime = millis();
|
|
||||||
darkTime = random(50,150);
|
|
||||||
dipInterval = random(5,250);// cycles of flicker
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
DBG_OUTPUT_PORT.println("Dip Time");
|
|
||||||
currentDipTime = millis();
|
|
||||||
if (currentDipTime - dipStartTime < darkTime) {
|
|
||||||
for (uint16_t i=3; i<WS2812FXStripSettings.stripSize; i++) {
|
|
||||||
updateLed(i, 0);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
timeToDip = false;
|
|
||||||
}
|
|
||||||
//strip->show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,70 +3,52 @@
|
|||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
|
||||||
// Prototypes
|
// Prototypes
|
||||||
void handleAutoStart();
|
|
||||||
char * listStatusJSON();
|
char * listStatusJSON();
|
||||||
#if defined(ENABLE_STATE_SAVE)
|
#if defined(ENABLE_STATE_SAVE)
|
||||||
bool writeConfigFS(bool);
|
bool writeConfigFS(bool);
|
||||||
void tickerSaveConfig();
|
void tickerSaveConfig();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ENABLE_E131)
|
|
||||||
void handleE131(){
|
|
||||||
if (!e131->isEmpty())
|
|
||||||
{
|
|
||||||
e131_packet_t packet;
|
|
||||||
e131->pull(&packet); // Pull packet from ring buffer
|
|
||||||
|
|
||||||
uint16_t universe = htons(packet.universe);
|
|
||||||
uint8_t *data = packet.property_values + 1;
|
|
||||||
|
|
||||||
if (universe < START_UNIVERSE || universe > END_UNIVERSE) return; //async will take care about filling the buffer
|
|
||||||
|
|
||||||
// Serial.printf("Universe %u / %u Channels | Packet#: %u / Errors: %u / CH1: %u\n",
|
|
||||||
// htons(packet.universe), // The Universe for this packet
|
|
||||||
// htons(packet.property_value_count) - 1, // Start code is ignored, we're interested in dimmer data
|
|
||||||
// e131.stats.num_packets, // Packet counter
|
|
||||||
// e131.stats.packet_errors, // Packet error counter
|
|
||||||
// packet.property_values[1]); // Dimmer data for Channel 1
|
|
||||||
/* #if defined(RGBW)
|
|
||||||
uint16_t multipacketOffset = (universe - START_UNIVERSE) * 128; //if more than 128 LEDs * 4 colors = 512 channels, client will send in next higher universe
|
|
||||||
if (NUMLEDS <= multipacketOffset) return;
|
|
||||||
uint16_t len = (128 + multipacketOffset > WS2812FXStripSettings.stripSize) ? (WS2812FXStripSettings.stripSize - multipacketOffset) : 128;
|
|
||||||
#else*/
|
|
||||||
uint16_t multipacketOffset = (universe - START_UNIVERSE) * 170; //if more than 170 LEDs * 3 colors = 510 channels, client will send in next higher universe
|
|
||||||
if (WS2812FXStripSettings.stripSize <= multipacketOffset) return;
|
|
||||||
uint16_t len = (170 + multipacketOffset > WS2812FXStripSettings.stripSize) ? (WS2812FXStripSettings.stripSize - multipacketOffset) : 170;
|
|
||||||
/* #endif */
|
|
||||||
for (uint16_t i = 0; i < len; i++){
|
|
||||||
uint16_t j = i * 3;
|
|
||||||
/* #if defined(RGBW)
|
|
||||||
strip->setPixelColor(i + multipacketOffset, data[j], data[j + 1], data[j + 2], data[j + 3]);
|
|
||||||
#else */
|
|
||||||
strip->setPixelColor(i + multipacketOffset, data[j], data[j + 1], data[j + 2], 0);
|
|
||||||
/* #endif */
|
|
||||||
}
|
|
||||||
strip->show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Call convertColors whenever main_color, back_color or xtra_color changes.
|
// Call convertColors whenever main_color, back_color or xtra_color changes.
|
||||||
|
|
||||||
void convertColors() {
|
void convertColors() {
|
||||||
if ((fadeEffect) && (fade_cnt > 1) && (fade_cnt < 254)) {
|
hex_colors_trans[0] = (uint32_t)(main_color.white << 24) | (main_color.red << 16) | (main_color.green << 8) | main_color.blue;
|
||||||
memcpy(hex_colors_mem, hex_colors_actual, sizeof(hex_colors_actual));
|
hex_colors_trans[1] = (uint32_t)(back_color.white << 24) | (back_color.red << 16) | (back_color.green << 8) | back_color.blue;
|
||||||
DBG_OUTPUT_PORT.println("Color transistion aborted. Restarting...!");
|
hex_colors_trans[2] = (uint32_t)(xtra_color.white << 24) | (xtra_color.red << 16) | (xtra_color.green << 8) | xtra_color.blue;
|
||||||
fade_cnt = 1;
|
|
||||||
} else {
|
|
||||||
memcpy(hex_colors_mem, hex_colors, sizeof(hex_colors));
|
|
||||||
}
|
|
||||||
hex_colors[0] = (uint32_t)(main_color.white << 24) | (main_color.red << 16) | (main_color.green << 8) | main_color.blue;
|
|
||||||
hex_colors[1] = (uint32_t)(back_color.white << 24) | (back_color.red << 16) | (back_color.green << 8) | back_color.blue;
|
|
||||||
hex_colors[2] = (uint32_t)(xtra_color.white << 24) | (xtra_color.red << 16) | (xtra_color.green << 8) | xtra_color.blue;
|
|
||||||
memcpy(hex_colors_actual, hex_colors, sizeof(hex_colors));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void convertColorsFade() {
|
||||||
|
if ((transEffect) && (trans_cnt > 1) && (trans_cnt < 254)) {
|
||||||
|
memcpy(hex_colors, strip->getColors(selected_segment), sizeof(strip->getColors(selected_segment)));
|
||||||
|
DBG_OUTPUT_PORT.println("Color transistion aborted. Restarting...!");
|
||||||
|
trans_cnt = 1;
|
||||||
|
} else {
|
||||||
|
//memcpy(hex_colors, hex_colors_trans, sizeof(hex_colors_trans));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t calculateColorTransitionSteps () {
|
||||||
|
//compare all colors and calculate steps
|
||||||
|
int trans_cnt_max = 0;
|
||||||
|
int calculate_max[4] = {};
|
||||||
|
for (uint8_t i=0; i<3; i++){
|
||||||
|
DBG_OUTPUT_PORT.printf("i: %i\r\n", i);
|
||||||
|
for (uint8_t j=0; j<4; j++) {
|
||||||
|
DBG_OUTPUT_PORT.printf("j: %i\r\n", j);
|
||||||
|
calculate_max[j] = ((hex_colors[i] >> ((3-j)*8)) & 0xFF) - ((hex_colors_trans[i] >> ((3-j)*8)) & 0xFF);
|
||||||
|
calculate_max[j] = abs(calculate_max[j]);
|
||||||
|
trans_cnt_max = max(trans_cnt_max, calculate_max[j]);
|
||||||
|
DBG_OUTPUT_PORT.printf("calcmax: %i %i\r\n", j, calculate_max[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DBG_OUTPUT_PORT.printf("max: %i\r\n", trans_cnt_max);
|
||||||
|
return trans_cnt_max;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void getArgs() {
|
void getArgs() {
|
||||||
if (mode == SET_ALL || mode == SET_COLOR) {
|
if (mode == SET) {
|
||||||
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);
|
||||||
main_color.white = ((rgb >> 24) & 0xFF);
|
main_color.white = ((rgb >> 24) & 0xFF);
|
||||||
@@ -140,17 +122,15 @@ void getArgs() {
|
|||||||
xtra_color.blue = constrain(xtra_color.blue, 0, 255);
|
xtra_color.blue = constrain(xtra_color.blue, 0, 255);
|
||||||
xtra_color.white = constrain(xtra_color.white, 0, 255);
|
xtra_color.white = constrain(xtra_color.white, 0, 255);
|
||||||
}
|
}
|
||||||
if (mode == SET_ALL || mode == SET_SPEED || mode == TV) {
|
if (mode == SET || mode == SET_SPEED) {
|
||||||
if ((server.arg("s") != "") && (server.arg("s").toInt() >= 0) && (server.arg("s").toInt() <= 255)) {
|
if ((server.arg("s") != "") && (server.arg("s").toInt() >= 0) && (server.arg("s").toInt() <= 255)) {
|
||||||
ws2812fx_speed = constrain(server.arg("s").toInt(), 0, 255);
|
ws2812fx_speed = constrain(server.arg("s").toInt(), 0, 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mode == SET_ALL || mode == SET_MODE) {
|
if (mode == SET) {
|
||||||
if ((server.arg("m") != "") && (server.arg("m").toInt() >= 0) && (server.arg("m").toInt() <= strip->getModeCount())) {
|
if ((server.arg("m") != "") && (server.arg("m").toInt() >= 0) && (server.arg("m").toInt() <= strip->getModeCount())) {
|
||||||
ws2812fx_mode = constrain(server.arg("m").toInt(), 0, strip->getModeCount() - 1);
|
ws2812fx_mode = constrain(server.arg("m").toInt(), 0, strip->getModeCount() - 1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (mode == SET_ALL || mode == SET_BRIGHTNESS || mode == AUTO || mode == TV || mode == E131) {
|
|
||||||
if ((server.arg("c") != "") && (server.arg("c").toInt() >= 0) && (server.arg("c").toInt() <= 100)) {
|
if ((server.arg("c") != "") && (server.arg("c").toInt() >= 0) && (server.arg("c").toInt() <= 100)) {
|
||||||
brightness = constrain((int) server.arg("c").toInt() * 2.55, 0, 255);
|
brightness = constrain((int) server.arg("c").toInt() * 2.55, 0, 255);
|
||||||
} else if ((server.arg("p") != "") && (server.arg("p").toInt() >= 0) && (server.arg("p").toInt() <= 255)) {
|
} else if ((server.arg("p") != "") && (server.arg("p").toInt() >= 0) && (server.arg("p").toInt() <= 255)) {
|
||||||
@@ -162,18 +142,22 @@ void getArgs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint16_t convertSpeed(uint8_t mcl_speed) {
|
uint16_t convertSpeed(uint8_t mcl_speed) {
|
||||||
//long ws2812_speed = mcl_speed * 256;
|
|
||||||
uint16_t ws2812_speed = 61760 * (exp(0.0002336 * mcl_speed) - exp(-0.03181 * mcl_speed));
|
uint16_t ws2812_speed = 61760 * (exp(0.0002336 * mcl_speed) - exp(-0.03181 * mcl_speed));
|
||||||
ws2812_speed = SPEED_MAX - ws2812_speed;
|
ws2812_speed = SPEED_MAX - ws2812_speed;
|
||||||
if (ws2812_speed < SPEED_MIN) {
|
ws2812_speed = constrain(ws2812_speed, SPEED_MIN, SPEED_MAX);
|
||||||
ws2812_speed = SPEED_MIN;
|
|
||||||
}
|
|
||||||
if (ws2812_speed > SPEED_MAX) {
|
|
||||||
ws2812_speed = SPEED_MAX;
|
|
||||||
}
|
|
||||||
return ws2812_speed;
|
return ws2812_speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t unconvertSpeed(uint16_t ws2812_speed) {
|
||||||
|
//log((SPEED_MAX - ws2812_speed)/61760) = (0.0002336 * mcl_speed) - (-0.03181 * mcl_speed);
|
||||||
|
//log((SPEED_MAX - ws2812_speed)/61760) = (0.0002336 + 0.03181) * mcl_speed;
|
||||||
|
uint16_t mcl_speed = (log((SPEED_MAX - ws2812_speed)/61760))/ (0.0002336 + 0.03181);
|
||||||
|
//uint16_t mcl_speed = 61760 * (exp(0.0002336 * mcl_speed) - exp(-0.03181 * mcl_speed));
|
||||||
|
mcl_speed = 255 - mcl_speed;
|
||||||
|
mcl_speed = constrain(mcl_speed, 0, 255);
|
||||||
|
return mcl_speed;
|
||||||
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
// Handler functions for WS and MQTT
|
// Handler functions for WS and MQTT
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
@@ -184,7 +168,7 @@ void handleSetMainColor(uint8_t * mypayload) {
|
|||||||
main_color.red = ((rgb >> 16) & 0xFF);
|
main_color.red = ((rgb >> 16) & 0xFF);
|
||||||
main_color.green = ((rgb >> 8) & 0xFF);
|
main_color.green = ((rgb >> 8) & 0xFF);
|
||||||
main_color.blue = ((rgb >> 0) & 0xFF);
|
main_color.blue = ((rgb >> 0) & 0xFF);
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleSetBackColor(uint8_t * mypayload) {
|
void handleSetBackColor(uint8_t * mypayload) {
|
||||||
@@ -194,7 +178,7 @@ void handleSetBackColor(uint8_t * mypayload) {
|
|||||||
back_color.red = ((rgb >> 16) & 0xFF);
|
back_color.red = ((rgb >> 16) & 0xFF);
|
||||||
back_color.green = ((rgb >> 8) & 0xFF);
|
back_color.green = ((rgb >> 8) & 0xFF);
|
||||||
back_color.blue = ((rgb >> 0) & 0xFF);
|
back_color.blue = ((rgb >> 0) & 0xFF);
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
void handleSetXtraColor(uint8_t * mypayload) {
|
void handleSetXtraColor(uint8_t * mypayload) {
|
||||||
// decode rgb data
|
// decode rgb data
|
||||||
@@ -203,7 +187,7 @@ void handleSetXtraColor(uint8_t * mypayload) {
|
|||||||
xtra_color.red = ((rgb >> 16) & 0xFF);
|
xtra_color.red = ((rgb >> 16) & 0xFF);
|
||||||
xtra_color.green = ((rgb >> 8) & 0xFF);
|
xtra_color.green = ((rgb >> 8) & 0xFF);
|
||||||
xtra_color.blue = ((rgb >> 0) & 0xFF);
|
xtra_color.blue = ((rgb >> 0) & 0xFF);
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleSetAllMode(uint8_t * mypayload) {
|
void handleSetAllMode(uint8_t * mypayload) {
|
||||||
@@ -215,7 +199,7 @@ void handleSetAllMode(uint8_t * mypayload) {
|
|||||||
main_color.blue = ((rgb >> 0) & 0xFF);
|
main_color.blue = ((rgb >> 0) & 0xFF);
|
||||||
DBG_OUTPUT_PORT.printf("WS: Set all leds to main color: R: [%u] G: [%u] B: [%u] W: [%u]\r\n", main_color.red, main_color.green, main_color.blue, main_color.white);
|
DBG_OUTPUT_PORT.printf("WS: Set all leds to main color: R: [%u] G: [%u] B: [%u] W: [%u]\r\n", main_color.red, main_color.green, main_color.blue, main_color.white);
|
||||||
ws2812fx_mode = FX_MODE_STATIC;
|
ws2812fx_mode = FX_MODE_STATIC;
|
||||||
mode = SET_ALL;
|
mode = SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleSetSingleLED(uint8_t * mypayload, uint8_t firstChar = 0) {
|
void handleSetSingleLED(uint8_t * mypayload, uint8_t firstChar = 0) {
|
||||||
@@ -260,7 +244,8 @@ void handleSetSingleLED(uint8_t * mypayload, uint8_t firstChar = 0) {
|
|||||||
strip->setPixelColor(led, color.red, color.green, color.blue, color.white);
|
strip->setPixelColor(led, color.red, color.green, color.blue, color.white);
|
||||||
strip->show();
|
strip->show();
|
||||||
}
|
}
|
||||||
mode = CUSTOM;
|
mode = HOLD;
|
||||||
|
ws2812fx_mode= FX_MODE_CUSTOM_1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleSetDifferentColors(uint8_t * mypayload) {
|
void handleSetDifferentColors(uint8_t * mypayload) {
|
||||||
@@ -422,6 +407,7 @@ bool setConfByConfString(String saved_conf_string) {
|
|||||||
getValue(saved_conf_string, '|', 8).toCharArray(tmp_rgbOrder, 4);
|
getValue(saved_conf_string, '|', 8).toCharArray(tmp_rgbOrder, 4);
|
||||||
checkRGBOrder(tmp_rgbOrder);
|
checkRGBOrder(tmp_rgbOrder);
|
||||||
WS2812FXStripSettings.fxoptions = constrain(((getValue(saved_conf_string, '|', 9).toInt()>>1)<<1), 0, 255);
|
WS2812FXStripSettings.fxoptions = constrain(((getValue(saved_conf_string, '|', 9).toInt()>>1)<<1), 0, 255);
|
||||||
|
transEffect = getValue(saved_conf_string, '|', 10).toInt();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
DBG_OUTPUT_PORT.println("Saved conf not found!");
|
DBG_OUTPUT_PORT.println("Saved conf not found!");
|
||||||
@@ -430,8 +416,6 @@ bool setConfByConfString(String saved_conf_string) {
|
|||||||
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());
|
||||||
@@ -470,7 +454,7 @@ bool setModeByStateString(String saved_state_string) {
|
|||||||
DBG_OUTPUT_PORT.print("Set to state: ");
|
DBG_OUTPUT_PORT.print("Set to state: ");
|
||||||
DBG_OUTPUT_PORT.println(listStatusJSON());
|
DBG_OUTPUT_PORT.println(listStatusJSON());
|
||||||
//prevmode=mode;
|
//prevmode=mode;
|
||||||
//mode = SET_ALL;
|
//mode = SET;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
DBG_OUTPUT_PORT.println("Saved state not found!");
|
DBG_OUTPUT_PORT.println("Saved state not found!");
|
||||||
@@ -479,91 +463,19 @@ bool setModeByStateString(String saved_state_string) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ENABLE_LEGACY_ANIMATIONS)
|
|
||||||
void handleSetNamedMode(uint8_t * mypayload) {
|
|
||||||
if (strcmp((char *) &mypayload[1], "off") == 0) {
|
|
||||||
mode = OFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(ENABLE_TV)
|
|
||||||
if (strcmp((char *) &mypayload[1], "tv") == 0) {
|
|
||||||
mode = TV;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ENABLE_E131)
|
|
||||||
if (strcmp((char *) &mypayload[1], "e131") == 0) {
|
|
||||||
mode = E131;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (strcmp((char *) &mypayload[1], "auto") == 0) {
|
|
||||||
mode = AUTO;
|
|
||||||
}
|
|
||||||
if (strcmp((char *) &mypayload[1], "all") == 0) {
|
|
||||||
ws2812fx_mode = FX_MODE_STATIC;
|
|
||||||
mode = SET_ALL;
|
|
||||||
}
|
|
||||||
if (strcmp((char *) &mypayload[1], "wipe") == 0) {
|
|
||||||
ws2812fx_mode = FX_MODE_COLOR_WIPE;
|
|
||||||
mode = SET_MODE;
|
|
||||||
}
|
|
||||||
if (strcmp((char *) &mypayload[1], "rainbow") == 0) {
|
|
||||||
ws2812fx_mode = FX_MODE_RAINBOW;
|
|
||||||
mode = SET_MODE;
|
|
||||||
}
|
|
||||||
if (strcmp((char *) &mypayload[1], "rainbowCycle") == 0) {
|
|
||||||
ws2812fx_mode = FX_MODE_RAINBOW_CYCLE;
|
|
||||||
mode = SET_MODE;
|
|
||||||
}
|
|
||||||
if (strcmp((char *) &mypayload[1], "theaterchase") == 0) {
|
|
||||||
ws2812fx_mode = FX_MODE_THEATER_CHASE;
|
|
||||||
mode = SET_MODE;
|
|
||||||
}
|
|
||||||
if (strcmp((char *) &mypayload[1], "twinkleRandom") == 0) {
|
|
||||||
ws2812fx_mode = FX_MODE_TWINKLE_RANDOM;
|
|
||||||
mode = SET_MODE;
|
|
||||||
}
|
|
||||||
if (strcmp((char *) &mypayload[1], "theaterchaseRainbow") == 0) {
|
|
||||||
ws2812fx_mode = FX_MODE_THEATER_CHASE_RAINBOW;
|
|
||||||
mode = SET_MODE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void handleSetWS2812FXMode(uint8_t * mypayload) {
|
void handleSetWS2812FXMode(uint8_t * mypayload) {
|
||||||
if (isDigit(mypayload[1])) {
|
if (isDigit(mypayload[1])) {
|
||||||
ws2812fx_mode = (uint8_t) strtol((const char *) &mypayload[1], NULL, 10);
|
ws2812fx_mode = (uint8_t) strtol((const char *) &mypayload[1], NULL, 10);
|
||||||
ws2812fx_mode = constrain(ws2812fx_mode, 0, strip->getModeCount() - 1);
|
ws2812fx_mode = constrain(ws2812fx_mode, 0, strip->getModeCount() - 1);
|
||||||
mode = SET_MODE;
|
mode = SET;
|
||||||
} else {
|
} else {
|
||||||
if (strcmp((char *) &mypayload[1], "off") == 0) {
|
if (strcmp((char *) &mypayload[1], "off") == 0) {
|
||||||
mode = OFF;
|
mode = OFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp((char *) &mypayload[1], "auto") == 0) {
|
|
||||||
mode = AUTO;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(ENABLE_TV)
|
|
||||||
if (strcmp((char *) &mypayload[1], "tv") == 0) {
|
|
||||||
mode = TV;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ENABLE_E131)
|
|
||||||
if (strcmp((char *) &mypayload[1], "e131") == 0) {
|
|
||||||
mode = E131;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (strcmp((char *) &mypayload[1], "custom") == 0) {
|
|
||||||
mode = CUSTOM;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char * listStatusJSON() {
|
char * listStatusJSON() {
|
||||||
//uint8_t tmp_mode = (mode == SET_MODE) ? (uint8_t) ws2812fx_mode : strip->getMode();
|
|
||||||
const size_t bufferSize = JSON_ARRAY_SIZE(12) + JSON_OBJECT_SIZE(6) + 500;
|
const size_t bufferSize = JSON_ARRAY_SIZE(12) + JSON_OBJECT_SIZE(6) + 500;
|
||||||
DynamicJsonDocument jsonBuffer(bufferSize);
|
DynamicJsonDocument jsonBuffer(bufferSize);
|
||||||
JsonObject root = jsonBuffer.to<JsonObject>();
|
JsonObject root = jsonBuffer.to<JsonObject>();
|
||||||
@@ -602,7 +514,6 @@ void getStatusJSON() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
char * listConfigJSON() {
|
char * listConfigJSON() {
|
||||||
//uint8_t tmp_mode = (mode == SET_MODE) ? (uint8_t) ws2812fx_mode : strip->getMode();
|
|
||||||
#if defined(ENABLE_MQTT)
|
#if defined(ENABLE_MQTT)
|
||||||
const size_t bufferSize = JSON_OBJECT_SIZE(9) + 500;
|
const size_t bufferSize = JSON_OBJECT_SIZE(9) + 500;
|
||||||
#else
|
#else
|
||||||
@@ -621,6 +532,7 @@ char * listConfigJSON() {
|
|||||||
root["ws_rgbo"] = WS2812FXStripSettings.RGBOrder;
|
root["ws_rgbo"] = WS2812FXStripSettings.RGBOrder;
|
||||||
root["ws_pin"] = WS2812FXStripSettings.pin;
|
root["ws_pin"] = WS2812FXStripSettings.pin;
|
||||||
root["ws_fxopt"] = WS2812FXStripSettings.fxoptions;
|
root["ws_fxopt"] = WS2812FXStripSettings.fxoptions;
|
||||||
|
root["transEffect"] = transEffect;
|
||||||
uint16_t msg_len = measureJson(root) + 1;
|
uint16_t msg_len = measureJson(root) + 1;
|
||||||
char * buffer = (char *) malloc(msg_len);
|
char * buffer = (char *) malloc(msg_len);
|
||||||
serializeJson(root, buffer, msg_len);
|
serializeJson(root, buffer, msg_len);
|
||||||
@@ -642,19 +554,6 @@ char * listModesJSON() {
|
|||||||
JsonObject objectoff = root.createNestedObject();
|
JsonObject objectoff = root.createNestedObject();
|
||||||
objectoff["mode"] = "off";
|
objectoff["mode"] = "off";
|
||||||
objectoff["name"] = "OFF";
|
objectoff["name"] = "OFF";
|
||||||
#if defined(ENABLE_TV)
|
|
||||||
JsonObject objecttv = root.createNestedObject();
|
|
||||||
objecttv["mode"] = "tv";
|
|
||||||
objecttv["name"] = "TV";
|
|
||||||
#endif
|
|
||||||
#if defined(ENABLE_E131)
|
|
||||||
JsonObject objecte131 = root.createNestedObject();
|
|
||||||
objecte131["mode"] = "e131";
|
|
||||||
objecte131["name"] = "E131";
|
|
||||||
#endif
|
|
||||||
JsonObject objectcustom = root.createNestedObject();
|
|
||||||
objectcustom["mode"] = "custom";
|
|
||||||
objectcustom["name"] = "CUSTOM WS";
|
|
||||||
for (uint8_t i = 0; i < strip->getModeCount(); i++) {
|
for (uint8_t i = 0; i < strip->getModeCount(); i++) {
|
||||||
JsonObject object = root.createNestedObject();
|
JsonObject object = root.createNestedObject();
|
||||||
object["mode"] = i;
|
object["mode"] = i;
|
||||||
@@ -713,37 +612,6 @@ void handleNotFound() {
|
|||||||
server.send ( 404, "text/plain", message );
|
server.send ( 404, "text/plain", message );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
|
||||||
// Functions and variables for automatic cycling
|
|
||||||
// ***************************************************************************
|
|
||||||
Ticker autoTicker;
|
|
||||||
uint8_t autoCount = 0;
|
|
||||||
|
|
||||||
void autoTick() {
|
|
||||||
uint32_t setcolors[] = {autoParams[autoCount][0],autoParams[autoCount][1],autoParams[autoCount][2]};
|
|
||||||
strip->setColors(0, setcolors);
|
|
||||||
strip->setSpeed(convertSpeed((uint8_t)autoParams[autoCount][3]));
|
|
||||||
strip->setMode((uint8_t)autoParams[autoCount][4]);
|
|
||||||
strip->trigger();
|
|
||||||
autoTicker.once_ms((uint32_t)autoParams[autoCount][5], autoTick);
|
|
||||||
DBG_OUTPUT_PORT.print("autoTick ");
|
|
||||||
DBG_OUTPUT_PORT.printf("autoTick[%d]: {0x%08x, 0x%08x, 0x%08x, %d, %d, %d}\r\n", autoCount, autoParams[autoCount][0], autoParams[autoCount][1], autoParams[autoCount][2], autoParams[autoCount][3], autoParams[autoCount][4], autoParams[autoCount][5]);
|
|
||||||
|
|
||||||
autoCount++;
|
|
||||||
if (autoCount >= (sizeof(autoParams) / sizeof(autoParams[0]))) autoCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void handleAutoStart() {
|
|
||||||
DBG_OUTPUT_PORT.println("Starting AUTO mode.");
|
|
||||||
autoCount = 0;
|
|
||||||
autoTick();
|
|
||||||
}
|
|
||||||
|
|
||||||
void handleAutoStop() {
|
|
||||||
DBG_OUTPUT_PORT.println("Stopping AUTO mode.");
|
|
||||||
autoTicker.detach();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
// Functions and variables
|
// Functions and variables
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
@@ -787,7 +655,7 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
|||||||
if (payload[0] == '%') {
|
if (payload[0] == '%') {
|
||||||
uint8_t b = (uint8_t) strtol((const char *) &payload[1], NULL, 10);
|
uint8_t b = (uint8_t) strtol((const char *) &payload[1], NULL, 10);
|
||||||
brightness = constrain(b, 0, 255);
|
brightness = constrain(b, 0, 255);
|
||||||
mode = SET_BRIGHTNESS;
|
mode = SET;
|
||||||
Dbg_Prefix(mqtt, num);
|
Dbg_Prefix(mqtt, num);
|
||||||
DBG_OUTPUT_PORT.printf("Set brightness to: [%u]\r\n", brightness);
|
DBG_OUTPUT_PORT.printf("Set brightness to: [%u]\r\n", brightness);
|
||||||
}
|
}
|
||||||
@@ -829,16 +697,6 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ENABLE_LEGACY_ANIMATIONS)
|
|
||||||
// = ==> Activate named mode
|
|
||||||
if (payload[0] == '=') {
|
|
||||||
// we get mode data
|
|
||||||
handleSetNamedMode(payload);
|
|
||||||
Dbg_Prefix(mqtt, num);
|
|
||||||
DBG_OUTPUT_PORT.printf("Activated mode [%u]!\r\n", mode);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// $ ==> Get status Info.
|
// $ ==> Get status Info.
|
||||||
if (payload[0] == '$') {
|
if (payload[0] == '$') {
|
||||||
char * buffer = listStatusJSON();
|
char * buffer = listStatusJSON();
|
||||||
@@ -896,7 +754,7 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
|||||||
tmp_fxoptions[3] = 0x00;
|
tmp_fxoptions[3] = 0x00;
|
||||||
WS2812FXStripSettings.fxoptions = ((constrain(atoi(tmp_fxoptions), 0, 255)>>1)<<1);
|
WS2812FXStripSettings.fxoptions = ((constrain(atoi(tmp_fxoptions), 0, 255)>>1)<<1);
|
||||||
updateStrip = true;
|
updateStrip = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (updateStrip){
|
if (updateStrip){
|
||||||
mode = INIT_STRIP;
|
mode = INIT_STRIP;
|
||||||
@@ -935,7 +793,14 @@ void checkpayload(uint8_t * payload, bool mqtt = false, uint8_t num = 0) {
|
|||||||
initMqtt();
|
initMqtt();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (payload[1] == 'e') {
|
||||||
|
char tmp_transEffect[2];
|
||||||
|
snprintf(tmp_transEffect, sizeof(tmp_transEffect), "%s", &payload[2]);
|
||||||
|
tmp_transEffect[sizeof(tmp_transEffect) - 1] = 0x00;
|
||||||
|
transEffect = atoi(tmp_transEffect);
|
||||||
|
updateConf = true;
|
||||||
|
}
|
||||||
|
|
||||||
char * buffer = listConfigJSON();
|
char * buffer = listConfigJSON();
|
||||||
if (mqtt == true) {
|
if (mqtt == true) {
|
||||||
DBG_OUTPUT_PORT.print("MQTT: ");
|
DBG_OUTPUT_PORT.print("MQTT: ");
|
||||||
@@ -1020,18 +885,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
DBG_OUTPUT_PORT.printf("WS: [%u] get Text: %s\r\n", num, payload);
|
DBG_OUTPUT_PORT.printf("WS: [%u] get Text: %s\r\n", num, payload);
|
||||||
|
|
||||||
checkpayload(payload, false, num);
|
checkpayload(payload, false, num);
|
||||||
|
|
||||||
// start auto cycling
|
|
||||||
if (strcmp((char *)payload, "start") == 0 ) {
|
|
||||||
mode = AUTO;
|
|
||||||
webSocket.sendTXT(num, "OK");
|
|
||||||
}
|
|
||||||
|
|
||||||
// stop auto cycling
|
|
||||||
if (strcmp((char *)payload, "stop") == 0 ) {
|
|
||||||
mode = SET_ALL;
|
|
||||||
webSocket.sendTXT(num, "OK");
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1133,23 +986,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
if (mode == OFF){
|
if (mode == OFF){
|
||||||
root["effect"] = "OFF";
|
root["effect"] = "OFF";
|
||||||
} else {
|
} else {
|
||||||
if (mode == AUTO){
|
root["effect"] = strip->getModeName(strip->getMode());
|
||||||
root["effect"] = "AUTO";
|
|
||||||
} else {
|
|
||||||
if (mode == TV){
|
|
||||||
root["effect"] = "TV";
|
|
||||||
} else {
|
|
||||||
if (mode == E131){
|
|
||||||
root["effect"] = "E131";
|
|
||||||
} else {
|
|
||||||
if (mode == CUSTOM){
|
|
||||||
root["effect"] = "CUSTOM WS";
|
|
||||||
} else {
|
|
||||||
root["effect"] = strip->getModeName(strip->getMode());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
char buffer[measureJson(root) + 1];
|
char buffer[measureJson(root) + 1];
|
||||||
@@ -1184,7 +1021,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
if (root.containsKey("state")) {
|
if (root.containsKey("state")) {
|
||||||
const char* state_in = root["state"];
|
const char* state_in = root["state"];
|
||||||
if (strcmp(state_in, on_cmd) == 0) {
|
if (strcmp(state_in, on_cmd) == 0) {
|
||||||
mode = SET_ALL;
|
mode = SET;
|
||||||
}
|
}
|
||||||
else if (strcmp(state_in, off_cmd) == 0) {
|
else if (strcmp(state_in, off_cmd) == 0) {
|
||||||
mode = OFF;
|
mode = OFF;
|
||||||
@@ -1207,14 +1044,14 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
xtra_color.green = (uint8_t) color["g3"];
|
xtra_color.green = (uint8_t) color["g3"];
|
||||||
xtra_color.blue = (uint8_t) color["b3"];
|
xtra_color.blue = (uint8_t) color["b3"];
|
||||||
xtra_color.white = (uint8_t) color["w3"];
|
xtra_color.white = (uint8_t) color["w3"];
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root.containsKey("white_value")) {
|
if (root.containsKey("white_value")) {
|
||||||
uint8_t json_white_value = constrain((uint8_t) root["white_value"], 0, 255);
|
uint8_t json_white_value = constrain((uint8_t) root["white_value"], 0, 255);
|
||||||
if (json_white_value != main_color.white) {
|
if (json_white_value != main_color.white) {
|
||||||
main_color.white = json_white_value;
|
main_color.white = json_white_value;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1231,14 +1068,14 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
color_temp = (uint16_t) root["color_temp"];
|
color_temp = (uint16_t) root["color_temp"];
|
||||||
uint16_t kelvin = 1000000 / color_temp;
|
uint16_t kelvin = 1000000 / color_temp;
|
||||||
main_color = temp2rgb(kelvin);
|
main_color = temp2rgb(kelvin);
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root.containsKey("brightness")) {
|
if (root.containsKey("brightness")) {
|
||||||
uint8_t json_brightness = constrain((uint8_t) root["brightness"], 0, 255); //fix #224
|
uint8_t json_brightness = constrain((uint8_t) root["brightness"], 0, 255); //fix #224
|
||||||
if (json_brightness != brightness) {
|
if (json_brightness != brightness) {
|
||||||
brightness = json_brightness;
|
brightness = json_brightness;
|
||||||
mode = SET_BRIGHTNESS;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1248,26 +1085,10 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
if(effectString == "OFF"){
|
if(effectString == "OFF"){
|
||||||
mode = OFF;
|
mode = OFF;
|
||||||
}
|
}
|
||||||
if(effectString == "AUTO"){
|
|
||||||
mode = AUTO;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#if defined(ENABLE_TV) and defined(ENABLE_HOMEASSISTANT)
|
|
||||||
if(effectString == "TV"){
|
|
||||||
mode = TV;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if defined(ENABLE_E131) and defined(ENABLE_HOMEASSISTANT)
|
|
||||||
if(effectString == "E131"){
|
|
||||||
mode = E131;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if(effectString == "CUSTOM WS"){
|
|
||||||
mode = CUSTOM;
|
|
||||||
}
|
|
||||||
for (uint8_t i = 0; i < strip->getModeCount(); i++) {
|
for (uint8_t i = 0; i < strip->getModeCount(); i++) {
|
||||||
if(String(strip->getModeName(i)) == effectString) {
|
if(String(strip->getModeName(i)) == effectString) {
|
||||||
mode = SET_MODE;
|
mode = SET;
|
||||||
ws2812fx_mode = i;
|
ws2812fx_mode = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1356,14 +1177,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
root["effect"] = "true";
|
root["effect"] = "true";
|
||||||
JsonArray effect_list = root.createNestedArray("effect_list");
|
JsonArray effect_list = root.createNestedArray("effect_list");
|
||||||
effect_list.add("OFF");
|
effect_list.add("OFF");
|
||||||
effect_list.add("AUTO");
|
|
||||||
#if defined(ENABLE_TV)
|
|
||||||
effect_list.add("TV");
|
|
||||||
#endif
|
|
||||||
#if defined(ENABLE_E131)
|
|
||||||
effect_list.add("E131");
|
|
||||||
#endif
|
|
||||||
effect_list.add("CUSTOM WS");
|
|
||||||
for (uint8_t i = 0; i < strip->getModeCount(); i++) {
|
for (uint8_t i = 0; i < strip->getModeCount(); i++) {
|
||||||
effect_list.add(strip->getModeName(i));
|
effect_list.add(strip->getModeName(i));
|
||||||
}
|
}
|
||||||
@@ -1469,14 +1282,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
root["effect"] = "true";
|
root["effect"] = "true";
|
||||||
JsonArray effect_list = root.createNestedArray("effect_list");
|
JsonArray effect_list = root.createNestedArray("effect_list");
|
||||||
effect_list.add("OFF");
|
effect_list.add("OFF");
|
||||||
effect_list.add("AUTO");
|
|
||||||
#if defined(ENABLE_TV)
|
|
||||||
effect_list.add("TV");
|
|
||||||
#endif
|
|
||||||
#if defined(ENABLE_E131)
|
|
||||||
effect_list.add("E131");
|
|
||||||
#endif
|
|
||||||
effect_list.add("CUSTOM WS");
|
|
||||||
for (uint8_t i = 0; i < strip->getModeCount(); i++) {
|
for (uint8_t i = 0; i < strip->getModeCount(); i++) {
|
||||||
effect_list.add(strip->getModeName(i));
|
effect_list.add(strip->getModeName(i));
|
||||||
}
|
}
|
||||||
@@ -1522,7 +1327,8 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
DBG_OUTPUT_PORT.printf("Short button press\r\n");
|
DBG_OUTPUT_PORT.printf("Short button press\r\n");
|
||||||
if (mode == OFF) {
|
if (mode == OFF) {
|
||||||
setModeByStateString(BTN_MODE_SHORT);
|
setModeByStateString(BTN_MODE_SHORT);
|
||||||
mode = SET_ALL;
|
prevmode = mode;
|
||||||
|
mode = SET;
|
||||||
} else {
|
} else {
|
||||||
mode = OFF;
|
mode = OFF;
|
||||||
}
|
}
|
||||||
@@ -1532,14 +1338,16 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
void mediumKeyPress() {
|
void mediumKeyPress() {
|
||||||
DBG_OUTPUT_PORT.printf("Medium button press\r\n");
|
DBG_OUTPUT_PORT.printf("Medium button press\r\n");
|
||||||
setModeByStateString(BTN_MODE_MEDIUM);
|
setModeByStateString(BTN_MODE_MEDIUM);
|
||||||
mode = SET_ALL;
|
prevmode = mode;
|
||||||
|
mode = SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
// called when button is kept pressed for 2 seconds or more
|
// called when button is kept pressed for 2 seconds or more
|
||||||
void longKeyPress() {
|
void longKeyPress() {
|
||||||
DBG_OUTPUT_PORT.printf("Long button press\r\n");
|
DBG_OUTPUT_PORT.printf("Long button press\r\n");
|
||||||
setModeByStateString(BTN_MODE_LONG);
|
setModeByStateString(BTN_MODE_LONG);
|
||||||
mode = SET_ALL;
|
prevmode = mode;
|
||||||
|
mode = SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
void button() {
|
void button() {
|
||||||
@@ -1583,7 +1391,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
tcs.getData(&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);
|
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;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
// called when button is kept pressed for less than 2 seconds
|
// called when button is kept pressed for less than 2 seconds
|
||||||
@@ -1729,6 +1537,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
|||||||
uint8_t temp_pin;
|
uint8_t temp_pin;
|
||||||
checkPin((uint8_t) root["ws_pin"]);
|
checkPin((uint8_t) root["ws_pin"]);
|
||||||
WS2812FXStripSettings.fxoptions = constrain(root["ws_fxopt"].as<uint8_t>(), 0, 255) & 0xFE;
|
WS2812FXStripSettings.fxoptions = constrain(root["ws_fxopt"].as<uint8_t>(), 0, 255) & 0xFE;
|
||||||
|
transEffect = root["transEffect"].as<bool>();
|
||||||
jsonBuffer.clear();
|
jsonBuffer.clear();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@@ -1849,7 +1658,7 @@ void handleRemote() {
|
|||||||
if (results.value == rmt_commands[ON_OFF]) { // ON/OFF TOGGLE
|
if (results.value == rmt_commands[ON_OFF]) { // ON/OFF TOGGLE
|
||||||
last_remote_cmd = 0;
|
last_remote_cmd = 0;
|
||||||
if (mode == OFF) {
|
if (mode == OFF) {
|
||||||
mode = SET_ALL;
|
mode = SET;
|
||||||
} else {
|
} else {
|
||||||
mode = OFF;
|
mode = OFF;
|
||||||
}
|
}
|
||||||
@@ -1859,18 +1668,18 @@ void handleRemote() {
|
|||||||
last_remote_cmd = results.value;
|
last_remote_cmd = results.value;
|
||||||
if (brightness + chng <= 255) {
|
if (brightness + chng <= 255) {
|
||||||
brightness = brightness + chng;
|
brightness = brightness + chng;
|
||||||
mode = SET_BRIGHTNESS;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (results.value == rmt_commands[BRIGHTNESS_DOWN]) { //Brightness down
|
if (results.value == rmt_commands[BRIGHTNESS_DOWN]) { //Brightness down
|
||||||
last_remote_cmd = results.value;
|
last_remote_cmd = results.value;
|
||||||
if (brightness - chng >= 0) {
|
if (brightness - chng >= 0) {
|
||||||
brightness = brightness - chng;
|
brightness = brightness - chng;
|
||||||
mode = SET_BRIGHTNESS;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((mode !=AUTO) && (mode != E131) && (mode != OFF)) {
|
if ((mode !=AUTO) && (mode != OFF)) {
|
||||||
if (results.value == rmt_commands[SPEED_UP]) { //Speed Up
|
if (results.value == rmt_commands[SPEED_UP]) { //Speed Up
|
||||||
last_remote_cmd = results.value;
|
last_remote_cmd = results.value;
|
||||||
if (ws2812fx_speed + chng <= 255) {
|
if (ws2812fx_speed + chng <= 255) {
|
||||||
@@ -1892,19 +1701,19 @@ void handleRemote() {
|
|||||||
if (selected_color == 1) {
|
if (selected_color == 1) {
|
||||||
if (main_color.red + chng <= 255) {
|
if (main_color.red + chng <= 255) {
|
||||||
main_color.red = main_color.red + chng;
|
main_color.red = main_color.red + chng;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selected_color == 2) {
|
if (selected_color == 2) {
|
||||||
if (back_color.red + chng <= 255) {
|
if (back_color.red + chng <= 255) {
|
||||||
back_color.red = back_color.red + chng;
|
back_color.red = back_color.red + chng;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selected_color == 3) {
|
if (selected_color == 3) {
|
||||||
if (xtra_color.red + chng <= 255) {
|
if (xtra_color.red + chng <= 255) {
|
||||||
xtra_color.red = xtra_color.red + chng;
|
xtra_color.red = xtra_color.red + chng;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1913,19 +1722,19 @@ void handleRemote() {
|
|||||||
if (selected_color == 1) {
|
if (selected_color == 1) {
|
||||||
if (main_color.red - chng >= 0) {
|
if (main_color.red - chng >= 0) {
|
||||||
main_color.red = main_color.red - chng;
|
main_color.red = main_color.red - chng;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selected_color == 2) {
|
if (selected_color == 2) {
|
||||||
if (back_color.red - chng >= 0) {
|
if (back_color.red - chng >= 0) {
|
||||||
back_color.red = back_color.red - chng;
|
back_color.red = back_color.red - chng;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selected_color == 3) {
|
if (selected_color == 3) {
|
||||||
if (xtra_color.red - chng >= 0) {
|
if (xtra_color.red - chng >= 0) {
|
||||||
xtra_color.red = xtra_color.red - chng;
|
xtra_color.red = xtra_color.red - chng;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1934,19 +1743,19 @@ void handleRemote() {
|
|||||||
if (selected_color == 1) {
|
if (selected_color == 1) {
|
||||||
if (main_color.green + chng <= 255) {
|
if (main_color.green + chng <= 255) {
|
||||||
main_color.green = main_color.green + chng;
|
main_color.green = main_color.green + chng;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selected_color == 2) {
|
if (selected_color == 2) {
|
||||||
if (back_color.green + chng <= 255) {
|
if (back_color.green + chng <= 255) {
|
||||||
back_color.green = back_color.green + chng;
|
back_color.green = back_color.green + chng;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selected_color == 3) {
|
if (selected_color == 3) {
|
||||||
if (xtra_color.green + chng <= 255) {
|
if (xtra_color.green + chng <= 255) {
|
||||||
xtra_color.green = xtra_color.green + chng;
|
xtra_color.green = xtra_color.green + chng;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1955,19 +1764,19 @@ void handleRemote() {
|
|||||||
if (selected_color == 1) {
|
if (selected_color == 1) {
|
||||||
if (main_color.green - chng >= 0) {
|
if (main_color.green - chng >= 0) {
|
||||||
main_color.green = main_color.green - chng;;
|
main_color.green = main_color.green - chng;;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selected_color == 2) {
|
if (selected_color == 2) {
|
||||||
if (back_color.green - chng >= 0) {
|
if (back_color.green - chng >= 0) {
|
||||||
back_color.green = back_color.green - chng;
|
back_color.green = back_color.green - chng;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selected_color == 3) {
|
if (selected_color == 3) {
|
||||||
if (xtra_color.green - chng >= 0) {
|
if (xtra_color.green - chng >= 0) {
|
||||||
xtra_color.green = xtra_color.green - chng;
|
xtra_color.green = xtra_color.green - chng;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1976,19 +1785,19 @@ void handleRemote() {
|
|||||||
if (selected_color == 1) {
|
if (selected_color == 1) {
|
||||||
if (main_color.blue + chng <= 255) {
|
if (main_color.blue + chng <= 255) {
|
||||||
main_color.blue = main_color.blue + chng;
|
main_color.blue = main_color.blue + chng;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selected_color == 2) {
|
if (selected_color == 2) {
|
||||||
if (back_color.blue + chng <= 255) {
|
if (back_color.blue + chng <= 255) {
|
||||||
back_color.blue = back_color.blue + chng;
|
back_color.blue = back_color.blue + chng;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selected_color == 3) {
|
if (selected_color == 3) {
|
||||||
if (xtra_color.blue + chng <= 255) {
|
if (xtra_color.blue + chng <= 255) {
|
||||||
xtra_color.blue = xtra_color.blue + chng;
|
xtra_color.blue = xtra_color.blue + chng;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1997,19 +1806,19 @@ void handleRemote() {
|
|||||||
if (selected_color == 1) {
|
if (selected_color == 1) {
|
||||||
if (main_color.blue - chng >= 0) {
|
if (main_color.blue - chng >= 0) {
|
||||||
main_color.blue = main_color.blue - chng;
|
main_color.blue = main_color.blue - chng;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selected_color == 2) {
|
if (selected_color == 2) {
|
||||||
if (back_color.blue - chng >= 0) {
|
if (back_color.blue - chng >= 0) {
|
||||||
back_color.blue = back_color.blue - chng;
|
back_color.blue = back_color.blue - chng;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selected_color == 3) {
|
if (selected_color == 3) {
|
||||||
if (xtra_color.blue - chng >= 0) {
|
if (xtra_color.blue - chng >= 0) {
|
||||||
xtra_color.blue = xtra_color.blue - chng;
|
xtra_color.blue = xtra_color.blue - chng;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2018,19 +1827,19 @@ void handleRemote() {
|
|||||||
if (selected_color == 1) {
|
if (selected_color == 1) {
|
||||||
if (main_color.white + chng <= 255) {
|
if (main_color.white + chng <= 255) {
|
||||||
main_color.white = main_color.white + chng;
|
main_color.white = main_color.white + chng;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selected_color == 2) {
|
if (selected_color == 2) {
|
||||||
if (back_color.white + chng <= 255) {
|
if (back_color.white + chng <= 255) {
|
||||||
back_color.white = back_color.white + chng;
|
back_color.white = back_color.white + chng;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selected_color == 3) {
|
if (selected_color == 3) {
|
||||||
if (xtra_color.white + chng <= 255) {
|
if (xtra_color.white + chng <= 255) {
|
||||||
xtra_color.white = xtra_color.white + chng;
|
xtra_color.white = xtra_color.white + chng;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2039,19 +1848,19 @@ void handleRemote() {
|
|||||||
if (selected_color == 1) {
|
if (selected_color == 1) {
|
||||||
if (main_color.white - chng >= 0) {
|
if (main_color.white - chng >= 0) {
|
||||||
main_color.white = main_color.white - chng;
|
main_color.white = main_color.white - chng;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selected_color == 2) {
|
if (selected_color == 2) {
|
||||||
if (back_color.white - chng >= 0) {
|
if (back_color.white - chng >= 0) {
|
||||||
back_color.white = back_color.white - chng;
|
back_color.white = back_color.white - chng;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selected_color == 3) {
|
if (selected_color == 3) {
|
||||||
if (xtra_color.white - chng >= 0) {
|
if (xtra_color.white - chng >= 0) {
|
||||||
xtra_color.white = xtra_color.white - chng;
|
xtra_color.white = xtra_color.white - chng;
|
||||||
mode = SET_COLOR;
|
mode = SET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2073,52 +1882,46 @@ void handleRemote() {
|
|||||||
if ((ws2812fx_mode < strip->getModeCount()-1) && (mode == HOLD)) {
|
if ((ws2812fx_mode < strip->getModeCount()-1) && (mode == HOLD)) {
|
||||||
ws2812fx_mode = ws2812fx_mode + 1;
|
ws2812fx_mode = ws2812fx_mode + 1;
|
||||||
}
|
}
|
||||||
mode = SET_MODE;
|
mode = SET;
|
||||||
}
|
}
|
||||||
if (results.value == rmt_commands[MODE_DOWN]) { //Mode down
|
if (results.value == rmt_commands[MODE_DOWN]) { //Mode down
|
||||||
last_remote_cmd = results.value;
|
last_remote_cmd = results.value;
|
||||||
if ((ws2812fx_mode > 0) && (mode == HOLD)) {
|
if ((ws2812fx_mode > 0) && (mode == HOLD)) {
|
||||||
ws2812fx_mode = ws2812fx_mode - 1;
|
ws2812fx_mode = ws2812fx_mode - 1;
|
||||||
}
|
}
|
||||||
mode = SET_MODE;
|
mode = SET;
|
||||||
}
|
}
|
||||||
if (results.value == rmt_commands[AUTOMODE]) { // Toggle Automode
|
if (results.value == rmt_commands[AUTOMODE]) { // Toggle Automode
|
||||||
last_remote_cmd = 0;
|
last_remote_cmd = 0;
|
||||||
if (mode != AUTO) {
|
ws2812fx_mode = 56;
|
||||||
mode = AUTO;
|
mode = SET;
|
||||||
} else {
|
|
||||||
mode = SET_ALL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#if defined(ENABLE_TV)
|
#if defined(CUSTOM_WS2812FX_ANIMATIONS)
|
||||||
if (results.value == rmt_commands[CUST_1]) { // Select TV Mode
|
if (results.value == rmt_commands[CUST_1]) { // Select TV Mode
|
||||||
last_remote_cmd = 0;
|
last_remote_cmd = 0;
|
||||||
if (mode == TV) {
|
ws2812fx_mode = 57;
|
||||||
mode = SET_ALL;
|
mode = SET;
|
||||||
} else {
|
|
||||||
mode = TV;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (results.value == rmt_commands[CUST_2]) { // Select Custom Mode 2
|
if (results.value == rmt_commands[CUST_2]) { // Select Custom Mode 2
|
||||||
last_remote_cmd = 0;
|
last_remote_cmd = 0;
|
||||||
ws2812fx_mode = 12;
|
ws2812fx_mode = 12;
|
||||||
mode = SET_MODE;
|
mode = SET;
|
||||||
}
|
}
|
||||||
if (results.value == rmt_commands[CUST_3]) { // Select Custom Mode 3
|
if (results.value == rmt_commands[CUST_3]) { // Select Custom Mode 3
|
||||||
last_remote_cmd = 0;
|
last_remote_cmd = 0;
|
||||||
ws2812fx_mode = 48;
|
ws2812fx_mode = 48;
|
||||||
mode = SET_MODE;
|
mode = SET;
|
||||||
}
|
}
|
||||||
if (results.value == rmt_commands[CUST_4]) { // Select Custom Mode 4
|
if (results.value == rmt_commands[CUST_4]) { // Select Custom Mode 4
|
||||||
last_remote_cmd = 0;
|
last_remote_cmd = 0;
|
||||||
ws2812fx_mode = 21;
|
ws2812fx_mode = 21;
|
||||||
mode = SET_MODE;
|
mode = SET;
|
||||||
}
|
}
|
||||||
if (results.value == rmt_commands[CUST_5]) { // Select Custom Mode 5
|
if (results.value == rmt_commands[CUST_5]) { // Select Custom Mode 5
|
||||||
last_remote_cmd = 0;
|
last_remote_cmd = 0;
|
||||||
ws2812fx_mode = 46;
|
ws2812fx_mode = 46;
|
||||||
mode = SET_MODE;
|
mode = SET;
|
||||||
}
|
}
|
||||||
irrecv.resume(); // Receive the next value
|
irrecv.resume(); // Receive the next value
|
||||||
}
|
}
|
||||||
@@ -2133,7 +1936,7 @@ uint32_t scale_wrgb(uint32_t wrgb, uint8_t level) {
|
|||||||
return (w << 24) | (r << 16) | (g << 8) | b;
|
return (w << 24) | (r << 16) | (g << 8) | b;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t fade(uint32_t newcolor, uint32_t oldcolor, uint8_t level) {
|
uint32_t trans(uint32_t newcolor, uint32_t oldcolor, uint8_t level) {
|
||||||
newcolor = scale_wrgb(newcolor, level);
|
newcolor = scale_wrgb(newcolor, level);
|
||||||
oldcolor = scale_wrgb(oldcolor, 255-level);
|
oldcolor = scale_wrgb(oldcolor, 255-level);
|
||||||
return newcolor + oldcolor;
|
return newcolor + oldcolor;
|
||||||
|
|||||||
@@ -118,21 +118,6 @@
|
|||||||
#else
|
#else
|
||||||
root["home_assistant"] = "OFF";
|
root["home_assistant"] = "OFF";
|
||||||
#endif
|
#endif
|
||||||
#if defined(ENABLE_LEGACY_ANIMATIONS)
|
|
||||||
root["legacy_animations"] = "ON";
|
|
||||||
#else
|
|
||||||
root["legacy_animations"] = "OFF";
|
|
||||||
#endif
|
|
||||||
#if defined(ENABLE_TV)
|
|
||||||
root["tv_animation"] = "ON";
|
|
||||||
#else
|
|
||||||
root["tv_animation"] = "OFF";
|
|
||||||
#endif
|
|
||||||
#if defined(ENABLE_E131)
|
|
||||||
root["e131_animations"] = "ON";
|
|
||||||
#else
|
|
||||||
root["e131_animations"] = "OFF";
|
|
||||||
#endif
|
|
||||||
#if defined(ENABLE_OTA)
|
#if defined(ENABLE_OTA)
|
||||||
#if ENABLE_OTA == 0
|
#if ENABLE_OTA == 0
|
||||||
root["ota"] = "ARDUINO";
|
root["ota"] = "ARDUINO";
|
||||||
@@ -192,12 +177,6 @@
|
|||||||
SPIFFS.format();
|
SPIFFS.format();
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/set_brightness", []() {
|
|
||||||
mode = SET_BRIGHTNESS;
|
|
||||||
getArgs();
|
|
||||||
getStatusJSON();
|
|
||||||
});
|
|
||||||
|
|
||||||
server.on("/get_brightness", []() {
|
server.on("/get_brightness", []() {
|
||||||
char str_brightness[4];
|
char str_brightness[4];
|
||||||
snprintf(str_brightness, sizeof(str_brightness), "%i", (int) (brightness / 2.55));
|
snprintf(str_brightness, sizeof(str_brightness), "%i", (int) (brightness / 2.55));
|
||||||
@@ -207,12 +186,6 @@
|
|||||||
DBG_OUTPUT_PORT.printf("/get_brightness: %i\r\n", (int) (brightness / 2.55));
|
DBG_OUTPUT_PORT.printf("/get_brightness: %i\r\n", (int) (brightness / 2.55));
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/set_speed", []() {
|
|
||||||
mode = SET_SPEED;
|
|
||||||
getArgs();
|
|
||||||
getStatusJSON();
|
|
||||||
});
|
|
||||||
|
|
||||||
server.on("/get_speed", []() {
|
server.on("/get_speed", []() {
|
||||||
char str_speed[4];
|
char str_speed[4];
|
||||||
snprintf(str_speed, sizeof(str_speed), "%i", ws2812fx_speed);
|
snprintf(str_speed, sizeof(str_speed), "%i", ws2812fx_speed);
|
||||||
@@ -346,9 +319,14 @@
|
|||||||
}
|
}
|
||||||
if (updateConf) {
|
if (updateConf) {
|
||||||
initMqtt();
|
initMqtt();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if(server.hasArg("trans_effect")){
|
||||||
|
transEffect = server.arg("trans_effect").toInt();
|
||||||
|
updateConf = true;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(ENABLE_STATE_SAVE)
|
#if defined(ENABLE_STATE_SAVE)
|
||||||
if (updateStrip || updateConf) {
|
if (updateStrip || updateConf) {
|
||||||
if(!settings_save_conf.active()) settings_save_conf.once(3, tickerSaveConfig);
|
if(!settings_save_conf.active()) settings_save_conf.once(3, tickerSaveConfig);
|
||||||
@@ -364,86 +342,14 @@
|
|||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/auto", []() {
|
server.on("/set", []() {
|
||||||
mode = AUTO;
|
|
||||||
getArgs();
|
|
||||||
getStatusJSON();
|
|
||||||
});
|
|
||||||
|
|
||||||
server.on("/all", []() {
|
|
||||||
prevmode = HOLD;
|
prevmode = HOLD;
|
||||||
ws2812fx_mode = FX_MODE_STATIC;
|
ws2812fx_mode = FX_MODE_STATIC;
|
||||||
mode = SET_ALL;
|
mode = SET;
|
||||||
getArgs();
|
getArgs();
|
||||||
getStatusJSON();
|
getStatusJSON();
|
||||||
});
|
});
|
||||||
|
|
||||||
#if defined(ENABLE_LEGACY_ANIMATIONS)
|
|
||||||
server.on("/wipe", []() {
|
|
||||||
ws2812fx_mode = FX_MODE_COLOR_WIPE;
|
|
||||||
mode = SET_ALL;
|
|
||||||
getArgs();
|
|
||||||
getStatusJSON();
|
|
||||||
});
|
|
||||||
|
|
||||||
server.on("/rainbow", []() {
|
|
||||||
ws2812fx_mode = FX_MODE_RAINBOW;
|
|
||||||
mode = SET_ALL;
|
|
||||||
getArgs();
|
|
||||||
getStatusJSON();
|
|
||||||
});
|
|
||||||
|
|
||||||
server.on("/rainbowcycle", []() {
|
|
||||||
ws2812fx_mode = FX_MODE_RAINBOW_CYCLE;
|
|
||||||
mode = SET_ALL;
|
|
||||||
getArgs();
|
|
||||||
getStatusJSON();
|
|
||||||
});
|
|
||||||
|
|
||||||
server.on("/theaterchase", []() {
|
|
||||||
ws2812fx_mode = FX_MODE_THEATER_CHASE;
|
|
||||||
mode = SET_ALL;
|
|
||||||
getArgs();
|
|
||||||
getStatusJSON();
|
|
||||||
});
|
|
||||||
|
|
||||||
server.on("/twinklerandom", []() {
|
|
||||||
ws2812fx_mode = FX_MODE_TWINKLE_RANDOM;
|
|
||||||
mode = SET_ALL;
|
|
||||||
getArgs();
|
|
||||||
getStatusJSON();
|
|
||||||
});
|
|
||||||
|
|
||||||
server.on("/theaterchaserainbow", []() {
|
|
||||||
ws2812fx_mode = FX_MODE_THEATER_CHASE_RAINBOW;
|
|
||||||
mode = SET_ALL;
|
|
||||||
getArgs();
|
|
||||||
getStatusJSON();
|
|
||||||
});
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ENABLE_E131)
|
|
||||||
server.on("/e131", []() {
|
|
||||||
mode = E131;
|
|
||||||
getArgs();
|
|
||||||
getStatusJSON();
|
|
||||||
});
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ENABLE_TV)
|
|
||||||
server.on("/tv", []() {
|
|
||||||
mode = TV;
|
|
||||||
getArgs();
|
|
||||||
getStatusJSON();
|
|
||||||
});
|
|
||||||
#endif
|
|
||||||
|
|
||||||
server.on("/get_modes", []() {
|
server.on("/get_modes", []() {
|
||||||
getModesJSON();
|
getModesJSON();
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/set_mode", []() {
|
|
||||||
mode = SET_MODE;
|
|
||||||
getArgs();
|
|
||||||
getStatusJSON();
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#define SKETCH_VERSION "2.2.7.BETA1.rgbw.3c"
|
#define SKETCH_VERSION "3.0.0.BETA1"
|
||||||
|
|||||||
@@ -167,9 +167,21 @@
|
|||||||
*
|
*
|
||||||
* 15 September 2019
|
* 15 September 2019
|
||||||
* Version Bump to 2.2.7.BETA1.rgbw.3colors
|
* Version Bump to 2.2.7.BETA1.rgbw.3colors
|
||||||
* adressed issue: #25 (added Custom Animation 'Gradient')
|
* adressed issue: #25 (added Custom Animation 'Gradient' with number 57)
|
||||||
* adressed issue: #30 (Status 'AUTO' is saved now)
|
* adressed issue: #30 (Status 'AUTO' is saved now)
|
||||||
* adressed issue: https://github.com/toblum/McLighting/issues/403 (Experimental Support of transitions: set fadeEffect = true in definitions.h)
|
* adressed issue: https://github.com/toblum/McLighting/issues/403 (Experimental Support of transitions: set transEffect = true in definitions.h)
|
||||||
* corrected use of DMA for Neopixelbus by Makuna (Tests for other strips than SK6812 GRBW were not made)
|
* corrected use of DMA for Neopixelbus by Makuna (Tests for other strips than SK6812 GRBW were not made)
|
||||||
*
|
*
|
||||||
|
* 27 September 2019
|
||||||
|
* Version Bump to 3.0.0.ALPHA1
|
||||||
|
* removed LEGACY_ANIMATIONS
|
||||||
|
* removed old Custom Animations from beginning of list.
|
||||||
|
* added Custom Animation 'AutoPlay' with number 56
|
||||||
|
* added Custom Animation 'Custom WS' with number 57
|
||||||
|
* added Custom Animation 'TV' with number 58
|
||||||
|
* added Custom Animation 'E1.31' with number 59
|
||||||
|
* moved Custom Animation 'Fire2012' to number 60
|
||||||
|
* moved Custom Animation 'Gradients' to number 61
|
||||||
|
* REST-API changes (will be documented soon)
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -60,6 +60,10 @@ I hope I didn't miss any sources and mentioned every author. In case I forgot so
|
|||||||
|
|
||||||
|
|
||||||
## Todos
|
## Todos
|
||||||
|
- [ ] Redesign of Code and bump to V3
|
||||||
|
- [ ] Removal of LEGACY_ANIMATIONS
|
||||||
|
- [ ] Add TV, E1.31 and AUTO to CUSTOM_WS2812FX_ANIMATIONS
|
||||||
|
- [ ] Include ws28fx library to code due to modifications in library
|
||||||
- [ ] Support multiple strips and control them separately or together [Issue](https://github.com/toblum/McLighting/issues/118)
|
- [ ] Support multiple strips and control them separately or together [Issue](https://github.com/toblum/McLighting/issues/118)
|
||||||
- [ ] Remove old / wrong EEPROM settings completely [Issue]
|
- [ ] Remove old / wrong EEPROM settings completely [Issue]
|
||||||
- [ ] Customer profile to define segments of (in)active areas on the strip [Issue](https://github.com/toblum/McLighting/issues/37)
|
- [ ] Customer profile to define segments of (in)active areas on the strip [Issue](https://github.com/toblum/McLighting/issues/37)
|
||||||
@@ -69,6 +73,7 @@ I hope I didn't miss any sources and mentioned every author. In case I forgot so
|
|||||||
- [ ] Multiple buttons/GPIO Inputs. [Issue](https://github.com/toblum/McLighting/issues/119)
|
- [ ] Multiple buttons/GPIO Inputs. [Issue](https://github.com/toblum/McLighting/issues/119)
|
||||||
- [ ] Music visualizer / Bring back ArtNet [Issue](https://github.com/toblum/McLighting/issues/111)
|
- [ ] Music visualizer / Bring back ArtNet [Issue](https://github.com/toblum/McLighting/issues/111)
|
||||||
- [ ] Display version and parameters (Number of LEDs, definition settings, ..) in the web UI [Issue](https://github.com/toblum/McLighting/issues/150)
|
- [ ] Display version and parameters (Number of LEDs, definition settings, ..) in the web UI [Issue](https://github.com/toblum/McLighting/issues/150)
|
||||||
|
- [ ] Support for up to ten segment
|
||||||
- [x] Save status: Added saving of status 'AUTO'. [Issue] https://github.com/FabLab-Luenen/McLighting/issues/30
|
- [x] Save status: Added saving of status 'AUTO'. [Issue] https://github.com/FabLab-Luenen/McLighting/issues/30
|
||||||
- [x] EXPERIMENTAL: Added transition feature on changing values of color brightness and speed. ATTENTION! Does not work proberly for all WS2812fx effects.
|
- [x] EXPERIMENTAL: Added transition feature on changing values of color brightness and speed. ATTENTION! Does not work proberly for all WS2812fx effects.
|
||||||
- [x] Added Custom Animation 'Gradient': [Issue] https://github.com/FabLab-Luenen/McLighting/issues/25
|
- [x] Added Custom Animation 'Gradient': [Issue] https://github.com/FabLab-Luenen/McLighting/issues/25
|
||||||
|
|||||||
Reference in New Issue
Block a user