2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00

31_MilightDevice: Queue length correction for long transitions

git-svn-id: https://svn.fhem.de/fhem/trunk@10675 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
markus-m 2016-01-31 03:11:12 +00:00
parent 504fac620f
commit 30a30a9c0f
2 changed files with 12 additions and 7 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it. # Do not insert empty lines here, update check depends on it.
- bugfix: 31_MilightDevice: Queue length correction for long transitions
- feature: 31_MilightDevice: Color changes during dim on lower brightness - feature: 31_MilightDevice: Color changes during dim on lower brightness
- bugfix: 30_MilightBridge/31_MilightDevice: Variable fallbacks, colorcast - bugfix: 30_MilightBridge/31_MilightDevice: Variable fallbacks, colorcast
- bugfix: 44_TEK603: fixed wrong values. - bugfix: 44_TEK603: fixed wrong values.

View File

@ -1681,7 +1681,7 @@ sub MilightDevice_HSV_Transition(@)
$hueFrom = ReadingsVal($hash->{NAME}, "hue", 0); $hueFrom = ReadingsVal($hash->{NAME}, "hue", 0);
$satFrom = ReadingsVal($hash->{NAME}, "saturation", 0); $satFrom = ReadingsVal($hash->{NAME}, "saturation", 0);
$valFrom = ReadingsVal($hash->{NAME}, "brightness", 0); $valFrom = ReadingsVal($hash->{NAME}, "brightness", 0);
$timeFrom = int(gettimeofday()); $timeFrom = gettimeofday();
Log3 ($hash, 5, "$hash->{NAME}_HSV_Transition: Prepare Start (actual): $hueFrom,$satFrom,$valFrom@".$timeFrom); Log3 ($hash, 5, "$hash->{NAME}_HSV_Transition: Prepare Start (actual): $hueFrom,$satFrom,$valFrom@".$timeFrom);
@ -1757,16 +1757,20 @@ sub MilightDevice_HSV_Transition(@)
$maxSteps = MilightDevice_DimSteps($hash); $maxSteps = MilightDevice_DimSteps($hash);
} }
# Calculate number of steps, limit to max number (no point running more if they are the same)
$steps = int($ramp * 1000 / $stepWidth);
if ($steps > $maxSteps)
{
$stepWidth *= ($steps/$maxSteps);
$steps = $maxSteps;
}
# Calculate minimum stepWidth # Calculate minimum stepWidth
# Min bridge delay as specified by Bridge * 3 (eg. 100*3=300ms). # Min bridge delay as specified by Bridge * 3 (eg. 100*3=300ms).
# On average min 3 commands need to be sent per step (eg. Group On; Mode; Brightness;) so this gets it approximately right # On average min 3 commands need to be sent per step (eg. Group On; Mode; Brightness;) so this gets it approximately right
my $minStepWidth = $hash->{IODev}->{INTERVAL} * 3; my $minStepWidth = $hash->{IODev}->{INTERVAL} * 3;
$stepWidth = $minStepWidth if ($stepWidth < $minStepWidth); # Make sure we have min stepWidth $stepWidth = $minStepWidth if ($stepWidth < $minStepWidth); # Make sure we have min stepWidth
# Calculate number of steps, limit to max number (no point running more if they are the same)
$steps = int($ramp * 1000 / $stepWidth);
$steps = $maxSteps if ($steps > $maxSteps);
Log3 ($hash, 4, "$hash->{NAME}_HSV_Transition: Steps: $steps; Step Interval(ms): $stepWidth"); Log3 ($hash, 4, "$hash->{NAME}_HSV_Transition: Steps: $steps; Step Interval(ms): $stepWidth");
# Calculate hue step # Calculate hue step
@ -1793,7 +1797,7 @@ sub MilightDevice_HSV_Transition(@)
} }
# Set target time for completion of sequence. # Set target time for completion of sequence.
# This may be slightly higher than what was requested since $stepWidth > minDelay (($steps * $stepWidth) > $ramp) # This may be slightly higher than what was requested since $stepWidth > minDelay (($steps * $stepWidth) > $ramp)
$hash->{helper}->{targetTime} = int($timeFrom + ($steps * $stepWidth / 1000)); $hash->{helper}->{targetTime} = $timeFrom + ($steps * $stepWidth / 1000);
Log3 ($hash, 5, "$hash->{NAME}_HSV_Transition: TargetTime: $hash->{helper}->{targetTime}"); Log3 ($hash, 5, "$hash->{NAME}_HSV_Transition: TargetTime: $hash->{helper}->{targetTime}");
return undef; return undef;
} }
@ -2066,7 +2070,7 @@ sub MilightDevice_CmdQueue_Exec(@)
MilightDevice_SetHSV($hash, $actualCmd->{hue}, $actualCmd->{sat}, $actualCmd->{val}, $repeat); MilightDevice_SetHSV($hash, $actualCmd->{hue}, $actualCmd->{sat}, $actualCmd->{val}, $repeat);
} }
$actualCmd->{inProgess} = 1; $actualCmd->{inProgess} = 1;
my $next = defined($nextCmd->{targetTime})?$nextCmd->{targetTime}:int(gettimeofday() + ($actualCmd->{delay} / 1000)); my $next = defined($nextCmd->{targetTime})?$nextCmd->{targetTime}:gettimeofday() + ($actualCmd->{delay} / 1000);
Log3 ($hash, 5, "$hash->{NAME}_CmdQueue_Exec: Next Exec: $next"); Log3 ($hash, 5, "$hash->{NAME}_CmdQueue_Exec: Next Exec: $next");
InternalTimer($next, "MilightDevice_CmdQueue_Exec", $hash, 0); InternalTimer($next, "MilightDevice_CmdQueue_Exec", $hash, 0);