Disabled auto white mode in segments with no RGB bus

This commit is contained in:
cschwinne 2022-03-08 02:16:33 +01:00
parent 5d90d8930e
commit b626c7620e
9 changed files with 46 additions and 36 deletions

View File

@ -2,6 +2,12 @@
### Builds after release 0.12.0
#### Build 2203080
- Disabled auto white mode in segments with no RGB bus
- Fixed hostname string not 0-terminated
- Fixed Popcorn mode not lighting first LED on pop
#### Build 2203060
- Dynamic hiding of unused color controls in UI (PR #2567)

View File

@ -657,7 +657,8 @@ class WS2812FX {
paletteFade = 0,
paletteBlend = 0,
milliampsPerLed = 55,
cctBlending = 0,
autoWhiteMode = RGBW_MODE_DUAL,
cctBlending = 0,
getBrightness(void),
getModeCount(void),
getPaletteCount(void),

View File

@ -152,17 +152,18 @@ void WS2812FX::service() {
_colors_t[slot] = transitions[t].currentColor(SEGMENT.colors[slot]);
}
if (!cctFromRgb || correctWB) busses.setSegmentCCT(_cct_t, correctWB);
_no_rgb = !(SEGMENT.getLightCapabilities() & 0x01);
for (uint8_t c = 0; c < NUM_COLORS; c++) {
// if segment is not RGB capable, treat RGB channels of main segment colors as if 0
// this prevents Dual mode with white value 0 from setting White channel from inaccessible RGB values
// If not RGB capable, also treat palette as if default (0), as palettes set white channel to 0
if (_no_rgb) _colors_t[c] = _colors_t[c] & 0xFF000000;
_colors_t[c] = gamma32(_colors_t[c]);
}
handle_palette();
// if segment is not RGB capable, force None auto white mode
// If not RGB capable, also treat palette as if default (0), as palettes set white channel to 0
_no_rgb = !(SEGMENT.getLightCapabilities() & 0x01);
if (_no_rgb) Bus::setAutoWhiteMode(RGBW_MODE_MANUAL_ONLY);
delay = (this->*_mode[SEGMENT.mode])(); //effect function
if (SEGMENT.mode != FX_MODE_HALLOWEEN_EYES) SEGENV.call++;
Bus::setAutoWhiteMode(strip.autoWhiteMode);
}
SEGENV.next_time = nowUp + delay;
@ -573,8 +574,9 @@ void WS2812FX::Segment::refreshLightCapabilities() {
_capabilities = 0; return;
}
uint8_t capabilities = 0;
uint8_t awm = Bus::getAutoWhiteMode();
uint8_t awm = instance->autoWhiteMode;
bool whiteSlider = (awm == RGBW_MODE_DUAL || awm == RGBW_MODE_MANUAL_ONLY);
bool segHasValidBus = false;
for (uint8_t b = 0; b < busses.getNumBusses(); b++) {
Bus *bus = busses.getBus(b);
@ -582,12 +584,13 @@ void WS2812FX::Segment::refreshLightCapabilities() {
if (bus->getStart() >= stop) continue;
if (bus->getStart() + bus->getLength() <= start) continue;
segHasValidBus = true;
uint8_t type = bus->getType();
if (!whiteSlider || (type != TYPE_ANALOG_1CH && (cctFromRgb || type != TYPE_ANALOG_2CH)))
if (type != TYPE_ANALOG_1CH && (cctFromRgb || type != TYPE_ANALOG_2CH))
{
capabilities |= 0x01; //segment supports RGB (full color)
capabilities |= 0x01; // segment supports RGB (full color)
}
if (bus->isRgbw() && whiteSlider) capabilities |= 0x02; //segment supports white channel
if (bus->isRgbw() && whiteSlider) capabilities |= 0x02; // segment supports white channel
if (!cctFromRgb) {
switch (type) {
case TYPE_ANALOG_5CH:
@ -597,6 +600,9 @@ void WS2812FX::Segment::refreshLightCapabilities() {
}
if (correctWB && type != TYPE_ANALOG_1CH) capabilities |= 0x04; //white balance correction (uses CCT slider)
}
// if seg has any bus, but no bus has RGB, it by definition supports white (at least for now)
// In case of no RGB, disregard auto white mode and always show a white slider
if (segHasValidBus && !(capabilities & 0x01)) capabilities |= 0x02; // segment supports white channel
_capabilities = capabilities;
}

View File

@ -80,13 +80,14 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
CJSON(strip.ablMilliampsMax, hw_led[F("maxpwr")]);
CJSON(strip.milliampsPerLed, hw_led[F("ledma")]);
Bus::setAutoWhiteMode(hw_led[F("rgbwm")] | Bus::getAutoWhiteMode());
CJSON(strip.autoWhiteMode, hw_led[F("rgbwm")]);
Bus::setAutoWhiteMode(strip.autoWhiteMode);
strip.fixInvalidSegments(); // refreshes segment light capabilities (in case auto white mode changed)
CJSON(correctWB, hw_led["cct"]);
CJSON(cctFromRgb, hw_led[F("cr")]);
CJSON(strip.cctBlending, hw_led[F("cb")]);
Bus::setCCTBlend(strip.cctBlending);
strip.setTargetFps(hw_led["fps"]); //NOP if 0, default 42 FPS
CJSON(strip.cctBlending, hw_led[F("cb")]);
Bus::setCCTBlend(strip.cctBlending);
strip.setTargetFps(hw_led["fps"]); //NOP if 0, default 42 FPS
JsonArray ins = hw_led["ins"];
@ -577,9 +578,9 @@ void serializeConfig() {
hw_led[F("ledma")] = strip.milliampsPerLed;
hw_led["cct"] = correctWB;
hw_led[F("cr")] = cctFromRgb;
hw_led[F("cb")] = strip.cctBlending;
hw_led["fps"] = strip.getTargetFps();
hw_led[F("rgbwm")] = Bus::getAutoWhiteMode();
hw_led[F("cb")] = strip.cctBlending;
hw_led["fps"] = strip.getTargetFps();
hw_led[F("rgbwm")] = strip.autoWhiteMode;
JsonArray hw_led_ins = hw_led.createNestedArray("ins");

View File

@ -226,7 +226,7 @@ void changeColor(uint32_t c, int16_t cct=-1)
bool isCCT = GET_BIT(capabilities, 2);
if (isRGB) mask |= 0x00FFFFFF; // RGB
if (hasW) mask |= 0xFF000000; // white
if (hasW && (Bus::getAutoWhiteMode() == RGBW_MODE_AUTO_ACCURATE) && (c & 0xFF000000)) { // white channel & white specified
if (hasW && (strip.autoWhiteMode == RGBW_MODE_AUTO_ACCURATE) && (c & 0xFF000000)) { // white channel & white specified
seg.setColor(0, c | 0xFFFFFF, i); // for accurate mode we fake white
} else if (c & mask) seg.setColor(0, c & mask, i); // only apply if not black
if (isCCT && cct >= 0) seg.setCCT(cct, i);
@ -242,7 +242,7 @@ void changeColor(uint32_t c, int16_t cct=-1)
bool isCCT = GET_BIT(capabilities, 2);
if (isRGB) mask |= 0x00FFFFFF; // RGB
if (hasW) mask |= 0xFF000000; // white
if (hasW && (Bus::getAutoWhiteMode() == RGBW_MODE_AUTO_ACCURATE) && (c & 0xFF000000)) { // white channel & white specified
if (hasW && (strip.autoWhiteMode == RGBW_MODE_AUTO_ACCURATE) && (c & 0xFF000000)) { // white channel & white specified
seg.setColor(0, c | 0xFFFFFF, i); // for accurate mode we fake white
} else if (c & mask) seg.setColor(0, c & mask, i); // only apply if not black
if (isCCT && cct >= 0) seg.setCCT(cct, i);

View File

@ -497,15 +497,6 @@ void serializeInfo(JsonObject root)
JsonObject leds = root.createNestedObject("leds");
leds[F("count")] = strip.getLengthTotal();
leds[F("rgbw")] = strip.hasRGBWBus(); //deprecated, use info.leds.lc
leds[F("wv")] = false; //deprecated, use info.leds.lc
leds["cct"] = correctWB || strip.hasCCTBus(); //deprecated, use info.leds.lc
switch (Bus::getAutoWhiteMode()) {
case RGBW_MODE_MANUAL_ONLY:
case RGBW_MODE_DUAL:
if (strip.hasWhiteChannel()) leds[F("wv")] = true;
break;
}
leds[F("pwr")] = strip.currentMilliamps;
leds["fps"] = strip.getFps();
@ -524,6 +515,10 @@ void serializeInfo(JsonObject root)
leds["lc"] = totalLC;
leds[F("rgbw")] = strip.hasRGBWBus(); // deprecated, use info.leds.lc
leds[F("wv")] = totalLC & 0x02; // deprecated, true if white slider should be displayed for any segment
leds["cct"] = totalLC & 0x04; // deprecated, use info.leds.lc
root[F("str")] = syncToggleReceive;
root[F("name")] = serverDescription;

View File

@ -84,10 +84,11 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
autoSegments = request->hasArg(F("MS"));
correctWB = request->hasArg(F("CCT"));
cctFromRgb = request->hasArg(F("CR"));
strip.cctBlending = request->arg(F("CB")).toInt();
Bus::setCCTBlend(strip.cctBlending);
Bus::setAutoWhiteMode(request->arg(F("AW")).toInt());
strip.setTargetFps(request->arg(F("FR")).toInt());
strip.cctBlending = request->arg(F("CB")).toInt();
Bus::setCCTBlend(strip.cctBlending);
strip.autoWhiteMode = (request->arg(F("AW")).toInt());
Bus::setAutoWhiteMode(strip.autoWhiteMode);
strip.setTargetFps(request->arg(F("FR")).toInt());
for (uint8_t s = 0; s < WLED_MAX_BUSSES; s++) {
char lp[4] = "L0"; lp[2] = 48+s; lp[3] = 0; //ascii 0-9 //strip data pin

View File

@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2203061
#define VERSION 2203080
//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG

View File

@ -382,9 +382,9 @@ void getSettingsJS(byte subPage, char* dest)
sappend('c',SET_F("MS"),autoSegments);
sappend('c',SET_F("CCT"),correctWB);
sappend('c',SET_F("CR"),cctFromRgb);
sappend('v',SET_F("CB"),strip.cctBlending);
sappend('v',SET_F("FR"),strip.getTargetFps());
sappend('v',SET_F("AW"),Bus::getAutoWhiteMode());
sappend('v',SET_F("CB"),strip.cctBlending);
sappend('v',SET_F("FR"),strip.getTargetFps());
sappend('v',SET_F("AW"),strip.autoWhiteMode);
for (uint8_t s=0; s < busses.getNumBusses(); s++) {
Bus* bus = busses.getBus(s);