diff --git a/wled00/data/settings_sync.htm b/wled00/data/settings_sync.htm index aacc4311..ac62cae7 100644 Binary files a/wled00/data/settings_sync.htm and b/wled00/data/settings_sync.htm differ diff --git a/wled00/html_settings.h b/wled00/html_settings.h index 4e5527ee..86aae39d 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -224,7 +224,9 @@ const char PAGE_settings_sync1[] PROGMEM = R"=====(

Sync setup

Button setup

-On/Off button enabled: +On/Off button enabled:
+Infrared receiver enabled:
+IR info

WLED Broadcast

UDP Port:
Receive Brightness, Color, and Effects
diff --git a/wled00/wled00.ino b/wled00/wled00.ino index e00b12d5..b116de09 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -21,10 +21,12 @@ //#define WLED_DISABLE_BLYNK //#define WLED_DISABLE_CRONIXIE //#define WLED_DISABLE_HUESYNC +//#define WLED_DISABLE_INFRARED //#define WLED_DISABLE_MOBILE_UI //to toggle usb serial debug (un)comment following line(s) -//#define WLED_DEBUG +#define WLED_DEBUG + //library inclusions #include @@ -33,15 +35,19 @@ #include #include "src/dependencies/webserver/WebServer.h" #include - #include + /*#ifndef WLED_DISABLE_INFRARED + #include + #endif*/ //there are issues with ESP32 infrared, so it is disabled for now #else #include #include #include #include - #include - #include - #include + #ifndef WLED_DISABLE_INFRARED + #include + #include + #include + #endif #endif #include @@ -68,7 +74,7 @@ //version code in format yymmddb (b = daily build) -#define VERSION 1811172 +#define VERSION 1811201 char versionString[] = "0.8.2-dev"; @@ -148,8 +154,8 @@ bool useHSBDefault = useHSB; //Sync CONFIG -bool buttonEnabled = true; -bool irEnabled = true; //Infrared receiver +bool buttonEnabled = true; +bool irEnabled = false; //Infrared receiver uint16_t udpPort = 21324; //WLED notifier default port uint16_t udpRgbPort = 19446; //Hyperion port @@ -158,7 +164,7 @@ bool receiveNotificationBrightness = true; //apply brightness from incoming n bool receiveNotificationColor = true; //apply color bool receiveNotificationEffects = true; //apply effects setup bool notifyDirect = true; //send notification if change via UI or HTTP API -bool notifyButton = true; +bool notifyButton = true; //send if updated by button or infrared remote bool notifyAlexa = false; //send notification if updated via Alexa bool notifyMacro = false; //send notification for macro bool notifyHue = true; //send notification if Hue light changes @@ -259,6 +265,7 @@ float tperLast = 0; //crossfade transition progress, 0 bool nightlightActive = false; bool nightlightActiveOld = false; uint32_t nightlightDelayMs = 10; +uint8_t nightlightDelayMinsDefault = nightlightDelayMins; unsigned long nightlightStartTime; byte briNlT = 0; //current nightlight brightness @@ -407,7 +414,7 @@ E131* e131; WS2812FX strip = WS2812FX(); //debug macros -#ifdef DEBUG +#ifdef WLED_DEBUG #define DEBUG_PRINT(x) Serial.print (x) #define DEBUG_PRINTLN(x) Serial.println (x) #define DEBUG_PRINTF(x) Serial.printf (x) @@ -524,7 +531,7 @@ void loop() { } //DEBUG serial logging - #ifdef DEBUG + #ifdef WLED_DEBUG if (millis() - debugTime > 5000) { DEBUG_PRINTLN("---MODULE DEBUG INFO---"); diff --git a/wled00/wled01_eeprom.ino b/wled00/wled01_eeprom.ino index 06dee8cf..56a0bc13 100644 --- a/wled00/wled01_eeprom.ino +++ b/wled00/wled01_eeprom.ino @@ -66,7 +66,7 @@ void saveSettingsToEEPROM() writeStringToEEPROM(128, apSSID, 32); writeStringToEEPROM(160, apPass, 64); - EEPROM.write(224, nightlightDelayMins); + EEPROM.write(224, nightlightDelayMinsDefault); EEPROM.write(225, nightlightFade); EEPROM.write(226, notifyDirectDefault); EEPROM.write(227, apChannel); @@ -138,6 +138,8 @@ void saveSettingsToEEPROM() EEPROM.write(380, colSecS[2]); EEPROM.write(381, whiteSecS); EEPROM.write(382, strip.paletteBlend); + + EEPROM.write(385, irEnabled); EEPROM.write(389, bootPreset); EEPROM.write(390, aOtaEnabled); @@ -256,7 +258,9 @@ void loadSettingsFromEEPROM(bool first) { if (EEPROM.read(233) != 233) //first boot/reset to default { + DEBUG_PRINT("Settings invalid, restoring defaults..."); saveSettingsToEEPROM(); + DEBUG_PRINTLN("done"); return; } int lastEEPROMversion = EEPROM.read(377); //last EEPROM version before update @@ -268,7 +272,8 @@ void loadSettingsFromEEPROM(bool first) readStringFromEEPROM(128, apSSID, 32); readStringFromEEPROM(160, apPass, 64); - nightlightDelayMins = EEPROM.read(224); + nightlightDelayMinsDefault = EEPROM.read(224); + nightlightDelayMins = nightlightDelayMinsDefault; nightlightFade = EEPROM.read(225); notifyDirectDefault = EEPROM.read(226); notifyDirect = notifyDirectDefault; @@ -343,6 +348,8 @@ void loadSettingsFromEEPROM(bool first) effectPaletteDefault = EEPROM.read(373); effectPalette = effectPaletteDefault; //374 - strip.paletteFade + irEnabled = EEPROM.read(385); + if (lastEEPROMversion > 0) { apWaitTimeSecs = EEPROM.read(375); recoveryAPDisabled = EEPROM.read(376); @@ -607,14 +614,16 @@ void saveMacro(byte index, String mc, bool sing=true) //only commit on single sa void commit() { - #ifdef ARDUINO_ARCH_ESP32 - delay(1); - portDISABLE_INTERRUPTS(); - #endif - - EEPROM.commit(); - - #ifdef ARDUINO_ARCH_ESP32 - portENABLE_INTERRUPTS(); - #endif + DEBUG_PRINT("s"); + /*#ifdef ARDUINO_ARCH_ESP32 + portMUX_TYPE mMux = portMUX_INITIALIZER_UNLOCKED; + portENTER_CRITICAL(&mMux); + #endif*/ + + EEPROM.commit(); + + /*#ifdef ARDUINO_ARCH_ESP32 + portEXIT_CRITICAL(&mMux); + #endif*/ + DEBUG_PRINT("."); } diff --git a/wled00/wled02_xml.ino b/wled00/wled02_xml.ino index 09694fbc..1730a6ef 100644 --- a/wled00/wled02_xml.ino +++ b/wled00/wled02_xml.ino @@ -216,7 +216,7 @@ void getSettingsJS(byte subPage) sappend('c',"T2",enableSecTransition); sappend('v',"BF",briMultiplier); sappend('v',"TB",nightlightTargetBri); - sappend('v',"TL",nightlightDelayMins); + sappend('v',"TL",nightlightDelayMinsDefault); sappend('c',"TW",nightlightFade); sappend('i',"PB",strip.paletteBlend); sappend('c',"RV",reverseMode); @@ -242,6 +242,7 @@ void getSettingsJS(byte subPage) if (subPage == 4) { sappend('c',"BT",buttonEnabled); + sappend('c',"IR",irEnabled); sappend('v',"UP",udpPort); sappend('c',"RB",receiveNotificationBrightness); sappend('c',"RC",receiveNotificationColor); diff --git a/wled00/wled05_init.ino b/wled00/wled05_init.ino index e93bc358..d6b2f732 100644 --- a/wled00/wled05_init.ino +++ b/wled00/wled05_init.ino @@ -251,7 +251,7 @@ void getBuildInfo() #else oappend("\r\nspiffs: false\r\n"); #endif - #ifdef DEBUG + #ifdef WLED_DEBUG oappend("debug: true\r\n"); #else oappend("debug: false\r\n"); @@ -260,8 +260,8 @@ void getBuildInfo() oappendi(BTNPIN); oappend("\r\nstrip-pin: gpio"); oappendi(LEDPIN); - oappend("\r\nbrand: wled\r\n"); - oappend("\r\nbuild-type: src\r\n"); + oappend("\r\nbrand: wled"); + oappend("\r\nbuild-type: dev\r\n"); } diff --git a/wled00/wled07_notify.ino b/wled00/wled07_notify.ino index faa524d8..4e1e01f8 100644 --- a/wled00/wled07_notify.ino +++ b/wled00/wled07_notify.ino @@ -150,56 +150,65 @@ void handleNotifications() olen = 0; notifierUdp.read(obuf, packetSize); char* udpIn = obuf; - - if (udpIn[0] == 0 && !realtimeActive && receiveNotifications) //wled notifier, block if realtime packets active + + //wled notifier, block if realtime packets active + if (udpIn[0] == 0 && !realtimeActive && receiveNotifications) { + //apply colors from notification if (receiveNotificationColor) { - col[0] = udpIn[3]; - col[1] = udpIn[4]; - col[2] = udpIn[5]; - } - if (udpIn[11] > 0 && receiveNotificationColor) //check if sending modules white val is inteded - { - white = udpIn[10]; - if (udpIn[11] > 1 ) + col[0] = udpIn[3]; + col[1] = udpIn[4]; + col[2] = udpIn[5]; + if (udpIn[11] > 0) //check if sending modules white val is inteded { - colSec[0] = udpIn[12]; - colSec[1] = udpIn[13]; - colSec[2] = udpIn[14]; - whiteSec = udpIn[15]; + white = udpIn[10]; + if (udpIn[11] > 1) + { + colSec[0] = udpIn[12]; + colSec[1] = udpIn[13]; + colSec[2] = udpIn[14]; + whiteSec = udpIn[15]; + } } } - if (udpIn[8] != effectCurrent && receiveNotificationEffects) + + //apply effects from notification + if (receiveNotificationEffects) { - effectCurrent = udpIn[8]; - strip.setMode(effectCurrent); - } - if (udpIn[9] != effectSpeed && receiveNotificationEffects) - { - effectSpeed = udpIn[9]; - strip.setSpeed(effectSpeed); - } - if (udpIn[11] > 2 && udpIn[16] != effectIntensity && receiveNotificationEffects) - { - effectIntensity = udpIn[16]; - strip.setIntensity(effectIntensity); + if (udpIn[8] != effectCurrent) + { + effectCurrent = udpIn[8]; + strip.setMode(effectCurrent); + } + if (udpIn[9] != effectSpeed) + { + effectSpeed = udpIn[9]; + strip.setSpeed(effectSpeed); + } + if (udpIn[11] > 2 && udpIn[16] != effectIntensity) + { + effectIntensity = udpIn[16]; + strip.setIntensity(effectIntensity); + } + if (udpIn[11] > 4 && udpIn[19] != effectPalette) + { + effectPalette = udpIn[19]; + strip.setPalette(effectPalette); + } } + if (udpIn[11] > 3) { transitionDelayTemp = ((udpIn[17] << 0) & 0xFF) + ((udpIn[18] << 8) & 0xFF00); } - if (udpIn[11] > 4 && udpIn[19] != effectPalette && receiveNotificationEffects) - { - effectPalette = udpIn[19]; - strip.setPalette(effectPalette); - } + nightlightActive = udpIn[6]; - if (!nightlightActive) - { - if (receiveNotificationBrightness) bri = udpIn[2]; - colorUpdated(3); - } + if (nightlightActive) nightlightDelayMins = udpIn[7]; + + if (receiveNotificationBrightness) bri = udpIn[2]; + colorUpdated(3); + } else if (udpIn[0] > 0 && udpIn[0] < 4 && receiveDirect) //1 warls //2 drgb //3 drgbw { realtimeIP = notifierUdp.remoteIP();