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
|
||||
|
||||
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,10 +224,10 @@
|
||||
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>();
|
||||
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>();
|
||||
@@ -240,7 +240,7 @@
|
||||
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.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;
|
||||
//root["fx_mode"] = strip->getMode(_seg);
|
||||
root["fx_mode"] = segState.mode[_seg];
|
||||
root["speed"] = segState.speed[_seg];
|
||||
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;
|
||||
//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;
|
||||
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;
|
||||
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
|
||||
*/
|
||||
|
||||
@@ -182,7 +182,9 @@
|
||||
var mkfile = document.createElement("button");
|
||||
mkfile.innerHTML = 'MkFile';
|
||||
document.getElementById(element).appendChild(mkfile);
|
||||
|
||||
var para = document.createElement("text");
|
||||
para.innerHTML = " Press Ctrl-S for save, Ctrl-Z for undo, Ctrl-Shift-Z for redo";
|
||||
document.getElementById(element).appendChild(para);
|
||||
function httpPostProcessRequest(){
|
||||
if (xmlHttp.readyState == 4){
|
||||
if(xmlHttp.status != 200) alert("ERROR["+xmlHttp.status+"]: "+xmlHttp.responseText);
|
||||
|
||||
Binary file not shown.
+284
-159
@@ -877,7 +877,7 @@ input[type=number], label{
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex xs12 sm7">
|
||||
<div class="flex xs12 sm8">
|
||||
<div class="sliders container">
|
||||
<div class="color-wrap" style="display:none">
|
||||
<div id="color-display"></div>
|
||||
@@ -912,6 +912,13 @@ input[type=number], label{
|
||||
<input type="number" id="speedNum">
|
||||
<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">
|
||||
<div class="flex xs12 sm2" id="selectSegLbl" style="text-align: left;"><p>selectSeg</p>
|
||||
<select id="selectseg" class="custom-select" style="border: 2px solid #aaaaaa; border-radius: 6px; width:90%; "></select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="message" class="container hidden" style="text-align: left;">
|
||||
<div id="wsmessageLbl" style="text-align: left;"><p>wsMessage</p>
|
||||
<input type="text" id="wsmessage" style="border: 2px solid #aaaaaa; border-radius: 6px; width:100%;" />
|
||||
@@ -959,14 +966,25 @@ input[type=number], label{
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout row wrap">
|
||||
<div class="flex xs12 sm4"><p>selectCount</p>
|
||||
<input type="number" min="0" max="65535" id="selectcount" style="border: 2px solid #aaaaaa; border-radius: 6px; width:100%;" />
|
||||
<div class="flex xs12 sm3"><p>selectSegCnt</p>
|
||||
<input type="number" min="1" max="9" id="selectsegcnt" style="border: 2px solid #aaaaaa; border-radius: 6px; width:50%;" />
|
||||
</div>
|
||||
<div class="flex xs12 sm4"><p>selectRGBO</p>
|
||||
<div class="flex xs12 sm3"><p>selectCount</p>
|
||||
<input type="number" min="0" max="65535" id="selectcount" style="border: 2px solid #aaaaaa; border-radius: 6px; width:50%;" />
|
||||
</div>
|
||||
<div class="flex xs12 sm3"><p>selectRGBO</p>
|
||||
<select id="selectrgbo" class="custom-select"></select>
|
||||
</div>
|
||||
<div class="flex xs12 sm4"><p>selectPin</p>
|
||||
<input type="number" min="0" max="16" id="selectpin" style="border: 2px solid #aaaaaa; border-radius: 6px; width:100%;" />
|
||||
<div class="flex xs12 sm3"><p>selectPin</p>
|
||||
<input type="number" min="0" max="16" id="selectpin" style="border: 2px solid #aaaaaa; border-radius: 6px; width:50%;" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout row wrap">
|
||||
<div class="flex xs12 sm6"><p>segStart</p>
|
||||
<input type="number" min="0" max="*jsvariable" id="segstart" style="border: 2px solid #aaaaaa; border-radius: 6px; width:90%;" />
|
||||
</div>
|
||||
<div class="flex xs12 sm6"><p>segStop</p>
|
||||
<input type="number" min="0" max="*jsvariable" id="segstop" style="border: 2px solid #aaaaaa; border-radius: 6px; width:90%;" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layout row wrap">
|
||||
@@ -1030,6 +1048,7 @@ var language = {
|
||||
connectError2: " times. Please use the RECONNECT button to try again.",
|
||||
loadModes: "Loading modes ...", // This language-string is not translated (settings not loaded yet)
|
||||
loadSettings: "Loading settings ...", // This language-string is not translated (settings not loaded yet)
|
||||
loadConfig: "Loading configuration ...",
|
||||
loadWebsock: "Connecting websockets ...",
|
||||
loadReady: "Ready ...",
|
||||
loadError: "Error loading animation modes, please try again...", // This language-string is not translated (settings not loaded yet)
|
||||
@@ -1043,6 +1062,9 @@ var language = {
|
||||
white: "White",
|
||||
not_greater: "cannot enter numbers greater than 255",
|
||||
not_less: "cannot enter numbers less than 0",
|
||||
selectSeg: "Select segment",
|
||||
segStart: "First LED of selected segment",
|
||||
segStop: "Last LED of selected segment",
|
||||
wsMessage: "Websocket Message:",
|
||||
selectLanguage: "Select Language:",
|
||||
selectHostname: "Hostname:",
|
||||
@@ -1050,6 +1072,7 @@ var language = {
|
||||
selectMQTTPort: "and Port:",
|
||||
selectMQTTUser: "MQTT Username:",
|
||||
selectMQTTPass: "MQTT Password:",
|
||||
selectSegCnt: "Number of Segments:",
|
||||
selectCount: "Strip LED Count:",
|
||||
selectRGBO: "RGB Order:",
|
||||
selectPin: "Strip GPIO Pin:",
|
||||
@@ -1086,6 +1109,7 @@ var language = {
|
||||
connectError2: " keer geprobeerd. Gebruik de Verbind opnieuw knop om opnieuw te proberen.",
|
||||
loadModes: "Modes laden...", // This language-string is not translated (settings not loaded yet)
|
||||
loadSettings: "Instellingen laden...", // This language-string is not translated (settings not loaded yet)
|
||||
loadConfig: "Configuratie laden ...",
|
||||
loadWebsock: "Websockets verbinden...",
|
||||
loadReady: "Klaar...",
|
||||
loadError: "Fout bij laden van animatie modes, probeer opnieuw...", // This language-string is not translated (settings not loaded yet)
|
||||
@@ -1099,6 +1123,9 @@ var language = {
|
||||
white: "Wit",
|
||||
not_greater: "Geen nummers hoger dan 255",
|
||||
not_less: "Geen nummers lager dan 0",
|
||||
selectSeg: "Selecteer segment",
|
||||
segStart: "Eerste LED van huidige segmenten",
|
||||
segStop: "Laatste LED van huidige segmenten",
|
||||
wsMessage: "Websocket message:",
|
||||
selectLanguage: "Selecteer Taal:",
|
||||
selectHostname: "Hostname:",
|
||||
@@ -1106,6 +1133,7 @@ var language = {
|
||||
selectMQTTPort: "en Port:",
|
||||
selectMQTTUser: "MQTT gebruikersnaam:",
|
||||
selectMQTTPass: "MQTT wachtwoord:",
|
||||
selectSegCnt: "Number of Segments:",
|
||||
selectCount: "LED nummer:",
|
||||
selectPin: "Strip GPIO Pin:",
|
||||
selectRGBO: "RGB Order:",
|
||||
@@ -1142,6 +1170,7 @@ var language = {
|
||||
connectError2: " mal versucht. Benutze WIEDER VERBINDEN, um es nochmal zu probieren.",
|
||||
loadModes: "Lade Modi ...", // This language-string is not translated (settings not loaded yet)
|
||||
loadSettings: "Lade Einstellungen ...", // This language-string is not translated (settings not loaded yet)
|
||||
loadConfig: "Lade Konfiguration ...",
|
||||
loadWebsock: "Verbinde Websockets ...",
|
||||
loadReady: "Fertig ...",
|
||||
loadError: "Fehler beim Laden der Animations-Modi, bitte nochmal versuchen...", // This language-string is not translated (settings not loaded yet)
|
||||
@@ -1155,6 +1184,9 @@ var language = {
|
||||
white: "Weiß",
|
||||
not_greater: "Akzeptiere keine Nummern größer 255",
|
||||
not_less: "Akzeptiere keine Nummern kleiner 0",
|
||||
selectSeg: "Segment wählen",
|
||||
segStart: "Erste LED des gewählten Segments",
|
||||
segStop: "Letzte LED des gewählten Segments",
|
||||
wsMessage: "Websocket Message:",
|
||||
selectLanguage: "Sprache auswählen:",
|
||||
selectHostname: "Hostname:",
|
||||
@@ -1162,6 +1194,7 @@ var language = {
|
||||
selectMQTTPort: "und Port:",
|
||||
selectMQTTUser: "MQTT Username:",
|
||||
selectMQTTPass: "MQTT Password:",
|
||||
selectSegCnt: "Anzahl Segmente:",
|
||||
selectCount: "Strip LED Anzahl:",
|
||||
selectRGBO: "RGB Reihenfolge:",
|
||||
selectPin: "Strip GPIO Pin:",
|
||||
@@ -1281,19 +1314,31 @@ var config = {
|
||||
mqtt_port: 0,
|
||||
mqtt_user: "",
|
||||
mqtt_pass: "",
|
||||
ws_seg: 1,
|
||||
ws_cnt: 0,
|
||||
ws_rgbo: "",
|
||||
ws_pin: 0,
|
||||
ws_fxopt: 0,
|
||||
enable_rgbw: false,
|
||||
transitionEffects: true
|
||||
ws_trans: false,
|
||||
enable_rgbw: false
|
||||
};
|
||||
var data = {
|
||||
var state = {
|
||||
mode: 0,
|
||||
segment: 0,
|
||||
brightness: 0
|
||||
}
|
||||
|
||||
var segstate = {
|
||||
start: 0,
|
||||
stop: 0,
|
||||
mode: null,
|
||||
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"},
|
||||
brightness: 192,
|
||||
speed: 192,
|
||||
ws2812fx_mode: null,
|
||||
ws_fxopt: 0
|
||||
}
|
||||
|
||||
|
||||
var data = {
|
||||
init: true,
|
||||
color_num: 1,
|
||||
modes: [],
|
||||
connection: null,
|
||||
@@ -1301,7 +1346,6 @@ var data = {
|
||||
num_additional_connections: 0,
|
||||
is_connected: false,
|
||||
refresh_interval: 0,
|
||||
init: true,
|
||||
color_disabled: false
|
||||
};
|
||||
var sendIt; // Timer to prevent lots of sending
|
||||
@@ -1331,17 +1375,17 @@ function displayColors(all = false) {
|
||||
clearTimeout(sendIt);
|
||||
sendIt = setTimeout(function() { set_color(); }, 50);
|
||||
} else {
|
||||
document.getElementById("colorSel1").style.backgroundColor = `rgb(${data.color.r}, ${data.color.g}, ${data.color.b})`;
|
||||
document.getElementById("colorHex1").innerHTML = "#" + data.color.hex;
|
||||
document.getElementById("colorSel2").style.backgroundColor = `rgb(${data.color.r2}, ${data.color.g2}, ${data.color.b2})`;
|
||||
document.getElementById("colorHex2").innerHTML = "#" + data.color.hex2;
|
||||
document.getElementById("colorSel3").style.backgroundColor = `rgb(${data.color.r3}, ${data.color.g3}, ${data.color.b3})`;
|
||||
document.getElementById("colorHex3").innerHTML = "#" + data.color.hex3;
|
||||
document.getElementById("colorSel1").style.backgroundColor = `rgb(${segstate.color.r}, ${segstate.color.g}, ${segstate.color.b})`;
|
||||
document.getElementById("colorHex1").innerHTML = "#" + segstate.color.hex;
|
||||
document.getElementById("colorSel2").style.backgroundColor = `rgb(${segstate.color.r2}, ${segstate.color.g2}, ${segstate.color.b2})`;
|
||||
document.getElementById("colorHex2").innerHTML = "#" + segstate.color.hex2;
|
||||
document.getElementById("colorSel3").style.backgroundColor = `rgb(${segstate.color.r3}, ${segstate.color.g3}, ${segstate.color.b3})`;
|
||||
document.getElementById("colorHex3").innerHTML = "#" + segstate.color.hex3;
|
||||
}
|
||||
}
|
||||
|
||||
// initial color val numbers when DOM is loaded
|
||||
function colorNumrVals(){
|
||||
function colorNumVals(){
|
||||
redNumVal.value = red.value;
|
||||
greenNumVal.value = green.value;
|
||||
blueNumVal.value = blue.value;
|
||||
@@ -1377,44 +1421,44 @@ function initSliderColors(){
|
||||
function changeRangeNumVal(){
|
||||
redNumVal.addEventListener('change', ()=>{
|
||||
// make sure numbers are entered between 0 to 255
|
||||
red.value = checkNumVal(redNumVal, red.value);
|
||||
if (data.color_num === 1) data.color.r = red.value;
|
||||
if (data.color_num === 2) data.color.r2 = red.value;
|
||||
if (data.color_num === 3) data.color.r3 = red.value;
|
||||
red.value = checkNumVal8(redNumVal, red.value);
|
||||
if (data.color_num === 1) segstate.color.r = red.value;
|
||||
if (data.color_num === 2) segstate.color.r2 = red.value;
|
||||
if (data.color_num === 3) segstate.color.r3 = red.value;
|
||||
initSliderColors();
|
||||
displayColors();
|
||||
});
|
||||
greenNumVal.addEventListener('change', ()=>{
|
||||
// make sure numbers are entered between 0 to 255
|
||||
green.value = checkNumVal(greenNumVal, green.value);
|
||||
if (data.color_num === 1) data.color.g = green.value;
|
||||
if (data.color_num === 2) data.color.g2 = green.value;
|
||||
if (data.color_num === 3) data.color.g3 = green.value;
|
||||
green.value = checkNumVal8(greenNumVal, green.value);
|
||||
if (data.color_num === 1) segstate.color.g = green.value;
|
||||
if (data.color_num === 2) segstate.color.g2 = green.value;
|
||||
if (data.color_num === 3) segstate.color.g3 = green.value;
|
||||
initSliderColors();
|
||||
displayColors();
|
||||
});
|
||||
blueNumVal.addEventListener('change', ()=>{
|
||||
// make sure numbers are entered between 0 to 255
|
||||
blue.value = checkNumVal(blueNumVal, blue.value);
|
||||
if (data.color_num === 1) data.color.b = blue.value;
|
||||
if (data.color_num === 2) data.color.b2 = blue.value;
|
||||
if (data.color_num === 3) data.color.b3 = blue.value;
|
||||
blue.value = checkNumVal8(blueNumVal, blue.value);
|
||||
if (data.color_num === 1) segstate.color.b = blue.value;
|
||||
if (data.color_num === 2) segstate.color.b2 = blue.value;
|
||||
if (data.color_num === 3) segstate.color.b3 = blue.value;
|
||||
initSliderColors();
|
||||
displayColors();
|
||||
});
|
||||
whiteNumVal.addEventListener('change', ()=>{
|
||||
// make sure numbers are entered between 0 to 255
|
||||
white.value = checkNumVal(whiteNumVal, white.value);
|
||||
if (data.color_num === 1) data.color.w = white.value;
|
||||
if (data.color_num === 2) data.color.w2 = white.value;
|
||||
if (data.color_num === 3) data.color.w3 = white.value;
|
||||
white.value = checkNumVal8(whiteNumVal, white.value);
|
||||
if (data.color_num === 1) segstate.color.w = white.value;
|
||||
if (data.color_num === 2) segstate.color.w2 = white.value;
|
||||
if (data.color_num === 3) segstate.color.w3 = white.value;
|
||||
initSliderColors();
|
||||
displayColors();
|
||||
});
|
||||
brightNumVal.addEventListener('change', ()=>{
|
||||
// make sure numbers are entered between 0 to 255
|
||||
bright.value = checkNumVal(brightNumVal, bright.value);
|
||||
data.brightness = bright.value;
|
||||
bright.value = checkNumVal8(brightNumVal, bright.value);
|
||||
state.brightness = bright.value;
|
||||
initSliderColors();
|
||||
// Send Brightness
|
||||
clearTimeout(sendIt);
|
||||
@@ -1422,14 +1466,14 @@ function changeRangeNumVal(){
|
||||
});
|
||||
speedNumVal.addEventListener('change', ()=>{
|
||||
// make sure numbers are entered between 0 to 255
|
||||
speed.value = checkNumVal(speedNumVal, speed.value);
|
||||
data.speed = speed.value;
|
||||
speed.value = checkNumVal8(speedNumVal, speed.value);
|
||||
segstate.speed = speed.value;
|
||||
// Send Speed
|
||||
clearTimeout(sendIt);
|
||||
sendIt = setTimeout(function() { set_speed(); }, 50);
|
||||
});
|
||||
}
|
||||
function checkNumVal(numVal, curVal) {
|
||||
function checkNumVal8(numVal, curVal) {
|
||||
if(numVal.value > 255) {
|
||||
alert(language[settings.lang]["not_greater"]);
|
||||
numVal.value = curVal;
|
||||
@@ -1440,6 +1484,17 @@ function checkNumVal(numVal, curVal) {
|
||||
return numVal.value;
|
||||
}
|
||||
|
||||
function checkNumVal16(numVal, curVal) {
|
||||
if(numVal.value > 65535) {
|
||||
alert(language[settings.lang]["not_greater"]);
|
||||
numVal.value = curVal;
|
||||
} else if(numVal.value < 0) {
|
||||
alert(language[settings.lang]["not_less"]);
|
||||
numVal.value = curVal;
|
||||
}
|
||||
return numVal.value;
|
||||
}
|
||||
|
||||
// Color Sliders controls
|
||||
function initcolorSliders(){
|
||||
var event = new Event('change');
|
||||
@@ -1447,7 +1502,7 @@ function initcolorSliders(){
|
||||
displayColors();
|
||||
initSliderColors();
|
||||
changeRangeNumVal();
|
||||
colorNumrVals();
|
||||
colorNumVals();
|
||||
// Trigger onChange event to send value
|
||||
redNumVal.dispatchEvent(event);
|
||||
});
|
||||
@@ -1456,7 +1511,7 @@ function initcolorSliders(){
|
||||
displayColors();
|
||||
initSliderColors();
|
||||
changeRangeNumVal();
|
||||
colorNumrVals();
|
||||
colorNumVals();
|
||||
// Trigger onChange event to send value
|
||||
greenNumVal.dispatchEvent(event);
|
||||
});
|
||||
@@ -1465,7 +1520,7 @@ function initcolorSliders(){
|
||||
displayColors();
|
||||
initSliderColors();
|
||||
changeRangeNumVal();
|
||||
colorNumrVals();
|
||||
colorNumVals();
|
||||
// Trigger onChange event to send value
|
||||
blueNumVal.dispatchEvent(event);
|
||||
});
|
||||
@@ -1474,7 +1529,7 @@ function initcolorSliders(){
|
||||
displayColors();
|
||||
initSliderColors();
|
||||
changeRangeNumVal();
|
||||
colorNumrVals();
|
||||
colorNumVals();
|
||||
// Trigger onChange event to send value
|
||||
whiteNumVal.dispatchEvent(event);
|
||||
});
|
||||
@@ -1482,14 +1537,14 @@ function initcolorSliders(){
|
||||
bright.addEventListener('input', () => {
|
||||
initSliderColors();
|
||||
changeRangeNumVal();
|
||||
colorNumrVals();
|
||||
colorNumVals();
|
||||
// Trigger onChange event to send value
|
||||
brightNumVal.dispatchEvent(event);
|
||||
});
|
||||
|
||||
speed.addEventListener('input', () => {
|
||||
changeRangeNumVal();
|
||||
colorNumrVals();
|
||||
colorNumVals();
|
||||
// Trigger onChange event to send value
|
||||
speedNumVal.dispatchEvent(event);
|
||||
});
|
||||
@@ -1518,8 +1573,11 @@ function xhttp(url, post, callback) {
|
||||
xhr.send(post);
|
||||
}
|
||||
function getModes() {
|
||||
document.getElementById("percentage").innerHTML = "0%";
|
||||
document.getElementById("percentage-done").setAttribute("stroke-dasharray", "0,100");
|
||||
document.getElementById("modal-content").innerHTML = language.en.loadModes;
|
||||
xhttp("http://" + host + "/get_modes", false, function(e) {
|
||||
//console.log("Getting modes list via REST:", e);
|
||||
console.log("Getting modes list via REST:", e);
|
||||
if (e && e.substring(0,6) !== "ERROR!") {
|
||||
modes = JSON.parse(e);
|
||||
if (typeof modes[0] !== "undefined") {
|
||||
@@ -1538,6 +1596,9 @@ function getModes() {
|
||||
|
||||
}
|
||||
function getConfig() {
|
||||
document.getElementById("percentage").innerHTML = "75%";
|
||||
document.getElementById("percentage-done").setAttribute("stroke-dasharray", "75,100");
|
||||
document.getElementById("modal-content").innerHTML = language.en.loadConfig;
|
||||
xhttp("http://" + host + "/config", false, function(e) {
|
||||
console.log("Getting config via REST:", e);
|
||||
if (e && e.substring(0,6) !== "ERROR!") {
|
||||
@@ -1548,14 +1609,14 @@ function getConfig() {
|
||||
if (typeof res.mqtt_port !== "undefined") config.mqtt_port = res.mqtt_port;
|
||||
if (typeof res.mqtt_user !== "undefined") config.mqtt_user = res.mqtt_user;
|
||||
if (typeof res.mqtt_pass !== "undefined") config.mqtt_pass = res.mqtt_pass;
|
||||
if (typeof res.ws_seg !== "undefined") config.ws_seg = res.ws_seg;
|
||||
if (typeof res.ws_cnt !== "undefined") config.ws_cnt = res.ws_cnt;
|
||||
if (typeof res.ws_rgbo !== "undefined") {
|
||||
config.ws_rgbo = res.ws_rgbo;
|
||||
config.enable_rgbw = config.ws_rgbo.includes("W");
|
||||
}
|
||||
if (typeof res.ws_pin !== "undefined") config.ws_pin = res.ws_pin;
|
||||
if (typeof res.ws_fxopt !== "undefined") config.ws_fxopt = res.ws_fxopt;
|
||||
if (typeof res.transEffect !== "undefined") config.transitionEffects = res.transEffect;
|
||||
if (typeof res.ws_trans !== "undefined") config.ws_trans = res.ws_trans;
|
||||
}
|
||||
} else {
|
||||
console.error(e);
|
||||
@@ -1567,9 +1628,9 @@ function getConfig() {
|
||||
} else {
|
||||
document.getElementById("white").parentNode.className = "hidden";
|
||||
white.value = 0;
|
||||
data.color.w = 0;
|
||||
data.color.w2 = 0;
|
||||
data.color.w3 = 0;
|
||||
segstate.color.w = 0;
|
||||
segstate.color.w2 = 0;
|
||||
segstate.color.w3 = 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1600,11 +1661,11 @@ function showModes(mode, index) {
|
||||
document.getElementById("modes").appendChild(div);
|
||||
}
|
||||
function readSettings() {
|
||||
document.getElementById("percentage").innerHTML = "33%";
|
||||
document.getElementById("percentage-done").setAttribute("stroke-dasharray", "33,100");
|
||||
document.getElementById("percentage").innerHTML = "25%";
|
||||
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) {
|
||||
@@ -1612,8 +1673,12 @@ function readSettings() {
|
||||
if (typeof(tmpsettings[set]) !== "undefined") settings[set] = tmpsettings[set];
|
||||
}
|
||||
applySettings();
|
||||
if (e && e.substring(0,6) !== "ERROR!") connectAdditionalNodes();
|
||||
else console.warn("ERROR loading settings", e);
|
||||
if (e && e.substring(0,6) !== "ERROR!") {
|
||||
connectAdditionalNodes();
|
||||
} else {
|
||||
console.warn("ERROR loading settings", e);
|
||||
saveSettings();
|
||||
}
|
||||
});
|
||||
}
|
||||
function applySettings() {
|
||||
@@ -1678,13 +1743,13 @@ function onSelectColNum(colnum) {
|
||||
x = document.getElementById("colorSel" + colnum);
|
||||
x.className = x.className.replace(/\belevation-3\b/g, "elevation-9");
|
||||
// Set ColorPicker and Sliders to selected color
|
||||
red.value = data.color["r" + (colnum > 1 ? colnum : "")];
|
||||
green.value = data.color["g" + (colnum > 1 ? colnum : "")];
|
||||
blue.value = data.color["b" + (colnum > 1 ? colnum : "")];
|
||||
white.value = data.color["w" + (colnum > 1 ? colnum : "")];
|
||||
red.value = segstate.color["r" + (colnum > 1 ? colnum : "")];
|
||||
green.value = segstate.color["g" + (colnum > 1 ? colnum : "")];
|
||||
blue.value = segstate.color["b" + (colnum > 1 ? colnum : "")];
|
||||
white.value = segstate.color["w" + (colnum > 1 ? colnum : "")];
|
||||
initSliderColors();
|
||||
changeRangeNumVal();
|
||||
colorNumrVals();
|
||||
colorNumVals();
|
||||
}
|
||||
function initSettings() {
|
||||
// Add languages to language select
|
||||
@@ -1736,11 +1801,33 @@ function initSettings() {
|
||||
config.mqtt_pass = mqtt_pass.value;
|
||||
ws_send("Cmw" + config.mqtt_pass);
|
||||
});
|
||||
var count = document.getElementById("selectcount");
|
||||
count.value = config.ws_cnt;
|
||||
count.addEventListener('change', ()=>{
|
||||
config.ws_cnt = count.value;
|
||||
ws_send("Csc" + config.ws_cnt);
|
||||
var selsegment = document.getElementById("selectseg");
|
||||
for(var i = 0; i < config.ws_seg; i++) {
|
||||
var option = document.createElement("OPTION");
|
||||
option.setAttribute("value", i);
|
||||
option.innerHTML = i;
|
||||
selsegment.appendChild(option);
|
||||
}
|
||||
selsegment.value = state.segment;
|
||||
selsegment.addEventListener('change', ()=>{
|
||||
state.segment = selsegment.value;
|
||||
ws_send("Ss" + state.segment);
|
||||
});
|
||||
var num_segments = document.getElementById("selectsegcnt");
|
||||
num_segments.value = config.ws_seg;
|
||||
num_segments.addEventListener('change', ()=>{
|
||||
config.ws_seg = num_segments.value;
|
||||
ws_send("Css" + config.ws_seg);
|
||||
while (selsegment.firstChild) {
|
||||
selsegment.removeChild(selsegment.firstChild);
|
||||
}
|
||||
for(var i = 0; i < config.ws_seg; i++) {
|
||||
var option = document.createElement("OPTION");
|
||||
option.setAttribute("value", i);
|
||||
option.innerHTML = i;
|
||||
selsegment.appendChild(option);
|
||||
}
|
||||
selsegment.value = state.segment;
|
||||
});
|
||||
var pin = document.getElementById("selectpin");
|
||||
pin.value = config.ws_pin;
|
||||
@@ -1760,6 +1847,28 @@ function initSettings() {
|
||||
config.ws_rgbo = rgbo.value;
|
||||
ws_send("Csr" + config.ws_rgbo);
|
||||
});
|
||||
var start = document.getElementById("segstart");
|
||||
start.setAttribute("max",config.ws_cnt-1);
|
||||
start.value = segstate.start;
|
||||
start.addEventListener('change', ()=>{
|
||||
segstate.start = start.value;
|
||||
ws_send("S[" + segstate.start);
|
||||
});
|
||||
var stop = document.getElementById("segstop");
|
||||
stop.setAttribute("max",config.ws_cnt-1);
|
||||
stop.value = segstate.stop;
|
||||
stop.addEventListener('change', ()=>{
|
||||
segstate.stop = stop.value;
|
||||
ws_send("S]" + segstate.stop);
|
||||
});
|
||||
var count = document.getElementById("selectcount");
|
||||
count.value = config.ws_cnt;
|
||||
count.addEventListener('change', ()=>{
|
||||
config.ws_cnt = count.value;
|
||||
ws_send("Csc" + config.ws_cnt);
|
||||
start.setAttribute("max",config.ws_cnt-1);
|
||||
stop.setAttribute("max",config.ws_cnt-1);
|
||||
});
|
||||
var optrev = document.getElementById("selectoptrev");
|
||||
for (var code in selectoptrev) {
|
||||
var option = document.createElement("OPTION");
|
||||
@@ -1767,10 +1876,10 @@ function initSettings() {
|
||||
option.innerHTML = selectoptrev[code];
|
||||
optrev.appendChild(option);
|
||||
}
|
||||
optrev.value = (config.ws_fxopt & 128);
|
||||
optrev.value = (segstate.ws_fxopt & 128);
|
||||
optrev.addEventListener('change', ()=>{
|
||||
config.ws_fxopt = optrev.value | optfade.value | optgamma.value | optsize.value;
|
||||
ws_send("Cso" + config.ws_fxopt);
|
||||
segstate.ws_fxopt = optrev.value | optfade.value | optgamma.value | optsize.value;
|
||||
ws_send("So" + segstate.ws_fxopt);
|
||||
});
|
||||
var optfade = document.getElementById("selectoptfade");
|
||||
for (var code in selectoptfade) {
|
||||
@@ -1779,10 +1888,10 @@ function initSettings() {
|
||||
option.innerHTML = selectoptfade[code];
|
||||
optfade.appendChild(option);
|
||||
}
|
||||
optfade.value = (config.ws_fxopt & 112);
|
||||
optfade.value = (segstate.ws_fxopt & 112);
|
||||
optfade.addEventListener('change', ()=>{
|
||||
config.ws_fxopt = optrev.value | optfade.value | optgamma.value | optsize.value;
|
||||
ws_send("Cso" + config.ws_fxopt);
|
||||
segstate.ws_fxopt = optrev.value | optfade.value | optgamma.value | optsize.value;
|
||||
ws_send("So" + segstate.ws_fxopt);
|
||||
});
|
||||
var optgamma = document.getElementById("selectoptgamma");
|
||||
for (var code in selectoptgamma) {
|
||||
@@ -1791,10 +1900,10 @@ function initSettings() {
|
||||
option.innerHTML = selectoptgamma[code];
|
||||
optgamma.appendChild(option);
|
||||
}
|
||||
optgamma.value = (config.ws_fxopt & 8);
|
||||
optgamma.value = (segstate.ws_fxopt & 8);
|
||||
optgamma.addEventListener('change', ()=>{
|
||||
config.ws_fxopt = optrev.value | optfade.value | optgamma.value | optsize.value;
|
||||
ws_send("Cso" + config.ws_fxopt);
|
||||
segstate.ws_fxopt = optrev.value | optfade.value | optgamma.value | optsize.value;
|
||||
ws_send("So" + segstate.ws_fxopt);
|
||||
});
|
||||
var optsize = document.getElementById("selectoptsize");
|
||||
for (var code in selectoptsize) {
|
||||
@@ -1803,10 +1912,10 @@ function initSettings() {
|
||||
option.innerHTML = selectoptsize[code];
|
||||
optsize.appendChild(option);
|
||||
}
|
||||
optsize.value = (config.ws_fxopt & 6)
|
||||
optsize.value = (segstate.ws_fxopt & 6)
|
||||
optsize.addEventListener('change', ()=>{
|
||||
config.ws_fxopt = optrev.value | optfade.value | optgamma.value | optsize.value;
|
||||
ws_send("Cso" + config.ws_fxopt);
|
||||
segstate.ws_fxopt = optrev.value | optfade.value | optgamma.value | optsize.value;
|
||||
ws_send("So" + segstate.ws_fxopt);
|
||||
});
|
||||
slavenodes.value = settings.slave_nodes;
|
||||
lang.addEventListener('change', ()=>{
|
||||
@@ -1855,6 +1964,7 @@ function initSettings() {
|
||||
settings.theme_back = colback.value;
|
||||
document.getElementById("container").style.backgroundColor = settings.theme_back;
|
||||
document.getElementById("language").style.backgroundColor = settings.theme_back;
|
||||
document.getElementById("selectseg").style.backgroundColor = settings.theme_back;
|
||||
document.getElementById("selectrgbo").style.backgroundColor = settings.theme_back;
|
||||
document.getElementById("selectoptrev").style.backgroundColor = settings.theme_back;
|
||||
document.getElementById("selectoptfade").style.backgroundColor = settings.theme_back;
|
||||
@@ -1867,6 +1977,7 @@ function initSettings() {
|
||||
for (var i = 0; i < icons.length; i++) {
|
||||
icons[i].style.color = (yiq >= 125) ? '#222' : '#EEE';
|
||||
}
|
||||
document.getElementById("selectSegLbl").style.color = (yiq >= 125) ? '#111' : '#EEE';
|
||||
document.getElementById("wsmessageLbl").style.color = (yiq >= 125) ? '#111' : '#EEE';
|
||||
document.getElementById("redNum").style.color = (yiq >= 125) ? '#111' : '#EEE';
|
||||
document.getElementById("greenNum").style.color = (yiq >= 125) ? '#111' : '#EEE';
|
||||
@@ -2018,8 +2129,8 @@ function ws_reconnect() {
|
||||
|
||||
function ws_connect() {
|
||||
data.connection = new ReconnectingWebSocket(ws_url, "arduino", ws_options);
|
||||
document.getElementById("percentage").innerHTML = "67%";
|
||||
document.getElementById("percentage-done").setAttribute("stroke-dasharray", "67,100");
|
||||
document.getElementById("percentage").innerHTML = "75%";
|
||||
document.getElementById("percentage-done").setAttribute("stroke-dasharray", "75,100");
|
||||
document.getElementById("modal-content").innerHTML = language[settings.lang].loadWebsock;
|
||||
|
||||
// When the connection is open, send some data to the server
|
||||
@@ -2031,12 +2142,12 @@ function ws_connect() {
|
||||
con.className = "hidden";
|
||||
con = document.getElementById("connected");
|
||||
con.className = con.className = "";
|
||||
document.getElementById("percentage").innerHTML = "100%";
|
||||
document.getElementById("percentage-done").setAttribute("stroke-dasharray", "100,100");
|
||||
document.getElementById("modal-content").innerHTML = language[settings.lang].loadReady;
|
||||
//setTimeout(function() { ws_send("$"); }, 2000);
|
||||
//setTimeout(function() { ws_send("C"); }, 3000);
|
||||
//setTimeout(function() { ws_send("~"); }, 4000);
|
||||
document.getElementById("percentage").innerHTML = "100%";
|
||||
document.getElementById("percentage-done").setAttribute("stroke-dasharray", "100,100");
|
||||
document.getElementById("modal-content").innerHTML = language[settings.lang].loadReady;
|
||||
};
|
||||
|
||||
// When the connection is open, send some data to the server
|
||||
@@ -2069,53 +2180,56 @@ function ws_connect() {
|
||||
// document.getElementById('modal').style.display = "none";
|
||||
// console.log("res", res);
|
||||
if (res) {
|
||||
// Status starts here
|
||||
if (typeof res.mode !== "undefined") data.mode = res.mode;
|
||||
if (typeof res.ws2812fx_mode !== "undefined") data.ws2812fx_mode = res.ws2812fx_mode;
|
||||
if (typeof res.speed !== "undefined") {
|
||||
data.speed = res.speed;
|
||||
// init SliderVals
|
||||
speed.value = res.speed;
|
||||
}
|
||||
if (typeof res.segment !== "undefined") { state.segment= res.segment; document.getElementById("selectseg").value = state.segment; }
|
||||
if (typeof res.mode !== "undefined") { state.mode = res.mode; }
|
||||
if (typeof res.brightness !== "undefined") {
|
||||
data.brightness = res.brightness;
|
||||
state.brightness = res.brightness;
|
||||
// init ColorSliderVals
|
||||
bright.value = res.brightness;
|
||||
}
|
||||
// Segment Status starts here
|
||||
if (typeof res.start !== "undefined") { segstate.start= res.start; document.getElementById("segstart").value = segstate.start; }
|
||||
if (typeof res.stop !== "undefined") { segstate.stop = res.stop; document.getElementById("segstop").value = segstate.stop; }
|
||||
if (typeof res.fx_mode !== "undefined") { segstate.mode = res.fx_mode; }
|
||||
if (typeof res.speed !== "undefined") {
|
||||
segstate.speed = res.speed;
|
||||
// init SliderVals
|
||||
speed.value = res.speed;
|
||||
}
|
||||
if (typeof res.color !== "undefined") {
|
||||
data.color.w = res.color[0];
|
||||
data.color.r = res.color[1];
|
||||
data.color.g = res.color[2];
|
||||
data.color.b = res.color[3];
|
||||
data.color.hex = rgbToHex([res.color[0], res.color[1], res.color[2], res.color[3]]);
|
||||
data.color.w2 = res.color[4];
|
||||
data.color.r2 = res.color[5];
|
||||
data.color.g2 = res.color[6];
|
||||
data.color.b2 = res.color[7];
|
||||
data.color.hex2 = rgbToHex([res.color[4], res.color[5], res.color[6], res.color[7]]);
|
||||
data.color.w3 = res.color[8];
|
||||
data.color.r3 = res.color[9];
|
||||
data.color.g3 = res.color[10];
|
||||
data.color.b3 = res.color[11];
|
||||
data.color.hex3 = rgbToHex([res.color[8], res.color[9], res.color[10], res.color[11]]);
|
||||
segstate.color.w = res.color[0];
|
||||
segstate.color.r = res.color[1];
|
||||
segstate.color.g = res.color[2];
|
||||
segstate.color.b = res.color[3];
|
||||
segstate.color.hex = rgbToHex([res.color[0], res.color[1], res.color[2], res.color[3]]);
|
||||
segstate.color.w2 = res.color[4];
|
||||
segstate.color.r2 = res.color[5];
|
||||
segstate.color.g2 = res.color[6];
|
||||
segstate.color.b2 = res.color[7];
|
||||
segstate.color.hex2 = rgbToHex([res.color[4], res.color[5], res.color[6], res.color[7]]);
|
||||
segstate.color.w3 = res.color[8];
|
||||
segstate.color.r3 = res.color[9];
|
||||
segstate.color.g3 = res.color[10];
|
||||
segstate.color.b3 = res.color[11];
|
||||
segstate.color.hex3 = rgbToHex([res.color[8], res.color[9], res.color[10], res.color[11]]);
|
||||
// init ColorSliderVals
|
||||
if (data.color_num === 1) {
|
||||
red.value = data.color.r;
|
||||
green.value = data.color.g;
|
||||
blue.value = data.color.b;
|
||||
white.value = data.color.w;
|
||||
red.value = segstate.color.r;
|
||||
green.value = segstate.color.g;
|
||||
blue.value = segstate.color.b;
|
||||
white.value = segstate.color.w;
|
||||
}
|
||||
if (data.color_num === 2) {
|
||||
red.value = data.color.r2;
|
||||
green.value = data.color.g2;
|
||||
blue.value = data.color.b2;
|
||||
white.value = data.color.w2;
|
||||
red.value = segstate.color.r2;
|
||||
green.value = segstate.color.g2;
|
||||
blue.value = segstate.color.b2;
|
||||
white.value = segstate.color.w2;
|
||||
}
|
||||
if (data.color_num === 3) {
|
||||
red.value = data.color.r3;
|
||||
green.value = data.color.g3;
|
||||
blue.value = data.color.b3;
|
||||
white.value = data.color.w3;
|
||||
red.value = segstate.color.r3;
|
||||
green.value = segstate.color.g3;
|
||||
blue.value = segstate.color.b3;
|
||||
white.value = segstate.color.w3;
|
||||
}
|
||||
}
|
||||
// Config starts here
|
||||
@@ -2124,6 +2238,7 @@ function ws_connect() {
|
||||
if (typeof res.mqtt_port !== "undefined") { config.mqtt_port = res.mqtt_port; document.getElementById("mqtt_port").value = config.mqtt_port; }
|
||||
if (typeof res.mqtt_user !== "undefined") { config.mqtt_user = res.mqtt_user; document.getElementById("mqtt_user").value = config.mqtt_user; }
|
||||
if (typeof res.mqtt_pass !== "undefined") { config.mqtt_pass = res.mqtt_pass; document.getElementById("mqtt_pass").value = config.mqtt_pass; }
|
||||
if (typeof res.ws_seg !== "undefined") { config.ws_seg = res.ws_seg; document.getElementById("selectsegcnt").value = config.ws_seg; }
|
||||
if (typeof res.ws_cnt !== "undefined") { config.ws_cnt = res.ws_cnt; document.getElementById("selectcount").value = config.ws_cnt; }
|
||||
if (typeof res.ws_rgbo !== "undefined") {
|
||||
config.ws_rgbo = res.ws_rgbo;
|
||||
@@ -2134,19 +2249,20 @@ function ws_connect() {
|
||||
} else {
|
||||
document.getElementById("white").parentNode.className = "hidden";
|
||||
white.value = 0;
|
||||
data.color.w = 0;
|
||||
data.color.w2 = 0;
|
||||
data.color.w3 = 0;
|
||||
segstate.color.w = 0;
|
||||
segstate.color.w2 = 0;
|
||||
segstate.color.w3 = 0;
|
||||
}
|
||||
|
||||
}
|
||||
if (typeof res.ws_pin !== "undefined") { config.ws_pin = res.ws_pin; document.getElementById("selectpin").value = config.ws_pin; }
|
||||
if (typeof res.ws_trans !== "undefined") { config.ws_trans = res.ws_trans; document.getElementById("set-transitionEffects").value = config.ws_trans; }
|
||||
if (typeof res.ws_fxopt !== "undefined") {
|
||||
config.ws_fxopt = res.ws_fxopt;
|
||||
document.getElementById("selectoptrev").value = (config.ws_fxopt & 128);
|
||||
document.getElementById("selectoptfade").value = (config.ws_fxopt & 112);
|
||||
document.getElementById("selectoptgamma").value = (config.ws_fxopt & 8);
|
||||
document.getElementById("selectoptsize").value = (config.ws_fxopt & 6);
|
||||
segstate.ws_fxopt = res.ws_fxopt;
|
||||
document.getElementById("selectoptrev").value = (segstate.ws_fxopt & 128);
|
||||
document.getElementById("selectoptfade").value = (segstate.ws_fxopt & 112);
|
||||
document.getElementById("selectoptgamma").value = (segstate.ws_fxopt & 8);
|
||||
document.getElementById("selectoptsize").value = (segstate.ws_fxopt & 6);
|
||||
}
|
||||
// Modes starts here
|
||||
if (typeof res[0] !== "undefined") {
|
||||
@@ -2157,18 +2273,22 @@ function ws_connect() {
|
||||
});
|
||||
}
|
||||
// init Color Vals
|
||||
colorNumrVals();
|
||||
colorNumVals();
|
||||
initSliderColors();
|
||||
// init Change Range Val
|
||||
changeRangeNumVal();
|
||||
// init Colors controls
|
||||
// init display Colors
|
||||
displayColors(true);
|
||||
console.log("displayColors finished!");
|
||||
select_active_button();
|
||||
console.log("select_active_button finished!");
|
||||
}
|
||||
if (data.init === true) {
|
||||
console.log("data.init: ", data.init);
|
||||
if (data.init == true) {
|
||||
console.log("Initializing...");
|
||||
// Set selected mode button
|
||||
//document.getElementById(data.ws2812fx_mode).style.backgroundColor = settings.theme_btnsel;
|
||||
//document.getElementById(segstate.mode).style.backgroundColor = settings.theme_btnsel;
|
||||
// Close Loading Modal
|
||||
setTimeout(() => {
|
||||
document.getElementById('modal').style.display = "none";
|
||||
@@ -2212,38 +2332,45 @@ function select_active_button() {
|
||||
for (i = 0; i < btns.length; i++) {
|
||||
btns[i].style.backgroundColor = settings.theme_btn;
|
||||
}
|
||||
if (data.mode != 1 || (data.mode === 1 && data.ws2812fx_mode !== 57)) { // CUSTOM WS MODE
|
||||
if (state.mode != 1 || (state.mode == 1 && segstate.mode != 57)) { // CUSTOM WS MODE
|
||||
wsmess = document.getElementById("message");
|
||||
var arr = wsmess.className.split(" ");
|
||||
if (arr.indexOf("hidden") === -1) {
|
||||
wsmess.className += " hidden";
|
||||
}
|
||||
segments = document.getElementById("segments");
|
||||
segments.className = segments.className.replace(/\b hidden\b/g, "");
|
||||
}
|
||||
if (data.mode >= 1) {
|
||||
document.getElementById(data.ws2812fx_mode).style.backgroundColor = settings.theme_btnsel;
|
||||
if (data.ws2812fx_mode === 56) { // AUTOPLAY
|
||||
if (state.mode >= 1) {
|
||||
document.getElementById(segstate.mode).style.backgroundColor = settings.theme_btnsel;
|
||||
if (segstate.mode == 56) { // AUTOPLAY
|
||||
disable_modebuttons(false);
|
||||
disable_color_selection(true);
|
||||
disable_bright_selection(false);
|
||||
disable_speed_selection(true);
|
||||
} else if (data.ws2812fx_mode === 57) { //CUSTOM_WS
|
||||
} else if (segstate.mode == 57) { //CUSTOM_WS
|
||||
wsmess = document.getElementById("message");
|
||||
wsmess.className = wsmess.className.replace(/\b hidden\b/g, "");
|
||||
sements = document.getElementById("segments");
|
||||
var arr = segments.className.split(" ");
|
||||
if (arr.indexOf("hidden") === -1) {
|
||||
segments.className += " hidden";
|
||||
}
|
||||
disable_modebuttons(false);
|
||||
disable_color_selection(true);
|
||||
disable_bright_selection(false);
|
||||
disable_speed_selection(true);
|
||||
} else if (data.ws2812fx_mode === 58) { //TV
|
||||
} else if (segstate.mode == 58) { //TV
|
||||
disable_modebuttons(false);
|
||||
disable_color_selection(true);
|
||||
disable_bright_selection(false);
|
||||
disable_speed_selection(false);
|
||||
} else if (data.ws2812fx_mode === 59) { //E1.31
|
||||
} else if (segstate.mode == 59) { //E1.31
|
||||
disable_modebuttons(false);
|
||||
disable_color_selection(true);
|
||||
disable_bright_selection(false);
|
||||
disable_speed_selection(true);
|
||||
} else if (data.ws2812fx_mode === 60) { //Fire2012
|
||||
} else if (segstate.mode == 60) { //Fire2012
|
||||
disable_modebuttons(false);
|
||||
disable_color_selection(true);
|
||||
disable_bright_selection(false);
|
||||
@@ -2254,7 +2381,7 @@ function select_active_button() {
|
||||
disable_bright_selection(false);
|
||||
disable_speed_selection(false);
|
||||
}
|
||||
} else if (data.mode === 0) {
|
||||
} else if (state.mode == 0) {
|
||||
document.getElementById("off").style.backgroundColor = settings.theme_btnsel;
|
||||
disable_modebuttons(false);
|
||||
disable_color_selection(true);
|
||||
@@ -2282,32 +2409,32 @@ function disable_modebuttons(status) {
|
||||
|
||||
function set_mode(mode_id) {
|
||||
if (Number.isInteger(mode_id)) {
|
||||
data.mode = 1;
|
||||
data.ws2812fx_mode = mode_id;
|
||||
state.mode = 1;
|
||||
segstate.mode = mode_id;
|
||||
} else {
|
||||
// For named modes
|
||||
if (mode_id == "off") {
|
||||
data.mode = 0;
|
||||
state.mode = 0;
|
||||
}
|
||||
}
|
||||
select_active_button();
|
||||
ws_send("/" + mode_id);
|
||||
}
|
||||
function set_speed() {
|
||||
ws_send("?" + data.speed);
|
||||
ws_send("?" + segstate.speed);
|
||||
}
|
||||
function set_brightness() {
|
||||
ws_send("%" + data.brightness);
|
||||
ws_send("%" + state.brightness);
|
||||
}
|
||||
function set_color() {
|
||||
if (data.color_num === 1) {
|
||||
ws_send("#" + rgbToHex([data.color.w, data.color.r, data.color.g, data.color.b]));
|
||||
ws_send("#" + rgbToHex([segstate.color.w, segstate.color.r, segstate.color.g, segstate.color.b]));
|
||||
}
|
||||
if (data.color_num === 2) {
|
||||
ws_send("##" + rgbToHex([data.color.w2, data.color.r2, data.color.g2, data.color.b2]));
|
||||
ws_send("##" + rgbToHex([segstate.color.w2, segstate.color.r2, segstate.color.g2, segstate.color.b2]));
|
||||
}
|
||||
if (data.color_num === 3) {
|
||||
ws_send("###" + rgbToHex([data.color.w3, data.color.r3, data.color.g3, data.color.b3]));
|
||||
ws_send("###" + rgbToHex([segstate.color.w3, segstate.color.r3, segstate.color.g3, segstate.color.b3]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2345,11 +2472,11 @@ function onSelectColor(event) {
|
||||
var color = context.getImageData(pos.x, pos.y, 1, 1).data;
|
||||
var hex_color = rgbToHex(color);
|
||||
var colnum = (data.color_num === 1) ? "" : data.color_num;
|
||||
data.color["hex" + colnum] = hex_color;
|
||||
data.color["r" + colnum] = color[0];
|
||||
data.color["g" + colnum] = color[1];
|
||||
data.color["b" + colnum] = color[2];
|
||||
data.color["w" + colnum] = 0;
|
||||
segstate.color["hex" + colnum] = hex_color;
|
||||
segstate.color["r" + colnum] = color[0];
|
||||
segstate.color["g" + colnum] = color[1];
|
||||
segstate.color["b" + colnum] = color[2];
|
||||
segstate.color["w" + colnum] = 0;
|
||||
red.value = color[0];
|
||||
green.value = color[1];
|
||||
blue.value = color[2];
|
||||
@@ -2357,7 +2484,7 @@ function onSelectColor(event) {
|
||||
displayColors();
|
||||
initSliderColors();
|
||||
changeRangeNumVal();
|
||||
colorNumrVals();
|
||||
colorNumVals();
|
||||
}
|
||||
}
|
||||
function redrawColorPicker() {
|
||||
@@ -2525,13 +2652,11 @@ document.addEventListener("DOMContentLoaded", function(event) {
|
||||
getModes();
|
||||
readSettings();
|
||||
ws_connect();
|
||||
ws_send("$")
|
||||
document.getElementById("modal-content").innerHTML = language.en.loadModes;
|
||||
ws_send("$");
|
||||
//ws_send("C");
|
||||
getConfig();
|
||||
canvas.width = 400;
|
||||
canvas.height = 400;
|
||||
|
||||
redrawColorPicker();
|
||||
});
|
||||
</script>
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user