Skip to content

Commit

Permalink
The brightness arguments in blink methods function now
Browse files Browse the repository at this point in the history
  • Loading branch information
speratus committed Nov 13, 2019
1 parent ecd75f7 commit f9fea94
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions blinkter/pixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def set_color(self, r: int, g: int, b: int):
The acceptable range for all of these parameters is between 0 and 255 inclusive.
Paramters
Parameters
----------------
:param r: int
Specifies the brightness to which the red LED should be set.
Expand Down Expand Up @@ -241,9 +241,6 @@ def increment_brightness(self, amount=0.0):
Increments the overall brightness of this pixel by the specified amount.
Similar to the :func:`increment` method, this method increases the brightness of the whole pixel by a specified
scale factor.
**WARNING**: This method in its current state is essentially useless because it has no effect on pixel
brightness. In the future, it will be functional, but more work needs to be done before it reaches that point.
Parameters
------------------
Expand Down Expand Up @@ -364,8 +361,20 @@ def blink(self, r=0, g=0, b=0, brightness=0.1, interval=0.05, duration=2.0):
:param duration: Optional[float]
The length of time in seconds during which this blink sequence will run.
:param brightness: Optional[float]
Sets the overall brightness of the pixel when blinking.
NOTE: If you set the brightness of the pixel using this option, the brightness set by this argument will
remain even after the pixel has finished blinking.
**WARNING**: This option does nothing in versions prior to version 1.0.0.
"""
thread = BlinkThread(self, interval, duration)

if 0 <= brightness <= 1.0 and brightness != self.brightness:
self.brightness = brightness

if r == 0 and g == 0 and b == 0:
self.black()
self.revert_color()
Expand Down Expand Up @@ -396,7 +405,10 @@ def start_blink(self, r=0, g=0, b=0, brightness=0.1, on_length=0.05, off_length=
:param brightness: Optional[int]
The overall brightness of the whole pixel during this blink sequence.
NOTE: this parameter is not supported. Including it as an argument will not change any of the pixel's behavior.
NOTE: Setting the brightness using this argument will carry over to the brightness that the pixel uses once
it is finished blinking.
**WARNING**: This option does nothing in versions prior to 1.0.0.
:param on_length: Optional[float]
The length of time in seconds that the pixel will be on for each flash.
Expand All @@ -405,6 +417,9 @@ def start_blink(self, r=0, g=0, b=0, brightness=0.1, on_length=0.05, off_length=
The length of time in seconds that the pixel will be off between flashes.
"""
thread = AdvancedBlinkThread(self, on_length, off_length)
if 0 <= brightness <= 1.0 and brightness != self.brightness:
self.brightness = brightness

if r == 0 and g == 0 and b == 0:
self.black()
self.revert_color()
Expand Down

0 comments on commit f9fea94

Please sign in to comment.