Skip to content

Commit 9e3fc34

Browse files
committed
Remove global AWM from configurationa and allow runtime override using "awm" JSON and "AW" HTTP API.
- see wled#5153 - see https://wled.discourse.group/t/should-awm-1-work-in-a-preset-how-to-toggle-away-from-default-handling/15018
1 parent 5c94b67 commit 9e3fc34

File tree

6 files changed

+16
-7
lines changed

6 files changed

+16
-7
lines changed

wled00/bus_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ bool PolyBus::_useParallelI2S = false;
933933
// Bus static member definition
934934
int16_t Bus::_cct = -1;
935935
uint8_t Bus::_cctBlend = 0;
936-
uint8_t Bus::_gAWM = 255;
936+
uint8_t Bus::_gAWM = AW_GLOBAL_DISABLED;
937937

938938
uint16_t BusDigital::_milliAmpsTotal = 0;
939939

wled00/cfg.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
176176
JsonObject hw_led = hw["led"];
177177

178178
CJSON(strip.milliAmpsMax, hw_led[F("maxpwr")]); // milliAmps max for strip ABL, 0 means no ABL or PP-ABL
179-
Bus::setGlobalAWMode(hw_led[F("rgbwm")] | AW_GLOBAL_DISABLED);
179+
Bus::setGlobalAWMode(hw_led[F("rgbwm")] | AW_GLOBAL_DISABLED); // legacy global AW mode setting (remove at some point)
180180
CJSON(strip.correctWB, hw_led["cct"]);
181181
CJSON(strip.cctFromRgb, hw_led[F("cr")]);
182182
CJSON(cctICused, hw_led[F("ic")]);
@@ -242,7 +242,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
242242
bool reversed = elm["rev"];
243243
bool refresh = elm["ref"] | false;
244244
uint16_t freqkHz = elm[F("freq")] | 0; // will be in kHz for DotStar and Hz for PWM
245-
uint8_t AWmode = elm[F("rgbwm")] | RGBW_MODE_MANUAL_ONLY;
245+
uint8_t AWmode = elm[F("rgbwm")] | (Bus::getGlobalAWMode() == AW_GLOBAL_DISABLED ? RGBW_MODE_MANUAL_ONLY : Bus::getGlobalAWMode());
246246
uint8_t maPerLed = elm[F("ledma")] | LED_MILLIAMPS_DEFAULT;
247247
uint16_t maMax = elm[F("maxpwr")] | 0; // maMax > 0 means per bus PP-ABL is enabled (bus has its own maximum allowable current)
248248
// To disable brightness limiter we either set output max current to 0 or single LED current to 0
@@ -897,7 +897,7 @@ void serializeConfig() {
897897
hw_led[F("ic")] = cctICused;
898898
hw_led[F("cb")] = Bus::getCCTBlend();
899899
hw_led["fps"] = strip.getTargetFps();
900-
hw_led[F("rgbwm")] = Bus::getGlobalAWMode(); // global auto white mode override
900+
//hw_led[F("rgbwm")] = Bus::getGlobalAWMode(); // global auto white mode override (deprecated and removed from configuration)
901901
#if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32C3)
902902
hw_led[F("prl")] = BusManager::hasParallelOutput();
903903
#endif

wled00/data/settings_leds.htm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197
// display global white channel overrides
198198
gId("wc").style.display = (gRGBW) ? 'inline':'none';
199199
if (!gRGBW) {
200-
d.Sf.AW.selectedIndex = 0;
200+
//d.Sf.AW.selectedIndex = 0;
201201
d.Sf.CR.checked = false;
202202
}
203203
// update start indexes, max values, calculate current, etc
@@ -905,6 +905,7 @@ <h3>Timed light</h3>
905905
<h3>White management</h3>
906906
White Balance correction: <input type="checkbox" name="CCT"><br>
907907
<div id="wc">
908+
<!--
908909
Global override for Auto-calculate white:<br>
909910
<select name="AW">
910911
<option value=255>Disabled</option>
@@ -915,6 +916,7 @@ <h3>White management</h3>
915916
<option value=4>Max</option>
916917
</select>
917918
<br>
919+
-->
918920
Calculate CCT from RGB: <input type="checkbox" name="CR"><br>
919921
CCT IC used (Athom 15W): <input type="checkbox" name="IC"><br>
920922
CCT additive blending: <input type="number" class="s" min="0" max="100" name="CB" onchange="UI()" required> %<br>

wled00/json.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,9 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
421421
strip.setTransition(tr * 100);
422422
}
423423

424+
// global AWM override
425+
Bus::setGlobalAWMode(root[F("awm")] | Bus::getGlobalAWMode()); // override AW mode setting
426+
424427
tr = root[F("tb")] | -1;
425428
if (tr >= 0) strip.timebase = (unsigned long)tr - millis();
426429

wled00/set.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
159159
cctICused = request->hasArg(F("IC"));
160160
uint8_t cctBlending = request->arg(F("CB")).toInt();
161161
Bus::setCCTBlend(cctBlending);
162-
Bus::setGlobalAWMode(request->arg(F("AW")).toInt());
162+
//Bus::setGlobalAWMode(request->arg(F("AW")).toInt());
163163
strip.setTargetFps(request->arg(F("FR")).toInt());
164164
#if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32C3)
165165
useParallelI2S = request->hasArg(F("PR"));
@@ -1091,6 +1091,10 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
10911091
if (check3Changed) seg.check3 = (bool)check3In;
10921092
}
10931093

1094+
// set global AWM override
1095+
pos = req.indexOf(F("AW="));
1096+
if (pos > 0) Bus::setGlobalAWMode(getNumVal(req, pos));
1097+
10941098
//set advanced overlay
10951099
pos = req.indexOf(F("OL="));
10961100
if (pos > 0) {

wled00/xml.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ void getSettingsJS(byte subPage, Print& settingsScript)
314314
printSetFormCheckbox(settingsScript,PSTR("CR"),strip.cctFromRgb);
315315
printSetFormValue(settingsScript,PSTR("CB"),Bus::getCCTBlend());
316316
printSetFormValue(settingsScript,PSTR("FR"),strip.getTargetFps());
317-
printSetFormValue(settingsScript,PSTR("AW"),Bus::getGlobalAWMode());
317+
//printSetFormValue(settingsScript,PSTR("AW"),Bus::getGlobalAWMode());
318318
printSetFormCheckbox(settingsScript,PSTR("PR"),BusManager::hasParallelOutput()); // get it from bus manager not global variable
319319

320320
unsigned sumMa = 0;

0 commit comments

Comments
 (0)