Merge branch 'main' into beta-3

This commit is contained in:
Blaz Kristan 2023-06-04 18:43:28 +02:00
commit 189d145393
8 changed files with 45 additions and 23 deletions

View File

@ -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;
}

View File

@ -44,13 +44,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;
@ -219,7 +219,7 @@ void MultiRelay::handleOffTimer() {
bool activeRelays = false;
for (int i=0; i<MULTI_RELAY_MAX_RELAYS; i++) {
if (_relay[i].active && _switchTimerStart > 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);

View File

@ -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; }

View File

@ -1329,6 +1329,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;

View File

@ -105,8 +105,15 @@ void onAlexaChange(EspalexaDevice* dev)
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;

View File

@ -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

View File

@ -23,3 +23,4 @@
*/
//#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

View File

@ -179,6 +179,10 @@ using PSRAMDynamicJsonDocument = BasicJsonDocument<PSRAM_Allocator>;
#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