File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed
Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff 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
974974int16_t Bus::_cct = -1 ;
975- uint8_t Bus::_cctBlend = 0 ;
975+ uint8_t Bus::_cctBlend = 0 ; // 0 - 127
976976uint8_t Bus::_gAWM = 255 ;
977977
978978uint16_t BusDigital::_milliAmpsTotal = 0 ;
Original file line number Diff line number Diff 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;
You can’t perform that action at this time.
0 commit comments