From a5161eb7f152d81b9982936fdcd230b7a3cbe9cd Mon Sep 17 00:00:00 2001 From: Justin Mutter Date: Wed, 31 May 2023 11:35:43 -0400 Subject: [PATCH 1/4] Use constant for mDNS name to allow setting from my_config.h (#3145) --- wled00/const.h | 1 + wled00/my_config_sample.h | 3 ++- wled00/wled.h | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/wled00/const.h b/wled00/const.h index f87db71d..cade2a0d 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -12,6 +12,7 @@ #define DEFAULT_AP_SSID "WLED-AP" #define DEFAULT_AP_PASS "wled1234" #define DEFAULT_OTA_PASS "wledota" +#define DEFAULT_MDNS_NAME "x" //increase if you need more #ifndef WLED_MAX_USERMODS diff --git a/wled00/my_config_sample.h b/wled00/my_config_sample.h index a7bd0f5a..000793de 100644 --- a/wled00/my_config_sample.h +++ b/wled00/my_config_sample.h @@ -22,4 +22,5 @@ #define CLIENT_PASS "Your_Password" */ -//#define MAX_LEDS 1500 //Maximum total LEDs. More than 1500 might create a low memory situation on ESP8266. \ No newline at end of file +//#define MAX_LEDS 1500 // Maximum total LEDs. More than 1500 might create a low memory situation on ESP8266. +//#define MDNS_NAME "wled" // mDNS hostname, ie: *.local diff --git a/wled00/wled.h b/wled00/wled.h index bcd87fd5..bb7938af 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -179,6 +179,10 @@ using PSRAMDynamicJsonDocument = BasicJsonDocument; #define CLIENT_PASS "" #endif +#ifndef MDNS_NAME + #define MDNS_NAME DEFAULT_MDNS_NAME +#endif + #if defined(WLED_AP_PASS) && !defined(WLED_AP_SSID) #error WLED_AP_PASS is defined but WLED_AP_SSID is still the default. \ Please change WLED_AP_SSID to something unique. @@ -289,7 +293,7 @@ WLED_GLOBAL char ntpServerName[33] _INIT("0.wled.pool.ntp.org"); // NTP server // WiFi CONFIG (all these can be changed via web UI, no need to set them here) WLED_GLOBAL char clientSSID[33] _INIT(CLIENT_SSID); WLED_GLOBAL char clientPass[65] _INIT(CLIENT_PASS); -WLED_GLOBAL char cmDNS[33] _INIT("x"); // mDNS address (placeholder, is replaced by wledXXXXXX.local) +WLED_GLOBAL char cmDNS[33] _INIT(MDNS_NAME); // mDNS address (*.local, replaced by wledXXXXXX if default is used) WLED_GLOBAL char apSSID[33] _INIT(""); // AP off by default (unless setup) WLED_GLOBAL byte apChannel _INIT(1); // 2.4GHz WiFi AP channel (1-13) WLED_GLOBAL byte apHide _INIT(0); // hidden AP SSID From e3783e0236aca8663e85379588c8839261f11657 Mon Sep 17 00:00:00 2001 From: dvdavide Date: Wed, 31 May 2023 20:11:30 +0200 Subject: [PATCH 2/4] Fix for displaying 1bpp bmp files (usermod EleksTube IPS) (#2988) * Fix for displaying 1bpp bmp files * EleksTubeIPS optimizations * Fixed incorrect paletteSize * stray tab --------- Co-authored-by: Aircoookie <21045690+Aircoookie@users.noreply.github.com> --- usermods/EleksTube_IPS/TFTs.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/usermods/EleksTube_IPS/TFTs.h b/usermods/EleksTube_IPS/TFTs.h index e614704f..030ec23a 100644 --- a/usermods/EleksTube_IPS/TFTs.h +++ b/usermods/EleksTube_IPS/TFTs.h @@ -133,13 +133,13 @@ private: return false; } - read32(bmpFS); // filesize in bytes - read32(bmpFS); // reserved + (void) read32(bmpFS); // filesize in bytes + (void) read32(bmpFS); // reserved seekOffset = read32(bmpFS); // start of bitmap headerSize = read32(bmpFS); // header size w = read32(bmpFS); // width h = read32(bmpFS); // height - read16(bmpFS); // color planes (must be 1) + (void) read16(bmpFS); // color planes (must be 1) bitDepth = read16(bmpFS); if (read32(bmpFS) != 0 || (bitDepth != 24 && bitDepth != 1 && bitDepth != 4 && bitDepth != 8)) { @@ -151,9 +151,9 @@ private: uint32_t palette[256]; if (bitDepth <= 8) // 1,4,8 bit bitmap: read color palette { - read32(bmpFS); read32(bmpFS); read32(bmpFS); // size, w resolution, h resolution + (void) read32(bmpFS); (void) read32(bmpFS); (void) read32(bmpFS); // size, w resolution, h resolution paletteSize = read32(bmpFS); - if (paletteSize == 0) paletteSize = bitDepth * bitDepth; //if 0, size is 2^bitDepth + if (paletteSize == 0) paletteSize = 1 << bitDepth; //if 0, size is 2^bitDepth bmpFS.seek(14 + headerSize); // start of color palette for (uint16_t i = 0; i < paletteSize; i++) { palette[i] = read32(bmpFS); @@ -198,7 +198,7 @@ private: } b = c; g = c >> 8; r = c >> 16; } - if (dimming != 255) { // only dimm when needed + if (dimming != 255) { // only dim when needed r *= dimming; g *= dimming; b *= dimming; r = r >> 8; g = g >> 8; b = b >> 8; } From 9d22a0696926dbe880eda4ea28194688ae97c78d Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 31 May 2023 20:12:17 +0200 Subject: [PATCH 3/4] Changes for allowing Alexa to change light color to White when auto-calculating from RGB (#3211) * Changes for allowing Alexa to change light color to White when auto-calculating from RGB * Update alexa.cpp Indention * Do not rely on global auto white override (gets white mode from segment light capabilities) * alexa.cpp: Removed unnecessary whitespaces --------- Co-authored-by: Aircoookie <21045690+Aircoookie@users.noreply.github.com> --- wled00/FX.h | 1 + wled00/FX_fcn.cpp | 8 ++++++++ wled00/alexa.cpp | 23 +++++++++++++++-------- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/wled00/FX.h b/wled00/FX.h index 40fb0d48..19b1fc4a 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -772,6 +772,7 @@ class WS2812FX { // 96 bytes getActiveSegmentsNum(void), getFirstSelectedSegId(void), getLastActiveSegmentId(void), + getActiveSegsLightCapabilities(bool selectedOnly = false), setPixelSegment(uint8_t n); inline uint8_t getBrightness(void) { return _brightness; } diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index fe26e029..c60ea5f2 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -1330,6 +1330,14 @@ void WS2812FX::setBrightness(uint8_t b, bool direct) { } } +uint8_t WS2812FX::getActiveSegsLightCapabilities(bool selectedOnly) { + uint8_t totalLC = 0; + for (segment &seg : _segments) { + if (seg.isActive() && (!selectedOnly || seg.isSelected())) totalLC |= seg.getLightCapabilities(); + } + return totalLC; +} + uint8_t WS2812FX::getFirstSelectedSegId(void) { size_t i = 0; diff --git a/wled00/alexa.cpp b/wled00/alexa.cpp index c122402a..179a522c 100644 --- a/wled00/alexa.cpp +++ b/wled00/alexa.cpp @@ -101,20 +101,27 @@ void onAlexaChange(EspalexaDevice* dev) { byte rgbw[4]; uint16_t ct = dev->getCt(); - if (!ct) return; - uint16_t k = 1000000 / ct; //mireds to kelvin - - if (strip.hasCCTBus()) { - strip.setCCT(k); - rgbw[0]= 0; rgbw[1]= 0; rgbw[2]= 0; rgbw[3]= 255; - } else if (strip.hasWhiteChannel()) { + if (!ct) return; + uint16_t k = 1000000 / ct; //mireds to kelvin + + if (strip.hasCCTBus()) { + bool hasManualWhite = strip.getActiveSegsLightCapabilities(true) & SEG_CAPABILITY_W; + + strip.setCCT(k); + if (hasManualWhite) { + rgbw[0] = 0; rgbw[1] = 0; rgbw[2] = 0; rgbw[3] = 255; + } else { + rgbw[0] = 255; rgbw[1] = 255; rgbw[2] = 255; rgbw[3] = 0; + dev->setValue(255); + } + } else if (strip.hasWhiteChannel()) { switch (ct) { //these values empirically look good on RGBW case 199: rgbw[0]=255; rgbw[1]=255; rgbw[2]=255; rgbw[3]=255; break; case 234: rgbw[0]=127; rgbw[1]=127; rgbw[2]=127; rgbw[3]=255; break; case 284: rgbw[0]= 0; rgbw[1]= 0; rgbw[2]= 0; rgbw[3]=255; break; case 350: rgbw[0]=130; rgbw[1]= 90; rgbw[2]= 0; rgbw[3]=255; break; case 383: rgbw[0]=255; rgbw[1]=153; rgbw[2]= 0; rgbw[3]=255; break; - default : colorKtoRGB(k, rgbw); + default : colorKtoRGB(k, rgbw); } } else { colorKtoRGB(k, rgbw); From 130f495fb6b7d987a967bfdd6ae9f50e7ad75184 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Thu, 1 Jun 2023 22:17:41 +0200 Subject: [PATCH 4/4] Bugfix multi relay. --- usermods/multi_relay/usermod_multi_relay.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/usermods/multi_relay/usermod_multi_relay.h b/usermods/multi_relay/usermod_multi_relay.h index 7e91e28a..ce71f789 100644 --- a/usermods/multi_relay/usermod_multi_relay.h +++ b/usermods/multi_relay/usermod_multi_relay.h @@ -36,13 +36,13 @@ typedef struct relay_t { int8_t pin; struct { // reduces memory footprint - bool active : 1; - bool mode : 1; - bool state : 1; - bool external : 1; - int8_t button : 4; + bool active : 1; // is the relay waiting to be switched + bool mode : 1; // does On mean 1 or 0 (inverted output) + bool state : 1; // 1 relay is On, 0 relay is Off + bool external : 1; // is the relay externally controlled + int8_t button : 4; // which button triggers relay }; - uint16_t delay; + uint16_t delay; // amount of ms to wait after it is activated } Relay; @@ -217,7 +217,7 @@ void MultiRelay::handleOffTimer() { bool activeRelays = false; for (int i=0; i 0 && now - _switchTimerStart > (_relay[i].delay*1000)) { - if (!_relay[i].external) toggleRelay(i); + if (!_relay[i].external) switchRelay(i, !offMode); _relay[i].active = false; } else if (periodicBroadcastSec && now - lastBroadcast > (periodicBroadcastSec*1000)) { if (_relay[i].pin>=0) publishMqtt(i);