Another logic for handling interval
of fade_brightness()
within __init__.py
#36
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously,
interval
was defined as the time delay between the end of one brightness change and the start of the next. This meant that the actual time between brightness changes was always longer than the specified interval, as it included the time taken by the brightness change itself. This resulted in the total fading time being longer than interval*steps, with the deviation increasing with more steps. This resulted in unpredictable time consumption.This PR adds a new parameter
strict_interval
to thefade_brightness()
.interval
can now be interpreted as the intended time between the start of each brightness change. However, if a brightness change takes longer than the specified interval, the actual interval will be longer, as the next change can't start until the current one finishes.test result:
test code:
This change makes the time consumption of
fade_brightness()
more predictable. Note that this PR is not intended to make the time consumption equal to the expectation, but to bring it closer.Furthermore, I recommend removing the
strict_interval
and making this new interval handling logic the default and only method.