mirror of
https://github.com/wled/WLED.git
synced 2025-07-09 11:56:35 +00:00
Autowhite cleanup
Fix for UCS8904 hasWhite().
This commit is contained in:
parent
7c108e5128
commit
cb95a7d418
@ -77,7 +77,7 @@ uint8_t IRAM_ATTR ColorOrderMap::getPixelColorOrder(uint16_t pix, uint8_t defaul
|
|||||||
|
|
||||||
uint32_t Bus::autoWhiteCalc(uint32_t c) {
|
uint32_t Bus::autoWhiteCalc(uint32_t c) {
|
||||||
uint8_t aWM = _autoWhiteMode;
|
uint8_t aWM = _autoWhiteMode;
|
||||||
if (_gAWM < 255) aWM = _gAWM;
|
if (_gAWM != AW_GLOBAL_DISABLED) aWM = _gAWM;
|
||||||
if (aWM == RGBW_MODE_MANUAL_ONLY) return c;
|
if (aWM == RGBW_MODE_MANUAL_ONLY) return c;
|
||||||
uint8_t w = W(c);
|
uint8_t w = W(c);
|
||||||
//ignore auto-white calculation if w>0 and mode DUAL (DUAL behaves as BRIGHTER if w==0)
|
//ignore auto-white calculation if w>0 and mode DUAL (DUAL behaves as BRIGHTER if w==0)
|
||||||
|
@ -114,7 +114,7 @@ class Bus {
|
|||||||
, _needsRefresh(refresh)
|
, _needsRefresh(refresh)
|
||||||
, _data(nullptr) // keep data access consistent across all types of buses
|
, _data(nullptr) // keep data access consistent across all types of buses
|
||||||
{
|
{
|
||||||
_autoWhiteMode = Bus::hasWhite(_type) ? aw : RGBW_MODE_MANUAL_ONLY;
|
_autoWhiteMode = Bus::hasWhite(type) ? aw : RGBW_MODE_MANUAL_ONLY;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~Bus() {} //throw the bus under the bus
|
virtual ~Bus() {} //throw the bus under the bus
|
||||||
@ -148,7 +148,7 @@ class Bus {
|
|||||||
}
|
}
|
||||||
virtual bool hasWhite(void) { return Bus::hasWhite(_type); }
|
virtual bool hasWhite(void) { return Bus::hasWhite(_type); }
|
||||||
static bool hasWhite(uint8_t type) {
|
static bool hasWhite(uint8_t type) {
|
||||||
if ((type >= TYPE_WS2812_1CH && type <= TYPE_WS2812_WWA) || type == TYPE_SK6812_RGBW || type == TYPE_TM1814) return true; // digital types with white channel
|
if ((type >= TYPE_WS2812_1CH && type <= TYPE_WS2812_WWA) || type == TYPE_SK6812_RGBW || type == TYPE_TM1814 || type == TYPE_UCS8904) return true; // digital types with white channel
|
||||||
if (type > TYPE_ONOFF && type <= TYPE_ANALOG_5CH && type != TYPE_ANALOG_3CH) return true; // analog types with white channel
|
if (type > TYPE_ONOFF && type <= TYPE_ANALOG_5CH && type != TYPE_ANALOG_3CH) return true; // analog types with white channel
|
||||||
if (type == TYPE_NET_DDP_RGBW) return true; // network types with white channel
|
if (type == TYPE_NET_DDP_RGBW) return true; // network types with white channel
|
||||||
return false;
|
return false;
|
||||||
|
@ -81,10 +81,9 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
|||||||
// initialize LED pins and lengths prior to other HW (except for ethernet)
|
// initialize LED pins and lengths prior to other HW (except for ethernet)
|
||||||
JsonObject hw_led = hw["led"];
|
JsonObject hw_led = hw["led"];
|
||||||
|
|
||||||
uint8_t autoWhiteMode = RGBW_MODE_MANUAL_ONLY;
|
|
||||||
CJSON(strip.ablMilliampsMax, hw_led[F("maxpwr")]);
|
CJSON(strip.ablMilliampsMax, hw_led[F("maxpwr")]);
|
||||||
CJSON(strip.milliampsPerLed, hw_led[F("ledma")]);
|
CJSON(strip.milliampsPerLed, hw_led[F("ledma")]);
|
||||||
Bus::setGlobalAWMode(hw_led[F("rgbwm")] | 255);
|
Bus::setGlobalAWMode(hw_led[F("rgbwm")] | AW_GLOBAL_DISABLED);
|
||||||
CJSON(correctWB, hw_led["cct"]);
|
CJSON(correctWB, hw_led["cct"]);
|
||||||
CJSON(cctFromRgb, hw_led[F("cr")]);
|
CJSON(cctFromRgb, hw_led[F("cr")]);
|
||||||
CJSON(strip.cctBlending, hw_led[F("cb")]);
|
CJSON(strip.cctBlending, hw_led[F("cb")]);
|
||||||
@ -150,7 +149,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint16_t length = elm["len"] | 1;
|
uint16_t length = elm["len"] | 1;
|
||||||
uint8_t colorOrder = (int)elm[F("order")];
|
uint8_t colorOrder = (int)elm[F("order")]; // contains white channel swap option in upper nibble
|
||||||
uint8_t skipFirst = elm[F("skip")];
|
uint8_t skipFirst = elm[F("skip")];
|
||||||
uint16_t start = elm["start"] | 0;
|
uint16_t start = elm["start"] | 0;
|
||||||
if (length==0 || start + length > MAX_LEDS) continue; // zero length or we reached max. number of LEDs, just stop
|
if (length==0 || start + length > MAX_LEDS) continue; // zero length or we reached max. number of LEDs, just stop
|
||||||
@ -159,7 +158,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
|||||||
bool refresh = elm["ref"] | false;
|
bool refresh = elm["ref"] | false;
|
||||||
uint16_t freqkHz = elm[F("freq")] | 0; // will be in kHz for DotStar and Hz for PWM (not yet implemented fully)
|
uint16_t freqkHz = elm[F("freq")] | 0; // will be in kHz for DotStar and Hz for PWM (not yet implemented fully)
|
||||||
ledType |= refresh << 7; // hack bit 7 to indicate strip requires off refresh
|
ledType |= refresh << 7; // hack bit 7 to indicate strip requires off refresh
|
||||||
uint8_t AWmode = elm[F("rgbwm")] | autoWhiteMode;
|
uint8_t AWmode = elm[F("rgbwm")] | RGBW_MODE_MANUAL_ONLY;
|
||||||
if (fromFS) {
|
if (fromFS) {
|
||||||
BusConfig bc = BusConfig(ledType, pins, start, length, colorOrder, reversed, skipFirst, AWmode, freqkHz, useGlobalLedBuffer);
|
BusConfig bc = BusConfig(ledType, pins, start, length, colorOrder, reversed, skipFirst, AWmode, freqkHz, useGlobalLedBuffer);
|
||||||
mem += BusManager::memUsage(bc);
|
mem += BusManager::memUsage(bc);
|
||||||
|
@ -148,7 +148,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
} else {
|
} else {
|
||||||
freqHz = 0;
|
freqHz = 0;
|
||||||
}
|
}
|
||||||
channelSwap = (type == TYPE_SK6812_RGBW || type == TYPE_TM1814) ? request->arg(wo).toInt() : 0;
|
channelSwap = Bus::hasWhite(type) ? request->arg(wo).toInt() : 0;
|
||||||
type |= request->hasArg(rf) << 7; // off refresh override
|
type |= request->hasArg(rf) << 7; // off refresh override
|
||||||
// actual finalization is done in WLED::loop() (removing old busses and adding new)
|
// actual finalization is done in WLED::loop() (removing old busses and adding new)
|
||||||
// this may happen even before this loop is finished so we do "doInitBusses" after the loop
|
// this may happen even before this loop is finished so we do "doInitBusses" after the loop
|
||||||
|
Loading…
x
Reference in New Issue
Block a user