Conflicts:
	wled00/cfg.cpp
	wled00/data/index.js
	wled00/fcn_declare.h
	wled00/html_ui.h
	wled00/json.cpp
	wled00/playlist.cpp
	wled00/wled.h
This commit is contained in:
Blaz Kristan 2021-03-14 11:41:55 +01:00
commit 0f7e22d8b7
18 changed files with 1779 additions and 1788 deletions

View File

@ -2,6 +2,11 @@
### Development versions after 0.11.1 release ### Development versions after 0.11.1 release
#### Build 2103130
- Added options for Auto Node discovery
- Optimized strings (no string both F() and raw)
#### Build 2103090 #### Build 2103090
- Added Auto Node discovery (PR #1683) - Added Auto Node discovery (PR #1683)

View File

@ -30,12 +30,12 @@ void deserializeConfig() {
return; return;
} }
//int rev_major = doc[F("rev")][0]; // 1 //int rev_major = doc["rev"][0]; // 1
//int rev_minor = doc[F("rev")][1]; // 0 //int rev_minor = doc["rev"][1]; // 0
//long vid = doc[F("vid")]; // 2010020 //long vid = doc[F("vid")]; // 2010020
JsonObject id = doc[F("id")]; JsonObject id = doc["id"];
getStringFromJson(cmDNS, id[F("mdns")], 33); getStringFromJson(cmDNS, id[F("mdns")], 33);
getStringFromJson(serverDescription, id[F("name")], 33); getStringFromJson(serverDescription, id[F("name")], 33);
getStringFromJson(alexaInvocationName, id[F("inv")], 33); getStringFromJson(alexaInvocationName, id[F("inv")], 33);
@ -47,9 +47,9 @@ void deserializeConfig() {
//If it is present however, we will use it //If it is present however, we will use it
getStringFromJson(clientPass, nw_ins_0["psk"], 65); getStringFromJson(clientPass, nw_ins_0["psk"], 65);
JsonArray nw_ins_0_ip = nw_ins_0[F("ip")]; JsonArray nw_ins_0_ip = nw_ins_0["ip"];
JsonArray nw_ins_0_gw = nw_ins_0[F("gw")]; JsonArray nw_ins_0_gw = nw_ins_0["gw"];
JsonArray nw_ins_0_sn = nw_ins_0[F("sn")]; JsonArray nw_ins_0_sn = nw_ins_0["sn"];
for (byte i = 0; i < 4; i++) { for (byte i = 0; i < 4; i++) {
CJSON(staticIP[i], nw_ins_0_ip[i]); CJSON(staticIP[i], nw_ins_0_ip[i]);
@ -57,7 +57,7 @@ void deserializeConfig() {
CJSON(staticSubnet[i], nw_ins_0_sn[i]); CJSON(staticSubnet[i], nw_ins_0_sn[i]);
} }
JsonObject ap = doc[F("ap")]; JsonObject ap = doc["ap"];
getStringFromJson(apSSID, ap[F("ssid")], 33); getStringFromJson(apSSID, ap[F("ssid")], 33);
getStringFromJson(apPass, ap["psk"] , 65); //normally not present due to security getStringFromJson(apPass, ap["psk"] , 65); //normally not present due to security
//int ap_pskl = ap[F("pskl")]; //int ap_pskl = ap[F("pskl")];
@ -72,11 +72,11 @@ void deserializeConfig() {
#ifdef WLED_USE_ETHERNET #ifdef WLED_USE_ETHERNET
JsonObject ethernet = doc[F("eth")]; JsonObject ethernet = doc[F("eth")];
CJSON(ethernetType, ethernet[F("type")]); CJSON(ethernetType, ethernet["type"]);
#endif #endif
/* /*
JsonArray ap_ip = ap[F("ip")]; JsonArray ap_ip = ap["ip"];
for (byte i = 0; i < 4; i++) { for (byte i = 0; i < 4; i++) {
apIP[i] = ap_ip; apIP[i] = ap_ip;
} }
@ -97,7 +97,7 @@ void deserializeConfig() {
CJSON(strip.ablMilliampsMax, hw_led[F("maxpwr")]); CJSON(strip.ablMilliampsMax, hw_led[F("maxpwr")]);
CJSON(strip.milliampsPerLed, hw_led[F("ledma")]); CJSON(strip.milliampsPerLed, hw_led[F("ledma")]);
//CJSON(strip.reverseMode, hw_led[F("rev")]); //CJSON(strip.reverseMode, hw_led["rev"]);
CJSON(strip.rgbwMode, hw_led[F("rgbwm")]); CJSON(strip.rgbwMode, hw_led[F("rgbwm")]);
JsonArray ins = hw_led["ins"]; JsonArray ins = hw_led["ins"];
@ -109,7 +109,7 @@ void deserializeConfig() {
for (JsonObject elm : ins) { for (JsonObject elm : ins) {
if (s >= WLED_MAX_BUSSES) break; if (s >= WLED_MAX_BUSSES) break;
uint8_t pins[5] = {255, 255, 255, 255, 255}; uint8_t pins[5] = {255, 255, 255, 255, 255};
JsonArray pinArr = elm[F("pin")]; JsonArray pinArr = elm["pin"];
if (pinArr.size() == 0) continue; if (pinArr.size() == 0) continue;
uint8_t i = 0; uint8_t i = 0;
for (int p : pinArr) { for (int p : pinArr) {
@ -126,8 +126,8 @@ void deserializeConfig() {
uint8_t colorOrder = (int)elm[F("order")]; uint8_t colorOrder = (int)elm[F("order")];
//(this shouldn't have been in ins obj. but remains here for compatibility) //(this shouldn't have been in ins obj. but remains here for compatibility)
skipFirstLed |= skipFirst = (bool) elm[F("skip")]; skipFirstLed |= skipFirst = (bool) elm[F("skip")];
uint8_t ledType = elm[F("type")] | TYPE_WS2812_RGB; uint8_t ledType = elm["type"] | TYPE_WS2812_RGB;
bool reversed = elm[F("rev")]; bool reversed = elm["rev"];
//RGBW mode is enabled if at least one of the strips is RGBW //RGBW mode is enabled if at least one of the strips is RGBW
if ((bool)elm[F("rgbw")]) SET_BIT(ledType,7); else UNSET_BIT(ledType,7); // hack bit 7 to indicate RGBW (as an override if necessary) if ((bool)elm[F("rgbw")]) SET_BIT(ledType,7); else UNSET_BIT(ledType,7); // hack bit 7 to indicate RGBW (as an override if necessary)
useRGBW |= (bool)elm[F("rgbw")]; useRGBW |= (bool)elm[F("rgbw")];
@ -141,8 +141,8 @@ void deserializeConfig() {
//strip.finalizeInit(); // will be done in WLED::beginStrip() //strip.finalizeInit(); // will be done in WLED::beginStrip()
JsonObject hw_btn_ins_0 = hw[F("btn")][F("ins")][0]; JsonObject hw_btn_ins_0 = hw[F("btn")][F("ins")][0];
CJSON(buttonEnabled, hw_btn_ins_0[F("type")]); CJSON(buttonEnabled, hw_btn_ins_0["type"]);
int hw_btn_pin = hw_btn_ins_0[F("pin")][0]; int hw_btn_pin = hw_btn_ins_0["pin"][0];
if (pinManager.allocatePin(hw_btn_pin,false)) { if (pinManager.allocatePin(hw_btn_pin,false)) {
btnPin = hw_btn_pin; btnPin = hw_btn_pin;
pinMode(btnPin, INPUT_PULLUP); pinMode(btnPin, INPUT_PULLUP);
@ -155,20 +155,20 @@ void deserializeConfig() {
CJSON(macroLongPress,hw_btn_ins_0_macros[1]); CJSON(macroLongPress,hw_btn_ins_0_macros[1]);
CJSON(macroDoublePress, hw_btn_ins_0_macros[2]); CJSON(macroDoublePress, hw_btn_ins_0_macros[2]);
//int hw_btn_ins_0_type = hw_btn_ins_0[F("type")]; // 0 //int hw_btn_ins_0_type = hw_btn_ins_0["type"]; // 0
#ifndef WLED_DISABLE_INFRARED #ifndef WLED_DISABLE_INFRARED
int hw_ir_pin = hw[F("ir")][F("pin")]; // 4 int hw_ir_pin = hw["ir"]["pin"]; // 4
if (pinManager.allocatePin(hw_ir_pin,false)) { if (pinManager.allocatePin(hw_ir_pin,false)) {
irPin = hw_ir_pin; irPin = hw_ir_pin;
} else { } else {
irPin = -1; irPin = -1;
} }
#endif #endif
CJSON(irEnabled, hw[F("ir")][F("type")]); CJSON(irEnabled, hw["ir"]["type"]);
JsonObject relay = hw[F("relay")]; JsonObject relay = hw[F("relay")];
int hw_relay_pin = relay[F("pin")]; int hw_relay_pin = relay["pin"];
if (pinManager.allocatePin(hw_relay_pin,true)) { if (pinManager.allocatePin(hw_relay_pin,true)) {
rlyPin = hw_relay_pin; rlyPin = hw_relay_pin;
pinMode(rlyPin, OUTPUT); pinMode(rlyPin, OUTPUT);
@ -176,17 +176,17 @@ void deserializeConfig() {
rlyPin = -1; rlyPin = -1;
} }
if (relay.containsKey("rev")) { if (relay.containsKey("rev")) {
rlyMde = !relay[F("rev")]; rlyMde = !relay["rev"];
} }
//int hw_status_pin = hw[F("status")][F("pin")]; // -1 //int hw_status_pin = hw[F("status")]["pin"]; // -1
JsonObject light = doc[F("light")]; JsonObject light = doc[F("light")];
CJSON(briMultiplier, light[F("scale-bri")]); CJSON(briMultiplier, light[F("scale-bri")]);
CJSON(strip.paletteBlend, light[F("pal-mode")]); CJSON(strip.paletteBlend, light[F("pal-mode")]);
float light_gc_bri = light[F("gc")]["bri"]; float light_gc_bri = light[F("gc")]["bri"];
float light_gc_col = light[F("gc")][F("col")]; // 2.8 float light_gc_col = light[F("gc")]["col"]; // 2.8
if (light_gc_bri > 1.5) strip.gammaCorrectBri = true; if (light_gc_bri > 1.5) strip.gammaCorrectBri = true;
else if (light_gc_bri > 0.5) strip.gammaCorrectBri = false; else if (light_gc_bri > 0.5) strip.gammaCorrectBri = false;
if (light_gc_col > 1.5) strip.gammaCorrectCol = true; if (light_gc_col > 1.5) strip.gammaCorrectCol = true;
@ -226,13 +226,13 @@ void deserializeConfig() {
CJSON(udpPort, if_sync[F("port0")]); // 21324 CJSON(udpPort, if_sync[F("port0")]); // 21324
CJSON(udpPort2, if_sync[F("port1")]); // 65506 CJSON(udpPort2, if_sync[F("port1")]); // 65506
JsonObject if_sync_recv = if_sync[F("recv")]; JsonObject if_sync_recv = if_sync["recv"];
CJSON(receiveNotificationBrightness, if_sync_recv["bri"]); CJSON(receiveNotificationBrightness, if_sync_recv["bri"]);
CJSON(receiveNotificationColor, if_sync_recv[F("col")]); CJSON(receiveNotificationColor, if_sync_recv["col"]);
CJSON(receiveNotificationEffects, if_sync_recv[F("fx")]); CJSON(receiveNotificationEffects, if_sync_recv[F("fx")]);
receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects); receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects);
JsonObject if_sync_send = if_sync[F("send")]; JsonObject if_sync_send = if_sync["send"];
CJSON(notifyDirectDefault, if_sync_send[F("dir")]); CJSON(notifyDirectDefault, if_sync_send[F("dir")]);
notifyDirect = notifyDirectDefault; notifyDirect = notifyDirectDefault;
CJSON(notifyButton, if_sync_send[F("btn")]); CJSON(notifyButton, if_sync_send[F("btn")]);
@ -241,9 +241,13 @@ void deserializeConfig() {
CJSON(notifyMacro, if_sync_send[F("macro")]); CJSON(notifyMacro, if_sync_send[F("macro")]);
CJSON(notifyTwice, if_sync_send[F("twice")]); CJSON(notifyTwice, if_sync_send[F("twice")]);
JsonObject if_live = interfaces[F("live")]; JsonObject if_nodes = interfaces["nodes"];
CJSON(receiveDirect, if_live[F("en")]); CJSON(nodeListEnabled, if_nodes[F("list")]);
CJSON(e131Port, if_live[F("port")]); // 5568 CJSON(nodeBroadcastEnabled, if_nodes[F("bcast")]);
JsonObject if_live = interfaces["live"];
CJSON(receiveDirect, if_live["en"]);
CJSON(e131Port, if_live["port"]); // 5568
CJSON(e131Multicast, if_live[F("mc")]); CJSON(e131Multicast, if_live[F("mc")]);
JsonObject if_live_dmx = if_live[F("dmx")]; JsonObject if_live_dmx = if_live[F("dmx")];
@ -263,19 +267,19 @@ void deserializeConfig() {
CJSON(macroAlexaOn, interfaces[F("va")][F("macros")][0]); CJSON(macroAlexaOn, interfaces[F("va")][F("macros")][0]);
CJSON(macroAlexaOff, interfaces[F("va")][F("macros")][1]); CJSON(macroAlexaOff, interfaces[F("va")][F("macros")][1]);
const char* apikey = interfaces[F("blynk")][F("token")] | "Hidden"; const char* apikey = interfaces["blynk"][F("token")] | "Hidden";
tdd = strnlen(apikey, 36); tdd = strnlen(apikey, 36);
if (tdd > 20 || tdd == 0) if (tdd > 20 || tdd == 0)
getStringFromJson(blynkApiKey, apikey, 36); //normally not present due to security getStringFromJson(blynkApiKey, apikey, 36); //normally not present due to security
JsonObject if_blynk = interfaces[F("blynk")]; JsonObject if_blynk = interfaces["blynk"];
getStringFromJson(blynkHost, if_blynk[F("host")], 33); getStringFromJson(blynkHost, if_blynk[F("host")], 33);
CJSON(blynkPort, if_blynk[F("port")]); CJSON(blynkPort, if_blynk["port"]);
JsonObject if_mqtt = interfaces[F("mqtt")]; JsonObject if_mqtt = interfaces["mqtt"];
CJSON(mqttEnabled, if_mqtt[F("en")]); CJSON(mqttEnabled, if_mqtt["en"]);
getStringFromJson(mqttServer, if_mqtt[F("broker")], 33); getStringFromJson(mqttServer, if_mqtt[F("broker")], 33);
CJSON(mqttPort, if_mqtt[F("port")]); // 1883 CJSON(mqttPort, if_mqtt["port"]); // 1883
getStringFromJson(mqttUser, if_mqtt[F("user")], 41); getStringFromJson(mqttUser, if_mqtt[F("user")], 41);
getStringFromJson(mqttPass, if_mqtt["psk"], 41); //normally not present due to security getStringFromJson(mqttPass, if_mqtt["psk"], 41); //normally not present due to security
getStringFromJson(mqttClientID, if_mqtt[F("cid")], 41); getStringFromJson(mqttClientID, if_mqtt[F("cid")], 41);
@ -284,23 +288,23 @@ void deserializeConfig() {
getStringFromJson(mqttGroupTopic, if_mqtt[F("topics")][F("group")], 33); // "" getStringFromJson(mqttGroupTopic, if_mqtt[F("topics")][F("group")], 33); // ""
JsonObject if_hue = interfaces[F("hue")]; JsonObject if_hue = interfaces[F("hue")];
CJSON(huePollingEnabled, if_hue[F("en")]); CJSON(huePollingEnabled, if_hue["en"]);
CJSON(huePollLightId, if_hue[F("id")]); CJSON(huePollLightId, if_hue["id"]);
tdd = if_hue[F("iv")] | -1; tdd = if_hue[F("iv")] | -1;
if (tdd >= 2) huePollIntervalMs = tdd * 100; if (tdd >= 2) huePollIntervalMs = tdd * 100;
JsonObject if_hue_recv = if_hue[F("recv")]; JsonObject if_hue_recv = if_hue["recv"];
CJSON(hueApplyOnOff, if_hue_recv["on"]); CJSON(hueApplyOnOff, if_hue_recv["on"]);
CJSON(hueApplyBri, if_hue_recv["bri"]); CJSON(hueApplyBri, if_hue_recv["bri"]);
CJSON(hueApplyColor, if_hue_recv[F("col")]); CJSON(hueApplyColor, if_hue_recv["col"]);
JsonArray if_hue_ip = if_hue[F("ip")]; JsonArray if_hue_ip = if_hue["ip"];
for (byte i = 0; i < 4; i++) for (byte i = 0; i < 4; i++)
CJSON(hueIP[i], if_hue_ip[i]); CJSON(hueIP[i], if_hue_ip[i]);
JsonObject if_ntp = interfaces[F("ntp")]; JsonObject if_ntp = interfaces[F("ntp")];
CJSON(ntpEnabled, if_ntp[F("en")]); CJSON(ntpEnabled, if_ntp["en"]);
getStringFromJson(ntpServerName, if_ntp[F("host")], 33); // "1.wled.pool.ntp.org" getStringFromJson(ntpServerName, if_ntp[F("host")], 33); // "1.wled.pool.ntp.org"
CJSON(currentTimezone, if_ntp[F("tz")]); CJSON(currentTimezone, if_ntp[F("tz")]);
CJSON(utcOffsetSecs, if_ntp[F("offset")]); CJSON(utcOffsetSecs, if_ntp[F("offset")]);
@ -348,7 +352,7 @@ void deserializeConfig() {
CJSON(timerWeekday[it], timer[F("dow")]); CJSON(timerWeekday[it], timer[F("dow")]);
if (timerWeekday[it] != dowPrev) { //present in JSON if (timerWeekday[it] != dowPrev) { //present in JSON
timerWeekday[it] <<= 1; //add active bit timerWeekday[it] <<= 1; //add active bit
int act = timer[F("en")] | actPrev; int act = timer["en"] | actPrev;
if (act) timerWeekday[it]++; if (act) timerWeekday[it]++;
} }
@ -395,7 +399,6 @@ void serializeConfig() {
DynamicJsonDocument doc(JSON_BUFFER_SIZE); DynamicJsonDocument doc(JSON_BUFFER_SIZE);
//{ //scope this to reduce stack size
JsonArray rev = doc.createNestedArray("rev"); JsonArray rev = doc.createNestedArray("rev");
rev.add(1); //major settings revision rev.add(1); //major settings revision
rev.add(0); //minor settings revision rev.add(0); //minor settings revision
@ -444,7 +447,7 @@ void serializeConfig() {
#ifdef WLED_USE_ETHERNET #ifdef WLED_USE_ETHERNET
JsonObject ethernet = doc.createNestedObject("eth"); JsonObject ethernet = doc.createNestedObject("eth");
ethernet[F("type")] = ethernetType; ethernet["type"] = ethernetType;
#endif #endif
JsonObject hw = doc.createNestedObject("hw"); JsonObject hw = doc.createNestedObject("hw");
@ -453,7 +456,7 @@ void serializeConfig() {
hw_led[F("total")] = ledCount; hw_led[F("total")] = ledCount;
hw_led[F("maxpwr")] = strip.ablMilliampsMax; hw_led[F("maxpwr")] = strip.ablMilliampsMax;
hw_led[F("ledma")] = strip.milliampsPerLed; hw_led[F("ledma")] = strip.milliampsPerLed;
hw_led[F("rev")] = false; //strip.reverseMode; // not used anymore, reversing per-strip hw_led["rev"] = false; //strip.reverseMode; // not used anymore, reversing per-strip
hw_led[F("rgbwm")] = strip.rgbwMode; hw_led[F("rgbwm")] = strip.rgbwMode;
JsonArray hw_led_ins = hw_led.createNestedArray("ins"); JsonArray hw_led_ins = hw_led.createNestedArray("ins");
@ -462,7 +465,7 @@ void serializeConfig() {
Bus *bus = busses.getBus(s); Bus *bus = busses.getBus(s);
if (!bus || bus->getLength()==0) break; if (!bus || bus->getLength()==0) break;
JsonObject ins = hw_led_ins.createNestedObject(); JsonObject ins = hw_led_ins.createNestedObject();
ins[F("en")] = true; ins["en"] = true;
ins[F("start")] = bus->getStart(); ins[F("start")] = bus->getStart();
ins[F("len")] = bus->getLength(); ins[F("len")] = bus->getLength();
JsonArray ins_pin = ins.createNestedArray("pin"); JsonArray ins_pin = ins.createNestedArray("pin");
@ -470,9 +473,9 @@ void serializeConfig() {
uint8_t nPins = bus->getPins(pins); uint8_t nPins = bus->getPins(pins);
for (uint8_t i = 0; i < nPins; i++) ins_pin.add(pins[i]); for (uint8_t i = 0; i < nPins; i++) ins_pin.add(pins[i]);
ins[F("order")] = bus->getColorOrder(); ins[F("order")] = bus->getColorOrder();
ins[F("rev")] = bus->reversed; ins["rev"] = bus->reversed;
ins[F("skip")] = skipFirstLed ? 1 : 0; ins[F("skip")] = skipFirstLed ? 1 : 0;
ins[F("type")] = bus->getType(); ins["type"] = bus->getType();
ins[F("rgbw")] = bus->isRgbw(); ins[F("rgbw")] = bus->isRgbw();
} }
@ -482,7 +485,7 @@ void serializeConfig() {
// button BTNPIN // button BTNPIN
JsonObject hw_btn_ins_0 = hw_btn_ins.createNestedObject(); JsonObject hw_btn_ins_0 = hw_btn_ins.createNestedObject();
hw_btn_ins_0[F("type")] = (buttonEnabled) ? BTN_TYPE_PUSH : BTN_TYPE_NONE; hw_btn_ins_0["type"] = (buttonEnabled) ? BTN_TYPE_PUSH : BTN_TYPE_NONE;
JsonArray hw_btn_ins_0_pin = hw_btn_ins_0.createNestedArray("pin"); JsonArray hw_btn_ins_0_pin = hw_btn_ins_0.createNestedArray("pin");
hw_btn_ins_0_pin.add(btnPin); hw_btn_ins_0_pin.add(btnPin);
@ -495,28 +498,28 @@ void serializeConfig() {
#ifndef WLED_DISABLE_INFRARED #ifndef WLED_DISABLE_INFRARED
if (irPin>=0) { if (irPin>=0) {
JsonObject hw_ir = hw.createNestedObject("ir"); JsonObject hw_ir = hw.createNestedObject("ir");
hw_ir[F("pin")] = irPin; hw_ir["pin"] = irPin;
hw_ir[F("type")] = irEnabled; // the byte 'irEnabled' does contain the IR-Remote Type ( 0=disabled ) hw_ir["type"] = irEnabled; // the byte 'irEnabled' does contain the IR-Remote Type ( 0=disabled )
} }
#endif #endif
JsonObject hw_relay = hw.createNestedObject("relay"); JsonObject hw_relay = hw.createNestedObject(F("relay"));
hw_relay[F("pin")] = rlyPin; hw_relay["pin"] = rlyPin;
hw_relay[F("rev")] = !rlyMde; hw_relay["rev"] = !rlyMde;
//JsonObject hw_status = hw.createNestedObject("status"); //JsonObject hw_status = hw.createNestedObject("status");
//hw_status[F("pin")] = -1; //hw_status["pin"] = -1;
JsonObject hw_aux = hw.createNestedObject("aux"); JsonObject hw_aux = hw.createNestedObject("aux");
hw_aux[F("pin")] = auxPin; hw_aux["pin"] = auxPin;
JsonObject light = doc.createNestedObject("light"); JsonObject light = doc.createNestedObject(F("light"));
light[F("scale-bri")] = briMultiplier; light[F("scale-bri")] = briMultiplier;
light[F("pal-mode")] = strip.paletteBlend; light[F("pal-mode")] = strip.paletteBlend;
JsonObject light_gc = light.createNestedObject("gc"); JsonObject light_gc = light.createNestedObject("gc");
light_gc["bri"] = (strip.gammaCorrectBri) ? 2.8 : 1.0; light_gc["bri"] = (strip.gammaCorrectBri) ? 2.8 : 1.0;
light_gc[F("col")] = (strip.gammaCorrectCol) ? 2.8 : 1.0; light_gc["col"] = (strip.gammaCorrectCol) ? 2.8 : 1.0;
JsonObject light_tr = light.createNestedObject("tr"); JsonObject light_tr = light.createNestedObject("tr");
light_tr[F("mode")] = fadeTransition; light_tr[F("mode")] = fadeTransition;
@ -539,7 +542,7 @@ void serializeConfig() {
JsonObject def_cy = def.createNestedObject("cy"); JsonObject def_cy = def.createNestedObject("cy");
def_cy["on"] = presetCyclingEnabled; def_cy["on"] = presetCyclingEnabled;
JsonArray def_cy_range = def_cy.createNestedArray("range"); JsonArray def_cy_range = def_cy.createNestedArray(F("range"));
def_cy_range.add(presetCycleMin); def_cy_range.add(presetCycleMin);
def_cy_range.add(presetCycleMax); def_cy_range.add(presetCycleMax);
def_cy[F("dur")] = presetCycleTime; def_cy[F("dur")] = presetCycleTime;
@ -553,7 +556,7 @@ void serializeConfig() {
JsonObject if_sync_recv = if_sync.createNestedObject("recv"); JsonObject if_sync_recv = if_sync.createNestedObject("recv");
if_sync_recv["bri"] = receiveNotificationBrightness; if_sync_recv["bri"] = receiveNotificationBrightness;
if_sync_recv[F("col")] = receiveNotificationColor; if_sync_recv["col"] = receiveNotificationColor;
if_sync_recv[F("fx")] = receiveNotificationEffects; if_sync_recv[F("fx")] = receiveNotificationEffects;
JsonObject if_sync_send = if_sync.createNestedObject("send"); JsonObject if_sync_send = if_sync.createNestedObject("send");
@ -564,9 +567,13 @@ void serializeConfig() {
if_sync_send[F("macro")] = notifyMacro; if_sync_send[F("macro")] = notifyMacro;
if_sync_send[F("twice")] = notifyTwice; if_sync_send[F("twice")] = notifyTwice;
JsonObject if_nodes = interfaces.createNestedObject("nodes");
if_nodes[F("list")] = nodeListEnabled;
if_nodes[F("bcast")] = nodeBroadcastEnabled;
JsonObject if_live = interfaces.createNestedObject("live"); JsonObject if_live = interfaces.createNestedObject("live");
if_live[F("en")] = receiveDirect; if_live["en"] = receiveDirect;
if_live[F("port")] = e131Port; if_live["port"] = e131Port;
if_live[F("mc")] = e131Multicast; if_live[F("mc")] = e131Multicast;
JsonObject if_live_dmx = if_live.createNestedObject("dmx"); JsonObject if_live_dmx = if_live.createNestedObject("dmx");
@ -588,29 +595,29 @@ void serializeConfig() {
JsonObject if_blynk = interfaces.createNestedObject("blynk"); JsonObject if_blynk = interfaces.createNestedObject("blynk");
if_blynk[F("token")] = strlen(blynkApiKey) ? "Hidden":""; if_blynk[F("token")] = strlen(blynkApiKey) ? "Hidden":"";
if_blynk[F("host")] = blynkHost; if_blynk[F("host")] = blynkHost;
if_blynk[F("port")] = blynkPort; if_blynk["port"] = blynkPort;
JsonObject if_mqtt = interfaces.createNestedObject("mqtt"); JsonObject if_mqtt = interfaces.createNestedObject("mqtt");
if_mqtt[F("en")] = mqttEnabled; if_mqtt["en"] = mqttEnabled;
if_mqtt[F("broker")] = mqttServer; if_mqtt[F("broker")] = mqttServer;
if_mqtt[F("port")] = mqttPort; if_mqtt["port"] = mqttPort;
if_mqtt[F("user")] = mqttUser; if_mqtt[F("user")] = mqttUser;
if_mqtt[F("pskl")] = strlen(mqttPass); if_mqtt[F("pskl")] = strlen(mqttPass);
if_mqtt[F("cid")] = mqttClientID; if_mqtt[F("cid")] = mqttClientID;
JsonObject if_mqtt_topics = if_mqtt.createNestedObject("topics"); JsonObject if_mqtt_topics = if_mqtt.createNestedObject(F("topics"));
if_mqtt_topics[F("device")] = mqttDeviceTopic; if_mqtt_topics[F("device")] = mqttDeviceTopic;
if_mqtt_topics[F("group")] = mqttGroupTopic; if_mqtt_topics[F("group")] = mqttGroupTopic;
JsonObject if_hue = interfaces.createNestedObject("hue"); JsonObject if_hue = interfaces.createNestedObject("hue");
if_hue[F("en")] = huePollingEnabled; if_hue["en"] = huePollingEnabled;
if_hue[F("id")] = huePollLightId; if_hue["id"] = huePollLightId;
if_hue[F("iv")] = huePollIntervalMs / 100; if_hue[F("iv")] = huePollIntervalMs / 100;
JsonObject if_hue_recv = if_hue.createNestedObject("recv"); JsonObject if_hue_recv = if_hue.createNestedObject("recv");
if_hue_recv["on"] = hueApplyOnOff; if_hue_recv["on"] = hueApplyOnOff;
if_hue_recv["bri"] = hueApplyBri; if_hue_recv["bri"] = hueApplyBri;
if_hue_recv[F("col")] = hueApplyColor; if_hue_recv["col"] = hueApplyColor;
JsonArray if_hue_ip = if_hue.createNestedArray("ip"); JsonArray if_hue_ip = if_hue.createNestedArray("ip");
for (byte i = 0; i < 4; i++) { for (byte i = 0; i < 4; i++) {
@ -618,7 +625,7 @@ void serializeConfig() {
} }
JsonObject if_ntp = interfaces.createNestedObject("ntp"); JsonObject if_ntp = interfaces.createNestedObject("ntp");
if_ntp[F("en")] = ntpEnabled; if_ntp["en"] = ntpEnabled;
if_ntp[F("host")] = ntpServerName; if_ntp[F("host")] = ntpServerName;
if_ntp[F("tz")] = currentTimezone; if_ntp[F("tz")] = currentTimezone;
if_ntp[F("offset")] = utcOffsetSecs; if_ntp[F("offset")] = utcOffsetSecs;
@ -636,10 +643,10 @@ void serializeConfig() {
ol[F("o5m")] = analogClock5MinuteMarks; ol[F("o5m")] = analogClock5MinuteMarks;
ol[F("osec")] = analogClockSecondsTrail; ol[F("osec")] = analogClockSecondsTrail;
JsonObject timers = doc.createNestedObject("timers"); JsonObject timers = doc.createNestedObject(F("timers"));
JsonObject cntdwn = timers.createNestedObject("cntdwn"); JsonObject cntdwn = timers.createNestedObject(F("cntdwn"));
JsonArray goal = cntdwn.createNestedArray("goal"); JsonArray goal = cntdwn.createNestedArray(F("goal"));
goal.add(countdownYear); goal.add(countdownMonth); goal.add(countdownDay); goal.add(countdownYear); goal.add(countdownMonth); goal.add(countdownDay);
goal.add(countdownHour); goal.add(countdownMin); goal.add(countdownSec); goal.add(countdownHour); goal.add(countdownMin); goal.add(countdownSec);
cntdwn[F("macro")] = macroCountdown; cntdwn[F("macro")] = macroCountdown;
@ -649,7 +656,7 @@ void serializeConfig() {
for (byte i = 0; i < 10; i++) { for (byte i = 0; i < 10; i++) {
if (timerMacro[i] == 0 && timerHours[i] == 0 && timerMinutes[i] == 0) continue; // sunrise/sunset get saved always (timerHours=255) if (timerMacro[i] == 0 && timerHours[i] == 0 && timerMinutes[i] == 0) continue; // sunrise/sunset get saved always (timerHours=255)
JsonObject timers_ins0 = timers_ins.createNestedObject(); JsonObject timers_ins0 = timers_ins.createNestedObject();
timers_ins0[F("en")] = (timerWeekday[i] & 0x01); timers_ins0["en"] = (timerWeekday[i] & 0x01);
timers_ins0[F("hour")] = timerHours[i]; timers_ins0[F("hour")] = timerHours[i];
timers_ins0[F("min")] = timerMinutes[i]; timers_ins0[F("min")] = timerMinutes[i];
timers_ins0[F("macro")] = timerMacro[i]; timers_ins0[F("macro")] = timerMacro[i];
@ -669,7 +676,7 @@ void serializeConfig() {
dmx[F("start")] = DMXStart; dmx[F("start")] = DMXStart;
dmx[F("start-led")] = DMXStartLED; dmx[F("start-led")] = DMXStartLED;
JsonArray dmx_fixmap = dmx.createNestedArray("fixmap"); JsonArray dmx_fixmap = dmx.createNestedArray(F("fixmap"));
for (byte i = 0; i < 15; i++) for (byte i = 0; i < 15; i++)
dmx_fixmap.add(DMXFixtureMap[i]); dmx_fixmap.add(DMXFixtureMap[i]);
#endif #endif
@ -695,7 +702,7 @@ bool deserializeConfigSec() {
JsonObject nw_ins_0 = doc["nw"][F("ins")][0]; JsonObject nw_ins_0 = doc["nw"][F("ins")][0];
getStringFromJson(clientPass, nw_ins_0["psk"], 65); getStringFromJson(clientPass, nw_ins_0["psk"], 65);
JsonObject ap = doc[F("ap")]; JsonObject ap = doc["ap"];
getStringFromJson(apPass, ap["psk"] , 65); getStringFromJson(apPass, ap["psk"] , 65);
JsonObject interfaces = doc["if"]; JsonObject interfaces = doc["if"];
@ -705,7 +712,7 @@ bool deserializeConfigSec() {
if (tdd > 20 || tdd == 0) if (tdd > 20 || tdd == 0)
getStringFromJson(blynkApiKey, apikey, 36); getStringFromJson(blynkApiKey, apikey, 36);
JsonObject if_mqtt = interfaces[F("mqtt")]; JsonObject if_mqtt = interfaces["mqtt"];
getStringFromJson(mqttPass, if_mqtt["psk"], 41); getStringFromJson(mqttPass, if_mqtt["psk"], 41);
getStringFromJson(hueApiKey, interfaces[F("hue")][F("key")], 47); getStringFromJson(hueApiKey, interfaces[F("hue")][F("key")], 47);

View File

@ -249,4 +249,12 @@
#endif #endif
#endif #endif
#ifdef WLED_ENABLE_DMX
#if (LEDPIN == 2)
#undef LEDPIN
#define LEDPIN 3
#warning "Pin conflict compiling with DMX and LEDs on pin 2. The default LED pin has been changed to pin 3."
#endif
#endif
#endif #endif

View File

@ -1053,12 +1053,6 @@ input[type="text"].fnd:not(:placeholder-shown) {
} }
} }
@media all and (max-width: 770px) {
#buttonNodes {
display: none;
}
}
@media all and (max-width: 1249px) { @media all and (max-width: 1249px) {
#buttonPcm, #buttonNo { #buttonPcm, #buttonNo {
display: none; display: none;

View File

@ -55,7 +55,7 @@ var cpick = new iro.ColorPicker("#picker", {
}); });
function handleVisibilityChange() { function handleVisibilityChange() {
if (!document.hidden && new Date () - lastUpdate > 3000) { if (!d.hidden && new Date () - lastUpdate > 3000) {
requestJson(null); requestJson(null);
} }
} }
@ -318,12 +318,12 @@ function qlName(i) {
} }
function cpBck() { function cpBck() {
var copyText = document.getElementById("bck"); var copyText = d.getElementById("bck");
copyText.select(); copyText.select();
copyText.setSelectionRange(0, 999999); copyText.setSelectionRange(0, 999999);
document.execCommand("copy"); d.execCommand("copy");
showToast("Copied to clipboard!"); showToast("Copied to clipboard!");
} }
@ -686,8 +686,12 @@ function populateNodes(i,n)
} }
} }
} }
if (nnodes == 0) cn += `No other instances found.`; if (i.ndc < 0) cn += `Instance List is disabled.`;
cn += `<table class="infot">${urows}${inforow("Current instance:",i.name)}</table>`; else if (nnodes == 0) cn += `No other instances found.`;
cn += `<table class="infot">
${urows}
${inforow("Current instance:",i.name)}
</table>`;
d.getElementById('kn').innerHTML = cn; d.getElementById('kn').innerHTML = cn;
} }
@ -1082,10 +1086,9 @@ function requestJson(command, rinfo = true, verbose = true, callback = null) {
syncTglRecv = info.str; syncTglRecv = info.str;
maxSeg = info.leds.maxseg; maxSeg = info.leds.maxseg;
pmt = info.fs.pmt; pmt = info.fs.pmt;
if (!command && pmt != pmtLast) { if (!command && pmt != pmtLast) setTimeout(loadPresets,99);
setTimeout(loadPresets,99);
}
pmtLast = pmt; pmtLast = pmt;
d.getElementById('buttonNodes').style.display = (info.ndc > 0 && window.innerWidth > 770) ? "block":"none";
lastinfo = info; lastinfo = info;
if (isInfo) populateInfo(info); if (isInfo) populateInfo(info);
s = json.state; s = json.state;
@ -1648,13 +1651,7 @@ function rSegs()
function loadPalettesData() function loadPalettesData()
{ {
if (palettesData) { if (palettesData || getPalettesDataCached()) return;
return;
}
if (getPalettesDataCached()) {
return;
}
var dateExpiration = new Date(); var dateExpiration = new Date();
palettesData = {}; palettesData = {};
@ -1687,9 +1684,7 @@ function getPalettesDataCached() {
function getPalettesData(page, callback) function getPalettesData(page, callback)
{ {
var url = `/json/palx?page=${page}`; var url = `/json/palx?page=${page}`;
if (loc) { if (loc) url = `http://${locip}${url}`;
url = `http://${locip}${url}`;
}
fetch(url, { fetch(url, {
method: 'get', method: 'get',
@ -1769,7 +1764,7 @@ function unfocusSliders() {
} }
//sliding UI //sliding UI
const _C = document.querySelector('.container'), N = 4; const _C = d.querySelector('.container'), N = 4;
let iSlide = 0, x0 = null, scrollS = 0, locked = false, w; let iSlide = 0, x0 = null, scrollS = 0, locked = false, w;
@ -1820,6 +1815,7 @@ function move(e) {
function size() { function size() {
w = window.innerWidth; w = window.innerWidth;
d.getElementById('buttonNodes').style.display = (lastinfo.ndc > 0 && w > 770) ? "block":"none";
var h = d.getElementById('top').clientHeight; var h = d.getElementById('top').clientHeight;
sCol('--th', h + "px"); sCol('--th', h + "px");
sCol('--bh', d.getElementById('bot').clientHeight + "px"); sCol('--bh', d.getElementById('bot').clientHeight + "px");

View File

@ -34,7 +34,7 @@ Infrared remote:
<h3>WLED Broadcast</h3> <h3>WLED Broadcast</h3>
UDP Port: <input name="UP" type="number" min="1" max="65535" class="d5" required><br> UDP Port: <input name="UP" type="number" min="1" max="65535" class="d5" required><br>
2nd Port: <input name="U2" type="number" min="1" max="65535" class="d5" required><br> 2nd Port: <input name="U2" type="number" min="1" max="65535" class="d5" required><br>
Receive <input type="checkbox" name="RB">Brightness, <input type="checkbox" name="RC">Color, and <input type="checkbox" name="RX">Effects<br> Receive: <input type="checkbox" name="RB">Brightness, <input type="checkbox" name="RC">Color, and <input type="checkbox" name="RX">Effects<br>
Send notifications on direct change: <input type="checkbox" name="SD"><br> Send notifications on direct change: <input type="checkbox" name="SD"><br>
Send notifications on button press or IR: <input type="checkbox" name="SB"><br> Send notifications on button press or IR: <input type="checkbox" name="SB"><br>
Send Alexa notifications: <input type="checkbox" name="SA"><br> Send Alexa notifications: <input type="checkbox" name="SA"><br>
@ -42,6 +42,9 @@ Send Philips Hue change notifications: <input type="checkbox" name="SH"><br>
Send Macro notifications: <input type="checkbox" name="SM"><br> Send Macro notifications: <input type="checkbox" name="SM"><br>
Send notifications twice: <input type="checkbox" name="S2"><br> Send notifications twice: <input type="checkbox" name="S2"><br>
<i>Reboot required to apply changes. </i> <i>Reboot required to apply changes. </i>
<h3>Instance List</h3>
Enable instance list: <input type="checkbox" name="NL"><br>
Make this instance discoverable: <input type="checkbox" name="NB"><br>
<h3>Realtime</h3> <h3>Realtime</h3>
Receive UDP realtime: <input type="checkbox" name="RD"><br><br> Receive UDP realtime: <input type="checkbox" name="RD"><br><br>
<i>Network DMX input</i><br> <i>Network DMX input</i><br>

View File

@ -60,6 +60,7 @@ input[type="checkbox"] {
-webkit-transform: scale(2); /* Safari and Chrome */ -webkit-transform: scale(2); /* Safari and Chrome */
-o-transform: scale(2); /* Opera */ -o-transform: scale(2); /* Opera */
transform: scale(2); transform: scale(2);
margin-right: 10px;
} }
select { select {
background: #333; background: #333;

View File

@ -62,10 +62,6 @@ void initDMX() {
dmx.init(512); // initialize with bus length dmx.init(512); // initialize with bus length
} }
#if (LEDPIN == 2)
#pragma message "Pin conflict compiling with DMX and LEDs on pin 2. Please set a different LEDPIN."
#endif
#else #else
void handleDMX() {} void handleDMX() {}
void initDMX() {} void initDMX() {}

View File

@ -6,7 +6,7 @@
*/ */
// Autogenerated from wled00/data/style.css, do not edit!! // Autogenerated from wled00/data/style.css, do not edit!!
const char PAGE_settingsCss[] PROGMEM = R"=====(<style>body{font-family:Verdana,sans-serif;text-align:center;background:#222;color:#fff;line-height:200%;margin:0}hr{border-color:#666}button{background:#333;color:#fff;font-family:Verdana,sans-serif;border:.3ch solid #333;border-radius:24px;display:inline-block;font-size:20px;margin:12px 8px 8px;padding:8px 12px;min-width:48px}.toprow{top:0;position:sticky;background-color:#222;z-index:1}.helpB{text-align:left;position:absolute;width:60px}input{background:#333;color:#fff;font-family:Verdana,sans-serif;border:.5ch solid #333}input[type=number]{width:4em;font-size:medium;margin:2px}input[type=number].big{width:80px}input[type=number].small{width:40px}select{margin:2px;font-size:medium}input[type=checkbox]{-ms-transform:scale(2);-moz-transform:scale(2);-webkit-transform:scale(2);-o-transform:scale(2);transform:scale(2)}select{background:#333;color:#fff;font-family:Verdana,sans-serif;border:.5ch solid #333}td{padding:2px}.d5{width:4.5em!important}</style>)====="; const char PAGE_settingsCss[] PROGMEM = R"=====(<style>body{font-family:Verdana,sans-serif;text-align:center;background:#222;color:#fff;line-height:200%;margin:0}hr{border-color:#666}button{background:#333;color:#fff;font-family:Verdana,sans-serif;border:.3ch solid #333;border-radius:24px;display:inline-block;font-size:20px;margin:12px 8px 8px;padding:8px 12px;min-width:48px}.toprow{top:0;position:sticky;background-color:#222;z-index:1}.helpB{text-align:left;position:absolute;width:60px}input{background:#333;color:#fff;font-family:Verdana,sans-serif;border:.5ch solid #333}input[type=number]{width:4em;font-size:medium;margin:2px}input[type=number].big{width:80px}input[type=number].small{width:40px}select{margin:2px;font-size:medium}input[type=checkbox]{-ms-transform:scale(2);-moz-transform:scale(2);-webkit-transform:scale(2);-o-transform:scale(2);transform:scale(2);margin-right:10px}select{background:#333;color:#fff;font-family:Verdana,sans-serif;border:.5ch solid #333}td{padding:2px}.d5{width:4.5em!important}</style>)=====";
// Autogenerated from wled00/data/settings.htm, do not edit!! // Autogenerated from wled00/data/settings.htm, do not edit!!
@ -227,7 +227,7 @@ value="6">6-key black</option><option value="7">9-key red</option></select><br>
<a href="https://github.com/Aircoookie/WLED/wiki/Infrared-Control" <a href="https://github.com/Aircoookie/WLED/wiki/Infrared-Control"
target="_blank">IR info</a><h3>WLED Broadcast</h3>UDP Port: <input name="UP" target="_blank">IR info</a><h3>WLED Broadcast</h3>UDP Port: <input name="UP"
type="number" min="1" max="65535" class="d5" required><br>2nd Port: <input type="number" min="1" max="65535" class="d5" required><br>2nd Port: <input
name="U2" type="number" min="1" max="65535" class="d5" required><br>Receive name="U2" type="number" min="1" max="65535" class="d5" required><br>Receive:
<input type="checkbox" name="RB">Brightness, <input type="checkbox" name="RC"> <input type="checkbox" name="RB">Brightness, <input type="checkbox" name="RC">
Color, and <input type="checkbox" name="RX">Effects<br> Color, and <input type="checkbox" name="RX">Effects<br>
Send notifications on direct change: <input type="checkbox" name="SD"><br> Send notifications on direct change: <input type="checkbox" name="SD"><br>
@ -236,22 +236,24 @@ Send Alexa notifications: <input type="checkbox" name="SA"><br>
Send Philips Hue change notifications: <input type="checkbox" name="SH"><br> Send Philips Hue change notifications: <input type="checkbox" name="SH"><br>
Send Macro notifications: <input type="checkbox" name="SM"><br> Send Macro notifications: <input type="checkbox" name="SM"><br>
Send notifications twice: <input type="checkbox" name="S2"><br><i> Send notifications twice: <input type="checkbox" name="S2"><br><i>
Reboot required to apply changes.</i><h3>Realtime</h3>Receive UDP realtime: Reboot required to apply changes.</i><h3>Instance List</h3>
<input type="checkbox" name="RD"><br><br><i>Network DMX input</i><br>Type: Enable instance list: <input type="checkbox" name="NL"><br>
<select name="DI" onchange="SP(),adj()"><option value="5568">E1.31 (sACN) Make this instance discoverable: <input type="checkbox" name="NB"><br><h3>
</option><option value="6454">Art-Net</option><option value="4048">DDP</option> Realtime</h3>Receive UDP realtime: <input type="checkbox" name="RD"><br><br><i>
<option value="0" selected="selected">Custom port</option></select><br><div Network DMX input</i><br>Type: <select name="DI" onchange="SP(),adj()"><option
id="xp">Port: <input name="EP" type="number" min="1" max="65535" value="5568" value="5568">E1.31 (sACN)</option><option value="6454">Art-Net</option><option
class="d5" required><br></div>Multicast: <input type="checkbox" name="EM"><br> value="4048">DDP</option><option value="0" selected="selected">Custom port
Start universe: <input name="EU" type="number" min="0" max="63999" required><br> </option></select><br><div id="xp">Port: <input name="EP" type="number" min="1"
<i>Reboot required.</i> Check out <a href="https://github.com/LedFx/LedFx" max="65535" value="5568" class="d5" required><br></div>Multicast: <input
target="_blank">LedFx</a>!<br>Skip out-of-sequence packets: <input type="checkbox" name="EM"><br>Start universe: <input name="EU" type="number"
type="checkbox" name="ES"><br>DMX start address: <input name="DA" type="number" min="0" max="63999" required><br><i>Reboot required.</i> Check out <a
min="0" max="510" required><br>DMX mode: <select name="DM"><option value="0"> href="https://github.com/LedFx/LedFx" target="_blank">LedFx</a>!<br>
Disabled</option><option value="1">Single RGB</option><option value="2"> Skip out-of-sequence packets: <input type="checkbox" name="ES"><br>
Single DRGB</option><option value="3">Effect</option><option value="4">Multi RGB DMX start address: <input name="DA" type="number" min="0" max="510" required>
</option><option value="5">Dimmer + Multi RGB</option><option value="6"> <br>DMX mode: <select name="DM"><option value="0">Disabled</option><option
Multi RGBW</option></select><br><a value="1">Single RGB</option><option value="2">Single DRGB</option><option
value="3">Effect</option><option value="4">Multi RGB</option><option value="5">
Dimmer + Multi RGB</option><option value="6">Multi RGBW</option></select><br><a
href="https://github.com/Aircoookie/WLED/wiki/E1.31-DMX" target="_blank"> href="https://github.com/Aircoookie/WLED/wiki/E1.31-DMX" target="_blank">
E1.31 info</a><br>Timeout: <input name="ET" type="number" min="1" max="65000" E1.31 info</a><br>Timeout: <input name="ET" type="number" min="1" max="65000"
required> ms<br>Force max brightness: <input type="checkbox" name="FB"><br> required> ms<br>Force max brightness: <input type="checkbox" name="FB"><br>

File diff suppressed because it is too large Load Diff

View File

@ -101,7 +101,7 @@ void onHueData(void* arg, AsyncClient* client, void *data, size_t len)
hueError = HUE_ERROR_JSON_PARSING; return; hueError = HUE_ERROR_JSON_PARSING; return;
} }
int hueErrorCode = root[0][F("error")][F("type")]; int hueErrorCode = root[0][F("error")]["type"];
if (hueErrorCode)//hue bridge returned error if (hueErrorCode)//hue bridge returned error
{ {
hueError = hueErrorCode; hueError = hueErrorCode;

View File

@ -8,7 +8,7 @@
void deserializeSegment(JsonObject elem, byte it) void deserializeSegment(JsonObject elem, byte it)
{ {
byte id = elem[F("id")] | it; byte id = elem["id"] | it;
if (id < strip.getMaxSegments()) if (id < strip.getMaxSegments())
{ {
WS2812FX::Segment& seg = strip.getSegment(id); WS2812FX::Segment& seg = strip.getSegment(id);
@ -33,7 +33,7 @@ void deserializeSegment(JsonObject elem, byte it)
seg.setOption(SEG_OPTION_ON, elem["on"] | seg.getOption(SEG_OPTION_ON), id); seg.setOption(SEG_OPTION_ON, elem["on"] | seg.getOption(SEG_OPTION_ON), id);
JsonArray colarr = elem[F("col")]; JsonArray colarr = elem["col"];
if (!colarr.isNull()) if (!colarr.isNull())
{ {
for (uint8_t i = 0; i < 3; i++) for (uint8_t i = 0; i < 3; i++)
@ -89,7 +89,7 @@ void deserializeSegment(JsonObject elem, byte it)
//if (pal != seg.palette && pal < strip.getPaletteCount()) strip.setPalette(pal); //if (pal != seg.palette && pal < strip.getPaletteCount()) strip.setPalette(pal);
seg.setOption(SEG_OPTION_SELECTED, elem[F("sel")] | seg.getOption(SEG_OPTION_SELECTED)); seg.setOption(SEG_OPTION_SELECTED, elem[F("sel")] | seg.getOption(SEG_OPTION_SELECTED));
seg.setOption(SEG_OPTION_REVERSED, elem[F("rev")] | seg.getOption(SEG_OPTION_REVERSED)); seg.setOption(SEG_OPTION_REVERSED, elem["rev"] | seg.getOption(SEG_OPTION_REVERSED));
seg.setOption(SEG_OPTION_MIRROR , elem[F("mi")] | seg.getOption(SEG_OPTION_MIRROR )); seg.setOption(SEG_OPTION_MIRROR , elem[F("mi")] | seg.getOption(SEG_OPTION_MIRROR ));
//temporary, strip object gets updated via colorUpdated() //temporary, strip object gets updated via colorUpdated()
@ -198,8 +198,8 @@ bool deserializeState(JsonObject root)
nightlightTargetBri = nl[F("tbri")] | nightlightTargetBri; nightlightTargetBri = nl[F("tbri")] | nightlightTargetBri;
JsonObject udpn = root["udpn"]; JsonObject udpn = root["udpn"];
notifyDirect = udpn[F("send")] | notifyDirect; notifyDirect = udpn["send"] | notifyDirect;
receiveNotifications = udpn[F("recv")] | receiveNotifications; receiveNotifications = udpn["recv"] | receiveNotifications;
bool noNotification = udpn[F("nn")]; //send no notification just for this request bool noNotification = udpn[F("nn")]; //send no notification just for this request
unsigned long timein = root[F("time")] | UINT32_MAX; unsigned long timein = root[F("time")] | UINT32_MAX;
@ -227,7 +227,7 @@ bool deserializeState(JsonObject root)
JsonVariant segVar = root["seg"]; JsonVariant segVar = root["seg"];
if (segVar.is<JsonObject>()) if (segVar.is<JsonObject>())
{ {
int id = segVar[F("id")] | -1; int id = segVar["id"] | -1;
if (id < 0) { //set all selected segments if (id < 0) { //set all selected segments
bool didSet = false; bool didSet = false;
@ -281,7 +281,8 @@ bool deserializeState(JsonObject root)
JsonObject playlist = root[F("playlist")]; JsonObject playlist = root[F("playlist")];
if (!playlist.isNull()) { if (!playlist.isNull()) {
loadPlaylist(playlist); return stateResponse; //maybe we need not return here loadPlaylist(playlist);
noNotification = true; //do not notify both for this request and the first playlist entry
} }
colorUpdated(noNotification ? NOTIFIER_CALL_MODE_NO_NOTIFY : NOTIFIER_CALL_MODE_DIRECT_CHANGE); colorUpdated(noNotification ? NOTIFIER_CALL_MODE_NO_NOTIFY : NOTIFIER_CALL_MODE_DIRECT_CHANGE);
@ -291,7 +292,7 @@ bool deserializeState(JsonObject root)
void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id, bool forPreset, bool segmentBounds) void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id, bool forPreset, bool segmentBounds)
{ {
root[F("id")] = id; root["id"] = id;
if (segmentBounds) { if (segmentBounds) {
root[F("start")] = seg.start; root[F("start")] = seg.start;
root["stop"] = seg.stop; root["stop"] = seg.stop;
@ -329,7 +330,7 @@ void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id, bool fo
root[F("ix")] = seg.intensity; root[F("ix")] = seg.intensity;
root[F("pal")] = seg.palette; root[F("pal")] = seg.palette;
root[F("sel")] = seg.isSelected(); root[F("sel")] = seg.isSelected();
root[F("rev")] = seg.getOption(SEG_OPTION_REVERSED); root["rev"] = seg.getOption(SEG_OPTION_REVERSED);
root[F("mi")] = seg.getOption(SEG_OPTION_MIRROR); root[F("mi")] = seg.getOption(SEG_OPTION_MIRROR);
} }
@ -370,8 +371,8 @@ void serializeState(JsonObject root, bool forPreset, bool includeBri, bool segme
} }
JsonObject udpn = root.createNestedObject("udpn"); JsonObject udpn = root.createNestedObject("udpn");
udpn[F("send")] = notifyDirect; udpn["send"] = notifyDirect;
udpn[F("recv")] = receiveNotifications; udpn["recv"] = receiveNotifications;
root[F("lor")] = realtimeOverride; root[F("lor")] = realtimeOverride;
} }
@ -484,7 +485,7 @@ void serializeInfo(JsonObject root)
fs_info["t"] = fsBytesTotal / 1000; fs_info["t"] = fsBytesTotal / 1000;
fs_info[F("pmt")] = presetsModifiedTime; fs_info[F("pmt")] = presetsModifiedTime;
root[F("ndc")] = Nodes.size(); root[F("ndc")] = nodeListEnabled ? (int)Nodes.size() : -1;
#ifdef ARDUINO_ARCH_ESP32 #ifdef ARDUINO_ARCH_ESP32
#ifdef WLED_DEBUG #ifdef WLED_DEBUG
@ -719,8 +720,8 @@ void serializeNodes(JsonObject root)
{ {
JsonObject node = nodes.createNestedObject(); JsonObject node = nodes.createNestedObject();
node[F("name")] = it->second.nodeName; node[F("name")] = it->second.nodeName;
node[F("type")] = it->second.nodeType; node["type"] = it->second.nodeType;
node[F("ip")] = it->second.ip.toString(); node["ip"] = it->second.ip.toString();
node[F("age")] = it->second.age; node[F("age")] = it->second.age;
node[F("vid")] = it->second.build; node[F("vid")] = it->second.build;
} }

View File

@ -34,46 +34,6 @@ void shufflePlaylist() {
} }
} }
/*
* The same thing as saving and loading playlist can be achieved using JSON API saved in a preset.
*
void deserializePlaylist() {
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
DEBUG_PRINTLN(F("Reading playlist from /playlist.json..."));
if (!readObjectFromFile("/playlist.json", nullptr, &doc)) return; //if file does not exist just exit
JsonObject playlist = doc[F("playlist")];
if (!playlist.isNull()) loadPlaylist(playlist);
}
void serializePlaylist() {
DynamicJsonDocument doc(JSON_BUFFER_SIZE/8); // we don't need big buffer (>1k is ok)
DEBUG_PRINTLN(F("Writing playlist to /playlist.json..."));
PlaylistEntry* entries = reinterpret_cast<PlaylistEntry*>(playlistEntries);
JsonObject playlist = doc.createNestedObject(F("playlist"));
JsonArray ps = playlist.createNestedArray(F("ps"));
JsonArray dur = playlist.createNestedArray(F("dur"));
JsonArray tr = playlist.createNestedArray(F("transition"));
for (uint8_t i=0; i<playlistLen; i++) {
ps.add(entries[i].preset);
dur.add(entries[i].dur);
tr.add(entries[i].tr);
}
playlist[F("repeat")] = playlistRepeat; // TODO: this one is decreasing with each loop
playlist[F("end")] = playlistEndPreset;
File f = WLED_FS.open("/playlist.json", "w");
if (f) serializeJson(doc, f);
f.close();
}
*/
void unloadPlaylist() { void unloadPlaylist() {
if (playlistEntries != nullptr) { if (playlistEntries != nullptr) {
delete[] playlistEntries; delete[] playlistEntries;
@ -84,7 +44,6 @@ void unloadPlaylist() {
} }
void loadPlaylist(JsonObject playlistObj) { void loadPlaylist(JsonObject playlistObj) {
unloadPlaylist(); unloadPlaylist();
JsonArray presets = playlistObj["ps"]; JsonArray presets = playlistObj["ps"];
@ -147,9 +106,7 @@ void handlePlaylist() {
++playlistIndex %= playlistLen; // -1 at 1st run (limit to playlistLen) ++playlistIndex %= playlistLen; // -1 at 1st run (limit to playlistLen)
if (!playlistRepeat && !playlistIndex) { //stop if repeat == 0 and restart of playlist if (!playlistRepeat && !playlistIndex) { //stop if repeat == 0 and restart of playlist
currentPlaylist = -1; unloadPlaylist();
delete[] playlistEntries;
playlistEntries = nullptr;
if (playlistEndPreset) applyPreset(playlistEndPreset); if (playlistEndPreset) applyPreset(playlistEndPreset);
return; return;
} }

View File

@ -221,6 +221,10 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
notifyMacro = request->hasArg(F("SM")); notifyMacro = request->hasArg(F("SM"));
notifyTwice = request->hasArg(F("S2")); notifyTwice = request->hasArg(F("S2"));
nodeListEnabled = request->hasArg(F("NL"));
if (!nodeListEnabled) Nodes.clear();
nodeBroadcastEnabled = request->hasArg(F("NB"));
receiveDirect = request->hasArg(F("RD")); receiveDirect = request->hasArg(F("RD"));
e131SkipOutOfSequence = request->hasArg(F("ES")); e131SkipOutOfSequence = request->hasArg(F("ES"));
e131Multicast = request->hasArg(F("EM")); e131Multicast = request->hasArg(F("EM"));

View File

@ -169,7 +169,7 @@ void handleNotifications()
// WLED nodes info notifications // WLED nodes info notifications
if (isSupp && udpIn[0] == 255 && udpIn[1] == 1 && len >= 40) { if (isSupp && udpIn[0] == 255 && udpIn[1] == 1 && len >= 40) {
if (notifier2Udp.remoteIP() == Network.localIP()) return; if (!nodeListEnabled || notifier2Udp.remoteIP() == Network.localIP()) return;
uint8_t unit = udpIn[39]; uint8_t unit = udpIn[39];
NodesMap::iterator it = Nodes.find(unit); NodesMap::iterator it = Nodes.find(unit);

View File

@ -258,7 +258,7 @@ void WLED::loop()
yield(); yield();
// refresh WLED nodes list // refresh WLED nodes list
refreshNodeList(); refreshNodeList();
sendSysInfoUDP(); if (nodeBroadcastEnabled) sendSysInfoUDP();
} }
yield(); yield();
@ -313,10 +313,13 @@ void WLED::setup()
DEBUG_PRINTLN(ESP.getFreeHeap()); DEBUG_PRINTLN(ESP.getFreeHeap());
registerUsermods(); registerUsermods();
//DEBUG_PRINT(F("LEDs inited. heap usage ~")); //DEBUG_PRINT(F("LEDs inited. heap usage ~"));
//DEBUG_PRINTLN(heapPreAlloc - ESP.getFreeHeap()); //DEBUG_PRINTLN(heapPreAlloc - ESP.getFreeHeap());
#ifdef WLED_USE_DMX //reserve GPIO2 as hardcoded DMX pin
pinManager.allocatePin(2);
#endif
bool fsinit = false; bool fsinit = false;
DEBUGFS_PRINTLN(F("Mount FS")); DEBUGFS_PRINTLN(F("Mount FS"));
#ifdef ARDUINO_ARCH_ESP32 #ifdef ARDUINO_ARCH_ESP32
@ -351,7 +354,9 @@ void WLED::setup()
if (strcmp(clientSSID, DEFAULT_CLIENT_SSID) == 0) if (strcmp(clientSSID, DEFAULT_CLIENT_SSID) == 0)
showWelcomePage = true; showWelcomePage = true;
WiFi.persistent(false); WiFi.persistent(false);
#ifdef WLED_USE_ETHERNET
WiFi.onEvent(WiFiEvent); WiFi.onEvent(WiFiEvent);
#endif
Serial.println(F("Ada")); Serial.println(F("Ada"));

View File

@ -8,7 +8,7 @@
*/ */
// version code in format yymmddb (b = daily build) // version code in format yymmddb (b = daily build)
#define VERSION 2103100 #define VERSION 2103130
//uncomment this if you have a "my_config.h" file you'd like to use //uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG //#define WLED_USE_MY_CONFIG
@ -253,6 +253,8 @@ WLED_GLOBAL bool syncToggleReceive _INIT(false); // UIs which only have a
// Sync CONFIG // Sync CONFIG
WLED_GLOBAL NodesMap Nodes; WLED_GLOBAL NodesMap Nodes;
WLED_GLOBAL bool nodeListEnabled _INIT(true);
WLED_GLOBAL bool nodeBroadcastEnabled _INIT(true);
WLED_GLOBAL bool buttonEnabled _INIT(true); WLED_GLOBAL bool buttonEnabled _INIT(true);
WLED_GLOBAL byte irEnabled _INIT(0); // Infrared receiver WLED_GLOBAL byte irEnabled _INIT(0); // Infrared receiver

View File

@ -282,6 +282,9 @@ void getSettingsJS(byte subPage, char* dest)
} }
if (i) oappend(SET_F(",")); if (i) oappend(SET_F(","));
oappend(SET_F("6,7,8,9,10,11")); // flash memory pins oappend(SET_F("6,7,8,9,10,11")); // flash memory pins
#ifdef WLED_ENABLE_DMX
oappend(SET_F(",2")); // DMX hardcoded pin
#endif
#ifdef WLED_DEBUG #ifdef WLED_DEBUG
oappend(SET_F(",1")); // debug output (TX) pin oappend(SET_F(",1")); // debug output (TX) pin
#endif #endif
@ -376,6 +379,10 @@ void getSettingsJS(byte subPage, char* dest)
sappend('c',SET_F("SH"),notifyHue); sappend('c',SET_F("SH"),notifyHue);
sappend('c',SET_F("SM"),notifyMacro); sappend('c',SET_F("SM"),notifyMacro);
sappend('c',SET_F("S2"),notifyTwice); sappend('c',SET_F("S2"),notifyTwice);
sappend('c',SET_F("NL"),nodeListEnabled);
sappend('c',SET_F("NB"),nodeBroadcastEnabled);
sappend('c',SET_F("RD"),receiveDirect); sappend('c',SET_F("RD"),receiveDirect);
sappend('v',SET_F("EP"),e131Port); sappend('v',SET_F("EP"),e131Port);
sappend('c',SET_F("ES"),e131SkipOutOfSequence); sappend('c',SET_F("ES"),e131SkipOutOfSequence);