From 4fdf85bbdb7e62938b255603e2af5fe8dbf2117e Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Thu, 7 Oct 2021 22:57:07 +0200 Subject: [PATCH] Add off override. --- wled00/FX_fcn.cpp | 2 +- wled00/bus_manager.h | 19 ++++++++++--------- wled00/cfg.cpp | 18 ++++-------------- wled00/data/settings_leds.htm | 17 +++++++++-------- wled00/html_settings.h | 2 +- wled00/set.cpp | 7 ++----- wled00/wled.cpp | 13 ------------- wled00/wled.h | 2 +- wled00/xml.cpp | 4 ++-- 9 files changed, 30 insertions(+), 54 deletions(-) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index cff70027..c039501d 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -97,7 +97,7 @@ void WS2812FX::finalizeInit(void) //RGBW mode is enabled if at least one of the strips is RGBW isRgbw |= bus->isRgbw(); //refresh is required to remain off if at least one of the strips requires the refresh. - isOffRefreshRequred |= BusManager::isOffRefreshRequred(bus->getType()); + isOffRefreshRequred |= bus->isOffRefreshRequired(); _length += bus->getLength(); } ledCount = _length; diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 83f42ccf..f968f6d0 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -36,11 +36,11 @@ struct BusConfig { uint8_t colorOrder; bool reversed; uint8_t skipAmount; - bool rgbwOverride; + bool refreshReq; uint8_t pins[5] = {LEDPIN, 255, 255, 255, 255}; BusConfig(uint8_t busType, uint8_t* ppins, uint16_t pstart, uint16_t len = 1, uint8_t pcolorOrder = COL_ORDER_GRB, bool rev = false, uint8_t skip = 0) { - rgbwOverride = (bool) GET_BIT(busType,7); - type = busType & 0x7F; // bit 7 may be/is hacked to include RGBW info (1=RGBW, 0=RGB) + refreshReq = (bool) GET_BIT(busType,7); + type = busType & 0x7F; // bit 7 may be/is hacked to include refresh info (1=refresh in off state, 0=no refresh) count = len; start = pstart; colorOrder = pcolorOrder; reversed = rev; skipAmount = skip; uint8_t nPins = 1; if (type >= TYPE_NET_DDP_RGB && type < 96) nPins = 4; //virtual network bus. 4 "pins" store IP address @@ -126,6 +126,10 @@ class Bus { return false; } + inline bool isOffRefreshRequired() { + return _needsRefresh; + } + bool reversed = false; protected: @@ -133,6 +137,7 @@ class Bus { uint8_t _bri = 255; uint16_t _start = 0; bool _valid = false; + bool _needsRefresh = false; }; @@ -149,9 +154,10 @@ class BusDigital : public Bus { _pins[1] = bc.pins[1]; } reversed = bc.reversed; + _needsRefresh = bc.refreshReq || bc.type == TYPE_TM1814; _skip = bc.skipAmount; //sacrificial pixels _len = bc.count + _skip; - _rgbw = bc.rgbwOverride || Bus::isRgbw(bc.type); // RGBW override in bit 7 + _rgbw = Bus::isRgbw(bc.type); _iType = PolyBus::getI(bc.type, _pins, nr, _rgbw); if (_iType == I_NONE) return; _busPtr = PolyBus::create(_iType, _pins, _len, nr); @@ -588,11 +594,6 @@ class BusManager { return Bus::isRgbw(type); } - //Return true if the strip requires a refresh to stay off. - static bool isOffRefreshRequred(uint8_t type) { - return type == TYPE_TM1814; - } - private: uint8_t numBusses = 0; Bus* busses[WLED_MAX_BUSSES]; diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index 8c0cf6bb..184adcae 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -114,24 +114,13 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { if (start > lC+length) continue; // something is very wrong :) uint8_t ledType = elm["type"] | TYPE_WS2812_RGB; bool reversed = elm["rev"]; - //if ((bool)elm[F("rgbw")]) SET_BIT(ledType,7); else UNSET_BIT(ledType,7); // hack bit 7 to indicate RGBW (as an override if necessary) + bool refresh = elm["ref"] | false; + ledType |= refresh << 7; // hack bit 7 to indicate strip requires off refresh s++; lC += length; BusConfig bc = BusConfig(ledType, pins, start, length, colorOrder, reversed, skipFirst); mem += BusManager::memUsage(bc); if (mem <= MAX_LED_MEMORY && busses.getNumBusses() <= WLED_MAX_BUSSES) busses.add(bc); // finalization will be done in WLED::beginStrip() -/* - BusConfig bc = BusConfig(ledType, pins, start, length, colorOrder, reversed, skipFirst); - if (bc.adjustBounds(ledCount)) { - //RGBW mode is enabled if at least one of the strips is RGBW - strip.isRgbw = (strip.isRgbw || BusManager::isRgbw(ledType)); - //refresh is required to remain off if at least one of the strips requires the refresh. - strip.isOffRefreshRequred |= BusManager::isOffRefreshRequred(ledType); - s++; - mem += busses.memUsage(bc); - if (mem <= MAX_LED_MEMORY) busses.add(bc); - } -*/ } // finalization done in beginStrip() } @@ -559,7 +548,8 @@ void serializeConfig() { ins[F("order")] = bus->getColorOrder(); ins["rev"] = bus->reversed; ins[F("skip")] = bus->skippedLeds(); - ins["type"] = bus->getType(); + ins["type"] = bus->getType() & 0x7F;; + ins["ref"] = bus->isOffRefreshRequired(); ins[F("rgbw")] = bus->isRgbw(); } diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index bb7470b9..304d54fa 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -160,18 +160,19 @@ } } if (change) { -// // blazoncek experimental extension -// gId("ew"+n).checked = (t == 30 || t == 31 || t == 44 || t == 45); // RGBW checkbox, TYPE_xxxx values from const.h + // blazoncek experimental extension + gId("rf"+n).checked = (gId("rf"+n).checked || t == 31); // LEDs require data in off state if (t > 31 && t < 48) d.getElementsByName("LC"+n)[0].value = 1; // for sanity change analog count just to 1 LED } -// // blazoncek experimental extension -// gId("ew"+n).onclick = (t > 31 && t < 48) ? (function(){return false}) : (function(){}); // prevent change for analog -// isRGBW |= gId("ew"+n).checked; + // blazoncek experimental extension + gId("rf"+n).onclick = (t == 31) ? (function(){return false}) : (function(){}); // prevent change for TM1814 isRGBW |= (t == 30 || t == 31 || (t > 40 && t < 46 && t != 43)); // RGBW checkbox, TYPE_xxxx values from const.h gId("co"+n).style.display = ((t>=80 && t<96) || t == 41 || t == 42) ? "none":"inline"; // hide color order for PWM W & WW/CW gId("dig"+n+"c").style.display = (t > 40 && t < 48) ? "none":"inline"; // hide count for analog gId("dig"+n+"r").style.display = (t>=80 && t<96) ? "none":"inline"; // hide reversed for virtual gId("dig"+n+"s").style.display = ((t>=80 && t<96) || (t > 40 && t < 48)) ? "none":"inline"; // hide skip 1st for virtual & analog + // blazoncek experimental extension + gId("dig"+n+"f").style.display = (t>=16 && t<32 || t>=50 && t<64) ? "inline":"none"; // hide refresh gId("rev"+n).innerHTML = (t > 40 && t < 48) ? "Inverted output":"Reversed (rotated 180°)"; // change reverse text for analog gId("psd"+n).innerHTML = (t > 40 && t < 48) ? "Index:":"Start:"; // change analog start description } @@ -333,9 +334,9 @@ ${i+1}: -
-
Reversed:  
-
Skip 1st LED:
+

Reversed:
+

Skip 1st LED:
+

Off Refresh:  
`; f.insertAdjacentHTML("beforeend", cn); } diff --git a/wled00/html_settings.h b/wled00/html_settings.h index ef1c2629..8876ce51 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -77,7 +77,7 @@ onclick="B()">Back // Autogenerated from wled00/data/settings_leds.htm, do not edit!! const char PAGE_settings_leds[] PROGMEM = R"=====(LED Settings