|
@ -108,14 +108,14 @@ void _generateBrightness() { |
|
|
// Scale white channel to match brightness
|
|
|
// Scale white channel to match brightness
|
|
|
_light_channel[3].value = constrain(_light_channel[3].value * LIGHT_WHITE_FACTOR, 0, 255); |
|
|
_light_channel[3].value = constrain(_light_channel[3].value * LIGHT_WHITE_FACTOR, 0, 255); |
|
|
|
|
|
|
|
|
// For the rest of channels, don't apply brightness, it is already in the inputValue:
|
|
|
|
|
|
|
|
|
// For the rest of channels, don't apply brightness, it is already in the target:
|
|
|
for (unsigned char i=4; i < _light_channel.size(); i++) { |
|
|
for (unsigned char i=4; i < _light_channel.size(); i++) { |
|
|
_light_channel[i].value = _light_channel[i].inputValue; |
|
|
_light_channel[i].value = _light_channel[i].inputValue; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
|
|
|
|
|
|
// Don't apply brightness, it is already in the inputValue:
|
|
|
|
|
|
|
|
|
// Don't apply brightness, it is already in the target:
|
|
|
for (unsigned char i=0; i < _light_channel.size(); i++) { |
|
|
for (unsigned char i=0; i < _light_channel.size(); i++) { |
|
|
if (_light_has_color & (i<3)) { |
|
|
if (_light_has_color & (i<3)) { |
|
|
_light_channel[i].value = _light_channel[i].inputValue * brightness; |
|
|
_light_channel[i].value = _light_channel[i].inputValue * brightness; |
|
@ -389,6 +389,7 @@ unsigned int _toPWM(unsigned char id) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void _shadow() { |
|
|
void _shadow() { |
|
|
|
|
|
|
|
|
// Update transition ticker
|
|
|
// Update transition ticker
|
|
|
_light_steps_left--; |
|
|
_light_steps_left--; |
|
|
if (_light_steps_left == 0) _light_transition_ticker.detach(); |
|
|
if (_light_steps_left == 0) _light_transition_ticker.detach(); |
|
@ -396,15 +397,20 @@ void _shadow() { |
|
|
// Transitions
|
|
|
// Transitions
|
|
|
unsigned char target; |
|
|
unsigned char target; |
|
|
for (unsigned int i=0; i < _light_channel.size(); i++) { |
|
|
for (unsigned int i=0; i < _light_channel.size(); i++) { |
|
|
target = _light_state ? _light_channel[i].value : 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
target = _light_state && _light_channel[i].state ? _light_channel[i].value : 0; |
|
|
|
|
|
|
|
|
if (_light_steps_left == 0) { |
|
|
if (_light_steps_left == 0) { |
|
|
_light_channel[i].current = target; |
|
|
_light_channel[i].current = target; |
|
|
} else { |
|
|
} else { |
|
|
double difference = (double) (target - _light_channel[i].current) / (_light_steps_left + 1); |
|
|
double difference = (double) (target - _light_channel[i].current) / (_light_steps_left + 1); |
|
|
_light_channel[i].current = _light_channel[i].current + difference; |
|
|
_light_channel[i].current = _light_channel[i].current + difference; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
_light_channel[i].shadow = _light_channel[i].current; |
|
|
_light_channel[i].shadow = _light_channel[i].current; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void _lightProviderUpdate() { |
|
|
void _lightProviderUpdate() { |
|
|