diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index 56e594795..ecf10d3f5 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -545,7 +545,7 @@ void BusPwm::show() { unsigned duty = (_data[i] * pwmBri) / 255; unsigned deadTime = 0; - if (_type == TYPE_ANALOG_2CH && Bus::getCCTBlend() == 0) { + if (_type == TYPE_ANALOG_2CH && Bus::_cctBlend == 0) { // add dead time between signals (when using dithering, two full 8bit pulses are required) deadTime = (1+dithering) << bitShift; // 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; // Bus static member definition int16_t Bus::_cct = -1; -uint8_t Bus::_cctBlend = 0; +uint8_t Bus::_cctBlend = 0; // 0 - 127 uint8_t Bus::_gAWM = 255; uint16_t BusDigital::_milliAmpsTotal = 0; diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 064b600a6..f183e4b5b 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -189,9 +189,9 @@ class Bus { static inline void setGlobalAWMode(uint8_t m) { if (m < 5) _gAWM = m; else _gAWM = AW_GLOBAL_DISABLED; } static inline uint8_t getGlobalAWMode() { return _gAWM; } static inline void setCCT(int16_t cct) { _cct = cct; } - static inline uint8_t getCCTBlend() { return _cctBlend; } - static inline void setCCTBlend(uint8_t b) { - _cctBlend = (std::min((int)b,100) * 127) / 100; + static inline uint8_t getCCTBlend() { return (_cctBlend * 100 + 64) / 127; } // returns 0-100, 100% = 127. +64 for rounding + static inline void setCCTBlend(uint8_t b) { // input is 0-100 + _cctBlend = (std::min((int)b,100) * 127 + 50) / 100; // +50 for rounding, b=100% -> 127 //compile-time limiter for hardware that can't power both white channels at max #ifdef WLED_MAX_CCT_BLEND if (_cctBlend > WLED_MAX_CCT_BLEND) _cctBlend = WLED_MAX_CCT_BLEND;