Skip to content

Commit 05557ca

Browse files
authored
Bugfix: convert cctBlend value back to "%" for UI (wled#4737)
* Bugfix: convert cctBlend value back to "%" for UI
1 parent a53baa9 commit 05557ca

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

wled00/bus_manager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ void BusPwm::show() {
545545
unsigned duty = (_data[i] * pwmBri) / 255;
546546
unsigned deadTime = 0;
547547

548-
if (_type == TYPE_ANALOG_2CH && Bus::getCCTBlend() == 0) {
548+
if (_type == TYPE_ANALOG_2CH && Bus::_cctBlend == 0) {
549549
// add dead time between signals (when using dithering, two full 8bit pulses are required)
550550
deadTime = (1+dithering) << bitShift;
551551
// we only need to take care of shortening the signal at (almost) full brightness otherwise pulses may overlap
@@ -972,7 +972,7 @@ bool PolyBus::_useParallelI2S = false;
972972

973973
// Bus static member definition
974974
int16_t Bus::_cct = -1;
975-
uint8_t Bus::_cctBlend = 0;
975+
uint8_t Bus::_cctBlend = 0; // 0 - 127
976976
uint8_t Bus::_gAWM = 255;
977977

978978
uint16_t BusDigital::_milliAmpsTotal = 0;

wled00/bus_manager.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ class Bus {
189189
static inline void setGlobalAWMode(uint8_t m) { if (m < 5) _gAWM = m; else _gAWM = AW_GLOBAL_DISABLED; }
190190
static inline uint8_t getGlobalAWMode() { return _gAWM; }
191191
static inline void setCCT(int16_t cct) { _cct = cct; }
192-
static inline uint8_t getCCTBlend() { return _cctBlend; }
193-
static inline void setCCTBlend(uint8_t b) {
194-
_cctBlend = (std::min((int)b,100) * 127) / 100;
192+
static inline uint8_t getCCTBlend() { return (_cctBlend * 100 + 64) / 127; } // returns 0-100, 100% = 127. +64 for rounding
193+
static inline void setCCTBlend(uint8_t b) { // input is 0-100
194+
_cctBlend = (std::min((int)b,100) * 127 + 50) / 100; // +50 for rounding, b=100% -> 127
195195
//compile-time limiter for hardware that can't power both white channels at max
196196
#ifdef WLED_MAX_CCT_BLEND
197197
if (_cctBlend > WLED_MAX_CCT_BLEND) _cctBlend = WLED_MAX_CCT_BLEND;

0 commit comments

Comments
 (0)