3.1.0.BETA1
Version Bump to 3.1.0.BETA1 bugfixes adressed issue: #39 uncooment //#define ENABLE_MQTT_INCLUDE_IP in defninitions.h
This commit is contained in:
@@ -369,16 +369,16 @@ void setup() {
|
||||
WiFiManagerParameter custom_mqtt_user("user", "MQTT user", mqtt_user, 32, " maxlength=32");
|
||||
WiFiManagerParameter custom_mqtt_pass("pass", "MQTT pass", mqtt_pass, 32, " maxlength=32 type=\"password\"");
|
||||
#endif
|
||||
sprintf(_stripSize, "%d", FXSettings.stripSize);
|
||||
sprintf(_stripSize, "%d", Config.stripSize);
|
||||
WiFiManagerParameter custom_strip_size("strip_size", "Number of LEDs", _stripSize, 4, " maxlength=4 type=\"number\"");
|
||||
#if !defined(USE_WS2812FX_DMA)
|
||||
char tmp_led_pin[3];
|
||||
sprintf(tmp_led_pin, "%d", FXSettings.pin);
|
||||
sprintf(tmp_led_pin, "%d", Config.pin);
|
||||
WiFiManagerParameter custom_led_pin("led_pin", "LED GPIO", tmp_led_pin, 2, " maxlength=2 type=\"number\"");
|
||||
#endif
|
||||
sprintf(_rgbOrder, "%s", FXSettings.RGBOrder);
|
||||
sprintf(_rgbOrder, "%s", Config.RGBOrder);
|
||||
WiFiManagerParameter custom_rgbOrder("rgbOrder", "RGBOrder", _rgbOrder, 4, " maxlength=4");
|
||||
sprintf(_fx_options, "%d", fx_options);
|
||||
sprintf(_fx_options, "%d", segState.options);
|
||||
WiFiManagerParameter custom_fxoptions("fxoptions", "fxOptions", _fx_options, 3, " maxlength=3");
|
||||
#endif
|
||||
|
||||
@@ -444,13 +444,13 @@ void setup() {
|
||||
strcpy(mqtt_pass, custom_mqtt_pass.getValue());
|
||||
#endif
|
||||
strcpy(_stripSize, custom_strip_size.getValue());
|
||||
FXSettings.stripSize = constrain(atoi(custom_strip_size.getValue()), 1, MAXLEDS);
|
||||
Config.stripSize = constrain(atoi(custom_strip_size.getValue()), 1, MAXLEDS);
|
||||
#if !defined(USE_WS2812FX_DMA)
|
||||
checkPin(atoi(custom_led_pin.getValue()));
|
||||
#endif
|
||||
strcpy(_rgbOrder, custom_rgbOrder.getValue());
|
||||
checkRGBOrder(_rgbOrder);
|
||||
fx_options = atoi(custom_fxoptions.getValue());
|
||||
segState.options = atoi(custom_fxoptions.getValue());
|
||||
if (updateConfig) {
|
||||
(writeConfigFS(updateConfig)) ? DBG_OUTPUT_PORT.println("WiFiManager config FS Save success!"): DBG_OUTPUT_PORT.println("WiFiManager config FS Save failure!");
|
||||
}
|
||||
@@ -561,9 +561,8 @@ void setup() {
|
||||
#if defined(ENABLE_REMOTE)
|
||||
irrecv.enableIRIn(); // Start the receiver
|
||||
#endif
|
||||
fx_speed_actual = fx_speed;
|
||||
brightness_trans = brightness;
|
||||
memcpy(hex_colors, hex_colors_trans, sizeof(hex_colors_trans));
|
||||
fx_speed_actual = segState.speed[State.segment];
|
||||
brightness_trans = State.brightness;
|
||||
initStrip();
|
||||
strip->setBrightness(0);
|
||||
DBG_OUTPUT_PORT.println("finished Main Setup!");
|
||||
@@ -625,91 +624,100 @@ void loop() {
|
||||
// Simple statemachine that handles the different modes
|
||||
// ***************************************************************************
|
||||
|
||||
if ((mode == OFF) && ((strip->getBrightness() == 0) || !FXSettings.transEffect)) {
|
||||
if ((State.mode == OFF) && ((strip->getBrightness() == 0) || !Config.transEffect)) {
|
||||
if(strip->isRunning()) {
|
||||
strip->strip_off(); // Workaround: to be shure,
|
||||
delay(10); // that strip is really off. Sometimes strip->stop isn't enought
|
||||
strip->stop(); // should clear memory
|
||||
autoCount = 0;
|
||||
autoDelay = 0;
|
||||
for (uint8_t i = 0; i < Config.segments; i++) {
|
||||
autoCount[i] = 0;
|
||||
autoDelay[i] = 0;
|
||||
}
|
||||
} else {
|
||||
if (prevmode != mode) { // Start temporarily to clear strip
|
||||
if (prevmode != State.mode) { // Start temporarily to clear strip
|
||||
strip->start();
|
||||
strip->strip_off(); // Workaround: to be shure,
|
||||
delay(10); // that strip is really off. Sometimes strip->stop isn't enought
|
||||
strip->stop(); // should clear memory
|
||||
autoCount = 0;
|
||||
autoDelay = 0;
|
||||
for (uint8_t i = 0; i < Config.segments; i++) {
|
||||
autoCount[i] = 0;
|
||||
autoDelay[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mode == OFF) {
|
||||
if (prevmode != mode) {
|
||||
if (State.mode == OFF) {
|
||||
if (prevmode != State.mode) {
|
||||
#if defined(ENABLE_MQTT)
|
||||
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK =off", "");
|
||||
#endif
|
||||
if (FXSettings.transEffect) {
|
||||
if (Config.transEffect) {
|
||||
brightness_trans = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mode == SET) {
|
||||
mode = HOLD;
|
||||
if (State.mode == SET) {
|
||||
State.mode = HOLD;
|
||||
// Segment
|
||||
if (prevsegment != FXSettings.segment) {
|
||||
if (prevsegment != State.segment) {
|
||||
#if defined(ENABLE_MQTT)
|
||||
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK Ss%i", FXSettings.segment);
|
||||
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK Ss%i", State.segment);
|
||||
#endif
|
||||
prevsegment = FXSettings.segment;
|
||||
prevsegment = State.segment;
|
||||
}
|
||||
// Mode
|
||||
if (fx_mode != strip->getMode(FXSettings.segment)) {
|
||||
if (segState.mode[State.segment] != fx_mode) {
|
||||
segState.mode[State.segment] = fx_mode;
|
||||
#if defined(ENABLE_MQTT)
|
||||
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK /%i", fx_mode);
|
||||
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK /%i", segState.mode[State.segment]);
|
||||
#endif
|
||||
strip->strip_off();
|
||||
autoCount = 0;
|
||||
autoDelay = 0;
|
||||
strip->setMode(FXSettings.segment, fx_mode);
|
||||
autoCount[State.segment] = 0;
|
||||
autoDelay[State.segment] = 0;
|
||||
//strip->setSpeed(State.segment, segState.speed[State.segment]);
|
||||
//strip->setColors(State.segment, segState.colors[State.segment]);
|
||||
strip->setMode(State.segment, segState.mode[State.segment]);
|
||||
}
|
||||
//Color
|
||||
/*if (memcmp(hex_colors_trans, strip->getColors(selected_segment), sizeof(hex_colors_trans)) != 0) {
|
||||
|
||||
/*if (memcmp(segmentState.colors[State.segment)], strip->getColors(State.segment), sizeof(segmentState.colors[State.segment)])) != 0) {
|
||||
convertColors();
|
||||
}*/
|
||||
// Brightness
|
||||
if (strip->getBrightness() != brightness) {
|
||||
if (strip->getBrightness() != State.brightness) {
|
||||
#if defined(ENABLE_MQTT)
|
||||
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK %%%i", brightness);
|
||||
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK %%%i", State.brightness);
|
||||
#endif
|
||||
brightness_trans = brightness;
|
||||
brightness_trans = State.brightness;
|
||||
}
|
||||
// Speed
|
||||
if (fx_speed_actual != fx_speed) {
|
||||
if (fx_speed_actual != segState.speed[State.segment]) {
|
||||
#if defined(ENABLE_MQTT)
|
||||
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK ?%i", fx_speed);
|
||||
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK ?%i", segState.speed[State.segment]);
|
||||
#endif
|
||||
}
|
||||
prevmode = SET;
|
||||
strip->trigger();
|
||||
//strip->trigger();
|
||||
}
|
||||
|
||||
if ((mode == HOLD) || ((mode == OFF) && (strip->getBrightness() > 0) && FXSettings.transEffect)) {
|
||||
if (fx_mode == FX_MODE_CUSTOM_0) {
|
||||
handleAutoPlay();
|
||||
}
|
||||
if ((State.mode == HOLD) || ((State.mode == OFF) && (strip->getBrightness() > 0) && Config.transEffect)) {
|
||||
if(!strip->isRunning()) strip->start();
|
||||
strip->service();
|
||||
for (uint8_t i = 0; i < Config.segments; i++) {
|
||||
if (segState.mode[i] == FX_MODE_CUSTOM_0) { handleAutoPlay(i); };
|
||||
}
|
||||
}
|
||||
|
||||
if (prevmode != mode) {
|
||||
if (prevmode != State.mode) {
|
||||
convertColors();
|
||||
if (memcmp(hex_colors_trans, strip->getColors(FXSettings.segment), sizeof(hex_colors_trans)) != 0) {
|
||||
convertColorsFade();
|
||||
if (memcmp(hexcolors_trans, strip->getColors(prevsegment), sizeof(hexcolors_trans)) != 0) {
|
||||
DBG_OUTPUT_PORT.println("Color changed!");
|
||||
trans_cnt_max = convertColorsFade(prevsegment);
|
||||
trans_cnt = 1;
|
||||
memcpy(segState.colors[prevsegment], hexcolors_trans, sizeof(hexcolors_trans));
|
||||
}
|
||||
strip->setSpeed(FXSettings.segment, convertSpeed(fx_speed_actual));
|
||||
strip->setSpeed(State.segment, convertSpeed(fx_speed_actual));
|
||||
//strip->setBrightness(brightness_actual);
|
||||
#if defined(ENABLE_MQTT)
|
||||
#if ENABLE_MQTT == 0
|
||||
@@ -724,14 +732,14 @@ void loop() {
|
||||
#endif
|
||||
}
|
||||
|
||||
prevmode = mode;
|
||||
prevmode = State.mode;
|
||||
|
||||
#if defined(ENABLE_STATE_SAVE)
|
||||
if (updateState){
|
||||
(writeStateFS(updateState)) ? DBG_OUTPUT_PORT.println("State FS Save Success!") : DBG_OUTPUT_PORT.println("State FS Save failure!");
|
||||
}
|
||||
if (updateSegState) {
|
||||
(writeSegmentStateFS(updateSegState, FXSettings.segment)) ? DBG_OUTPUT_PORT.println("Segment State FS Save Success!") : DBG_OUTPUT_PORT.println("Segment State FS Save failure!");
|
||||
(writeSegmentStateFS(updateSegState, State.segment)) ? DBG_OUTPUT_PORT.println("Segment State FS Save Success!") : DBG_OUTPUT_PORT.println("Segment State FS Save failure!");
|
||||
}
|
||||
if (updateConfig) {
|
||||
(writeConfigFS(updateConfig)) ? DBG_OUTPUT_PORT.println("Config FS Save success!"): DBG_OUTPUT_PORT.println("Config FS Save failure!");
|
||||
@@ -739,62 +747,57 @@ void loop() {
|
||||
#endif
|
||||
|
||||
// Async color transition
|
||||
if (memcmp(hex_colors_trans, strip->getColors(FXSettings.segment), sizeof(hex_colors_trans)) != 0) {
|
||||
if (FXSettings.transEffect) {
|
||||
if ((segState.mode[prevsegment] != FX_MODE_CUSTOM_0) && (memcmp(hexcolors_trans, strip->getColors(prevsegment), sizeof(hexcolors_trans)) != 0)) {
|
||||
if (Config.transEffect) {
|
||||
if ((trans_cnt > 0) && (trans_cnt < trans_cnt_max)) {
|
||||
if (colorFadeDelay <= millis()) {
|
||||
uint32_t hex_colors_actual[3] = {};
|
||||
hex_colors_actual[0] = trans(hex_colors_trans[0], hex_colors[0], trans_cnt, trans_cnt_max);
|
||||
hex_colors_actual[1] = trans(hex_colors_trans[1], hex_colors[1], trans_cnt, trans_cnt_max);
|
||||
hex_colors_actual[2] = trans(hex_colors_trans[2], hex_colors[2], trans_cnt, trans_cnt_max);
|
||||
strip->setColors(prevsegment, hex_colors_actual);
|
||||
uint32_t _hexcolors_new[3] = {};
|
||||
_hexcolors_new[0] = trans(hexcolors_trans[0], strip->getColors(prevsegment)[0], trans_cnt, trans_cnt_max);
|
||||
_hexcolors_new[1] = trans(hexcolors_trans[1], strip->getColors(prevsegment)[1], trans_cnt, trans_cnt_max);
|
||||
_hexcolors_new[2] = trans(hexcolors_trans[2], strip->getColors(prevsegment)[2], trans_cnt, trans_cnt_max);
|
||||
strip->setColors(prevsegment, _hexcolors_new);
|
||||
trans_cnt++;
|
||||
colorFadeDelay = millis() + TRANS_COLOR_DELAY;
|
||||
if (mode == HOLD) strip->trigger();
|
||||
if (State.mode == HOLD) strip->trigger();
|
||||
}
|
||||
} else if (trans_cnt >= trans_cnt_max) {
|
||||
memcpy(hex_colors, hex_colors_trans, sizeof(hex_colors_trans));
|
||||
strip->setColors(prevsegment, hex_colors);
|
||||
if (mode == HOLD) strip->trigger();
|
||||
trans_cnt = 0;
|
||||
strip->setColors(prevsegment, hexcolors_trans);
|
||||
if (State.mode == HOLD) strip->trigger();
|
||||
DBG_OUTPUT_PORT.println("Color transition finished!");
|
||||
trans_cnt = 0;
|
||||
}
|
||||
} else {
|
||||
memcpy(hex_colors, hex_colors_trans, sizeof(hex_colors_trans));
|
||||
strip->setColors(prevsegment, hex_colors);
|
||||
if (mode == HOLD) strip->trigger();
|
||||
trans_cnt = 0;
|
||||
strip->setColors(prevsegment, hexcolors_trans);
|
||||
if (State.mode == HOLD) strip->trigger();
|
||||
}
|
||||
}
|
||||
// Async speed transition
|
||||
if (fx_speed_actual != fx_speed) {
|
||||
//if (FXSettings.transEffect) {
|
||||
if (true == false) {
|
||||
if ((segState.mode[prevsegment] != FX_MODE_CUSTOM_0) && (fx_speed_actual != segState.speed[prevsegment])) {
|
||||
//if (Config.transEffect) {
|
||||
if (true == false) { // disabled for the moment
|
||||
if (speedFadeDelay <= millis()) {
|
||||
DBG_OUTPUT_PORT.println("Speed actual: ");
|
||||
DBG_OUTPUT_PORT.println(fx_speed_actual);
|
||||
DBG_OUTPUT_PORT.println(convertSpeed(fx_speed_actual));
|
||||
DBG_OUTPUT_PORT.println(unconvertSpeed(convertSpeed(fx_speed_actual)));
|
||||
if (fx_speed_actual < fx_speed) {
|
||||
if (fx_speed_actual < segState.speed[prevsegment]) {
|
||||
fx_speed_actual++;
|
||||
}
|
||||
if (fx_speed_actual > fx_speed) {
|
||||
if (fx_speed_actual > segState.speed[prevsegment]) {
|
||||
fx_speed_actual--;
|
||||
}
|
||||
speedFadeDelay = millis() + TRANS_DELAY;
|
||||
strip->setSpeed(prevsegment, convertSpeed(fx_speed_actual));
|
||||
if (mode == HOLD) strip->trigger();
|
||||
if (State.mode == HOLD) strip->trigger();
|
||||
}
|
||||
} else {
|
||||
fx_speed_actual = fx_speed;
|
||||
fx_speed_actual = segState.speed[State.segment];
|
||||
strip->setSpeed(prevsegment, convertSpeed(fx_speed_actual));
|
||||
if (mode == HOLD) strip->trigger();
|
||||
if (State.mode == HOLD) strip->trigger();
|
||||
}
|
||||
}
|
||||
|
||||
// Async brightness transition
|
||||
if (strip->getBrightness() != brightness_trans) {
|
||||
if (FXSettings.transEffect) {
|
||||
if (Config.transEffect) {
|
||||
if(brightnessFadeDelay <= millis()) {
|
||||
if (strip->getBrightness() < brightness_trans) {
|
||||
strip->increaseBrightness(1);
|
||||
@@ -803,20 +806,20 @@ void loop() {
|
||||
strip->decreaseBrightness(1);
|
||||
}
|
||||
brightnessFadeDelay = millis() + TRANS_DELAY;
|
||||
//if (mode == HOLD) strip->trigger();
|
||||
//if (State.mode == HOLD) strip->trigger();
|
||||
strip->trigger();
|
||||
}
|
||||
} else {
|
||||
brightness_trans = brightness;
|
||||
brightness_trans = State.brightness;
|
||||
strip->setBrightness(brightness_trans);
|
||||
if (mode == HOLD) strip->trigger();
|
||||
if (State.mode == HOLD) strip->trigger();
|
||||
}
|
||||
}
|
||||
|
||||
/* // Segment change only if color and speed transitions are finished, because they are segment specific
|
||||
if (prevsegment != FXSettings.segment) {
|
||||
if ((memcmp(hex_colors_trans, strip->getColors(FXSettings.segment), sizeof(hex_colors_trans)) == 0) && (fx_speed_actual == fx_speed)) {
|
||||
FXSettings.segment = prevsegment;
|
||||
if (prevsegment != State.segment) {
|
||||
if ((memcmp(hexcolors_trans, strip->getColors(State.segment), sizeof(hexcolors_trans)) == 0) && (fx_speed_actual == segState.speed[State.segment])) {
|
||||
State.segment = prevsegment;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -910,7 +910,7 @@ input[type=number], label{
|
||||
<div>
|
||||
<label for="speed" style="padding:8px 7px 3px 7px;"><i aria-hidden="true" class="material-icons">timer</i></label>
|
||||
<input type="number" id="speedNum">
|
||||
<input value="255" type="range" min="0" max="65535" id="speed">
|
||||
<input value="255" type="range" min="0" max="255" id="speed">
|
||||
</div>
|
||||
<div id="segments" class="container" style="text-align: left;">
|
||||
<div class="layout row wrap">
|
||||
@@ -1324,14 +1324,14 @@ var config = {
|
||||
var state = {
|
||||
mode: 0,
|
||||
segment: 0,
|
||||
brightness: 192
|
||||
brightness: 0
|
||||
}
|
||||
|
||||
var segstate = {
|
||||
start: 0,
|
||||
stop: 0,
|
||||
mode: null,
|
||||
speed: 192,
|
||||
speed: 0,
|
||||
color: {w:0, r:0, g:0, b:0, hex:"00000000", w2:0, r2:0, g2:0, b2:0, hex2:"00000000", w3:0, r3:0, g3:0, b3:0, hex3:"00000000"},
|
||||
ws_fxopt: 0
|
||||
}
|
||||
@@ -1466,7 +1466,7 @@ function changeRangeNumVal(){
|
||||
});
|
||||
speedNumVal.addEventListener('change', ()=>{
|
||||
// make sure numbers are entered between 0 to 255
|
||||
speed.value = checkNumVal16(speedNumVal, speed.value);
|
||||
speed.value = checkNumVal8(speedNumVal, speed.value);
|
||||
segstate.speed = speed.value;
|
||||
// Send Speed
|
||||
clearTimeout(sendIt);
|
||||
@@ -1665,7 +1665,7 @@ function readSettings() {
|
||||
document.getElementById("percentage-done").setAttribute("stroke-dasharray", "25,100");
|
||||
document.getElementById("modal-content").innerHTML = language.en.loadSettings;
|
||||
xhttp("http://" + host + "/uistate.json", false, function(e) {
|
||||
//console.log("readSettings()", e);
|
||||
console.log("Read Settings: ", e);
|
||||
tmpsettings = (e && e.substring(0,6) !== "ERROR!") ? JSON.parse(e) : {};
|
||||
// Replace default settings with saved ones
|
||||
for (var set in settings) {
|
||||
@@ -1827,9 +1827,6 @@ function initSettings() {
|
||||
option.innerHTML = i;
|
||||
selsegment.appendChild(option);
|
||||
}
|
||||
if (state.segment > config.ws_seg - 1) {
|
||||
state.segment = config.ws_seg - 1;
|
||||
}
|
||||
selsegment.value = state.segment;
|
||||
});
|
||||
var pin = document.getElementById("selectpin");
|
||||
|
||||
Binary file not shown.
@@ -26,12 +26,12 @@ char HOSTNAME[65] = "McLightingRGBW"; // Friedly hostname is configurable just
|
||||
#if defined(ENABLE_BUTTON_GY33)
|
||||
#define GAMMA 2.5 // Gamma correction for GY-33 sensor
|
||||
#endif
|
||||
#define ENABLE_REMOTE 13 // If defined, enable Remote Control via TSOP31238. The value defines the input pin (13 / D7) for TSOP31238 Out
|
||||
//#define ENABLE_REMOTE 13 // If defined, enable Remote Control via TSOP31238. The value defines the input pin (13 / D7) for TSOP31238 Out
|
||||
|
||||
#define ENABLE_STATE_SAVE // If defined, load saved state on reboot and save state on SPIFFS
|
||||
|
||||
#define CUSTOM_WS2812FX_ANIMATIONS // uncomment and put animations in "custom_ws2812fx_animations.h"
|
||||
//#define USE_HTML_MIN_GZ // uncomment for using index.htm & edit.htm from PROGMEM instead of SPIFFS
|
||||
#define USE_HTML_MIN_GZ // uncomment for using index.htm & edit.htm from PROGMEM instead of SPIFFS
|
||||
|
||||
#define TRANS_COLOR_DELAY 5 // Delay for color transition
|
||||
#define TRANS_DELAY 10 // Delay for brightness and speed transition
|
||||
@@ -50,7 +50,6 @@ unsigned long speedFadeDelay = 0;
|
||||
uint8_t END_UNIVERSE = START_UNIVERSE; // Total number of Universes to listen for, starting at UNIVERSE
|
||||
|
||||
#endif
|
||||
uint8_t num_segments = 1;
|
||||
uint8_t prevsegment = 0;
|
||||
|
||||
#if defined(ENABLE_REMOTE)
|
||||
@@ -95,9 +94,9 @@ uint8_t prevsegment = 0;
|
||||
// parameters for automatically cycling favorite patterns
|
||||
uint32_t autoParams[][6] = { // main_color, back_color, xtra_color, speed, mode, duration (milliseconds)
|
||||
{0x00ff0000, 0x0000ff00, 0x00000000, 200, 1, 5000}, // blink red/geen for 5 seconds
|
||||
{0x0000ff00, 0x000000ff, 0x00000000, 200, 3, 10000}, // wipe green/blue for 10 seconds
|
||||
{0x000000ff, 0x00ff0000, 0x00000000, 60, 14, 10000}, // dual scan blue on red for 10 seconds
|
||||
{0x000000ff, 0x00ff0000, 0x00000000, 40, 45, 15000}, // fireworks blue/red for 15 seconds
|
||||
{0x0000ff00, 0x000000ff, 0x00000000, 180, 3, 10000}, // wipe green/blue for 10 seconds
|
||||
{0x000000ff, 0x00ff0000, 0x00000000, 100, 14, 10000}, // dual scan blue on red for 10 seconds
|
||||
{0x000000ff, 0x00ff0000, 0x00000000, 100, 45, 15000}, // fireworks blue/red for 15 seconds
|
||||
{0x00ff0000, 0x0000ff00, 0x000000ff, 40, 54, 15000} // tricolor chase red/green/blue for 15 seconds
|
||||
};
|
||||
|
||||
@@ -143,26 +142,51 @@ uint32_t autoParams[][6] = { // main_color, back_color, xtra_color, speed, mod
|
||||
// ***************************************************************************
|
||||
#define DBG_OUTPUT_PORT Serial // Set debug output port
|
||||
|
||||
uint8_t autoCount[10] = {}; // Global variable for storing the counter for automated playback for each segment
|
||||
unsigned long autoDelay[10] = {}; // Global variable for storing the time to next auto effect for each segment
|
||||
struct {
|
||||
uint16_t start = 0;
|
||||
uint16_t stop = NUMLEDS - 1;
|
||||
uint8_t mode[10] = {}; // Global variable for storing the WS2812FX mode to set for each segment
|
||||
uint8_t speed[10] = {}; // Global variable for storing the speed for effects --> smaller == slower
|
||||
uint32_t colors[10][3] = {}; // 2 dim. Color array for setting colors of WS2812FX
|
||||
uint8_t options = FX_OPTIONS;
|
||||
} segState;
|
||||
|
||||
// List of all color modes
|
||||
enum MODE {OFF, HOLD, SET};
|
||||
MODE mode = SET; // Standard mode that is active when software starts
|
||||
MODE prevmode = HOLD; // Do not change
|
||||
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
|
||||
|
||||
uint16_t seg_start = 0;
|
||||
uint16_t seg_stop = NUMLEDS - 1;
|
||||
uint16_t fx_speed = 1000; // Global variable for storing the speed for effects --> smaller == slower
|
||||
struct {
|
||||
uint8_t segment = 0; // Actual selected segment
|
||||
MODE mode = SET; // Standard mode that is active when software starts
|
||||
uint8_t brightness = 196; // Global variable for storing the brightness (255 == 100%)
|
||||
uint8_t fx_mode = 0; // Global variable for storing the WS2812FX mode to set
|
||||
uint32_t hex_colors[3] = {}; // Color array for setting colors of WS2812FX
|
||||
uint8_t fx_options = FX_OPTIONS;
|
||||
} State;
|
||||
|
||||
struct {
|
||||
uint8_t segments = 1;
|
||||
uint16_t stripSize = NUMLEDS;
|
||||
char RGBOrder[5] = RGBORDER;
|
||||
#if defined(USE_WS2812FX_DMA)
|
||||
#if USE_WS2812FX_DMA == 0
|
||||
uint8_t pin = 3;
|
||||
#endif
|
||||
#if USE_WS2812FX_DMA == 1
|
||||
uint8_t pin = 2;
|
||||
#endif
|
||||
#if USE_WS2812FX_DMA == 2
|
||||
uint8_t pin = 1;
|
||||
#endif
|
||||
#else
|
||||
uint8_t pin = LED_PIN;
|
||||
#endif
|
||||
bool transEffect = false;
|
||||
} Config;
|
||||
|
||||
uint16_t fx_speed_actual = 1000; // Global variable for storing the speed for effects while fading --> smaller == slower
|
||||
uint8_t fx_speed_actual = 196; // Global variable for storing the speed for effects while fading --> smaller == slower
|
||||
uint8_t fx_mode = 0;
|
||||
uint8_t brightness_trans = 0; // Global variable for storing the brightness before change
|
||||
uint32_t hex_colors_trans[3] = {}; // Color array of colors of WS2812FX before fading
|
||||
uint32_t hexcolors_trans[3] = {}; // Color array of colors of WS2812FX before fading
|
||||
struct ledstate // Data structure to store a state of a single led
|
||||
{
|
||||
uint8_t red;
|
||||
@@ -202,23 +226,3 @@ bool updateConfig = false; // For WiFiManger custom config and config
|
||||
byte KeyPressCount_gy33 = 0;
|
||||
byte prevKeyState_gy33 = HIGH; // button is active low
|
||||
#endif
|
||||
|
||||
struct {
|
||||
uint8_t segment = 0;
|
||||
uint16_t stripSize = NUMLEDS;
|
||||
char RGBOrder[5] = RGBORDER;
|
||||
#if defined(USE_WS2812FX_DMA)
|
||||
#if USE_WS2812FX_DMA == 0
|
||||
uint8_t pin = 3;
|
||||
#endif
|
||||
#if USE_WS2812FX_DMA == 1
|
||||
uint8_t pin = 2;
|
||||
#endif
|
||||
#if USE_WS2812FX_DMA == 2
|
||||
uint8_t pin = 1;
|
||||
#endif
|
||||
#else
|
||||
uint8_t pin = LED_PIN;
|
||||
#endif
|
||||
bool transEffect = false;
|
||||
} FXSettings;
|
||||
|
||||
@@ -77,14 +77,14 @@
|
||||
strcpy(mqtt_user, root["mqtt_user"]);
|
||||
strcpy(mqtt_pass, root["mqtt_pass"]);
|
||||
#endif
|
||||
num_segments = constrain(root["ws_seg"].as<uint8_t>(), 1, MAX_NUM_SEGMENTS - 1);
|
||||
FXSettings.stripSize = constrain(root["ws_cnt"].as<uint16_t>(), 1, MAXLEDS);
|
||||
Config.segments = constrain(root["ws_seg"].as<uint8_t>(), 1, MAX_NUM_SEGMENTS - 1);
|
||||
Config.stripSize = constrain(root["ws_cnt"].as<uint16_t>(), 1, MAXLEDS);
|
||||
char _rgbOrder[5];
|
||||
strcpy(_rgbOrder, root["ws_rgbo"]);
|
||||
checkRGBOrder(_rgbOrder);
|
||||
uint8_t temp_pin;
|
||||
checkPin((uint8_t) root["ws_pin"]);
|
||||
FXSettings.transEffect = root["ws_trans"].as<bool>();
|
||||
Config.transEffect = root["ws_trans"].as<bool>();
|
||||
jsonBuffer.clear();
|
||||
return true;
|
||||
} else {
|
||||
@@ -151,9 +151,9 @@
|
||||
JsonObject root = jsonBuffer.as<JsonObject>();
|
||||
serializeJson(root, DBG_OUTPUT_PORT);
|
||||
DBG_OUTPUT_PORT.println("");
|
||||
FXSettings.segment = root["segment"];
|
||||
mode = static_cast<MODE>(root["mode"].as<uint8_t>());
|
||||
brightness = root["brightness"];
|
||||
State.segment = root["segment"];
|
||||
State.mode = static_cast<MODE>(root["mode"].as<uint8_t>());
|
||||
State.brightness = root["brightness"];
|
||||
jsonBuffer.clear();
|
||||
return true;
|
||||
} else {
|
||||
@@ -199,10 +199,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
bool readSegmentStateFS(uint8_t seg) {
|
||||
bool readSegmentStateFS(uint8_t _seg) {
|
||||
//read strip state from FS JSON
|
||||
char filename[28];
|
||||
snprintf(filename, 28, "/stripstate_segment_%02i.json", seg);
|
||||
snprintf(filename, 28, "/stripstate_segment_%02i.json", _seg);
|
||||
filename[27] = 0x00;
|
||||
if (SPIFFS.exists(filename)) {
|
||||
//file exists, reading and loading
|
||||
@@ -224,23 +224,23 @@
|
||||
JsonObject root = jsonBuffer.as<JsonObject>();
|
||||
serializeJson(root, DBG_OUTPUT_PORT);
|
||||
DBG_OUTPUT_PORT.println("");
|
||||
seg_start = constrain(root["start"].as<uint16_t>(), 0, FXSettings.stripSize - 1) ;
|
||||
seg_stop = constrain(root["stop"].as<uint16_t>(), 0, FXSettings.stripSize - 1);
|
||||
fx_mode = root["fx_mode"].as<uint8_t>();
|
||||
fx_speed = root["speed"].as<uint8_t>();
|
||||
main_color.white = root["color"][0].as<uint8_t>();
|
||||
main_color.red = root["color"][1].as<uint8_t>();
|
||||
main_color.green = root["color"][2].as<uint8_t>();
|
||||
main_color.blue = root["color"][3].as<uint8_t>();
|
||||
back_color.white = root["color"][4].as<uint8_t>();
|
||||
back_color.red = root["color"][5].as<uint8_t>();
|
||||
back_color.green = root["color"][6].as<uint8_t>();
|
||||
back_color.blue = root["color"][7].as<uint8_t>();
|
||||
xtra_color.white = root["color"][8].as<uint8_t>();
|
||||
xtra_color.red = root["color"][9].as<uint8_t>();
|
||||
xtra_color.green = root["color"][10].as<uint8_t>();
|
||||
xtra_color.blue = root["color"][11].as<uint8_t>();
|
||||
fx_options = constrain(root["ws_fxopt"].as<uint8_t>(), 0, 255) & 0xFE;
|
||||
segState.start = constrain(root["start"].as<uint16_t>(), 0, Config.stripSize - 1) ;
|
||||
segState.stop = constrain(root["stop"].as<uint16_t>(), 0, Config.stripSize - 1);
|
||||
segState.mode[_seg] = root["fx_mode"].as<uint8_t>();
|
||||
segState.speed[_seg] = root["speed"].as<uint8_t>();
|
||||
main_color.white = root["color"][0].as<uint8_t>();
|
||||
main_color.red = root["color"][1].as<uint8_t>();
|
||||
main_color.green = root["color"][2].as<uint8_t>();
|
||||
main_color.blue = root["color"][3].as<uint8_t>();
|
||||
back_color.white = root["color"][4].as<uint8_t>();
|
||||
back_color.red = root["color"][5].as<uint8_t>();
|
||||
back_color.green = root["color"][6].as<uint8_t>();
|
||||
back_color.blue = root["color"][7].as<uint8_t>();
|
||||
xtra_color.white = root["color"][8].as<uint8_t>();
|
||||
xtra_color.red = root["color"][9].as<uint8_t>();
|
||||
xtra_color.green = root["color"][10].as<uint8_t>();
|
||||
xtra_color.blue = root["color"][11].as<uint8_t>();
|
||||
segState.options = constrain(root["ws_fxopt"].as<uint8_t>(), 0, 255) & 0xFE;
|
||||
convertColors();
|
||||
jsonBuffer.clear();
|
||||
return true;
|
||||
@@ -254,7 +254,7 @@
|
||||
}
|
||||
} else {
|
||||
DBG_OUTPUT_PORT.printf("Couldn't find \"/%s\"", filename);
|
||||
writeSegmentStateFS(true, seg);
|
||||
writeSegmentStateFS(true, _seg);
|
||||
}
|
||||
//end read
|
||||
return false;
|
||||
|
||||
@@ -1,25 +1,55 @@
|
||||
// Prototypes
|
||||
bool readSegmentStateFS(uint8_t seg);
|
||||
bool readSegmentStateFS(uint8_t _seg);
|
||||
// End Prototypes
|
||||
|
||||
uint16_t convertSpeed(uint16_t _mcl_speed) {
|
||||
uint16_t _fx_speed = 61760 * (exp(0.0002336 * _mcl_speed) - exp(-0.03181 * _mcl_speed));
|
||||
_fx_speed = SPEED_MAX - _fx_speed;
|
||||
_fx_speed = constrain(_fx_speed, SPEED_MIN, SPEED_MAX);
|
||||
//return _fx_speed;
|
||||
return _mcl_speed;
|
||||
// Call convertColors whenever main_color, back_color or xtra_color changes.
|
||||
void convertColors() {
|
||||
hexcolors_trans[0] = (uint32_t)(main_color.white << 24) | (main_color.red << 16) | (main_color.green << 8) | main_color.blue;
|
||||
hexcolors_trans[1] = (uint32_t)(back_color.white << 24) | (back_color.red << 16) | (back_color.green << 8) | back_color.blue;
|
||||
hexcolors_trans[2] = (uint32_t)(xtra_color.white << 24) | (xtra_color.red << 16) | (xtra_color.green << 8) | xtra_color.blue;
|
||||
}
|
||||
|
||||
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;
|
||||
/*uint32_t* convertColors2(uint8_t _w, uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _w2, uint8_t _r2, uint8_t _g2, uint8_t _b2, uint8_t _w3, uint8_t _r3, uint8_t _g3, uint8_t _b3) {
|
||||
uint32_t _hexcolors[3] = {};
|
||||
_hexcolors[0] = (uint32_t)(_w << 24) | (_r << 16) | (_g << 8) | _b;
|
||||
_hexcolors[1] = (uint32_t)(_w2 << 24) | (_r2 << 16) | (_g2 << 8) | _b2;
|
||||
_hexcolors[2] = (uint32_t)(_w3 << 24) | (_r3 << 16) | (_g3 << 8) | _b3;
|
||||
return _hexcolors;
|
||||
}*/
|
||||
|
||||
uint16_t convertSpeed(uint8_t _mcl_speed) {
|
||||
uint16_t _fx_speed = 0;
|
||||
if (_mcl_speed < 50) {
|
||||
_fx_speed = 65535 - (_mcl_speed * 1000);
|
||||
} else if (_mcl_speed < 100) {
|
||||
_fx_speed = 16535 - ((_mcl_speed-49) * 250);
|
||||
} else if (_mcl_speed < 150) {
|
||||
_fx_speed = 4035 - ((_mcl_speed-99) * 50);
|
||||
} else if (_mcl_speed < 200) {
|
||||
_fx_speed = 1535 - ((_mcl_speed-149) * 25);
|
||||
} else {
|
||||
_fx_speed = 285 - ((_mcl_speed-199) * 5);
|
||||
}
|
||||
_fx_speed = constrain(_fx_speed, SPEED_MIN, SPEED_MAX);
|
||||
return _fx_speed;
|
||||
}
|
||||
|
||||
/*uint8_t unconvertSpeed(uint16_t _fx_speed) {
|
||||
uint16_t _mcl_speed = 0;
|
||||
if (_fx_speed <= 285) {
|
||||
_mcl_speed = ((285 - _fx_speed)/5) + 199;
|
||||
} else if (_fx_speed < 1535) {
|
||||
_mcl_speed = ((1535 - _fx_speed)/25) + 149;
|
||||
} else if (_fx_speed < 4035) {
|
||||
_mcl_speed = ((4035 - _fx_speed)/50) + 99;
|
||||
} else if (_mcl_speed < 16535) {
|
||||
_mcl_speed = ((16535 - _fx_speed)/250) + 49;
|
||||
} else {
|
||||
_mcl_speed = ((65535 - _fx_speed)/1000);
|
||||
}
|
||||
return _mcl_speed;
|
||||
}*/
|
||||
|
||||
bool checkPin(uint8_t pin) {
|
||||
#if defined(USE_WS2812FX_DMA)
|
||||
#if USE_WS2812FX_DMA == 0
|
||||
@@ -32,8 +62,8 @@ bool checkPin(uint8_t pin) {
|
||||
pin = 2;
|
||||
#endif
|
||||
#endif
|
||||
if (((pin >= 0 && pin <= 5) || (pin >= 12 && pin <= 16)) && (pin != FXSettings.pin)) {
|
||||
FXSettings.pin = pin;
|
||||
if (((pin >= 0 && pin <= 5) || (pin >= 12 && pin <= 16)) && (pin != Config.pin)) {
|
||||
Config.pin = pin;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -105,22 +135,22 @@ neoPixelType checkRGBOrder(char rgbOrder[5]) {
|
||||
returnOrder = NEO_BGRW;
|
||||
} else {
|
||||
DBG_OUTPUT_PORT.print("invalid input!");
|
||||
uint16_t check = checkRGBOrder(FXSettings.RGBOrder);
|
||||
uint16_t check = checkRGBOrder(Config.RGBOrder);
|
||||
if (check != 0) {
|
||||
returnOrder = static_cast<neoPixelType>(check);
|
||||
strcpy(rgbOrder, FXSettings.RGBOrder);
|
||||
strcpy(rgbOrder, Config.RGBOrder);
|
||||
} else {
|
||||
returnOrder = static_cast<neoPixelType>(checkRGBOrder(RGBORDER));
|
||||
strcpy(rgbOrder, RGBORDER);
|
||||
}
|
||||
}
|
||||
DBG_OUTPUT_PORT.println("success!");
|
||||
strcpy(FXSettings.RGBOrder, rgbOrder);
|
||||
strcpy(Config.RGBOrder, rgbOrder);
|
||||
return returnOrder;
|
||||
}
|
||||
|
||||
// function to Initialize the strip
|
||||
void initStrip(uint16_t _stripSize = FXSettings.stripSize, char _RGBOrder[5] = FXSettings.RGBOrder, uint8_t _pin = FXSettings.pin){
|
||||
void initStrip(uint16_t _stripSize = Config.stripSize, uint8_t _num_segments = Config.segments, char _RGBOrder[5] = Config.RGBOrder, uint8_t _pin = Config.pin){
|
||||
DBG_OUTPUT_PORT.println("Initializing strip!");
|
||||
/*#if defined(USE_WS2812FX_DMA)
|
||||
if (dma != NULL) {
|
||||
@@ -134,15 +164,15 @@ void initStrip(uint16_t _stripSize = FXSettings.stripSize, char _RGBOrder[5] = F
|
||||
strip->resetSegments();
|
||||
strip->resetSegmentRuntimes();
|
||||
delete(strip);
|
||||
FXSettings.stripSize = _stripSize;
|
||||
strcpy(FXSettings.RGBOrder, _RGBOrder);
|
||||
FXSettings.pin = _pin;
|
||||
Config.stripSize = _stripSize;
|
||||
strcpy(Config.RGBOrder, _RGBOrder);
|
||||
Config.pin = _pin;
|
||||
}
|
||||
|
||||
if (ledstates != NULL) {
|
||||
delete(ledstates);
|
||||
}
|
||||
ledstates = new uint8_t [FXSettings.stripSize];
|
||||
ledstates = new uint8_t [_stripSize];
|
||||
|
||||
#if !defined(LED_TYPE_WS2811)
|
||||
strip = new WS2812FX(_stripSize, _pin, checkRGBOrder(_RGBOrder) + NEO_KHZ800);
|
||||
@@ -167,19 +197,23 @@ void initStrip(uint16_t _stripSize = FXSettings.stripSize, char _RGBOrder[5] = F
|
||||
strip->setCustomShow(DMA_Show);
|
||||
#endif
|
||||
//parameters: index, start, stop, mode, color, speed, options
|
||||
for (uint8_t seg=0; seg < num_segments; seg++) {
|
||||
if (seg != FXSettings.segment) { // Read actual segment last
|
||||
(readSegmentStateFS(seg)) ? DBG_OUTPUT_PORT.println("Segment state config FS read Success!") : DBG_OUTPUT_PORT.println("Segment state config FS read failure!");
|
||||
strip->setSegment(seg, seg_start, seg_stop, fx_mode, hex_colors_trans, convertSpeed(fx_speed), fx_options);
|
||||
for (uint8_t _seg=0; _seg < Config.segments; _seg++) {
|
||||
if (_seg != State.segment) { // Read actual segment last
|
||||
(readSegmentStateFS(_seg)) ? DBG_OUTPUT_PORT.println("Segment state config FS read Success!") : DBG_OUTPUT_PORT.println("Segment state config FS read failure!");
|
||||
memcpy(segState.colors[_seg], hexcolors_trans, sizeof(hexcolors_trans));
|
||||
strip->setSegment(_seg, segState.start, segState.stop, segState.mode[_seg], segState.colors[_seg], convertSpeed(segState.speed[_seg]), segState.options);
|
||||
}
|
||||
}
|
||||
//read actual segment last to set all vars correctly
|
||||
(readSegmentStateFS(FXSettings.segment)) ? DBG_OUTPUT_PORT.println("Segment state config FS read Success!") : DBG_OUTPUT_PORT.println("Segment state config FS read failure!");
|
||||
strip->setSegment(FXSettings.segment, seg_start, seg_stop , 0, hex_colors_trans, convertSpeed(fx_speed), fx_options);
|
||||
strip->setMode(FXSettings.segment, fx_mode);
|
||||
fx_speed_actual = fx_speed;
|
||||
(readSegmentStateFS(State.segment)) ? DBG_OUTPUT_PORT.println("Segment state config FS read Success!") : DBG_OUTPUT_PORT.println("Segment state config FS read failure!");
|
||||
memcpy(segState.colors[State.segment], hexcolors_trans, sizeof(hexcolors_trans));
|
||||
strip->setSegment(State.segment, segState.start, segState.stop , segState.mode[State.segment], hexcolors_trans, convertSpeed(segState.speed[State.segment]), segState.options);
|
||||
fx_speed_actual = segState.speed[State.segment];
|
||||
fx_mode = segState.mode[State.segment];
|
||||
prevsegment = State.segment;
|
||||
strip->setCustomMode(0, F("Autoplay"), handleAuto);
|
||||
strip->setCustomMode(1, F("Custom WS"), handleCustomWS);
|
||||
strip->setCustomMode(9, F("Segment OFF"), handleSegmentOFF);
|
||||
#if defined(CUSTOM_WS2812FX_ANIMATIONS)
|
||||
strip->setCustomMode(2, F("TV"), handleTV);
|
||||
strip->setCustomMode(3, F("E1.31"), handleE131);
|
||||
@@ -191,7 +225,7 @@ void initStrip(uint16_t _stripSize = FXSettings.stripSize, char _RGBOrder[5] = F
|
||||
if (e131 != NULL) { delete(e131); }
|
||||
e131 = new ESPAsyncE131(END_UNIVERSE - START_UNIVERSE + 1);
|
||||
float universe_leds = 170.0; // a universe has only 512 (0..511) channels: 3*170 or 4*128 <= 512
|
||||
if (strstr(FXSettings.RGBOrder, "W") != NULL) {
|
||||
if (strstr(Config.RGBOrder, "W") != NULL) {
|
||||
//universe_leds = 128.0;
|
||||
}
|
||||
float float_enduni = _stripSize/universe_leds;
|
||||
@@ -209,41 +243,25 @@ void initStrip(uint16_t _stripSize = FXSettings.stripSize, char _RGBOrder[5] = F
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// Call convertColors whenever main_color, back_color or xtra_color changes.
|
||||
void convertColors() {
|
||||
hex_colors_trans[0] = (uint32_t)(main_color.white << 24) | (main_color.red << 16) | (main_color.green << 8) | main_color.blue;
|
||||
hex_colors_trans[1] = (uint32_t)(back_color.white << 24) | (back_color.red << 16) | (back_color.green << 8) | back_color.blue;
|
||||
hex_colors_trans[2] = (uint32_t)(xtra_color.white << 24) | (xtra_color.red << 16) | (xtra_color.green << 8) | xtra_color.blue;
|
||||
}
|
||||
|
||||
uint32_t* convertColors2(uint8_t w, uint8_t r, uint8_t g, uint8_t b, uint8_t w2, uint8_t r2, uint8_t g2, uint8_t b2, uint8_t w3, uint8_t r3, uint8_t g3, uint8_t b3) {
|
||||
uint32_t hexcolors[3] = {};
|
||||
hexcolors[0] = (uint32_t)(w << 24) | (r << 16) | (g << 8) | b;
|
||||
hexcolors[1] = (uint32_t)(w2 << 24) | (r2 << 16) | (g2 << 8) | b2;
|
||||
hexcolors[2] = (uint32_t)(w3 << 24) | (r3 << 16) | (g3 << 8) | b3;
|
||||
return hexcolors;
|
||||
}
|
||||
|
||||
void getSegmentParams(uint8_t _seg) {
|
||||
seg_start = strip->getSegment(_seg)->start;;
|
||||
seg_stop = strip->getSegment(_seg)->stop;;
|
||||
fx_mode = strip->getMode(_seg);
|
||||
fx_speed = strip->getSpeed(_seg);
|
||||
fx_speed_actual = fx_speed;
|
||||
main_color.white = ((strip->getColors(_seg)[0] >> 24) & 0xFF);
|
||||
main_color.red = ((strip->getColors(_seg)[0] >> 16) & 0xFF);
|
||||
main_color.green = ((strip->getColors(_seg)[0] >> 8) & 0xFF);
|
||||
main_color.blue = ((strip->getColors(_seg)[0]) & 0xFF);
|
||||
back_color.white = ((strip->getColors(_seg)[1] >> 24) & 0xFF);
|
||||
back_color.red = ((strip->getColors(_seg)[1] >> 16) & 0xFF);
|
||||
back_color.green = ((strip->getColors(_seg)[1] >> 8) & 0xFF);
|
||||
back_color.blue = ((strip->getColors(_seg)[1]) & 0xFF);
|
||||
xtra_color.white = ((strip->getColors(_seg)[2] >> 24) & 0xFF);
|
||||
xtra_color.red = ((strip->getColors(_seg)[2] >> 16) & 0xFF);
|
||||
xtra_color.green = ((strip->getColors(_seg)[2] >> 8) & 0xFF);
|
||||
xtra_color.blue = ((strip->getColors(_seg)[2] >> 0) & 0xFF);
|
||||
fx_options = strip->getOptions(_seg);
|
||||
segState.start = strip->getSegment(_seg)->start;;
|
||||
segState.stop = strip->getSegment(_seg)->stop;;
|
||||
//segState.mode[_seg] = strip->getMode(_seg);
|
||||
//segState.speed[_seg] = unconvertSpeed(strip->getSpeed(_seg));
|
||||
fx_speed_actual = segState.speed[_seg];
|
||||
main_color.white = ((segState.colors[_seg][0] >> 24) & 0xFF);
|
||||
main_color.red = ((segState.colors[_seg][0] >> 16) & 0xFF);
|
||||
main_color.green = ((segState.colors[_seg][0] >> 8) & 0xFF);
|
||||
main_color.blue = ((segState.colors[_seg][0]) & 0xFF);
|
||||
back_color.white = ((segState.colors[_seg][1] >> 24) & 0xFF);
|
||||
back_color.red = ((segState.colors[_seg][1] >> 16) & 0xFF);
|
||||
back_color.green = ((segState.colors[_seg][1] >> 8) & 0xFF);
|
||||
back_color.blue = ((segState.colors[_seg][1]) & 0xFF);
|
||||
xtra_color.white = ((segState.colors[_seg][2] >> 24) & 0xFF);
|
||||
xtra_color.red = ((segState.colors[_seg][2] >> 16) & 0xFF);
|
||||
xtra_color.green = ((segState.colors[_seg][2] >> 8) & 0xFF);
|
||||
xtra_color.blue = ((segState.colors[_seg][2] >> 0) & 0xFF);
|
||||
segState.options = strip->getOptions(_seg);
|
||||
}
|
||||
|
||||
void setSegmentSize() {
|
||||
@@ -251,30 +269,33 @@ void setSegmentSize() {
|
||||
delay(10);
|
||||
if(strip->isRunning()) strip->stop();
|
||||
strip->resetSegmentRuntimes();
|
||||
strip->setSegment(FXSettings.segment, seg_start, seg_stop , fx_mode, hex_colors_trans, convertSpeed(fx_speed), fx_options);
|
||||
strip->setSegment(State.segment, segState.start, segState.stop , segState.mode[State.segment], hexcolors_trans, convertSpeed(segState.speed[State.segment]), segState.options);
|
||||
}
|
||||
|
||||
void calculateColorTransitionSteps() {
|
||||
uint8_t calculateColorTransitionSteps(uint8_t _seg) {
|
||||
//compare all colors and calculate steps
|
||||
trans_cnt_max = 0;
|
||||
int calculate_max[4] = {};
|
||||
int _trans_cnt_max = 0;
|
||||
int _calculate_max[4] = {};
|
||||
for (uint8_t i=0; i<3; i++){
|
||||
for (uint8_t j=0; j<4; 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]);
|
||||
_calculate_max[j] = ((strip->getColors(_seg)[i] >> ((3-j)*8)) & 0xFF) - ((hexcolors_trans[i] >> ((3-j)*8)) & 0xFF);
|
||||
_calculate_max[j] = abs(_calculate_max[j]);
|
||||
_trans_cnt_max = max(_trans_cnt_max, _calculate_max[j]);
|
||||
}
|
||||
}
|
||||
return _trans_cnt_max;
|
||||
}
|
||||
|
||||
void convertColorsFade() {
|
||||
if (FXSettings.transEffect) {
|
||||
uint8_t convertColorsFade(uint8_t _seg) {
|
||||
if (Config.transEffect) {
|
||||
if (trans_cnt > 1) {
|
||||
memcpy(hex_colors, strip->getColors(FXSettings.segment), sizeof(hex_colors));
|
||||
//memcpy(segState.colors[_seg], strip->getColors(_seg), sizeof(segState.colors[_seg]));
|
||||
DBG_OUTPUT_PORT.println("Color transistion aborted. Restarting...!");
|
||||
trans_cnt = 1;
|
||||
}
|
||||
calculateColorTransitionSteps();
|
||||
return calculateColorTransitionSteps(_seg);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1614
-1601
File diff suppressed because it is too large
Load Diff
@@ -10,14 +10,14 @@ char * listStateJSONfull() {
|
||||
const size_t bufferSize = JSON_ARRAY_SIZE(12) + JSON_OBJECT_SIZE(19) + 250;
|
||||
DynamicJsonDocument jsonBuffer(bufferSize);
|
||||
JsonObject root = jsonBuffer.to<JsonObject>();
|
||||
root["segment"] = FXSettings.segment;
|
||||
root["start"] = seg_start;
|
||||
root["stop"] = seg_stop;
|
||||
root["mode"] = (uint8_t) mode;
|
||||
root["segment"] = State.segment;
|
||||
root["start"] = segState.start;
|
||||
root["stop"] = segState.stop;
|
||||
root["mode"] = (uint8_t) State.mode;
|
||||
//getSegmentParams(segment);
|
||||
root["fx_mode"] = fx_mode;
|
||||
root["speed"] = fx_speed;
|
||||
root["brightness"] = brightness;
|
||||
root["fx_mode"] = segState.mode[State.segment];
|
||||
root["speed"] = segState.speed[State.segment];
|
||||
root["brightness"] = State.brightness;
|
||||
JsonArray color = root.createNestedArray("color");
|
||||
color.add(main_color.white);
|
||||
color.add(main_color.red);
|
||||
@@ -31,7 +31,7 @@ char * listStateJSONfull() {
|
||||
color.add(xtra_color.red);
|
||||
color.add(xtra_color.green);
|
||||
color.add(xtra_color.blue);
|
||||
root["ws_fxopt"] = fx_options;
|
||||
root["ws_fxopt"] = segState.options;
|
||||
root["hostname"] = HOSTNAME;
|
||||
#if defined(ENABLE_MQTT)
|
||||
root["mqtt_host"] = mqtt_host;
|
||||
@@ -39,11 +39,11 @@ char * listStateJSONfull() {
|
||||
root["mqtt_user"] = mqtt_user;
|
||||
root["mqtt_pass"] = mqtt_pass;
|
||||
#endif
|
||||
root["ws_seg"] = num_segments;
|
||||
root["ws_cnt"] = FXSettings.stripSize;
|
||||
root["ws_rgbo"] = FXSettings.RGBOrder;
|
||||
root["ws_pin"] = FXSettings.pin;
|
||||
root["ws_trans"] = FXSettings.transEffect;
|
||||
root["ws_seg"] = Config.segments;
|
||||
root["ws_cnt"] = Config.stripSize;
|
||||
root["ws_rgbo"] = Config.RGBOrder;
|
||||
root["ws_pin"] = Config.pin;
|
||||
root["ws_trans"] = Config.transEffect;
|
||||
uint16_t msg_len = measureJson(root) + 1;
|
||||
char * buffer = (char *) malloc(msg_len);
|
||||
serializeJson(root, buffer, msg_len);
|
||||
@@ -55,9 +55,9 @@ char * listStateJSON() {
|
||||
const size_t bufferSize = JSON_OBJECT_SIZE(3) + 25;
|
||||
DynamicJsonDocument jsonBuffer(bufferSize);
|
||||
JsonObject root = jsonBuffer.to<JsonObject>();
|
||||
root["segment"] = FXSettings.segment;
|
||||
root["mode"] = (uint8_t) mode;
|
||||
root["brightness"] = brightness;
|
||||
root["segment"] = State.segment;
|
||||
root["mode"] = (uint8_t) State.mode;
|
||||
root["brightness"] = State.brightness;
|
||||
uint16_t msg_len = measureJson(root) + 1;
|
||||
char * buffer = (char *) malloc(msg_len);
|
||||
serializeJson(root, buffer, msg_len);
|
||||
@@ -65,49 +65,36 @@ char * listStateJSON() {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
char * listSegmentStateJSON(uint8_t seg) {
|
||||
char * listSegmentStateJSON(uint8_t _seg) {
|
||||
const size_t bufferSize = JSON_ARRAY_SIZE(12) + JSON_OBJECT_SIZE(6) + 100;
|
||||
DynamicJsonDocument jsonBuffer(bufferSize);
|
||||
JsonObject root = jsonBuffer.to<JsonObject>();
|
||||
if (seg == FXSettings.segment) {
|
||||
root["start"] = seg_start;
|
||||
root["stop"] = seg_stop;
|
||||
if (_seg == State.segment) {
|
||||
root["start"] = segState.start;
|
||||
root["stop"] = segState.stop;
|
||||
} else {
|
||||
root["start"] = strip->getSegment(seg)->start;
|
||||
root["stop"] = strip->getSegment(seg)->stop;
|
||||
root["start"] = strip->getSegment(_seg)->start;
|
||||
root["stop"] = strip->getSegment(_seg)->stop;
|
||||
}
|
||||
//getSegmentParams(seg);
|
||||
root["fx_mode"] = strip->getMode(seg);
|
||||
root["speed"] = fx_speed;
|
||||
JsonArray color = root.createNestedArray("color");
|
||||
if (seg == FXSettings.segment) {
|
||||
color.add(main_color.white);
|
||||
color.add(main_color.red);
|
||||
color.add(main_color.green);
|
||||
color.add(main_color.blue);
|
||||
color.add(back_color.white);
|
||||
color.add(back_color.red);
|
||||
color.add(back_color.green);
|
||||
color.add(back_color.blue);
|
||||
color.add(xtra_color.white);
|
||||
color.add(xtra_color.red);
|
||||
color.add(xtra_color.green);
|
||||
color.add(xtra_color.blue);
|
||||
} else {
|
||||
color.add((strip->getColors(seg)[0] >> 24) & 0xFF);
|
||||
color.add((strip->getColors(seg)[0] >> 16) & 0xFF);
|
||||
color.add((strip->getColors(seg)[0] >> 8) & 0xFF);
|
||||
color.add((strip->getColors(seg)[0]) & 0xFF);
|
||||
color.add((strip->getColors(seg)[1] >> 24) & 0xFF);
|
||||
color.add((strip->getColors(seg)[1] >> 16) & 0xFF);
|
||||
color.add((strip->getColors(seg)[1] >> 8) & 0xFF);
|
||||
color.add((strip->getColors(seg)[1]) & 0xFF);
|
||||
color.add((strip->getColors(seg)[2] >> 24) & 0xFF);
|
||||
color.add((strip->getColors(seg)[2] >> 16) & 0xFF);
|
||||
color.add((strip->getColors(seg)[2] >> 8) & 0xFF);
|
||||
color.add((strip->getColors(seg)[2]) & 0xFF);
|
||||
}
|
||||
root["ws_fxopt"] = fx_options;
|
||||
//root["fx_mode"] = strip->getMode(_seg);
|
||||
root["fx_mode"] = segState.mode[_seg];
|
||||
root["speed"] = segState.speed[_seg];
|
||||
JsonArray color = root.createNestedArray("color");
|
||||
//color.add((strip->getColors(_seg)[0] >> 24) & 0xFF);
|
||||
color.add((segState.colors[_seg][0] >> 24) & 0xFF);
|
||||
color.add((segState.colors[_seg][0] >> 16) & 0xFF);
|
||||
color.add((segState.colors[_seg][0] >> 8) & 0xFF);
|
||||
color.add((segState.colors[_seg][0]) & 0xFF);
|
||||
color.add((segState.colors[_seg][1] >> 24) & 0xFF);
|
||||
color.add((segState.colors[_seg][1] >> 16) & 0xFF);
|
||||
color.add((segState.colors[_seg][1] >> 8) & 0xFF);
|
||||
color.add((segState.colors[_seg][1]) & 0xFF);
|
||||
color.add((segState.colors[_seg][2] >> 24) & 0xFF);
|
||||
color.add((segState.colors[_seg][2] >> 16) & 0xFF);
|
||||
color.add((segState.colors[_seg][2] >> 8) & 0xFF);
|
||||
color.add((segState.colors[_seg][2]) & 0xFF);
|
||||
root["ws_fxopt"] = segState.options;
|
||||
uint16_t msg_len = measureJson(root) + 1;
|
||||
char * buffer = (char *) malloc(msg_len);
|
||||
serializeJson(root, buffer, msg_len);
|
||||
@@ -137,11 +124,11 @@ char * listConfigJSON() {
|
||||
root["mqtt_user"] = mqtt_user;
|
||||
root["mqtt_pass"] = mqtt_pass;
|
||||
#endif
|
||||
root["ws_seg"] = num_segments;
|
||||
root["ws_cnt"] = FXSettings.stripSize;
|
||||
root["ws_rgbo"] = FXSettings.RGBOrder;
|
||||
root["ws_pin"] = FXSettings.pin;
|
||||
root["ws_trans"] = FXSettings.transEffect;
|
||||
root["ws_seg"] = Config.segments;
|
||||
root["ws_cnt"] = Config.stripSize;
|
||||
root["ws_rgbo"] = Config.RGBOrder;
|
||||
root["ws_pin"] = Config.pin;
|
||||
root["ws_trans"] = Config.transEffect;
|
||||
uint16_t msg_len = measureJson(root) + 1;
|
||||
char * buffer = (char *) malloc(msg_len);
|
||||
serializeJson(root, buffer, msg_len);
|
||||
@@ -211,10 +198,10 @@ char * listESPStateJSON() {
|
||||
#else
|
||||
root["animation_lib"] = "WS2812FX";
|
||||
#endif
|
||||
root["ws2812_pin"] = FXSettings.pin;
|
||||
root["led_count"] = FXSettings.stripSize;
|
||||
root["rgb_order"] = FXSettings.RGBOrder;
|
||||
if (strstr(FXSettings.RGBOrder, "W") != NULL) {
|
||||
root["ws2812_pin"] = Config.pin;
|
||||
root["led_count"] = Config.stripSize;
|
||||
root["rgb_order"] = Config.RGBOrder;
|
||||
if (strstr(Config.RGBOrder, "W") != NULL) {
|
||||
root["rgbw_mode"] = "ON";
|
||||
} else {
|
||||
root["rgbw_mode"] = "OFF";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Prototypes
|
||||
uint16_t convertSpeed(uint16_t _mcl_speed);
|
||||
uint16_t convertSpeed(uint8_t _mcl_speed);
|
||||
uint32_t trans(uint32_t _newcolor, uint32_t _oldcolor, uint8_t _level, uint8_t _steps);
|
||||
// End Prototypes
|
||||
/*
|
||||
@@ -12,22 +12,28 @@ More info on how to create custom aniamtions for WS2812FX: https://github.com/ki
|
||||
// ***************************************************************************
|
||||
// Functions and variables for automatic cycling
|
||||
// ***************************************************************************
|
||||
|
||||
void handleAutoPlay() {
|
||||
uint16_t handleSegmentOFF(void) {
|
||||
WS2812FX::Segment* _seg = strip->getSegment();
|
||||
if (autoDelay <= millis()) {
|
||||
hex_colors_trans[0] = autoParams[autoCount][0];
|
||||
hex_colors_trans[1] = autoParams[autoCount][1];
|
||||
hex_colors_trans[2] = autoParams[autoCount][2];
|
||||
strip->setColors(FXSettings.segment, hex_colors_trans);
|
||||
strip->setSpeed(FXSettings.segment, convertSpeed((uint16_t)autoParams[autoCount][3]));
|
||||
strip->setMode(FXSettings.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;
|
||||
return _seg->speed;
|
||||
}
|
||||
|
||||
void handleAutoPlay(uint8_t _seg) {
|
||||
//WS2812FX::Segment* _seg = strip->getSegment();
|
||||
if (autoDelay[_seg] <= millis()) {
|
||||
uint32_t _hex_colors[3] = {};
|
||||
//if (_seg ==
|
||||
_hex_colors[0] = autoParams[autoCount[_seg]][0];
|
||||
_hex_colors[1] = autoParams[autoCount[_seg]][1];
|
||||
_hex_colors[2] = autoParams[autoCount[_seg]][2];
|
||||
//}
|
||||
strip->setColors(_seg, _hex_colors);
|
||||
strip->setSpeed(_seg, convertSpeed((uint16_t)autoParams[autoCount[_seg]][3]));
|
||||
strip->setMode(_seg, (uint8_t)autoParams[autoCount[_seg]][4]);
|
||||
//strip->trigger();
|
||||
autoDelay[_seg] = millis() + (unsigned long)autoParams[autoCount[_seg]][5];
|
||||
DBG_OUTPUT_PORT.printf("autoTick[%d][%d]: {0x%08x, 0x%08x, 0x%08x, %d, %d, %d}\r\n", _seg, autoCount[_seg], autoParams[autoCount[_seg]][0], autoParams[autoCount[_seg]][1], autoParams[autoCount[_seg]][2], autoParams[autoCount[_seg]][3], autoParams[autoCount[_seg]][4], autoParams[autoCount[_seg]][5]);
|
||||
autoCount[_seg]++;
|
||||
if (autoCount[_seg] >= (sizeof(autoParams) / sizeof(autoParams[0]))) autoCount[_seg] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +47,7 @@ void handleAutoPlay() {
|
||||
unsigned long dipStartTime;
|
||||
unsigned long currentMillis;
|
||||
uint8_t ledState = LOW;
|
||||
long previousMillis = 0;
|
||||
unsigned long previousMillis = 0;
|
||||
uint16_t interv = 2000;
|
||||
uint8_t twitch = 50;
|
||||
uint8_t dipCount = 0;
|
||||
@@ -119,7 +125,7 @@ uint16_t handleTV(void) {
|
||||
if(currentMillis-previousMillis > interv) {
|
||||
previousMillis = currentMillis;
|
||||
//interv = random(750,4001);//Adjusts the interval for more/less frequent random light changes
|
||||
interv = random(1000-(fx_speed*2),5001-(fx_speed*8));
|
||||
interv = random(1000-(_seg->speed/128),5001-(_seg->speed/32));
|
||||
twitch = random(40,100);// Twitch provides motion effect but can be a bit much if too high
|
||||
dipCount = dipCount++;
|
||||
}
|
||||
@@ -145,7 +151,7 @@ uint16_t handleTV(void) {
|
||||
currentDipTime = millis();
|
||||
if (currentDipTime - dipStartTime < darkTime) {
|
||||
for (uint16_t i=(_seg->start + 3); i<= _seg->stop; i++) {
|
||||
ledstates[i] = brightness;
|
||||
ledstates[i] = State.brightness;
|
||||
for (uint16_t j=_seg->start; j<=_seg->stop; j++) {
|
||||
uint16_t index = (j%3 == 0) ? 400 : random(0,767);
|
||||
hsb2rgbAN1(index, 200, ledstates[j], j);
|
||||
@@ -178,11 +184,11 @@ uint16_t handleE131(void) {
|
||||
/* #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 > FXSettings.stripSize) ? (FXSettings.stripSize - multipacketOffset) : 128;
|
||||
uint16_t len = (128 + multipacketOffset > Config.stripSize) ? (Config.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 (FXSettings.stripSize <= multipacketOffset) return _seg->speed;
|
||||
uint16_t len = (170 + multipacketOffset > FXSettings.stripSize) ? (FXSettings.stripSize - multipacketOffset) : 170;
|
||||
if (Config.stripSize <= multipacketOffset) return _seg->speed;
|
||||
uint16_t len = (170 + multipacketOffset > Config.stripSize) ? (Config.stripSize - multipacketOffset) : 170;
|
||||
/* #endif */
|
||||
for (uint16_t i = 0; i < len; i++){
|
||||
if ((i >= _seg->start) && (i <= _seg->stop)) {
|
||||
@@ -219,11 +225,13 @@ uint16_t handleFire2012(void) {
|
||||
}
|
||||
|
||||
// Step 4. Map from heat cells to LED colors
|
||||
|
||||
// 98 143
|
||||
for( uint16_t j = _seg->start; j <= _seg->stop; j++) {
|
||||
CRGB color = HeatColor(ledstates[j]);
|
||||
uint16_t pixel;
|
||||
if ((_seg->options & 128) > 0) {
|
||||
pixel = _seg->stop - j;
|
||||
pixel = _seg->stop + (_seg->start - j);
|
||||
} else {
|
||||
pixel = j;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
bool handleSetMainColor(uint8_t * mypayload) {
|
||||
// decode rgb data
|
||||
uint32_t rgb = (uint32_t) strtoul((const char *) &mypayload[1], NULL, 16);
|
||||
if (rgb != strip->getColors(FXSettings.segment)[0]) {
|
||||
if (rgb != segState.colors[State.segment][0]) {
|
||||
main_color.white = ((rgb >> 24) & 0xFF);
|
||||
main_color.red = ((rgb >> 16) & 0xFF);
|
||||
main_color.green = ((rgb >> 8) & 0xFF);
|
||||
@@ -20,7 +20,7 @@ bool handleSetMainColor(uint8_t * mypayload) {
|
||||
bool handleSetBackColor(uint8_t * mypayload) {
|
||||
// decode rgb data
|
||||
uint32_t rgb = (uint32_t) strtoul((const char *) &mypayload[2], NULL, 16);
|
||||
if (rgb != strip->getColors(FXSettings.segment)[1]) {
|
||||
if (rgb != segState.colors[State.segment][1]) {
|
||||
back_color.white = ((rgb >> 24) & 0xFF);
|
||||
back_color.red = ((rgb >> 16) & 0xFF);
|
||||
back_color.green = ((rgb >> 8) & 0xFF);
|
||||
@@ -32,7 +32,7 @@ bool handleSetBackColor(uint8_t * mypayload) {
|
||||
bool handleSetXtraColor(uint8_t * mypayload) {
|
||||
// decode rgb data
|
||||
uint32_t rgb = (uint32_t) strtoul((const char *) &mypayload[3], NULL, 16);
|
||||
if (rgb != strip->getColors(FXSettings.segment)[2]) {
|
||||
if (rgb != segState.colors[State.segment][2]) {
|
||||
xtra_color.white = ((rgb >> 24) & 0xFF);
|
||||
xtra_color.red = ((rgb >> 16) & 0xFF);
|
||||
xtra_color.green = ((rgb >> 8) & 0xFF);
|
||||
@@ -45,14 +45,14 @@ bool handleSetXtraColor(uint8_t * mypayload) {
|
||||
bool handleSetAllMode(uint8_t * mypayload) {
|
||||
// decode rgb data
|
||||
uint32_t rgb = (uint32_t) strtoul((const char *) &mypayload[1], NULL, 16);
|
||||
if ((mode = OFF) || (fx_mode != strip->getMode(FXSettings.segment)) || (rgb != strip->getColors(FXSettings.segment)[0])) {
|
||||
if ((State.mode = OFF) || (segState.mode[State.segment] != strip->getMode(State.segment)) || (rgb != segState.colors[State.segment][0])) {
|
||||
main_color.white = ((rgb >> 24) & 0xFF);
|
||||
main_color.red = ((rgb >> 16) & 0xFF);
|
||||
main_color.green = ((rgb >> 8) & 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);
|
||||
fx_mode = FX_MODE_STATIC;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -65,8 +65,8 @@ void handleSetSingleLED(uint8_t * mypayload, uint8_t firstChar = 0) {
|
||||
templed[4] = 0x00;
|
||||
uint8_t led = atoi(templed);
|
||||
|
||||
DBG_OUTPUT_PORT.printf("led value: [%i]. Entry threshold: <= [%i] (=> %s)\r\n", led, FXSettings.stripSize, mypayload );
|
||||
if (led <= FXSettings.stripSize) {
|
||||
DBG_OUTPUT_PORT.printf("led value: [%i]. Entry threshold: <= [%i] (=> %s)\r\n", led, Config.stripSize, mypayload );
|
||||
if (led <= Config.stripSize) {
|
||||
char redhex[3];
|
||||
char greenhex[3];
|
||||
char bluehex[3];
|
||||
@@ -100,7 +100,7 @@ void handleSetSingleLED(uint8_t * mypayload, uint8_t firstChar = 0) {
|
||||
strip->setPixelColor(led, color.red, color.green, color.blue, color.white);
|
||||
strip->show();
|
||||
}
|
||||
mode = HOLD;
|
||||
State.mode = HOLD;
|
||||
fx_mode= FX_MODE_CUSTOM_1;
|
||||
}
|
||||
|
||||
@@ -151,13 +151,13 @@ bool setModeByStateString(String saved_state_string) {
|
||||
if (getValue(saved_state_string, '|', 0) == "STA") {
|
||||
DBG_OUTPUT_PORT.printf("Parsed state: %s\r\n", saved_state_string.c_str());
|
||||
String str_mode = getValue(saved_state_string, '|', 1);
|
||||
mode = static_cast<MODE>(str_mode.toInt());
|
||||
State.mode = static_cast<MODE>(str_mode.toInt());
|
||||
String str_fx_mode = getValue(saved_state_string, '|', 2);
|
||||
fx_mode = str_fx_mode.toInt();
|
||||
String str_fx_speed = getValue(saved_state_string, '|', 3);
|
||||
fx_speed = str_fx_speed.toInt();
|
||||
segState.speed[State.segment] = str_fx_speed.toInt();
|
||||
String str_brightness = getValue(saved_state_string, '|', 4);
|
||||
brightness = str_brightness.toInt();
|
||||
State.brightness = str_brightness.toInt();
|
||||
String str_red = getValue(saved_state_string, '|', 5);
|
||||
main_color.red = str_red.toInt();
|
||||
String str_green = getValue(saved_state_string, '|', 6);
|
||||
@@ -185,7 +185,7 @@ bool setModeByStateString(String saved_state_string) {
|
||||
DBG_OUTPUT_PORT.print("Set to state: ");
|
||||
DBG_OUTPUT_PORT.println(listStateJSON());
|
||||
//prevmode=mode;
|
||||
//mode = SET;
|
||||
//State.mode = SET;
|
||||
return true;
|
||||
} else {
|
||||
DBG_OUTPUT_PORT.println("Saved state not found!");
|
||||
@@ -198,13 +198,13 @@ void handleSetWS2812FXMode(uint8_t * mypayload) {
|
||||
if (isDigit(mypayload[1])) {
|
||||
fx_mode = (uint8_t) strtol((const char *) &mypayload[1], NULL, 10);
|
||||
fx_mode = constrain(fx_mode, 0, strip->getModeCount() - 1);
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
} else {
|
||||
if (strcmp((char *) &mypayload[1], "off") == 0) {
|
||||
if (mode == OFF) { mode = SET; } else { mode = OFF; };
|
||||
if (State.mode == OFF) { State.mode = SET; } else { State.mode = OFF; };
|
||||
}
|
||||
if (strcmp((char *) &mypayload[1], "on") == 0) {
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -268,25 +268,25 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
|
||||
if (_payload[0] == 'S') {
|
||||
if (_payload[1] == 's') {
|
||||
uint8_t seg = (uint8_t) strtol((const char *) &_payload[2], NULL, 10);
|
||||
FXSettings.segment = constrain(seg, 0, num_segments - 1);
|
||||
if (prevsegment != FXSettings.segment) {
|
||||
prevsegment = FXSettings.segment;
|
||||
getSegmentParams(FXSettings.segment);
|
||||
State.segment = constrain(seg, 0, Config.segments - 1);
|
||||
if (prevsegment != State.segment) {
|
||||
prevsegment = State.segment;
|
||||
getSegmentParams(State.segment);
|
||||
//convertColors();
|
||||
//memcpy(hex_colors, hex_colors_trans, sizeof(hex_colors_trans));
|
||||
memcpy(hex_colors_trans, hex_colors, sizeof(hex_colors_trans));
|
||||
//memcpy(segState.colors[State.segment], hexcolors_trans, sizeof(hexcolors_trans));
|
||||
memcpy(hexcolors_trans, segState.colors[State.segment], sizeof(hexcolors_trans));
|
||||
_updateState = true;
|
||||
Dbg_Prefix(mqtt, num);
|
||||
DBG_OUTPUT_PORT.printf("Set segment to: [%u]\r\n", FXSettings.segment);
|
||||
DBG_OUTPUT_PORT.printf("Set segment to: [%u]\r\n", State.segment);
|
||||
}
|
||||
}
|
||||
// / ==> Set segment first LED
|
||||
if (_payload[1] == '[') {
|
||||
uint16_t _seg_start = (uint16_t) strtol((const char *) &_payload[2], NULL, 10);
|
||||
//getSegmentParams(FXSettings.segment);
|
||||
_seg_start = constrain(_seg_start, 0, FXSettings.stripSize - 1);
|
||||
if (_seg_start != seg_start) {
|
||||
seg_start = _seg_start;
|
||||
//getSegmentParams(State.segment);
|
||||
_seg_start = constrain(_seg_start, 0, Config.stripSize - 1);
|
||||
if (_seg_start != segState.start) {
|
||||
segState.start = _seg_start;
|
||||
_updateSegState = true;
|
||||
setSegmentSize();
|
||||
Dbg_Prefix(mqtt, num);
|
||||
@@ -296,10 +296,10 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
|
||||
// / ==> Set segment last LED
|
||||
if (_payload[1] == ']') {
|
||||
uint16_t _seg_stop = (uint16_t) strtol((const char *) &_payload[2], NULL, 10);
|
||||
//getSegmentParams(FXSettings.segment);
|
||||
_seg_stop = constrain(_seg_stop, seg_start, FXSettings.stripSize - 1);
|
||||
if (_seg_stop != seg_stop) {
|
||||
seg_stop = _seg_stop;
|
||||
//getSegmentParams(State.segment);
|
||||
_seg_stop = constrain(_seg_stop, segState.start, Config.stripSize - 1);
|
||||
if (_seg_stop != segState.stop) {
|
||||
segState.stop = _seg_stop;
|
||||
_updateSegState = true;
|
||||
setSegmentSize();
|
||||
Dbg_Prefix(mqtt, num);
|
||||
@@ -310,15 +310,15 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
|
||||
char _fx_options[4];
|
||||
snprintf(_fx_options, sizeof(_fx_options), "%s", &_payload[2]);
|
||||
_fx_options[3] = 0x00;
|
||||
if (((constrain(atoi(_fx_options), 0, 255)>>1)<<1) != fx_options) {
|
||||
fx_options = ((constrain(atoi(_fx_options), 0, 255)>>1)<<1);
|
||||
if (((constrain(atoi(_fx_options), 0, 255)>>1)<<1) != segState.options) {
|
||||
segState.options= ((constrain(atoi(_fx_options), 0, 255)>>1)<<1);
|
||||
_updateSegState = true;
|
||||
strip->setOptions(FXSettings.segment, fx_options);
|
||||
strip->setOptions(State.segment, segState.options);
|
||||
Dbg_Prefix(mqtt, num);
|
||||
DBG_OUTPUT_PORT.printf("Set segment options to: [%u]\r\n", fx_options);
|
||||
DBG_OUTPUT_PORT.printf("Set segment options to: [%u]\r\n", segState.options);
|
||||
}
|
||||
}
|
||||
char * buffer = listSegmentStateJSON(FXSettings.segment);
|
||||
char * buffer = listSegmentStateJSON(State.segment);
|
||||
if (mqtt == true) {
|
||||
DBG_OUTPUT_PORT.print("MQTT: ");
|
||||
#if defined(ENABLE_MQTT)
|
||||
@@ -338,7 +338,7 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
|
||||
// / ==> Set WS2812 mode.
|
||||
if (_payload[0] == '/') {
|
||||
handleSetWS2812FXMode(_payload);
|
||||
if (fx_mode != strip->getMode(FXSettings.segment)) {
|
||||
if (fx_mode != strip->getMode(State.segment)) {
|
||||
_updateSegState = true;
|
||||
Dbg_Prefix(mqtt, num);
|
||||
DBG_OUTPUT_PORT.printf("Set WS2812 mode: [%s]\r\n", _payload);
|
||||
@@ -369,28 +369,28 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
|
||||
#if defined(ENABLE_MQTT)
|
||||
snprintf(mqtt_buf, sizeof(mqtt_buf), "OK %s", _payload);
|
||||
#endif
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
|
||||
// ? ==> Set speed
|
||||
if (_payload[0] == '?') {
|
||||
uint16_t _fx_speed = (uint16_t) strtol((const char *) &_payload[1], NULL, 10);
|
||||
fx_speed = constrain(_fx_speed, SPEED_MIN, SPEED_MAX );
|
||||
mode = SET;
|
||||
segState.speed[State.segment] = constrain(_fx_speed, SPEED_MIN, SPEED_MAX );
|
||||
State.mode = SET;
|
||||
_updateSegState = true;
|
||||
Dbg_Prefix(mqtt, num);
|
||||
DBG_OUTPUT_PORT.printf("Set speed to: [%u]\r\n", fx_speed);
|
||||
DBG_OUTPUT_PORT.printf("Set speed to: [%u]\r\n", segState.speed[State.segment]);
|
||||
}
|
||||
|
||||
// % ==> Set brightness
|
||||
if (_payload[0] == '%') {
|
||||
uint8_t b = (uint8_t) strtol((const char *) &_payload[1], NULL, 10);
|
||||
brightness = constrain(b, 0, 255);
|
||||
if (strip->getBrightness() != brightness) {
|
||||
mode = SET;
|
||||
State.brightness = constrain(b, 0, 255);
|
||||
if (strip->getBrightness() != State.brightness) {
|
||||
State.mode = SET;
|
||||
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", State.brightness);
|
||||
_updateState = true;
|
||||
}
|
||||
}
|
||||
@@ -451,24 +451,24 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
|
||||
if (_payload[0] == 'C') {
|
||||
bool _updateStrip = false;
|
||||
bool _updateConfig = false;
|
||||
bool _updateSegState = false;
|
||||
bool _updateState = false;
|
||||
if (_payload[1] == 's') {
|
||||
if (_payload[2] == 's') {
|
||||
char _num_segments[3];
|
||||
snprintf(_num_segments, sizeof(_num_segments), "%s", &_payload[3]);
|
||||
_num_segments[2] = 0x00;
|
||||
num_segments = constrain(atoi(_num_segments), 1, MAX_NUM_SEGMENTS - 1);
|
||||
if (FXSettings.segment >= num_segments) {
|
||||
FXSettings.segment = num_segments - 1;
|
||||
Config.segments = constrain(atoi(_num_segments), 1, MAX_NUM_SEGMENTS - 1);
|
||||
if (State.segment >= Config.segments) {
|
||||
State.segment = Config.segments - 1;
|
||||
_updateState = true;
|
||||
}
|
||||
_updateStrip = true;
|
||||
_updateSegState = true;
|
||||
}
|
||||
if (_payload[2] == 'c') {
|
||||
char tmp_count[6];
|
||||
snprintf(tmp_count, sizeof(tmp_count), "%s", &_payload[3]);
|
||||
tmp_count[5] = 0x00;
|
||||
FXSettings.stripSize = constrain(atoi(tmp_count), 1, MAXLEDS);
|
||||
Config.stripSize = constrain(atoi(tmp_count), 1, MAXLEDS);
|
||||
_updateStrip = true;
|
||||
}
|
||||
if (_payload[2] == 'r') {
|
||||
@@ -529,7 +529,7 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
|
||||
char _transEffect[2];
|
||||
snprintf(_transEffect, sizeof(_transEffect), "%s", &_payload[2]);
|
||||
_transEffect[sizeof(_transEffect) - 1] = 0x00;
|
||||
FXSettings.transEffect = atoi(_transEffect);
|
||||
Config.transEffect = atoi(_transEffect);
|
||||
_updateConfig = true;
|
||||
}
|
||||
|
||||
@@ -554,15 +554,14 @@ void checkpayload(uint8_t * _payload, bool mqtt = false, uint8_t num = 0) {
|
||||
DBG_OUTPUT_PORT.println("Saving config.json!");
|
||||
if(!save_conf.active()) save_conf.once(3, tickerSaveConfig);
|
||||
}
|
||||
if (_updateSegState) {
|
||||
DBG_OUTPUT_PORT.println("Saving stripstate_segment.json!");
|
||||
if(!save_seg_state.active()) save_seg_state.once(3, tickerSaveSegmentState);
|
||||
|
||||
if (_updateState) {
|
||||
DBG_OUTPUT_PORT.println("Saving stripstate.json!");
|
||||
if(!save_state.active()) save_state.once(3, tickerSaveState);
|
||||
}
|
||||
#endif
|
||||
_updateStrip = false;
|
||||
_updateConfig = false;
|
||||
_updateSegState = false;
|
||||
_updateState = false;
|
||||
DBG_OUTPUT_PORT.printf("Get status info: %s\r\n", buffer);
|
||||
free (buffer);
|
||||
}
|
||||
@@ -713,7 +712,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
||||
const size_t bufferSize = JSON_OBJECT_SIZE(6) + JSON_OBJECT_SIZE(12) + 1000;
|
||||
DynamicJsonDocument jsonBuffer(bufferSize);
|
||||
JsonObject root = jsonBuffer.to<JsonObject>();
|
||||
root["state"] = (mode != OFF) ? on_cmd : off_cmd;
|
||||
root["state"] = (State.mode != OFF) ? on_cmd : off_cmd;
|
||||
#if defined(ENABLE_MQTT_INCLUDE_IP)
|
||||
root["ip"] = WiFi.localIP();
|
||||
#endif
|
||||
@@ -730,16 +729,16 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
||||
color["g3"] = xtra_color.green;
|
||||
color["b3"] = xtra_color.blue;
|
||||
color["w3"] = xtra_color.white;
|
||||
if (strstr(FXSettings.RGBOrder, "W") != NULL) {
|
||||
if (strstr(Config.RGBOrder, "W") != NULL) {
|
||||
root["white_value"]= main_color.white;
|
||||
}
|
||||
root["brightness"] = brightness;
|
||||
root["brightness"] = State.brightness;
|
||||
root["color_temp"] = color_temp;
|
||||
root["speed"] = fx_speed;
|
||||
root["speed"] = segState.speed[State.segment];
|
||||
//char modeName[30];
|
||||
//strncpy_P(modeName, (PGM_P)strip->getModeName(strip->getMode()), sizeof(modeName)); // copy from progmem
|
||||
#if defined(ENABLE_HOMEASSISTANT)
|
||||
if (mode == OFF){
|
||||
if (State.mode == OFF){
|
||||
root["effect"] = "OFF";
|
||||
} else {
|
||||
root["effect"] = strip->getModeName(strip->getMode());
|
||||
@@ -777,10 +776,10 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
||||
if (root.containsKey("state")) {
|
||||
const char* state_in = root["state"];
|
||||
if (strcmp(state_in, on_cmd) == 0) {
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
else if (strcmp(state_in, off_cmd) == 0) {
|
||||
mode = OFF;
|
||||
State.mode = OFF;
|
||||
jsonBuffer.clear();
|
||||
return true;
|
||||
}
|
||||
@@ -800,22 +799,22 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
||||
xtra_color.green = (uint8_t) color["g3"];
|
||||
xtra_color.blue = (uint8_t) color["b3"];
|
||||
xtra_color.white = (uint8_t) color["w3"];
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
|
||||
if (root.containsKey("white_value")) {
|
||||
uint8_t json_white_value = constrain((uint8_t) root["white_value"], 0, 255);
|
||||
if (json_white_value != main_color.white) {
|
||||
main_color.white = json_white_value;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
|
||||
if (root.containsKey("speed")) {
|
||||
uint16_t _fx_speed = constrain((uint8_t) root["speed"], SPEED_MIN, SPEED_MAX);
|
||||
if (_fx_speed != fx_speed) {
|
||||
fx_speed = _fx_speed;
|
||||
mode = SET;
|
||||
uint8_t _fx_speed = constrain((uint8_t) root["speed"], 0, 255);
|
||||
if (_fx_speed != segState.speed[State.segment]) {
|
||||
segState.speed[State.segment] = _fx_speed;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -824,14 +823,14 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
||||
color_temp = (uint16_t) root["color_temp"];
|
||||
uint16_t kelvin = 1000000 / color_temp;
|
||||
main_color = temp2rgb(kelvin);
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
|
||||
if (root.containsKey("brightness")) {
|
||||
uint8_t json_brightness = constrain((uint8_t) root["brightness"], 0, 255); //fix #224
|
||||
if (json_brightness != brightness) {
|
||||
brightness = json_brightness;
|
||||
mode = SET;
|
||||
if (json_brightness != State.brightness) {
|
||||
State.brightness = json_brightness;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -839,12 +838,12 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
||||
String effectString = root["effect"].as<String>();
|
||||
#if defined(ENABLE_HOMEASSISTANT)
|
||||
if(effectString == "OFF"){
|
||||
mode = OFF;
|
||||
State.mode = OFF;
|
||||
}
|
||||
#endif
|
||||
for (uint8_t i = 0; i < strip->getModeCount(); i++) {
|
||||
if(String(strip->getModeName(i)) == effectString) {
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
fx_mode = i;
|
||||
break;
|
||||
}
|
||||
@@ -925,7 +924,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
||||
#endif
|
||||
root["brightness"] = "true";
|
||||
root["rgb"] = "true";
|
||||
if (strstr(FXSettings.RGBOrder, "W") != NULL) {
|
||||
if (strstr(Config.RGBOrder, "W") != NULL) {
|
||||
root["white_value"]= "true";
|
||||
}
|
||||
root["optimistic"] = "false";
|
||||
@@ -1030,7 +1029,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
||||
#endif
|
||||
root["brightness"] = "true";
|
||||
root["rgb"] = "true";
|
||||
if (strstr(FXSettings.RGBOrder, "W") != NULL) {
|
||||
if (strstr(Config.RGBOrder, "W") != NULL) {
|
||||
root["white_value"]= "true";
|
||||
}
|
||||
root["optimistic"] = "false";
|
||||
@@ -1081,12 +1080,12 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
||||
#if defined(ENABLE_BUTTON)
|
||||
void shortKeyPress() {
|
||||
DBG_OUTPUT_PORT.printf("Short button press\r\n");
|
||||
if (mode == OFF) {
|
||||
if (State.mode == OFF) {
|
||||
setModeByStateString(BTN_MODE_SHORT);
|
||||
prevmode = mode;
|
||||
mode = SET;
|
||||
prevmode = State.mode;
|
||||
State.mode = SET;
|
||||
} else {
|
||||
mode = OFF;
|
||||
State.mode = OFF;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1094,16 +1093,16 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
||||
void mediumKeyPress() {
|
||||
DBG_OUTPUT_PORT.printf("Medium button press\r\n");
|
||||
setModeByStateString(BTN_MODE_MEDIUM);
|
||||
prevmode = mode;
|
||||
mode = SET;
|
||||
prevmode = State.mode;
|
||||
State.mode = SET;
|
||||
}
|
||||
|
||||
// called when button is kept pressed for 2 seconds or more
|
||||
void longKeyPress() {
|
||||
DBG_OUTPUT_PORT.printf("Long button press\r\n");
|
||||
setModeByStateString(BTN_MODE_LONG);
|
||||
prevmode = mode;
|
||||
mode = SET;
|
||||
prevmode = State.mode;
|
||||
State.mode = SET;
|
||||
}
|
||||
|
||||
void button() {
|
||||
@@ -1147,7 +1146,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
|
||||
tcs.getData(&r, &g, &b, &col, &conf);
|
||||
DBG_OUTPUT_PORT.printf("Colors: R: [%d] G: [%d] B: [%d] Color: [%d] Conf: [%d]\r\n", (int)r, (int)g, (int)b, (int)col, (int)conf);
|
||||
main_color.red = (pow((r/255.0), GAMMA)*255); main_color.green = (pow((g/255.0), GAMMA)*255); main_color.blue = (pow((b/255.0), GAMMA)*255);main_color.white = 0;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
|
||||
// called when button is kept pressed for less than 2 seconds
|
||||
@@ -1207,62 +1206,62 @@ void handleRemote() {
|
||||
}
|
||||
if (results.value == rmt_commands[ON_OFF]) { // ON/OFF TOGGLE
|
||||
last_remote_cmd = 0;
|
||||
if (mode == OFF) {
|
||||
mode = SET;
|
||||
if (State.mode == OFF) {
|
||||
State.mode = SET;
|
||||
} else {
|
||||
mode = OFF;
|
||||
State.mode = OFF;
|
||||
}
|
||||
}
|
||||
if (mode == HOLD) {
|
||||
if (State.mode == HOLD) {
|
||||
if (results.value == rmt_commands[BRIGHTNESS_UP]) { //Brightness Up
|
||||
last_remote_cmd = results.value;
|
||||
if (brightness + chng <= 255) {
|
||||
brightness = brightness + chng;
|
||||
mode = SET;
|
||||
if (State.brightness + chng <= 255) {
|
||||
State.brightness = State.brightness + chng;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
if (results.value == rmt_commands[BRIGHTNESS_DOWN]) { //Brightness down
|
||||
last_remote_cmd = results.value;
|
||||
if (brightness - chng >= 0) {
|
||||
brightness = brightness - chng;
|
||||
mode = SET;
|
||||
if (State.brightness - chng >= 0) {
|
||||
State.brightness = State.brightness - chng;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
if ((fx_mode < 56) || (fx_mode > 57)) {
|
||||
if ((segState.mode[State.segment] < FX_MODE_CUSTOM_0) || (segState.mode[State.segment] > FX_MODE_CUSTOM_1)) {
|
||||
if (results.value == rmt_commands[SPEED_UP]) { //Speed Up
|
||||
last_remote_cmd = results.value;
|
||||
if (fx_speed + chng <= 65535) {
|
||||
fx_speed = fx_speed + (chng * 5);
|
||||
mode = SET;
|
||||
if (segState.speed[State.segment] + chng <= 65535) {
|
||||
segState.speed[State.segment] = segState.speed[State.segment] + chng;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
if (results.value == rmt_commands[SPEED_DOWN]) { //Speed down
|
||||
last_remote_cmd = results.value;
|
||||
if (fx_speed - chng >= 0) {
|
||||
fx_speed = fx_speed - (chng * 5);
|
||||
mode = SET;
|
||||
if (segState.speed[State.segment] - chng >= 0) {
|
||||
segState.speed[State.segment] = segState.speed[State.segment] - chng;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((fx_mode < 56) || (fx_mode > 60)) {
|
||||
if ((segState.mode[State.segment] < FX_MODE_CUSTOM_0) || (segState.mode[State.segment] > FX_MODE_CUSTOM_4)) {
|
||||
if (results.value == rmt_commands[RED_UP]) { //Red Up
|
||||
last_remote_cmd = results.value;
|
||||
if (selected_color == 1) {
|
||||
if (main_color.red + chng <= 255) {
|
||||
main_color.red = main_color.red + chng;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
if (selected_color == 2) {
|
||||
if (back_color.red + chng <= 255) {
|
||||
back_color.red = back_color.red + chng;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
if (selected_color == 3) {
|
||||
if (xtra_color.red + chng <= 255) {
|
||||
xtra_color.red = xtra_color.red + chng;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1271,19 +1270,19 @@ void handleRemote() {
|
||||
if (selected_color == 1) {
|
||||
if (main_color.red - chng >= 0) {
|
||||
main_color.red = main_color.red - chng;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
if (selected_color == 2) {
|
||||
if (back_color.red - chng >= 0) {
|
||||
back_color.red = back_color.red - chng;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
if (selected_color == 3) {
|
||||
if (xtra_color.red - chng >= 0) {
|
||||
xtra_color.red = xtra_color.red - chng;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1292,19 +1291,19 @@ void handleRemote() {
|
||||
if (selected_color == 1) {
|
||||
if (main_color.green + chng <= 255) {
|
||||
main_color.green = main_color.green + chng;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
if (selected_color == 2) {
|
||||
if (back_color.green + chng <= 255) {
|
||||
back_color.green = back_color.green + chng;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
if (selected_color == 3) {
|
||||
if (xtra_color.green + chng <= 255) {
|
||||
xtra_color.green = xtra_color.green + chng;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1313,19 +1312,19 @@ void handleRemote() {
|
||||
if (selected_color == 1) {
|
||||
if (main_color.green - chng >= 0) {
|
||||
main_color.green = main_color.green - chng;;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
if (selected_color == 2) {
|
||||
if (back_color.green - chng >= 0) {
|
||||
back_color.green = back_color.green - chng;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
if (selected_color == 3) {
|
||||
if (xtra_color.green - chng >= 0) {
|
||||
xtra_color.green = xtra_color.green - chng;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1334,19 +1333,19 @@ void handleRemote() {
|
||||
if (selected_color == 1) {
|
||||
if (main_color.blue + chng <= 255) {
|
||||
main_color.blue = main_color.blue + chng;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
if (selected_color == 2) {
|
||||
if (back_color.blue + chng <= 255) {
|
||||
back_color.blue = back_color.blue + chng;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
if (selected_color == 3) {
|
||||
if (xtra_color.blue + chng <= 255) {
|
||||
xtra_color.blue = xtra_color.blue + chng;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1355,19 +1354,19 @@ void handleRemote() {
|
||||
if (selected_color == 1) {
|
||||
if (main_color.blue - chng >= 0) {
|
||||
main_color.blue = main_color.blue - chng;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
if (selected_color == 2) {
|
||||
if (back_color.blue - chng >= 0) {
|
||||
back_color.blue = back_color.blue - chng;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
if (selected_color == 3) {
|
||||
if (xtra_color.blue - chng >= 0) {
|
||||
xtra_color.blue = xtra_color.blue - chng;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1376,19 +1375,19 @@ void handleRemote() {
|
||||
if (selected_color == 1) {
|
||||
if (main_color.white + chng <= 255) {
|
||||
main_color.white = main_color.white + chng;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
if (selected_color == 2) {
|
||||
if (back_color.white + chng <= 255) {
|
||||
back_color.white = back_color.white + chng;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
if (selected_color == 3) {
|
||||
if (xtra_color.white + chng <= 255) {
|
||||
xtra_color.white = xtra_color.white + chng;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1397,19 +1396,19 @@ void handleRemote() {
|
||||
if (selected_color == 1) {
|
||||
if (main_color.white - chng >= 0) {
|
||||
main_color.white = main_color.white - chng;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
if (selected_color == 2) {
|
||||
if (back_color.white - chng >= 0) {
|
||||
back_color.white = back_color.white - chng;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
if (selected_color == 3) {
|
||||
if (xtra_color.white - chng >= 0) {
|
||||
xtra_color.white = xtra_color.white - chng;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1429,49 +1428,49 @@ void handleRemote() {
|
||||
} // end of if HOLD
|
||||
if (results.value == rmt_commands[MODE_UP]) { //Mode Up
|
||||
last_remote_cmd = results.value;
|
||||
if ((fx_mode < strip->getModeCount()-1) && (mode == HOLD)) {
|
||||
fx_mode = fx_mode + 1;
|
||||
if ((segState.mode[State.segment] < strip->getModeCount()-1) && (State.mode == HOLD)) {
|
||||
fx_mode = segState.mode[State.segment] + 1;
|
||||
}
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
if (results.value == rmt_commands[MODE_DOWN]) { //Mode down
|
||||
last_remote_cmd = results.value;
|
||||
if ((fx_mode > 0) && (mode == HOLD)) {
|
||||
fx_mode = fx_mode - 1;
|
||||
if ((segState.mode[State.segment] > 0) && (State.mode == HOLD)) {
|
||||
fx_mode = segState.mode[State.segment] - 1;
|
||||
}
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
if (results.value == rmt_commands[AUTOMODE]) { // Toggle Automode
|
||||
last_remote_cmd = 0;
|
||||
fx_mode = 56;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
#if defined(CUSTOM_WS2812FX_ANIMATIONS)
|
||||
if (results.value == rmt_commands[CUST_1]) { // Select TV Mode
|
||||
last_remote_cmd = 0;
|
||||
fx_mode = 57;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
#endif
|
||||
if (results.value == rmt_commands[CUST_2]) { // Select Custom Mode 2
|
||||
last_remote_cmd = 0;
|
||||
fx_mode = 12;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
if (results.value == rmt_commands[CUST_3]) { // Select Custom Mode 3
|
||||
last_remote_cmd = 0;
|
||||
fx_mode = 48;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
if (results.value == rmt_commands[CUST_4]) { // Select Custom Mode 4
|
||||
last_remote_cmd = 0;
|
||||
fx_mode = 21;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
if (results.value == rmt_commands[CUST_5]) { // Select Custom Mode 5
|
||||
last_remote_cmd = 0;
|
||||
fx_mode = 46;
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
}
|
||||
irrecv.resume(); // Receive the next value
|
||||
}
|
||||
|
||||
@@ -84,26 +84,26 @@ server.on("/format_spiffs", []() {
|
||||
|
||||
server.on("/get_brightness", []() {
|
||||
char str_brightness[4];
|
||||
snprintf(str_brightness, sizeof(str_brightness), "%i", (int) (brightness / 2.55));
|
||||
snprintf(str_brightness, sizeof(str_brightness), "%i", (int) (State.brightness / 2.55));
|
||||
str_brightness[sizeof(str_brightness) - 1] = 0x00;
|
||||
server.sendHeader("Access-Control-Allow-Origin", "*");
|
||||
server.send(200, "text/plain", str_brightness );
|
||||
DBG_OUTPUT_PORT.printf("/get_brightness: %i\r\n", (int) (brightness / 2.55));
|
||||
DBG_OUTPUT_PORT.printf("/get_brightness: %i\r\n", (int) (State.brightness / 2.55));
|
||||
});
|
||||
|
||||
server.on("/get_speed", []() {
|
||||
char str_speed[6];
|
||||
snprintf(str_speed, sizeof(str_speed), "%i", fx_speed);
|
||||
char str_speed[4];
|
||||
snprintf(str_speed, sizeof(str_speed), "%i", segState.speed[State.segment]);
|
||||
str_speed[sizeof(str_speed) - 1] = 0x00;
|
||||
server.sendHeader("Access-Control-Allow-Origin", "*");
|
||||
server.send(200, "text/plain", str_speed );
|
||||
DBG_OUTPUT_PORT.printf("/get_speed: %i\r\n", fx_speed);
|
||||
DBG_OUTPUT_PORT.printf("/get_speed: %i\r\n", segState.speed[State.segment]);
|
||||
});
|
||||
|
||||
server.on("/get_switch", []() {
|
||||
server.sendHeader("Access-Control-Allow-Origin", "*");
|
||||
server.send(200, "text/plain", (mode == OFF) ? "0" : "1" );
|
||||
DBG_OUTPUT_PORT.printf("/get_switch: %s\r\n", (mode == OFF) ? "0" : "1");
|
||||
server.send(200, "text/plain", (State.mode == OFF) ? "0" : "1" );
|
||||
DBG_OUTPUT_PORT.printf("/get_switch: %s\r\n", (State.mode == OFF) ? "0" : "1");
|
||||
});
|
||||
|
||||
server.on("/get_color", []() {
|
||||
@@ -161,20 +161,25 @@ server.on("/config", []() {
|
||||
// ToDo do not save if no change
|
||||
bool _updateStrip = false;
|
||||
bool _updateConfig = false;
|
||||
if(server.hasArg("seg")){
|
||||
uint8_t _ws_seg = server.arg("seg").toInt();
|
||||
bool _updateState = false;
|
||||
if(server.hasArg("ws_seg")){
|
||||
uint8_t _ws_seg = server.arg("ws_seg").toInt();
|
||||
_ws_seg = constrain(_ws_seg, 1, MAX_NUM_SEGMENTS - 1);
|
||||
if (_ws_seg != num_segments){
|
||||
num_segments = _ws_seg;
|
||||
_updateStrip = true;
|
||||
if (_ws_seg != Config.segments){
|
||||
Config.segments = _ws_seg;
|
||||
_updateStrip = true;
|
||||
if (State.segment >= Config.segments) {
|
||||
State.segment = Config.segments - 1;
|
||||
_updateState = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(server.hasArg("ws_cnt")){
|
||||
uint16_t _stripSize = server.arg("ws_cnt").toInt();
|
||||
if (_stripSize > 0) {
|
||||
_stripSize = constrain(_stripSize, 1, MAXLEDS);
|
||||
if (_stripSize != FXSettings.stripSize) {
|
||||
FXSettings.stripSize = _stripSize;
|
||||
if (_stripSize != Config.stripSize) {
|
||||
Config.stripSize = _stripSize;
|
||||
_updateStrip = true;
|
||||
}
|
||||
}
|
||||
@@ -192,7 +197,7 @@ server.on("/config", []() {
|
||||
if (checkPin(server.arg("ws_pin").toInt())) {
|
||||
_updateStrip = true;
|
||||
DBG_OUTPUT_PORT.print("Pin was set to: ");
|
||||
DBG_OUTPUT_PORT.println(FXSettings.pin);
|
||||
DBG_OUTPUT_PORT.println(Config.pin);
|
||||
} else {
|
||||
DBG_OUTPUT_PORT.println("invalid input or same value!");
|
||||
}
|
||||
@@ -254,80 +259,87 @@ server.on("/config", []() {
|
||||
#endif
|
||||
|
||||
if(server.hasArg("trans_effect")){
|
||||
FXSettings.transEffect = server.arg("trans_effect").toInt();
|
||||
Config.transEffect = server.arg("trans_effect").toInt();
|
||||
_updateConfig = true;
|
||||
}
|
||||
|
||||
#if defined(ENABLE_STATE_SAVE)
|
||||
if (_updateStrip || _updateConfig) {
|
||||
DBG_OUTPUT_PORT.println("Saving config.json!");
|
||||
if(!save_conf.active()) save_conf.once(3, tickerSaveConfig);
|
||||
}
|
||||
if (_updateState) {
|
||||
DBG_OUTPUT_PORT.println("Saving stripstate.json!");
|
||||
if(!save_state.active()) save_state.once(3, tickerSaveState);
|
||||
}
|
||||
#endif
|
||||
_updateStrip = false;
|
||||
_updateConfig = false;
|
||||
_updateState = false;
|
||||
getConfigJSON();
|
||||
});
|
||||
|
||||
server.on("/off", []() {
|
||||
if (prevmode != OFF) {
|
||||
mode = OFF;
|
||||
getStateJSON();
|
||||
#if defined(ENABLE_STATE_SAVE)
|
||||
if(!save_state.active()) save_state.once(3, tickerSaveState);
|
||||
#endif
|
||||
}
|
||||
if (State.mode == OFF) { State.mode = SET; } else { State.mode = OFF; };
|
||||
getStateJSON();
|
||||
#if defined(ENABLE_STATE_SAVE)
|
||||
DBG_OUTPUT_PORT.println("Saving stripstate.json!");
|
||||
if(!save_state.active()) save_state.once(3, tickerSaveState);
|
||||
#endif
|
||||
});
|
||||
|
||||
server.on("/on", []() {
|
||||
if (prevmode == OFF) {
|
||||
mode = SET;
|
||||
State.mode = SET;
|
||||
getStateJSON();
|
||||
#if defined(ENABLE_STATE_SAVE)
|
||||
DBG_OUTPUT_PORT.println("Saving stripstate.json!");
|
||||
if(!save_state.active()) save_state.once(3, tickerSaveState);
|
||||
#endif
|
||||
} else {
|
||||
getStateJSON();
|
||||
}
|
||||
});
|
||||
|
||||
server.on("/set", []() {
|
||||
prevmode = HOLD;
|
||||
fx_mode = FX_MODE_STATIC;
|
||||
boolean _updateState = false;
|
||||
boolean _updateSegState = false;
|
||||
// Segment
|
||||
if ((server.arg("seg") != "") && (server.arg("seg").toInt() >= 0) && (server.arg("seg").toInt() <= MAX_NUM_SEGMENTS)) {
|
||||
FXSettings.segment = server.arg("seg").toInt();
|
||||
if (prevsegment != FXSettings.segment) {
|
||||
prevsegment = FXSettings.segment;
|
||||
getSegmentParams(FXSettings.segment);
|
||||
memcpy(hex_colors_trans, hex_colors, sizeof(hex_colors_trans));
|
||||
mode = SET;
|
||||
State.segment = server.arg("seg").toInt();
|
||||
if (prevsegment != State.segment) {
|
||||
prevsegment = State.segment;
|
||||
getSegmentParams(State.segment);
|
||||
memcpy(hexcolors_trans, segState.colors[State.segment], sizeof(hexcolors_trans));
|
||||
State.mode = SET;
|
||||
_updateState = true;
|
||||
}
|
||||
}
|
||||
if ((server.arg("start") != "") && (server.arg("start").toInt() >= 0) && (server.arg("start").toInt() <= MAX_NUM_SEGMENTS)) {
|
||||
if ((server.arg("start") != "") && (server.arg("start").toInt() >= 0) && (server.arg("start").toInt() <= segState.stop)) {
|
||||
uint16_t _seg_start = server.arg("start").toInt();
|
||||
_seg_start = constrain(seg_start, 0, FXSettings.stripSize -1);
|
||||
if (_seg_start != seg_start) {
|
||||
seg_start = _seg_start;
|
||||
_seg_start = constrain(segState.start, 0, Config.stripSize -1);
|
||||
if (_seg_start != segState.start) {
|
||||
segState.start = _seg_start;
|
||||
setSegmentSize();
|
||||
_updateSegState = true;
|
||||
}
|
||||
}
|
||||
if ((server.arg("stop") != "") && (server.arg("stop").toInt() >= 0) && (server.arg("stop").toInt() <= MAX_NUM_SEGMENTS)) {
|
||||
if ((server.arg("stop") != "") && (server.arg("stop").toInt() >= segState.start) && (server.arg("stop").toInt() <= Config.stripSize)) {
|
||||
uint16_t _seg_stop = server.arg("stop").toInt();
|
||||
_seg_stop = constrain(_seg_stop, seg_start, FXSettings.stripSize - 1);
|
||||
if (_seg_stop != seg_stop) {
|
||||
seg_stop = _seg_stop;
|
||||
_seg_stop = constrain(_seg_stop, segState.start, Config.stripSize - 1);
|
||||
if (_seg_stop != segState.stop) {
|
||||
segState.stop = _seg_stop;
|
||||
setSegmentSize();
|
||||
_updateSegState = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(server.hasArg("fxopt")){
|
||||
uint8_t _ws_fxopt = ((constrain(server.arg("fxopt").toInt(), 0, 255)>>1)<<1);
|
||||
if (_ws_fxopt != fx_options) {
|
||||
fx_options = _ws_fxopt;
|
||||
strip->setOptions(FXSettings.segment, fx_options);
|
||||
uint8_t _fx_options = ((constrain(server.arg("fxopt").toInt(), 0, 255)>>1)<<1);
|
||||
if (_fx_options != segState.options) {
|
||||
segState.options = _fx_options;
|
||||
strip->setOptions(State.segment, segState.options);
|
||||
_updateSegState = true;
|
||||
}
|
||||
}
|
||||
@@ -407,28 +419,28 @@ server.on("/set", []() {
|
||||
|
||||
|
||||
// Speed
|
||||
if ((server.arg("s") != "") && (server.arg("s").toInt() >= 0) && (server.arg("s").toInt() <= 65535)) {
|
||||
fx_speed = constrain(server.arg("s").toInt(), SPEED_MIN, SPEED_MAX);
|
||||
mode = SET;
|
||||
if ((server.arg("s") != "") && (server.arg("s").toInt() >= 0) && (server.arg("s").toInt() <= 255)) {
|
||||
segState.speed[State.segment] = constrain(server.arg("s").toInt(), 0, 255);
|
||||
State.mode = SET;
|
||||
_updateSegState = true;
|
||||
}
|
||||
//Mode
|
||||
if ((server.arg("m") != "") && (server.arg("m").toInt() >= 0) && (server.arg("m").toInt() <= strip->getModeCount())) {
|
||||
fx_mode = constrain(server.arg("m").toInt(), 0, strip->getModeCount() - 1);
|
||||
if (fx_mode != strip->getMode(FXSettings.segment)) {
|
||||
mode = SET;
|
||||
if (fx_mode != segState.mode[State.segment]) {
|
||||
State.mode = SET;
|
||||
_updateSegState = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Brightness
|
||||
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);
|
||||
State.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)) {
|
||||
brightness = constrain(server.arg("p").toInt(), 0, 255);
|
||||
State.brightness = constrain(server.arg("p").toInt(), 0, 255);
|
||||
}
|
||||
if (strip->getBrightness() != brightness) {
|
||||
mode = SET;
|
||||
if (strip->getBrightness() != State.brightness) {
|
||||
State.mode = SET;
|
||||
_updateState = true;
|
||||
}
|
||||
DBG_OUTPUT_PORT.printf("Get Args: %s\r\n", listStateJSONfull());
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define SKETCH_VERSION "3.1.0.ALPHA2"
|
||||
#define SKETCH_VERSION "3.1.0.BETA1"
|
||||
|
||||
@@ -195,10 +195,18 @@
|
||||
* removal of saving to EEPROM
|
||||
* first integration of multi segments
|
||||
*
|
||||
* * 3 October 2019
|
||||
* 3 October 2019
|
||||
* Version Bump to 3.1.0.ALPHA2
|
||||
* further code changes
|
||||
* further integration of multi segments
|
||||
* integration of multi segments to GUI
|
||||
*
|
||||
* 5 October 2019
|
||||
* Version Bump to 3.1.0.ALPHA2
|
||||
* further code changes
|
||||
* further integration of multi segments
|
||||
* known problem: as always: AUTOPLAY (as it is not multi segment capable yet)
|
||||
*
|
||||
* Version Bump to 3.1.0.BETA1
|
||||
* bugfixes
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user