diff --git a/wled00/data/settings_sync.htm b/wled00/data/settings_sync.htm
old mode 100755
new mode 100644
index 848bf4f2d..57d7d18ac
--- a/wled00/data/settings_sync.htm
+++ b/wled00/data/settings_sync.htm
@@ -199,7 +199,7 @@ Realtime LED offset:
Emulate Alexa device:
Alexa invocation name:
-Also emulate devices to call the first presets
+Also emulate devices to call the first presets
⚠ MQTT and Hue sync all connect to external hosts!
@@ -245,6 +245,10 @@ Hue Bridge IP:
Hue status: Disabled in this build
Serial
+
+ This firmware build does support Serial interface.
+
+
Baud rate:
Keep at 115200 to use Improv. Some boards may not support high rates.
+
diff --git a/wled00/ir.cpp b/wled00/ir.cpp
index 9e1974366..e4541cd90 100644
--- a/wled00/ir.cpp
+++ b/wled00/ir.cpp
@@ -714,9 +714,8 @@ void handleIR()
if (strip.isUpdating() && timeDiff < 240) return; // be nice, but not too nice
irCheckedTime = currentTime;
if (irrecv->decode(&results)) {
- if (results.value != 0) { // only print results if anything is received ( != 0 )
- if (!pinManager.isPinAllocated(hardwareTX) || pinManager.getPinOwner(hardwareTX) == PinOwner::DebugOut) // Serial TX pin (GPIO 1 on ESP32 and ESP8266)
- Serial.printf_P(PSTR("IR recv: 0x%lX\n"), (unsigned long)results.value);
+ if (results.value != 0 && serialCanTX) { // only print results if anything is received ( != 0 )
+ Serial.printf_P(PSTR("IR recv: 0x%lX\n"), (unsigned long)results.value);
}
decodeIR(results.value);
irrecv->resume();
diff --git a/wled00/pin_manager.cpp b/wled00/pin_manager.cpp
index 47cba2ec6..be2a4f977 100644
--- a/wled00/pin_manager.cpp
+++ b/wled00/pin_manager.cpp
@@ -1,6 +1,18 @@
#include "pin_manager.h"
#include "wled.h"
+#ifdef ARDUINO_ARCH_ESP32
+ #ifdef bitRead
+ // Arduino variants assume 32 bit values
+ #undef bitRead
+ #undef bitSet
+ #undef bitClear
+ #define bitRead(var,bit) (((unsigned long long)(var)>>(bit))&0x1ULL)
+ #define bitSet(var,bit) ((var)|=(1ULL<<(bit)))
+ #define bitClear(var,bit) ((var)&=(~(1ULL<<(bit))))
+ #endif
+#endif
+
#ifdef WLED_DEBUG
static void DebugPrintOwnerTag(PinOwner tag)
{
diff --git a/wled00/pin_manager.h b/wled00/pin_manager.h
index a8ddf5f75..a64900c89 100644
--- a/wled00/pin_manager.h
+++ b/wled00/pin_manager.h
@@ -87,7 +87,11 @@ class PinManagerClass {
PinOwner ownerTag[WLED_NUM_PINS] = { PinOwner::None };
public:
- PinManagerClass() : pinAlloc(0), i2cAllocCount(0), spiAllocCount(0) {}
+ PinManagerClass() : pinAlloc(0ULL), i2cAllocCount(0), spiAllocCount(0) {
+ #ifdef ARDUINO_ARCH_ESP32
+ ledcAlloc = 0;
+ #endif
+ }
// De-allocates a single pin
bool deallocatePin(byte gpio, PinOwner tag);
// De-allocates multiple pins but only if all can be deallocated (PinOwner has to be specified)
diff --git a/wled00/wled.cpp b/wled00/wled.cpp
index c46fc8ebf..bc1cc7b73 100644
--- a/wled00/wled.cpp
+++ b/wled00/wled.cpp
@@ -54,17 +54,19 @@ void WLED::loop()
#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();
+ #ifdef WLED_ENABLE_ADALIGHT
handleSerial();
+ #endif
handleImprovWifiScan();
handleNotifications();
handleTransitions();
-#ifdef WLED_ENABLE_DMX
+ #ifdef WLED_ENABLE_DMX
handleDMX();
-#endif
+ #endif
#ifdef WLED_DEBUG
unsigned long usermodMillis = millis();
@@ -476,10 +478,14 @@ void WLED::setup()
WiFi.mode(WIFI_STA); // enable scanning
findWiFi(true); // start scanning for available WiFi-s
+ // all GPIOs are allocated at this point
+ serialCanRX = !pinManager.isPinAllocated(hardwareRX); // Serial RX pin (GPIO 3 on ESP32 and ESP8266)
+ serialCanTX = !pinManager.isPinAllocated(hardwareTX) || pinManager.getPinOwner(hardwareTX) == PinOwner::DebugOut; // Serial TX pin (GPIO 1 on ESP32 and ESP8266)
+
#ifdef WLED_ENABLE_ADALIGHT
//Serial RX (Adalight, Improv, Serial JSON) only possible if GPIO3 unused
//Serial TX (Debug, Improv, Serial JSON) only possible if GPIO1 unused
- if (!pinManager.isPinAllocated(hardwareRX) && !pinManager.isPinAllocated(hardwareTX)) {
+ if (serialCanRX && serialCanTX) {
Serial.println(F("Ada"));
}
#endif
@@ -491,10 +497,6 @@ void WLED::setup()
if (mqttClientID[0] == 0) sprintf_P(mqttClientID, PSTR("WLED-%*s"), 6, escapedMac.c_str() + 6);
#endif
-#ifdef WLED_ENABLE_ADALIGHT
- if (Serial.available() > 0 && Serial.peek() == 'I') handleImprovPacket();
-#endif
-
#ifndef WLED_DISABLE_OTA
if (aOtaEnabled) {
ArduinoOTA.onStart([]() {
@@ -521,7 +523,7 @@ void WLED::setup()
#endif
#ifdef WLED_ENABLE_ADALIGHT
- if (Serial.available() > 0 && Serial.peek() == 'I') handleImprovPacket();
+ if (serialCanRX && Serial.available() > 0 && Serial.peek() == 'I') handleImprovPacket();
#endif
// HTTP server page init
diff --git a/wled00/wled.h b/wled00/wled.h
index 23c345907..33dea8b03 100644
--- a/wled00/wled.h
+++ b/wled00/wled.h
@@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
-#define VERSION 2409140
+#define VERSION 2409170
//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG
@@ -510,6 +510,8 @@ WLED_GLOBAL bool hueApplyColor _INIT(true);
#endif
WLED_GLOBAL uint16_t serialBaud _INIT(1152); // serial baud rate, multiply by 100
+WLED_GLOBAL bool serialCanRX _INIT(false);
+WLED_GLOBAL bool serialCanTX _INIT(false);
#ifndef WLED_DISABLE_ESPNOW
WLED_GLOBAL bool enableESPNow _INIT(false); // global on/off for ESP-NOW
diff --git a/wled00/wled_serial.cpp b/wled00/wled_serial.cpp
index 3ca7c7f2f..ad9bb1413 100644
--- a/wled00/wled_serial.cpp
+++ b/wled00/wled_serial.cpp
@@ -28,7 +28,7 @@ void updateBaudRate(uint32_t rate){
if (rate100 == currentBaud || rate100 < 96) return;
currentBaud = rate100;
- if (!pinManager.isPinAllocated(hardwareTX) || pinManager.getPinOwner(hardwareTX) == PinOwner::DebugOut){
+ if (serialCanTX){
Serial.print(F("Baud is now ")); Serial.println(rate);
}
@@ -38,7 +38,7 @@ void updateBaudRate(uint32_t rate){
// RGB LED data return as JSON array. Slow, but easy to use on the other end.
void sendJSON(){
- if (!pinManager.isPinAllocated(hardwareTX) || pinManager.getPinOwner(hardwareTX) == PinOwner::DebugOut) {
+ if (serialCanTX) {
unsigned used = strip.getLengthTotal();
Serial.write('[');
for (unsigned i=0; ias());
- //only send response if TX pin is unused for other purposes
- if (verboseResponse && (!pinManager.isPinAllocated(hardwareTX) || pinManager.getPinOwner(hardwareTX) == PinOwner::DebugOut)) {
- pDoc->clear();
- JsonObject state = pDoc->createNestedObject("state");
- serializeState(state);
- JsonObject info = pDoc->createNestedObject("info");
- serializeInfo(info);
+ if (!error) {
+ verboseResponse = deserializeState(pDoc->as());
+ //only send response if TX pin is unused for other purposes
+ if (verboseResponse && serialCanTX) {
+ pDoc->clear();
+ JsonObject state = pDoc->createNestedObject("state");
+ serializeState(state);
+ JsonObject info = pDoc->createNestedObject("info");
+ serializeInfo(info);
- serializeJson(*pDoc, Serial);
- Serial.println();
+ serializeJson(*pDoc, Serial);
+ Serial.println();
+ }
}
releaseJSONBufferLock();
}
@@ -199,11 +186,10 @@ void handleSerial()
// All other received bytes will disable Continuous Serial Streaming
if (continuousSendLED && next != 'O'){
continuousSendLED = false;
- }
+ }
Serial.read(); //discard the byte
}
- #endif
// If Continuous Serial Streaming is enabled, send new LED data as bytes
if (continuousSendLED && (lastUpdate != strip.getLastShow())){
diff --git a/wled00/xml.cpp b/wled00/xml.cpp
index ef23c0909..71d66d002 100644
--- a/wled00/xml.cpp
+++ b/wled00/xml.cpp
@@ -571,6 +571,9 @@ void getSettingsJS(byte subPage, char* dest)
oappend(SET_F("toggle('Hue');")); // hide Hue Sync settings
#endif
sappend('v',SET_F("BD"),serialBaud);
+ #ifndef WLED_ENABLE_ADALIGHT
+ oappend(SET_F("toggle('Serial);"));
+ #endif
}
if (subPage == SUBPAGE_TIME)