mirror of
https://github.com/xoseperez/espurna.git
synced 2026-03-17 05:37:08 +01:00
Fix per channel state on/off for lights (#830)
This commit is contained in:
@@ -108,14 +108,14 @@ void _generateBrightness() {
|
||||
// Scale white channel to match brightness
|
||||
_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++) {
|
||||
_light_channel[i].value = _light_channel[i].inputValue;
|
||||
}
|
||||
|
||||
} 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++) {
|
||||
if (_light_has_color & (i<3)) {
|
||||
_light_channel[i].value = _light_channel[i].inputValue * brightness;
|
||||
@@ -389,6 +389,7 @@ unsigned int _toPWM(unsigned char id) {
|
||||
}
|
||||
|
||||
void _shadow() {
|
||||
|
||||
// Update transition ticker
|
||||
_light_steps_left--;
|
||||
if (_light_steps_left == 0) _light_transition_ticker.detach();
|
||||
@@ -396,15 +397,20 @@ void _shadow() {
|
||||
// Transitions
|
||||
unsigned char target;
|
||||
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) {
|
||||
_light_channel[i].current = target;
|
||||
} else {
|
||||
double difference = (double) (target - _light_channel[i].current) / (_light_steps_left + 1);
|
||||
_light_channel[i].current = _light_channel[i].current + difference;
|
||||
}
|
||||
|
||||
_light_channel[i].shadow = _light_channel[i].current;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void _lightProviderUpdate() {
|
||||
|
||||
Reference in New Issue
Block a user