Skip to content

Commit

Permalink
fix intensity scaling in blink, pulse, and morph
Browse files Browse the repository at this point in the history
  • Loading branch information
chaddcw committed Mar 26, 2021
1 parent 60bd105 commit b117e3d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions blinkstick/blinkstick.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,11 +722,9 @@ def pulse(self, channel=0, index=0, red=0, green=0, blue=0, name=None, hex=None,
@type steps: int
@param steps: Number of gradient steps
"""
r, g, b = self._determine_rgb(red=red, green=green, blue=blue, name=name, hex=hex)

self.turn_off()
for x in range(repeats):
self.morph(channel=channel, index=index, red=r, green=g, blue=b, duration=duration, steps=steps)
self.morph(channel=channel, index=index, red=red, green=green, blue=blue, name=name, hex=hex, duration=duration, steps=steps)
self.morph(channel=channel, index=index, red=0, green=0, blue=0, duration=duration, steps=steps)

def blink(self, channel=0, index=0, red=0, green=0, blue=0, name=None, hex=None, repeats=1, delay=500):
Expand All @@ -748,12 +746,11 @@ def blink(self, channel=0, index=0, red=0, green=0, blue=0, name=None, hex=None,
@type delay: int
@param delay: time in milliseconds to light LED for, and also between blinks
"""
r, g, b = self._determine_rgb(red=red, green=green, blue=blue, name=name, hex=hex)
ms_delay = float(delay) / float(1000)
for x in range(repeats):
if x:
time.sleep(ms_delay)
self.set_color(channel=channel, index=index, red=r, green=g, blue=b)
self.set_color(channel=channel, index=index, red=red, green=green, blue=blue, name=name, hex=hex)
time.sleep(ms_delay)
self.set_color(channel=channel, index=index)

Expand All @@ -778,6 +775,8 @@ def morph(self, channel=0, index=0, red=0, green=0, blue=0, name=None, hex=None,
"""

r_end, g_end, b_end = self._determine_rgb(red=red, green=green, blue=blue, name=name, hex=hex)
# descale the above values
r_end, g_end, b_end = _remap_rgb_value_reverse([r_end, g_end, b_end], self.max_rgb_value)

r_start, g_start, b_start = _remap_rgb_value_reverse(self._get_color_rgb(index), self.max_rgb_value)

Expand Down

0 comments on commit b117e3d

Please sign in to comment.