Updated aut-white calculation.

This commit is contained in:
Blaž Kristan 2021-10-27 14:02:48 +02:00 committed by GitHub
parent 8ca298b299
commit f55f803531
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -124,21 +124,15 @@ class Bus {
uint8_t _autoWhiteMode = 0; uint8_t _autoWhiteMode = 0;
uint32_t autoWhiteCalc(uint32_t c) { uint32_t autoWhiteCalc(uint32_t c) {
switch (_autoWhiteMode) { if (_autoWhiteMode == RGBW_MODE_MANUAL_ONLY) return c;
case RGBW_MODE_MANUAL_ONLY: uint8_t r = R(c);
break; uint8_t g = G(c);
default: uint8_t b = B(c);
//white value is set to lowest RGB channel, thank you to @Def3nder! uint8_t w = W(c);
uint8_t r = R(c); // ignore auto-white calculation if w>0 and mode DUAL (DUAL behaves as BRIGHTER if w==0)
uint8_t g = G(c); if (!(w > 0 && _autoWhiteMode == RGBW_MODE_DUAL)) w = r < g ? (r < b ? r : b) : (g < b ? g : b);
uint8_t b = B(c); if (_autoWhiteMode == RGBW_MODE_AUTO_ACCURATE) { r -= w; g -= w; b -= w; } // subtract w in ACCURATE mode
uint8_t w = W(c); return RGBW32(r, g, b, w);
if (_autoWhiteMode == RGBW_MODE_AUTO_BRIGHTER || w == 0) w = r < g ? (r < b ? r : b) : (g < b ? g : b);
if (_autoWhiteMode == RGBW_MODE_AUTO_ACCURATE) { r -= w; g -= w; b -= w; }
c = RGBW32(r, g, b, w);
break;
}
return c;
} }
}; };