From 276a93605db67f8ed9557ffbeb72b5564852df5b Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Fri, 9 Feb 2024 22:15:29 +0100 Subject: [PATCH] Multiupdate - allow DMX for S2 & C3 (ESPDMX, needs testing) - (debug) string cleanup & optimisation - WLED_BRAND for AP SSID --- usermods/BH1750_v2/usermod_bh1750.h | 2 +- usermods/Cronixie/usermod_cronixie.h | 4 +- usermods/RelayBlinds/usermod.cpp | 4 +- .../usermod_sn_photoresistor.h | 2 +- .../Si7021_MQTT_HA/usermod_si7021_mqtt_ha.h | 4 +- usermods/audioreactive/audio_reactive.h | 48 +++++++++------ usermods/audioreactive/audio_source.h | 10 ++-- usermods/boblight/boblight.h | 6 +- usermods/mpu6050_imu/usermod_mpu6050_imu.h | 2 +- usermods/multi_relay/usermod_multi_relay.h | 2 +- .../usermod_v2_SensorsToMqtt.h | 4 +- .../usermod_v2_klipper_percentage.h | 30 +++++----- usermods/wireguard/wireguard.h | 4 +- wled00/cfg.cpp | 14 ++--- wled00/const.h | 19 +++++- wled00/dmx.cpp | 6 +- wled00/file.cpp | 4 +- wled00/json.cpp | 49 +++++++-------- wled00/led.cpp | 1 - wled00/pin_manager.cpp | 2 +- wled00/set.cpp | 8 +-- wled00/src/dependencies/dmx/ESPDMX.cpp | 2 +- wled00/util.cpp | 2 +- wled00/wled.cpp | 10 ++-- wled00/wled.h | 59 +++++++------------ wled00/wled_server.cpp | 35 +++++++---- 26 files changed, 167 insertions(+), 166 deletions(-) diff --git a/usermods/BH1750_v2/usermod_bh1750.h b/usermods/BH1750_v2/usermod_bh1750.h index 006040dda..ede4aabc4 100644 --- a/usermods/BH1750_v2/usermod_bh1750.h +++ b/usermods/BH1750_v2/usermod_bh1750.h @@ -86,7 +86,7 @@ private: StaticJsonDocument<600> doc; - doc[F("name")] = String(serverDescription) + F(" ") + name; + doc[F("name")] = String(serverDescription) + " " + name; doc[F("state_topic")] = topic; doc[F("unique_id")] = String(mqttClientID) + name; if (unitOfMeasurement != "") diff --git a/usermods/Cronixie/usermod_cronixie.h b/usermods/Cronixie/usermod_cronixie.h index 534fd3a7c..671c5d134 100644 --- a/usermods/Cronixie/usermod_cronixie.h +++ b/usermods/Cronixie/usermod_cronixie.h @@ -114,7 +114,7 @@ class UsermodCronixie : public Usermod { //W Week of Month | WW Week of Year //D Day of Week | DD Day Of Month | DDD Day Of Year - DEBUG_PRINT("cset "); + DEBUG_PRINT(F("cset ")); DEBUG_PRINTLN(cronixieDisplay); for (int i = 0; i < 6; i++) @@ -160,7 +160,7 @@ class UsermodCronixie : public Usermod { //case 'v': break; //user var1 } } - DEBUG_PRINT("result "); + DEBUG_PRINT(F("result ")); for (int i = 0; i < 5; i++) { DEBUG_PRINT((int)dP[i]); diff --git a/usermods/RelayBlinds/usermod.cpp b/usermods/RelayBlinds/usermod.cpp index ee61b0cce..911053099 100644 --- a/usermods/RelayBlinds/usermod.cpp +++ b/usermods/RelayBlinds/usermod.cpp @@ -43,12 +43,12 @@ void handleRelay() digitalWrite(PIN_UP_RELAY, LOW); upActiveBefore = true; upStartTime = millis(); - DEBUG_PRINTLN("UPA"); + DEBUG_PRINTLN(F("UPA")); } if (millis()- upStartTime > PIN_ON_TIME) { upActive = false; - DEBUG_PRINTLN("UPN"); + DEBUG_PRINTLN(F("UPN")); } } else if (upActiveBefore) { diff --git a/usermods/SN_Photoresistor/usermod_sn_photoresistor.h b/usermods/SN_Photoresistor/usermod_sn_photoresistor.h index 1e92d7d71..c09b5d907 100644 --- a/usermods/SN_Photoresistor/usermod_sn_photoresistor.h +++ b/usermods/SN_Photoresistor/usermod_sn_photoresistor.h @@ -119,7 +119,7 @@ public: } else { - DEBUG_PRINTLN("Missing MQTT connection. Not publishing data"); + DEBUG_PRINTLN(F("Missing MQTT connection. Not publishing data")); } } #endif diff --git a/usermods/Si7021_MQTT_HA/usermod_si7021_mqtt_ha.h b/usermods/Si7021_MQTT_HA/usermod_si7021_mqtt_ha.h index bdf784844..9f027382d 100644 --- a/usermods/Si7021_MQTT_HA/usermod_si7021_mqtt_ha.h +++ b/usermods/Si7021_MQTT_HA/usermod_si7021_mqtt_ha.h @@ -93,8 +93,8 @@ class Si7021_MQTT_HA : public Usermod JsonObject device = doc.createNestedObject("device"); // attach the sensor to the same device device["name"] = String(serverDescription); - device["model"] = "WLED"; - device["manufacturer"] = "Aircoookie"; + device["model"] = F(WLED_PRODUCT_NAME); + device["manufacturer"] = F(WLED_BRAND); device["identifiers"] = String("wled-") + String(serverDescription); device["sw_version"] = VERSION; diff --git a/usermods/audioreactive/audio_reactive.h b/usermods/audioreactive/audio_reactive.h index 4016ebfb2..4e433ba99 100644 --- a/usermods/audioreactive/audio_reactive.h +++ b/usermods/audioreactive/audio_reactive.h @@ -4,6 +4,10 @@ #include #include +#ifdef WLED_ENABLE_DMX + #error This audio reactive usermod is not compatible with DMX Out. +#endif + #ifndef ARDUINO_ARCH_ESP32 #error This audio reactive usermod does not support the ESP8266. #endif @@ -662,6 +666,9 @@ class AudioReactive : public Usermod { // strings to reduce flash memory usage (used more than twice) static const char _name[]; static const char _enabled[]; + static const char _config[]; + static const char _dynamics[]; + static const char _frequency[]; static const char _inputLvl[]; static const char _analogmic[]; static const char _digitalmic[]; @@ -1275,16 +1282,16 @@ class AudioReactive : public Usermod { { #ifdef WLED_DEBUG if ((disableSoundProcessing == false) && (audioSyncEnabled == 0)) { // we just switched to "disabled" - DEBUG_PRINTLN("[AR userLoop] realtime mode active - audio processing suspended."); - DEBUG_PRINTF( " RealtimeMode = %d; RealtimeOverride = %d\n", int(realtimeMode), int(realtimeOverride)); + DEBUG_PRINTLN(F("[AR userLoop] realtime mode active - audio processing suspended.")); + DEBUG_PRINTF(" RealtimeMode = %d; RealtimeOverride = %d\n", int(realtimeMode), int(realtimeOverride)); } #endif disableSoundProcessing = true; } else { #ifdef WLED_DEBUG if ((disableSoundProcessing == true) && (audioSyncEnabled == 0) && audioSource->isInitialized()) { // we just switched to "enabled" - DEBUG_PRINTLN("[AR userLoop] realtime mode ended - audio processing resumed."); - DEBUG_PRINTF( " RealtimeMode = %d; RealtimeOverride = %d\n", int(realtimeMode), int(realtimeOverride)); + DEBUG_PRINTLN(F("[AR userLoop] realtime mode ended - audio processing resumed.")); + DEBUG_PRINTF(" RealtimeMode = %d; RealtimeOverride = %d\n", int(realtimeMode), int(realtimeOverride)); } #endif if ((disableSoundProcessing == true) && (audioSyncEnabled == 0)) lastUMRun = millis(); // just left "realtime mode" - update timekeeping @@ -1703,29 +1710,29 @@ class AudioReactive : public Usermod { #endif JsonObject dmic = top.createNestedObject(FPSTR(_digitalmic)); - dmic[F("type")] = dmType; + dmic["type"] = dmType; JsonArray pinArray = dmic.createNestedArray("pin"); pinArray.add(i2ssdPin); pinArray.add(i2swsPin); pinArray.add(i2sckPin); pinArray.add(mclkPin); - JsonObject cfg = top.createNestedObject("config"); + JsonObject cfg = top.createNestedObject(FPSTR(_config)); cfg[F("squelch")] = soundSquelch; cfg[F("gain")] = sampleGain; cfg[F("AGC")] = soundAgc; - JsonObject dynLim = top.createNestedObject("dynamics"); + JsonObject dynLim = top.createNestedObject(FPSTR(_dynamics)); dynLim[F("limiter")] = limiterOn; dynLim[F("rise")] = attackTime; dynLim[F("fall")] = decayTime; - JsonObject freqScale = top.createNestedObject("frequency"); + JsonObject freqScale = top.createNestedObject(FPSTR(_frequency)); freqScale[F("scale")] = FFTScalingMode; JsonObject sync = top.createNestedObject("sync"); - sync[F("port")] = audioSyncPort; - sync[F("mode")] = audioSyncEnabled; + sync["port"] = audioSyncPort; + sync["mode"] = audioSyncEnabled; } @@ -1773,18 +1780,18 @@ class AudioReactive : public Usermod { configComplete &= getJsonValue(top[FPSTR(_digitalmic)]["pin"][2], i2sckPin); configComplete &= getJsonValue(top[FPSTR(_digitalmic)]["pin"][3], mclkPin); - configComplete &= getJsonValue(top["config"][F("squelch")], soundSquelch); - configComplete &= getJsonValue(top["config"][F("gain")], sampleGain); - configComplete &= getJsonValue(top["config"][F("AGC")], soundAgc); + configComplete &= getJsonValue(top[FPSTR(_config)][F("squelch")], soundSquelch); + configComplete &= getJsonValue(top[FPSTR(_config)][F("gain")], sampleGain); + configComplete &= getJsonValue(top[FPSTR(_config)][F("AGC")], soundAgc); - configComplete &= getJsonValue(top["dynamics"][F("limiter")], limiterOn); - configComplete &= getJsonValue(top["dynamics"][F("rise")], attackTime); - configComplete &= getJsonValue(top["dynamics"][F("fall")], decayTime); + configComplete &= getJsonValue(top[FPSTR(_dynamics)][F("limiter")], limiterOn); + configComplete &= getJsonValue(top[FPSTR(_dynamics)][F("rise")], attackTime); + configComplete &= getJsonValue(top[FPSTR(_dynamics)][F("fall")], decayTime); - configComplete &= getJsonValue(top["frequency"][F("scale")], FFTScalingMode); + configComplete &= getJsonValue(top[FPSTR(_frequency)][F("scale")], FFTScalingMode); - configComplete &= getJsonValue(top["sync"][F("port")], audioSyncPort); - configComplete &= getJsonValue(top["sync"][F("mode")], audioSyncEnabled); + configComplete &= getJsonValue(top["sync"]["port"], audioSyncPort); + configComplete &= getJsonValue(top["sync"]["mode"], audioSyncEnabled); if (initDone) { // add/remove custom/audioreactive palettes @@ -1955,6 +1962,9 @@ void AudioReactive::fillAudioPalettes() { // strings to reduce flash memory usage (used more than twice) const char AudioReactive::_name[] PROGMEM = "AudioReactive"; const char AudioReactive::_enabled[] PROGMEM = "enabled"; +const char AudioReactive::_config[] PROGMEM = "config"; +const char AudioReactive::_dynamics[] PROGMEM = "dynamics"; +const char AudioReactive::_frequency[] PROGMEM = "frequency"; const char AudioReactive::_inputLvl[] PROGMEM = "inputLevel"; #if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) const char AudioReactive::_analogmic[] PROGMEM = "analogmic"; diff --git a/usermods/audioreactive/audio_source.h b/usermods/audioreactive/audio_source.h index e970e19c6..18d00da3c 100644 --- a/usermods/audioreactive/audio_source.h +++ b/usermods/audioreactive/audio_source.h @@ -192,7 +192,7 @@ class I2SSource : public AudioSource { } virtual void initialize(int8_t i2swsPin = I2S_PIN_NO_CHANGE, int8_t i2ssdPin = I2S_PIN_NO_CHANGE, int8_t i2sckPin = I2S_PIN_NO_CHANGE, int8_t mclkPin = I2S_PIN_NO_CHANGE) { - DEBUGSR_PRINTLN("I2SSource:: initialize()."); + DEBUGSR_PRINTLN(F("I2SSource:: initialize().")); if (i2swsPin != I2S_PIN_NO_CHANGE && i2ssdPin != I2S_PIN_NO_CHANGE) { if (!pinManager.allocatePin(i2swsPin, true, PinOwner::UM_Audioreactive) || !pinManager.allocatePin(i2ssdPin, false, PinOwner::UM_Audioreactive)) { // #206 @@ -413,7 +413,7 @@ public: }; void initialize(int8_t i2swsPin, int8_t i2ssdPin, int8_t i2sckPin, int8_t mclkPin) { - DEBUGSR_PRINTLN("ES7243:: initialize();"); + DEBUGSR_PRINTLN(F("ES7243:: initialize();")); if ((i2sckPin < 0) || (mclkPin < 0)) { DEBUGSR_PRINTF("\nAR: invalid I2S pin: SCK=%d, MCLK=%d\n", i2sckPin, mclkPin); return; @@ -529,7 +529,7 @@ class ES8388Source : public I2SSource { }; void initialize(int8_t i2swsPin, int8_t i2ssdPin, int8_t i2sckPin, int8_t mclkPin) { - DEBUGSR_PRINTLN("ES8388Source:: initialize();"); + DEBUGSR_PRINTLN(F("ES8388Source:: initialize();")); if ((i2sckPin < 0) || (mclkPin < 0)) { DEBUGSR_PRINTF("\nAR: invalid I2S pin: SCK=%d, MCLK=%d\n", i2sckPin, mclkPin); return; @@ -587,7 +587,7 @@ class I2SAdcSource : public I2SSource { AudioSourceType getType(void) {return(Type_I2SAdc);} void initialize(int8_t audioPin, int8_t = I2S_PIN_NO_CHANGE, int8_t = I2S_PIN_NO_CHANGE, int8_t = I2S_PIN_NO_CHANGE) { - DEBUGSR_PRINTLN("I2SAdcSource:: initialize()."); + DEBUGSR_PRINTLN(F("I2SAdcSource:: initialize().")); _myADCchannel = 0x0F; if(!pinManager.allocatePin(audioPin, false, PinOwner::UM_Audioreactive)) { DEBUGSR_PRINTF("failed to allocate GPIO for audio analog input: %d\n", audioPin); @@ -759,7 +759,7 @@ class SPH0654 : public I2SSource { {} void initialize(int8_t i2swsPin, int8_t i2ssdPin, int8_t i2sckPin, int8_t = I2S_PIN_NO_CHANGE) { - DEBUGSR_PRINTLN("SPH0654:: initialize();"); + DEBUGSR_PRINTLN(F("SPH0654:: initialize();")); I2SSource::initialize(i2swsPin, i2ssdPin, i2sckPin); #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) // these registers are only existing in "classic" ESP32 diff --git a/usermods/boblight/boblight.h b/usermods/boblight/boblight.h index 55803a24d..6744d87e5 100644 --- a/usermods/boblight/boblight.h +++ b/usermods/boblight/boblight.h @@ -318,7 +318,7 @@ class BobLightUsermod : public Usermod { void addToConfig(JsonObject& root) override { JsonObject umData = root.createNestedObject(FPSTR(_name)); umData[FPSTR(_enabled)] = enabled; - umData[F("port")] = bobPort; + umData[ "port" ] = bobPort; umData[F("top")] = top; umData[F("bottom")] = bottom; umData[F("left")] = left; @@ -334,7 +334,7 @@ class BobLightUsermod : public Usermod { configComplete &= getJsonValue(umData[FPSTR(_enabled)], en); enable(en); - configComplete &= getJsonValue(umData[F("port")], bobPort); + configComplete &= getJsonValue(umData[ "port" ], bobPort); configComplete &= getJsonValue(umData[F("bottom")], bottom, 16); configComplete &= getJsonValue(umData[F("top")], top, 16); configComplete &= getJsonValue(umData[F("left")], left, 9); @@ -392,7 +392,7 @@ void BobLightUsermod::pollBob() { //get data from the client while (bobClient.available()) { String input = bobClient.readStringUntil('\n'); - // DEBUG_PRINT("Client: "); DEBUG_PRINTLN(input); // may be to stressful on Serial + // DEBUG_PRINT(F("Client: ")); DEBUG_PRINTLN(input); // may be to stressful on Serial if (input.startsWith(F("hello"))) { DEBUG_PRINTLN(F("hello")); bobClient.print(F("hello\n")); diff --git a/usermods/mpu6050_imu/usermod_mpu6050_imu.h b/usermods/mpu6050_imu/usermod_mpu6050_imu.h index a3301bfff..51dd646c7 100644 --- a/usermods/mpu6050_imu/usermod_mpu6050_imu.h +++ b/usermods/mpu6050_imu/usermod_mpu6050_imu.h @@ -233,7 +233,7 @@ class MPU6050Driver : public Usermod { * Use it to initialize network interfaces */ void connected() { - //DEBUG_PRINTLN("Connected to WiFi!"); + //DEBUG_PRINTLN(F("Connected to WiFi!")); } diff --git a/usermods/multi_relay/usermod_multi_relay.h b/usermods/multi_relay/usermod_multi_relay.h index db8823ed9..2f47693e9 100644 --- a/usermods/multi_relay/usermod_multi_relay.h +++ b/usermods/multi_relay/usermod_multi_relay.h @@ -262,7 +262,7 @@ void MultiRelay::InitHtmlAPIHandle() { // https://github.com/me-no-dev/ESPAsync DEBUG_PRINTLN(F("Relays: Initialize HTML API")); server.on("/relays", HTTP_GET, [this](AsyncWebServerRequest *request) { - DEBUG_PRINTLN("Relays: HTML API"); + DEBUG_PRINTLN(F("Relays: HTML API")); String janswer; String error = ""; //int params = request->params(); diff --git a/usermods/sensors_to_mqtt/usermod_v2_SensorsToMqtt.h b/usermods/sensors_to_mqtt/usermod_v2_SensorsToMqtt.h index 4f51750ac..9b5bd8c88 100644 --- a/usermods/sensors_to_mqtt/usermod_v2_SensorsToMqtt.h +++ b/usermods/sensors_to_mqtt/usermod_v2_SensorsToMqtt.h @@ -85,8 +85,8 @@ private: JsonObject device = doc.createNestedObject("device"); // attach the sensor to the same device device["identifiers"] = String("wled-sensor-") + mqttClientID; - device["manufacturer"] = "Aircoookie"; - device["model"] = "WLED"; + device["manufacturer"] = F(WLED_BRAND); + device["model"] = F(WLED_PRODUCT_NAME); device["sw_version"] = VERSION; device["name"] = mqttClientID; diff --git a/usermods/usermod_v2_klipper_percentage/usermod_v2_klipper_percentage.h b/usermods/usermod_v2_klipper_percentage/usermod_v2_klipper_percentage.h index 2f591b154..bd4170dd2 100644 --- a/usermods/usermod_v2_klipper_percentage/usermod_v2_klipper_percentage.h +++ b/usermods/usermod_v2_klipper_percentage/usermod_v2_klipper_percentage.h @@ -6,7 +6,7 @@ class klipper_percentage : public Usermod { private: unsigned long lastTime = 0; - String ip = "192.168.25.207"; + String ip = F("0.0.0.0"); WiFiClient wifiClient; char errorMessage[100] = ""; int printPercent = 0; @@ -30,7 +30,7 @@ private: { // Send HTTP request client.println(F("GET /printer/objects/query?virtual_sdcard=progress HTTP/1.0")); - client.println("Host: " + ip); + client.print(F("Host: ")); client.println(ip); client.println(F("Connection: close")); if (client.println() == 0) { @@ -41,7 +41,7 @@ private: // Check HTTP status char status[32] = {0}; client.readBytesUntil('\r', status, sizeof(status)); - if (strcmp(status, "HTTP/1.1 200 OK") != 0) + if (strcmp_P(status, PSTR("HTTP/1.1 200 OK")) != 0) { strcat(errorMessage, PSTR("Unexpected response: ")); strcat(errorMessage, status); @@ -86,11 +86,11 @@ public: strcat(errorMessage, PSTR("deserializeJson() failed: ")); strcat(errorMessage, error.c_str()); } - printPercent = (int)(klipperDoc["result"]["status"]["virtual_sdcard"]["progress"].as() * 100); + printPercent = (int)(klipperDoc[F("result")][F("status")][F("virtual_sdcard")][F("progress")].as() * 100); - DEBUG_PRINT("Percent: "); - DEBUG_PRINTLN((int)(klipperDoc["result"]["status"]["virtual_sdcard"]["progress"].as() * 100)); - DEBUG_PRINT("LEDs: "); + DEBUG_PRINT(F("Percent: ")); + DEBUG_PRINTLN((int)(klipperDoc[F("result")][F("status")][F("virtual_sdcard")][F("progress")].as() * 100)); + DEBUG_PRINT(F("LEDs: ")); DEBUG_PRINTLN(direction == 2 ? (strip.getLengthTotal() / 2) * printPercent / 100 : strip.getLengthTotal() * printPercent / 100); } else @@ -106,10 +106,10 @@ public: void addToConfig(JsonObject &root) { - JsonObject top = root.createNestedObject("Klipper Printing Percentage"); - top["Enabled"] = enabled; - top["Klipper IP"] = ip; - top["Direction"] = direction; + JsonObject top = root.createNestedObject(F("Klipper Printing Percentage")); + top[F("Enabled")] = enabled; + top[F("Klipper IP")] = ip; + top[F("Direction")] = direction; } bool readFromConfig(JsonObject &root) @@ -117,12 +117,12 @@ public: // default settings values could be set here (or below using the 3-argument getJsonValue()) instead of in the class definition or constructor // setting them inside readFromConfig() is slightly more robust, handling the rare but plausible use case of single value being missing after boot (e.g. if the cfg.json was manually edited and a value was removed) - JsonObject top = root["Klipper Printing Percentage"]; + JsonObject top = root[F("Klipper Printing Percentage")]; bool configComplete = !top.isNull(); - configComplete &= getJsonValue(top["Klipper IP"], ip); - configComplete &= getJsonValue(top["Enabled"], enabled); - configComplete &= getJsonValue(top["Direction"], direction); + configComplete &= getJsonValue(top[F("Klipper IP")], ip); + configComplete &= getJsonValue(top[F("Enabled")], enabled); + configComplete &= getJsonValue(top[F("Direction")], direction); return configComplete; } diff --git a/usermods/wireguard/wireguard.h b/usermods/wireguard/wireguard.h index c4e1fd504..8c88d0001 100644 --- a/usermods/wireguard/wireguard.h +++ b/usermods/wireguard/wireguard.h @@ -66,7 +66,7 @@ class WireguardUsermod : public Usermod { void addToConfig(JsonObject& root) { JsonObject top = root.createNestedObject(F("WireGuard")); top[F("host")] = endpoint_address; - top[F("port")] = endpoint_port; + top["port"] = endpoint_port; top["ip"] = local_ip.toString(); top["psk"] = preshared_key; top[F("pem")] = private_key; @@ -77,7 +77,7 @@ class WireguardUsermod : public Usermod { bool readFromConfig(JsonObject& root) { JsonObject top = root[F("WireGuard")]; - if (top[F("host")].isNull() || top[F("port")].isNull() || top["ip"].isNull() || top[F("pem")].isNull() || top[F("pub")].isNull() || top[F("tz")].isNull()) { + if (top[F("host")].isNull() || top["port"].isNull() || top["ip"].isNull() || top[F("pem")].isNull() || top[F("pub")].isNull() || top[F("tz")].isNull()) { is_enabled = false; return false; } else { diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index 3a61c1225..771ada25b 100755 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -421,7 +421,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { CJSON(useESPNowSync, if_sync[F("espnow")]); #endif - JsonObject if_sync_recv = if_sync["recv"]; + JsonObject if_sync_recv = if_sync[F("recv")]; CJSON(receiveNotificationBrightness, if_sync_recv["bri"]); CJSON(receiveNotificationColor, if_sync_recv["col"]); CJSON(receiveNotificationEffects, if_sync_recv["fx"]); @@ -429,7 +429,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { CJSON(receiveSegmentOptions, if_sync_recv["seg"]); CJSON(receiveSegmentBounds, if_sync_recv["sb"]); - JsonObject if_sync_send = if_sync["send"]; + JsonObject if_sync_send = if_sync[F("send")]; CJSON(sendNotifications, if_sync_send["en"]); sendNotificationsRT = sendNotifications; CJSON(notifyDirect, if_sync_send[F("dir")]); @@ -440,7 +440,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { if (if_sync_send[F("twice")]) udpNumRetries = 1; // import setting from 0.13 and earlier CJSON(udpNumRetries, if_sync_send["ret"]); - JsonObject if_nodes = interfaces["nodes"]; + JsonObject if_nodes = interfaces[F("nodes")]; CJSON(nodeListEnabled, if_nodes[F("list")]); CJSON(nodeBroadcastEnabled, if_nodes[F("bcast")]); @@ -896,7 +896,7 @@ void serializeConfig() { if_sync[F("espnow")] = useESPNowSync; #endif - JsonObject if_sync_recv = if_sync.createNestedObject("recv"); + JsonObject if_sync_recv = if_sync.createNestedObject(F("recv")); if_sync_recv["bri"] = receiveNotificationBrightness; if_sync_recv["col"] = receiveNotificationColor; if_sync_recv["fx"] = receiveNotificationEffects; @@ -904,7 +904,7 @@ void serializeConfig() { if_sync_recv["seg"] = receiveSegmentOptions; if_sync_recv["sb"] = receiveSegmentBounds; - JsonObject if_sync_send = if_sync.createNestedObject("send"); + JsonObject if_sync_send = if_sync.createNestedObject(F("send")); if_sync_send["en"] = sendNotifications; if_sync_send[F("dir")] = notifyDirect; if_sync_send["btn"] = notifyButton; @@ -913,7 +913,7 @@ void serializeConfig() { if_sync_send["grp"] = syncGroups; if_sync_send["ret"] = udpNumRetries; - JsonObject if_nodes = interfaces.createNestedObject("nodes"); + JsonObject if_nodes = interfaces.createNestedObject(F("nodes")); if_nodes[F("list")] = nodeListEnabled; if_nodes[F("bcast")] = nodeBroadcastEnabled; @@ -969,7 +969,7 @@ void serializeConfig() { if_hue["id"] = huePollLightId; if_hue[F("iv")] = huePollIntervalMs / 100; - JsonObject if_hue_recv = if_hue.createNestedObject("recv"); + JsonObject if_hue_recv = if_hue.createNestedObject(F("recv")); if_hue_recv["on"] = hueApplyOnOff; if_hue_recv["bri"] = hueApplyBri; if_hue_recv["col"] = hueApplyColor; diff --git a/wled00/const.h b/wled00/const.h index 50c3b39be..de600758b 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -7,9 +7,26 @@ #define GRADIENT_PALETTE_COUNT 58 +// You can define custom product info from build flags. +// This is useful to allow API consumer to identify what type of WLED version +// they are interacting with. Be aware that changing this might cause some third +// party API consumers to consider this as a non-WLED device since the values +// returned by the API and by MQTT will no longer be default. However, most +// third party only uses mDNS to validate, so this is generally fine to change. +// For example, Home Assistant will still work fine even with this value changed. +// Use like this: +// -D WLED_BRAND="\"Custom Brand\"" +// -D WLED_PRODUCT_NAME="\"Custom Product\"" +#ifndef WLED_BRAND + #define WLED_BRAND "WLED" +#endif +#ifndef WLED_PRODUCT_NAME + #define WLED_PRODUCT_NAME "FOSS" +#endif + //Defaults #define DEFAULT_CLIENT_SSID "Your_Network" -#define DEFAULT_AP_SSID "WLED-AP" +#define DEFAULT_AP_SSID WLED_BRAND "-AP" #define DEFAULT_AP_PASS "wled1234" #define DEFAULT_OTA_PASS "wledota" #define DEFAULT_MDNS_NAME "x" diff --git a/wled00/dmx.cpp b/wled00/dmx.cpp index bcd7e7f9e..6bdf80a79 100644 --- a/wled00/dmx.cpp +++ b/wled00/dmx.cpp @@ -69,14 +69,10 @@ void handleDMX() } void initDMX() { - #ifdef ESP8266 + #if defined(ESP8266) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S2) dmx.init(512); // initialize with bus length #else dmx.initWrite(512); // initialize with bus length #endif } - -#else -void handleDMX() {} -void initDMX() {} #endif diff --git a/wled00/file.cpp b/wled00/file.cpp index fc3dc7eeb..7354db239 100644 --- a/wled00/file.cpp +++ b/wled00/file.cpp @@ -226,7 +226,7 @@ bool appendObjectToFile(const char* key, JsonDocument* content, uint32_t s, uint if (pos == 0) //not found { - DEBUGFS_PRINTLN("not }"); + DEBUGFS_PRINTLN(F("not }")); f.seek(0); while (bufferedFind("}",false)) //find last closing bracket in JSON if not last char { @@ -395,7 +395,7 @@ static String getContentType(AsyncWebServerRequest* request, String filename){ } bool handleFileRead(AsyncWebServerRequest* request, String path){ - DEBUG_PRINTLN("WS FileRead: " + path); + DEBUG_PRINT(F("WS FileRead: ")); DEBUG_PRINTLN(path); if(path.endsWith("/")) path += "index.htm"; if(path.indexOf(F("sec")) > -1) return false; String contentType = getContentType(request, path); diff --git a/wled00/json.cpp b/wled00/json.cpp index 8e1284c10..b4bb38715 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -31,7 +31,7 @@ bool deserializeSegment(JsonObject elem, byte it, byte presetId) newSeg = true; } - //DEBUG_PRINTLN("-- JSON deserialize segment."); + //DEBUG_PRINTLN(F("-- JSON deserialize segment.")); Segment& seg = strip.getSegment(id); //DEBUG_PRINTF("-- Original segment: %p (%p)\n", &seg, seg.data); Segment prev = seg; //make a backup so we can tell if something changed (calling copy constructor) @@ -353,9 +353,9 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId) nightlightTargetBri = nl[F("tbri")] | nightlightTargetBri; JsonObject udpn = root["udpn"]; - sendNotificationsRT = getBoolVal(udpn["send"], sendNotificationsRT); - syncGroups = udpn["sgrp"] | syncGroups; - receiveGroups = udpn["rgrp"] | receiveGroups; + sendNotificationsRT = getBoolVal(udpn[F("send")], sendNotificationsRT); + syncGroups = udpn[F("sgrp")] | syncGroups; + receiveGroups = udpn[F("rgrp")] | receiveGroups; if ((bool)udpn[F("nn")]) callMode = CALL_MODE_NO_NOTIFY; //send no notification just for this request unsigned long timein = root["time"] | UINT32_MAX; //backup time source if NTP not synced @@ -438,7 +438,7 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId) // applying preset (2 cases: a) API call includes all preset values ("pd"), b) API only specifies preset ID ("ps")) byte presetToRestore = 0; // a) already applied preset content (requires "seg" or "win" but will ignore the rest) - if (!root["pd"].isNull() && stateChanged) { + if (!root[F("pd")].isNull() && stateChanged) { currentPreset = root[F("pd")] | currentPreset; if (root["win"].isNull()) presetCycCurr = currentPreset; // otherwise it was set in handleSet() [set.cpp] presetToRestore = currentPreset; // stateUpdated() will clear the preset, so we need to restore it after @@ -579,17 +579,13 @@ void serializeState(JsonObject root, bool forPreset, bool includeBri, bool segme nl["dur"] = nightlightDelayMins; nl["mode"] = nightlightMode; nl[F("tbri")] = nightlightTargetBri; - if (nightlightActive) { - nl[F("rem")] = (nightlightDelayMs - (millis() - nightlightStartTime)) / 1000; // seconds remaining - } else { - nl[F("rem")] = -1; - } + nl[F("rem")] = nightlightActive ? (nightlightDelayMs - (millis() - nightlightStartTime)) / 1000 : -1; // seconds remaining JsonObject udpn = root.createNestedObject("udpn"); - udpn["send"] = sendNotificationsRT; - udpn["recv"] = receiveGroups != 0; - udpn["sgrp"] = syncGroups; - udpn["rgrp"] = receiveGroups; + udpn[F("send")] = sendNotificationsRT; + udpn[F("recv")] = receiveGroups != 0; + udpn[F("sgrp")] = syncGroups; + udpn[F("rgrp")] = receiveGroups; root[F("lor")] = realtimeOverride; } @@ -687,12 +683,7 @@ void serializeInfo(JsonObject root) case REALTIME_MODE_DDP: root["lm"] = F("DDP"); break; } - if (realtimeIP[0] == 0) - { - root[F("lip")] = ""; - } else { - root[F("lip")] = realtimeIP.toString(); - } + root[F("lip")] = realtimeIP[0] == 0 ? "" : realtimeIP.toString(); #ifdef WLED_ENABLE_WEBSOCKETS root[F("ws")] = ws.count(); @@ -729,7 +720,7 @@ void serializeInfo(JsonObject root) root[F("ndc")] = nodeListEnabled ? (int)Nodes.size() : -1; - #ifdef ARDUINO_ARCH_ESP32 +#ifdef ARDUINO_ARCH_ESP32 #ifdef WLED_DEBUG wifi_info[F("txPower")] = (int) WiFi.getTxPower(); wifi_info[F("sleep")] = (bool) WiFi.getSleep(); @@ -740,21 +731,21 @@ void serializeInfo(JsonObject root) root[F("arch")] = ESP.getChipModel(); #endif root[F("core")] = ESP.getSdkVersion(); - //root[F("maxalloc")] = ESP.getMaxAllocHeap(); #ifdef WLED_DEBUG - root[F("resetReason0")] = (int)rtc_get_reset_reason(0); - root[F("resetReason1")] = (int)rtc_get_reset_reason(1); + root[F("maxalloc")] = ESP.getMaxAllocHeap(); + root[F("resetReason0")] = (int)rtc_get_reset_reason(0); + root[F("resetReason1")] = (int)rtc_get_reset_reason(1); #endif root[F("lwip")] = 0; //deprecated - #else +#else root[F("arch")] = "esp8266"; root[F("core")] = ESP.getCoreVersion(); - //root[F("maxalloc")] = ESP.getMaxFreeBlockSize(); #ifdef WLED_DEBUG - root[F("resetReason")] = (int)ESP.getResetInfoPtr()->reason; + root[F("maxalloc")] = ESP.getMaxFreeBlockSize(); + root[F("resetReason")] = (int)ESP.getResetInfoPtr()->reason; #endif root[F("lwip")] = LWIP_VERSION_MAJOR; - #endif +#endif root[F("freeheap")] = ESP.getFreeHeap(); #if defined(ARDUINO_ARCH_ESP32) && defined(BOARD_HAS_PSRAM) @@ -983,7 +974,7 @@ void serializeNetworks(JsonObject root) void serializeNodes(JsonObject root) { - JsonArray nodes = root.createNestedArray("nodes"); + JsonArray nodes = root.createNestedArray(F("nodes")); for (NodesMap::iterator it = Nodes.begin(); it != Nodes.end(); ++it) { diff --git a/wled00/led.cpp b/wled00/led.cpp index b8b51873c..ba772df9b 100644 --- a/wled00/led.cpp +++ b/wled00/led.cpp @@ -214,7 +214,6 @@ void colorUpdated(byte callMode) { void handleNightlight() { - static unsigned long lastNlUpdate; unsigned long now = millis(); if (now < 100 && lastNlUpdate > 0) lastNlUpdate = 0; // take care of millis() rollover if (now - lastNlUpdate < 100) return; // allow only 10 NL updates per second diff --git a/wled00/pin_manager.cpp b/wled00/pin_manager.cpp index 102acd0ea..a2c3567cb 100644 --- a/wled00/pin_manager.cpp +++ b/wled00/pin_manager.cpp @@ -109,7 +109,7 @@ bool PinManagerClass::allocateMultiplePins(const managed_pin_type * mptArray, by #ifdef WLED_DEBUG DEBUG_PRINT(F("PIN ALLOC: Invalid pin attempted to be allocated: GPIO ")); DEBUG_PRINT(gpio); - DEBUG_PRINT(" as "); DEBUG_PRINT(mptArray[i].isOutput ? "output": "input"); + DEBUG_PRINT(F(" as ")); DEBUG_PRINT(mptArray[i].isOutput ? "output": "input"); DEBUG_PRINTLN(F("")); #endif shouldFail = true; diff --git a/wled00/set.cpp b/wled00/set.cpp index 14a3723d7..5996c4380 100755 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -694,10 +694,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) else subObj[name].add(value.toInt()); // we may have an int j++; } - DEBUG_PRINT("["); - DEBUG_PRINT(j); - DEBUG_PRINT("] = "); - DEBUG_PRINTLN(value); + DEBUG_PRINT(F("[")); DEBUG_PRINT(j); DEBUG_PRINT(F("] = ")); DEBUG_PRINTLN(value); } else { // we are using a hidden field with the same name as our parameter (!before the actual parameter!) // to describe the type of parameter (text,float,int), for boolean parameters the first field contains "off" @@ -716,8 +713,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) } else if (type == "int") subObj[name] = value.toInt(); else subObj[name] = value; // text fields } - DEBUG_PRINT(" = "); - DEBUG_PRINTLN(value); + DEBUG_PRINT(F(" = ")); DEBUG_PRINTLN(value); } } usermods.readFromConfig(um); // force change of usermod parameters diff --git a/wled00/src/dependencies/dmx/ESPDMX.cpp b/wled00/src/dependencies/dmx/ESPDMX.cpp index d0d652c82..936f979c2 100644 --- a/wled00/src/dependencies/dmx/ESPDMX.cpp +++ b/wled00/src/dependencies/dmx/ESPDMX.cpp @@ -11,7 +11,7 @@ // - - - - - /* ----- LIBRARIES ----- */ -#ifdef ESP8266 +#if defined(ESP8266) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S2) #include diff --git a/wled00/util.cpp b/wled00/util.cpp index 71f556078..ea89adc68 100644 --- a/wled00/util.cpp +++ b/wled00/util.cpp @@ -173,7 +173,7 @@ bool oappend(const char* txt) void prepareHostname(char* hostname) { - sprintf_P(hostname, "wled-%*s", 6, escapedMac.c_str() + 6); + sprintf_P(hostname, PSTR("wled-%*s"), 6, escapedMac.c_str() + 6); const char *pC = serverDescription; uint8_t pos = 5; // keep "wled-" while (*pC && pos < 24) { // while !null and not over length diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 0df4712f4..e395bc13b 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -36,7 +36,7 @@ void WLED::loop() { static uint32_t lastHeap = UINT32_MAX; static unsigned long heapTime = 0; - #ifdef WLED_DEBUG +#ifdef WLED_DEBUG static unsigned long lastRun = 0; unsigned long loopMillis = millis(); size_t loopDelay = loopMillis - lastRun; @@ -49,12 +49,12 @@ void WLED::loop() static unsigned long maxStripMillis = 0; static size_t avgStripMillis = 0; unsigned long stripMillis; - #endif +#endif handleTime(); - #ifndef WLED_DISABLE_INFRARED +#ifndef WLED_DISABLE_INFRARED handleIR(); // 2nd call to function needed for ESP32 to return valid results -- should be good for ESP8266, too - #endif +#endif handleConnection(); handleSerial(); handleImprovWifiScan(); @@ -813,7 +813,7 @@ void WLED::initConnection() DEBUG_PRINT(F("Connecting to ")); DEBUG_PRINT(multiWiFi[selectedWiFi].clientSSID); - DEBUG_PRINTLN("..."); + DEBUG_PRINTLN(F("...")); // convert the "serverDescription" into a valid DNS hostname (alphanumeric) char hostname[25]; diff --git a/wled00/wled.h b/wled00/wled.h index b546d06d1..0fbe7a68b 100755 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -10,24 +10,6 @@ // version code in format yymmddb (b = daily build) #define VERSION 2402060 -// You can define custom product info from build flags. -// This is useful to allow API consumer to identify what type of WLED version -// they are interacting with. Be aware that changing this might cause some third -// party API consumers to consider this as a non-WLED device since the values -// returned by the API and by MQTT will no longer be default. However, most -// third party only uses mDNS to validate, so this is generally fine to change. -// For example, Home Assistant will still work fine even with this value changed. -// Use like this: -// -D WLED_BRAND="\"Custom Brand\"" -// -D WLED_PRODUCT_NAME="\"Custom Product\"" -#ifndef WLED_BRAND - #define WLED_BRAND "WLED" -#endif -#ifndef WLED_PRODUCT_NAME - #define WLED_PRODUCT_NAME "FOSS" -#endif - - //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG @@ -155,7 +137,7 @@ #endif #ifdef WLED_ENABLE_DMX - #ifdef ESP8266 + #if defined(ESP8266) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S2) #include "src/dependencies/dmx/ESPDMX.h" #else //ESP32 #include "src/dependencies/dmx/SparkFunDMX.h" @@ -428,12 +410,19 @@ WLED_GLOBAL bool arlsDisableGammaCorrection _INIT(true); // activate if WLED_GLOBAL bool arlsForceMaxBri _INIT(false); // enable to force max brightness if source has very dark colors that would be black #ifdef WLED_ENABLE_DMX - #ifdef ESP8266 + #if defined(ESP8266) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S2) WLED_GLOBAL DMXESPSerial dmx; #else //ESP32 WLED_GLOBAL SparkFunDMX dmx; #endif -WLED_GLOBAL uint16_t e131ProxyUniverse _INIT(0); // output this E1.31 (sACN) / ArtNet universe via MAX485 (0 = disabled) + WLED_GLOBAL uint16_t e131ProxyUniverse _INIT(0); // output this E1.31 (sACN) / ArtNet universe via MAX485 (0 = disabled) + // dmx CONFIG + WLED_GLOBAL byte DMXChannels _INIT(7); // number of channels per fixture + WLED_GLOBAL byte DMXFixtureMap[15] _INIT_N(({ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 })); + // assigns the different channels to different functions. See wled21_dmx.ino for more information. + WLED_GLOBAL uint16_t DMXGap _INIT(10); // gap between the fixtures. makes addressing easier because you don't have to memorize odd numbers when climbing up onto a rig. + WLED_GLOBAL uint16_t DMXStart _INIT(10); // start address of the first fixture + WLED_GLOBAL uint16_t DMXStartLED _INIT(0); // LED from which DMX fixtures start #endif WLED_GLOBAL uint16_t e131Universe _INIT(1); // settings for E1.31 (sACN) protocol (only DMX_MODE_MULTIPLE_* can span over consecutive universes) WLED_GLOBAL uint16_t e131Port _INIT(5568); // DMX in port. E1.31 default is 5568, Art-Net is 6454 @@ -538,16 +527,6 @@ WLED_GLOBAL unsigned long lastEditTime _INIT(0); WLED_GLOBAL uint16_t userVar0 _INIT(0), userVar1 _INIT(0); //available for use in usermod -#ifdef WLED_ENABLE_DMX - // dmx CONFIG - WLED_GLOBAL byte DMXChannels _INIT(7); // number of channels per fixture - WLED_GLOBAL byte DMXFixtureMap[15] _INIT_N(({ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 })); - // assigns the different channels to different functions. See wled21_dmx.ino for more information. - WLED_GLOBAL uint16_t DMXGap _INIT(10); // gap between the fixtures. makes addressing easier because you don't have to memorize odd numbers when climbing up onto a rig. - WLED_GLOBAL uint16_t DMXStart _INIT(10); // start address of the first fixture - WLED_GLOBAL uint16_t DMXStartLED _INIT(0); // LED from which DMX fixtures start -#endif - // internal global variable declarations // wifi WLED_GLOBAL bool apActive _INIT(false); @@ -577,6 +556,7 @@ WLED_GLOBAL bool nightlightActiveOld _INIT(false); WLED_GLOBAL uint32_t nightlightDelayMs _INIT(10); WLED_GLOBAL byte nightlightDelayMinsDefault _INIT(nightlightDelayMins); WLED_GLOBAL unsigned long nightlightStartTime; +WLED_GLOBAL unsigned long lastNlUpdate; WLED_GLOBAL byte briNlT _INIT(0); // current nightlight brightness WLED_GLOBAL byte colNlT[] _INIT_N(({ 0, 0, 0, 0 })); // current nightlight color @@ -619,6 +599,7 @@ WLED_GLOBAL bool udpConnected _INIT(false), udp2Connected _INIT(false), udpRgbCo WLED_GLOBAL bool showWelcomePage _INIT(false); // hue +#ifndef WLED_DISABLE_HUESYNC WLED_GLOBAL byte hueError _INIT(HUE_ERROR_INACTIVE); // WLED_GLOBAL uint16_t hueFailCount _INIT(0); WLED_GLOBAL float hueXLast _INIT(0), hueYLast _INIT(0); @@ -628,6 +609,7 @@ WLED_GLOBAL unsigned long hueLastRequestSent _INIT(0); WLED_GLOBAL bool hueAuthRequired _INIT(false); WLED_GLOBAL bool hueReceived _INIT(false); WLED_GLOBAL bool hueStoreAllowed _INIT(false), hueNewKey _INIT(false); +#endif // countdown WLED_GLOBAL unsigned long countdownTime _INIT(1514764800L); @@ -735,7 +717,9 @@ WLED_GLOBAL AsyncWebServer server _INIT_N(((80))); #ifdef WLED_ENABLE_WEBSOCKETS WLED_GLOBAL AsyncWebSocket ws _INIT_N((("/ws"))); #endif +#ifndef WLED_DISABLE_HUESYNC WLED_GLOBAL AsyncClient *hueClient _INIT(NULL); +#endif WLED_GLOBAL AsyncWebHandler *editHandler _INIT(nullptr); // udp interface objects @@ -848,7 +832,7 @@ WLED_GLOBAL volatile uint8_t jsonBufferLock _INIT(0); WLED_GLOBAL unsigned long debugTime _INIT(0); WLED_GLOBAL int lastWifiState _INIT(3); WLED_GLOBAL unsigned long wifiStateChangedTime _INIT(0); - WLED_GLOBAL unsigned long loops _INIT(0); + WLED_GLOBAL unsigned loops _INIT(0); #endif #ifdef ARDUINO_ARCH_ESP32 @@ -863,13 +847,12 @@ WLED_GLOBAL volatile uint8_t jsonBufferLock _INIT(0); } while(0) #else #define WLED_SET_AP_SSID() do { \ - strcpy_P(apSSID, PSTR(WLED_AP_SSID)); \ snprintf_P(\ - apSSID+strlen(WLED_AP_SSID), \ - sizeof(apSSID)-strlen(WLED_AP_SSID), \ - PSTR("-%*s"), \ - 6, \ - escapedMac.c_str() + 6\ + apSSID, \ + sizeof(apSSID)-1, \ + PSTR("%s-%s"), \ + WLED_BRAND, \ + escapedMac.c_str()+6 \ ); \ } while(0) #endif diff --git a/wled00/wled_server.cpp b/wled00/wled_server.cpp index af5f0a47e..1737a1fe8 100644 --- a/wled00/wled_server.cpp +++ b/wled00/wled_server.cpp @@ -491,20 +491,21 @@ void serveJsonError(AsyncWebServerRequest* request, uint16_t code, uint16_t erro String dmxProcessor(const String& var) { String mapJS; - #ifdef WLED_ENABLE_DMX - if (var == F("DMXVARS")) { - mapJS += "\nCN=" + String(DMXChannels) + ";\n"; - mapJS += "CS="+ String(DMXStart) + ";\n"; - mapJS += "CG=" + String(DMXGap) + ";\n"; - mapJS += "LC=" + String(strip.getLengthTotal()) + ";\n"; - mapJS += F("var CH=["); - for (int i=0;i<15;i++) { - mapJS += String(DMXFixtureMap[i]) + ','; - } - mapJS += F("0];"); + if (var == F("DMXVARS")) { + mapJS += F("\nCN="); + mapJS += String(DMXChannels); + mapJS += F(";\nCS="); + mapJS += String(DMXStart); + mapJS += F(";\nCG="); + mapJS += String(DMXGap); + mapJS += F(";\nLC="); + mapJS += String(strip.getLengthTotal()); + mapJS += F(";\nvar CH=["); + for (int i=0; i<15; i++) { + mapJS += String(DMXFixtureMap[i]) + ','; } - #endif - + mapJS += F("0];"); + } return mapJS; } #endif @@ -550,9 +551,13 @@ void serveSettings(AsyncWebServerRequest* request, bool post) { else if (url.indexOf( "sync") > 0) subPage = SUBPAGE_SYNC; else if (url.indexOf( "time") > 0) subPage = SUBPAGE_TIME; else if (url.indexOf(F("sec")) > 0) subPage = SUBPAGE_SEC; +#ifdef WLED_ENABLE_DMX else if (url.indexOf( "dmx") > 0) subPage = SUBPAGE_DMX; +#endif else if (url.indexOf( "um") > 0) subPage = SUBPAGE_UM; +#ifndef WLED_DISABLE_2D else if (url.indexOf( "2D") > 0) subPage = SUBPAGE_2D; +#endif else if (url.indexOf(F("lock")) > 0) subPage = SUBPAGE_LOCK; } else if (url.indexOf("/update") >= 0) subPage = SUBPAGE_UPDATE; // update page, for PIN check @@ -583,9 +588,13 @@ void serveSettings(AsyncWebServerRequest* request, bool post) { case SUBPAGE_SYNC : strcpy_P(s, PSTR("Sync")); break; case SUBPAGE_TIME : strcpy_P(s, PSTR("Time")); break; case SUBPAGE_SEC : strcpy_P(s, PSTR("Security")); if (doReboot) strcpy_P(s2, PSTR("Rebooting, please wait ~10 seconds...")); break; +#ifdef WLED_ENABLE_DMX case SUBPAGE_DMX : strcpy_P(s, PSTR("DMX")); break; +#endif case SUBPAGE_UM : strcpy_P(s, PSTR("Usermods")); break; +#ifndef WLED_DISABLE_2D case SUBPAGE_2D : strcpy_P(s, PSTR("2D")); break; +#endif case SUBPAGE_PINREQ : strcpy_P(s, correctPIN ? PSTR("PIN accepted") : PSTR("PIN rejected")); break; }