Skip to content

Commit b626c76

Browse files
committed
Disabled auto white mode in segments with no RGB bus
1 parent 5d90d89 commit b626c76

File tree

9 files changed

+46
-36
lines changed

9 files changed

+46
-36
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
### Builds after release 0.12.0
44

5+
#### Build 2203080
6+
7+
- Disabled auto white mode in segments with no RGB bus
8+
- Fixed hostname string not 0-terminated
9+
- Fixed Popcorn mode not lighting first LED on pop
10+
511
#### Build 2203060
612

713
- Dynamic hiding of unused color controls in UI (PR #2567)

wled00/FX.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,8 @@ class WS2812FX {
657657
paletteFade = 0,
658658
paletteBlend = 0,
659659
milliampsPerLed = 55,
660-
cctBlending = 0,
660+
autoWhiteMode = RGBW_MODE_DUAL,
661+
cctBlending = 0,
661662
getBrightness(void),
662663
getModeCount(void),
663664
getPaletteCount(void),

wled00/FX_fcn.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,18 @@ void WS2812FX::service() {
152152
_colors_t[slot] = transitions[t].currentColor(SEGMENT.colors[slot]);
153153
}
154154
if (!cctFromRgb || correctWB) busses.setSegmentCCT(_cct_t, correctWB);
155-
_no_rgb = !(SEGMENT.getLightCapabilities() & 0x01);
156155
for (uint8_t c = 0; c < NUM_COLORS; c++) {
157-
// if segment is not RGB capable, treat RGB channels of main segment colors as if 0
158-
// this prevents Dual mode with white value 0 from setting White channel from inaccessible RGB values
159-
// If not RGB capable, also treat palette as if default (0), as palettes set white channel to 0
160-
if (_no_rgb) _colors_t[c] = _colors_t[c] & 0xFF000000;
161156
_colors_t[c] = gamma32(_colors_t[c]);
162157
}
163158
handle_palette();
159+
160+
// if segment is not RGB capable, force None auto white mode
161+
// If not RGB capable, also treat palette as if default (0), as palettes set white channel to 0
162+
_no_rgb = !(SEGMENT.getLightCapabilities() & 0x01);
163+
if (_no_rgb) Bus::setAutoWhiteMode(RGBW_MODE_MANUAL_ONLY);
164164
delay = (this->*_mode[SEGMENT.mode])(); //effect function
165165
if (SEGMENT.mode != FX_MODE_HALLOWEEN_EYES) SEGENV.call++;
166+
Bus::setAutoWhiteMode(strip.autoWhiteMode);
166167
}
167168

168169
SEGENV.next_time = nowUp + delay;
@@ -573,21 +574,23 @@ void WS2812FX::Segment::refreshLightCapabilities() {
573574
_capabilities = 0; return;
574575
}
575576
uint8_t capabilities = 0;
576-
uint8_t awm = Bus::getAutoWhiteMode();
577+
uint8_t awm = instance->autoWhiteMode;
577578
bool whiteSlider = (awm == RGBW_MODE_DUAL || awm == RGBW_MODE_MANUAL_ONLY);
579+
bool segHasValidBus = false;
578580

579581
for (uint8_t b = 0; b < busses.getNumBusses(); b++) {
580582
Bus *bus = busses.getBus(b);
581583
if (bus == nullptr || bus->getLength()==0) break;
582584
if (bus->getStart() >= stop) continue;
583585
if (bus->getStart() + bus->getLength() <= start) continue;
584586

587+
segHasValidBus = true;
585588
uint8_t type = bus->getType();
586-
if (!whiteSlider || (type != TYPE_ANALOG_1CH && (cctFromRgb || type != TYPE_ANALOG_2CH)))
589+
if (type != TYPE_ANALOG_1CH && (cctFromRgb || type != TYPE_ANALOG_2CH))
587590
{
588-
capabilities |= 0x01; //segment supports RGB (full color)
591+
capabilities |= 0x01; // segment supports RGB (full color)
589592
}
590-
if (bus->isRgbw() && whiteSlider) capabilities |= 0x02; //segment supports white channel
593+
if (bus->isRgbw() && whiteSlider) capabilities |= 0x02; // segment supports white channel
591594
if (!cctFromRgb) {
592595
switch (type) {
593596
case TYPE_ANALOG_5CH:
@@ -597,6 +600,9 @@ void WS2812FX::Segment::refreshLightCapabilities() {
597600
}
598601
if (correctWB && type != TYPE_ANALOG_1CH) capabilities |= 0x04; //white balance correction (uses CCT slider)
599602
}
603+
// if seg has any bus, but no bus has RGB, it by definition supports white (at least for now)
604+
// In case of no RGB, disregard auto white mode and always show a white slider
605+
if (segHasValidBus && !(capabilities & 0x01)) capabilities |= 0x02; // segment supports white channel
600606
_capabilities = capabilities;
601607
}
602608

wled00/cfg.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,14 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
8080

8181
CJSON(strip.ablMilliampsMax, hw_led[F("maxpwr")]);
8282
CJSON(strip.milliampsPerLed, hw_led[F("ledma")]);
83-
Bus::setAutoWhiteMode(hw_led[F("rgbwm")] | Bus::getAutoWhiteMode());
83+
CJSON(strip.autoWhiteMode, hw_led[F("rgbwm")]);
84+
Bus::setAutoWhiteMode(strip.autoWhiteMode);
8485
strip.fixInvalidSegments(); // refreshes segment light capabilities (in case auto white mode changed)
8586
CJSON(correctWB, hw_led["cct"]);
8687
CJSON(cctFromRgb, hw_led[F("cr")]);
87-
CJSON(strip.cctBlending, hw_led[F("cb")]);
88-
Bus::setCCTBlend(strip.cctBlending);
89-
strip.setTargetFps(hw_led["fps"]); //NOP if 0, default 42 FPS
88+
CJSON(strip.cctBlending, hw_led[F("cb")]);
89+
Bus::setCCTBlend(strip.cctBlending);
90+
strip.setTargetFps(hw_led["fps"]); //NOP if 0, default 42 FPS
9091

9192
JsonArray ins = hw_led["ins"];
9293

@@ -577,9 +578,9 @@ void serializeConfig() {
577578
hw_led[F("ledma")] = strip.milliampsPerLed;
578579
hw_led["cct"] = correctWB;
579580
hw_led[F("cr")] = cctFromRgb;
580-
hw_led[F("cb")] = strip.cctBlending;
581-
hw_led["fps"] = strip.getTargetFps();
582-
hw_led[F("rgbwm")] = Bus::getAutoWhiteMode();
581+
hw_led[F("cb")] = strip.cctBlending;
582+
hw_led["fps"] = strip.getTargetFps();
583+
hw_led[F("rgbwm")] = strip.autoWhiteMode;
583584

584585
JsonArray hw_led_ins = hw_led.createNestedArray("ins");
585586

wled00/ir.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ void changeColor(uint32_t c, int16_t cct=-1)
226226
bool isCCT = GET_BIT(capabilities, 2);
227227
if (isRGB) mask |= 0x00FFFFFF; // RGB
228228
if (hasW) mask |= 0xFF000000; // white
229-
if (hasW && (Bus::getAutoWhiteMode() == RGBW_MODE_AUTO_ACCURATE) && (c & 0xFF000000)) { // white channel & white specified
229+
if (hasW && (strip.autoWhiteMode == RGBW_MODE_AUTO_ACCURATE) && (c & 0xFF000000)) { // white channel & white specified
230230
seg.setColor(0, c | 0xFFFFFF, i); // for accurate mode we fake white
231231
} else if (c & mask) seg.setColor(0, c & mask, i); // only apply if not black
232232
if (isCCT && cct >= 0) seg.setCCT(cct, i);
@@ -242,7 +242,7 @@ void changeColor(uint32_t c, int16_t cct=-1)
242242
bool isCCT = GET_BIT(capabilities, 2);
243243
if (isRGB) mask |= 0x00FFFFFF; // RGB
244244
if (hasW) mask |= 0xFF000000; // white
245-
if (hasW && (Bus::getAutoWhiteMode() == RGBW_MODE_AUTO_ACCURATE) && (c & 0xFF000000)) { // white channel & white specified
245+
if (hasW && (strip.autoWhiteMode == RGBW_MODE_AUTO_ACCURATE) && (c & 0xFF000000)) { // white channel & white specified
246246
seg.setColor(0, c | 0xFFFFFF, i); // for accurate mode we fake white
247247
} else if (c & mask) seg.setColor(0, c & mask, i); // only apply if not black
248248
if (isCCT && cct >= 0) seg.setCCT(cct, i);

wled00/json.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -497,15 +497,6 @@ void serializeInfo(JsonObject root)
497497

498498
JsonObject leds = root.createNestedObject("leds");
499499
leds[F("count")] = strip.getLengthTotal();
500-
leds[F("rgbw")] = strip.hasRGBWBus(); //deprecated, use info.leds.lc
501-
leds[F("wv")] = false; //deprecated, use info.leds.lc
502-
leds["cct"] = correctWB || strip.hasCCTBus(); //deprecated, use info.leds.lc
503-
switch (Bus::getAutoWhiteMode()) {
504-
case RGBW_MODE_MANUAL_ONLY:
505-
case RGBW_MODE_DUAL:
506-
if (strip.hasWhiteChannel()) leds[F("wv")] = true;
507-
break;
508-
}
509500

510501
leds[F("pwr")] = strip.currentMilliamps;
511502
leds["fps"] = strip.getFps();
@@ -524,6 +515,10 @@ void serializeInfo(JsonObject root)
524515

525516
leds["lc"] = totalLC;
526517

518+
leds[F("rgbw")] = strip.hasRGBWBus(); // deprecated, use info.leds.lc
519+
leds[F("wv")] = totalLC & 0x02; // deprecated, true if white slider should be displayed for any segment
520+
leds["cct"] = totalLC & 0x04; // deprecated, use info.leds.lc
521+
527522
root[F("str")] = syncToggleReceive;
528523

529524
root[F("name")] = serverDescription;

wled00/set.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,11 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
8484
autoSegments = request->hasArg(F("MS"));
8585
correctWB = request->hasArg(F("CCT"));
8686
cctFromRgb = request->hasArg(F("CR"));
87-
strip.cctBlending = request->arg(F("CB")).toInt();
88-
Bus::setCCTBlend(strip.cctBlending);
89-
Bus::setAutoWhiteMode(request->arg(F("AW")).toInt());
90-
strip.setTargetFps(request->arg(F("FR")).toInt());
87+
strip.cctBlending = request->arg(F("CB")).toInt();
88+
Bus::setCCTBlend(strip.cctBlending);
89+
strip.autoWhiteMode = (request->arg(F("AW")).toInt());
90+
Bus::setAutoWhiteMode(strip.autoWhiteMode);
91+
strip.setTargetFps(request->arg(F("FR")).toInt());
9192

9293
for (uint8_t s = 0; s < WLED_MAX_BUSSES; s++) {
9394
char lp[4] = "L0"; lp[2] = 48+s; lp[3] = 0; //ascii 0-9 //strip data pin

wled00/wled.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
// version code in format yymmddb (b = daily build)
11-
#define VERSION 2203061
11+
#define VERSION 2203080
1212

1313
//uncomment this if you have a "my_config.h" file you'd like to use
1414
//#define WLED_USE_MY_CONFIG

wled00/xml.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,9 @@ void getSettingsJS(byte subPage, char* dest)
382382
sappend('c',SET_F("MS"),autoSegments);
383383
sappend('c',SET_F("CCT"),correctWB);
384384
sappend('c',SET_F("CR"),cctFromRgb);
385-
sappend('v',SET_F("CB"),strip.cctBlending);
386-
sappend('v',SET_F("FR"),strip.getTargetFps());
387-
sappend('v',SET_F("AW"),Bus::getAutoWhiteMode());
385+
sappend('v',SET_F("CB"),strip.cctBlending);
386+
sappend('v',SET_F("FR"),strip.getTargetFps());
387+
sappend('v',SET_F("AW"),strip.autoWhiteMode);
388388

389389
for (uint8_t s=0; s < busses.getNumBusses(); s++) {
390390
Bus* bus = busses.getBus(s);

0 commit comments

Comments
 (0)