Skip to content

Commit 496e46c

Browse files
committed
reformat code to comply with black
1 parent cf4a1fe commit 496e46c

File tree

2 files changed

+45
-11
lines changed

2 files changed

+45
-11
lines changed

adafruit_led_animation/animation.py

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ class ColorCycle(Animation):
212212
:param colors: A list of colors to cycle through in ``(r, g, b)`` tuple, or ``0x000000`` hex
213213
format. Defaults to a rainbow color cycle.
214214
"""
215+
215216
def __init__(self, pixel_object, speed, colors=RAINBOW, name=None):
216217
self.colors = colors
217218
super().__init__(pixel_object, speed, colors[0], name=name)
@@ -386,24 +387,37 @@ class RainbowComet(Comet):
386387
"""
387388

388389
# pylint: disable=too-many-arguments
389-
def __init__(self, pixel_object, speed, tail_length=10, reverse=False, bounce=False,
390-
colorwheel_offset=0, name=None):
390+
def __init__(
391+
self,
392+
pixel_object,
393+
speed,
394+
tail_length=10,
395+
reverse=False,
396+
bounce=False,
397+
colorwheel_offset=0,
398+
name=None,
399+
):
391400
self._colorwheel_is_tuple = isinstance(colorwheel(0), tuple)
392401
self._colorwheel_offset = colorwheel_offset
393402

394403
super().__init__(pixel_object, speed, 0, tail_length, reverse, bounce, name)
395404

396405
def _calc_brightness(self, n, color):
397-
brightness = ((n * self._color_step) + self._color_offset)
406+
brightness = (n * self._color_step) + self._color_offset
398407
if not self._colorwheel_is_tuple:
399-
color = (color & 0xff, ((color & 0xff00) >> 8), (color >> 16))
408+
color = (color & 0xFF, ((color & 0xFF00) >> 8), (color >> 16))
400409
return [int(i * brightness) for i in color]
401410

402411
def __recompute_color(self, color):
403412
factor = int(256 / self._tail_length)
404413
self._comet_colors = [BLACK] + [
405-
self._calc_brightness(n, colorwheel(int(
406-
(n * factor) + self._color_offset + self._colorwheel_offset) % 256))
414+
self._calc_brightness(
415+
n,
416+
colorwheel(
417+
int((n * factor) + self._color_offset + self._colorwheel_offset)
418+
% 256
419+
),
420+
)
407421
for n in range(self._tail_length - 1)
408422
]
409423
self._reverse_comet_colors = list(reversed(self._comet_colors))
@@ -652,7 +666,6 @@ def reverse(self, value):
652666
self._direction = -1 if self._reverse else 1
653667

654668
def draw(self):
655-
656669
def bar_colors():
657670
bar_no = 0
658671
for i in range(self._offset, 0, -1):
@@ -713,9 +726,18 @@ class RainbowChase(Chase):
713726
:param reverse: Reverse direction of movement.
714727
:param wheel_step: How many colors to skip in `colorwheel` per bar (default 8)
715728
"""
729+
716730
# pylint: disable=too-many-arguments
717-
def __init__(self, pixel_object, speed, size=2, spacing=3, reverse=False, name=None,
718-
wheel_step=8):
731+
def __init__(
732+
self,
733+
pixel_object,
734+
speed,
735+
size=2,
736+
spacing=3,
737+
reverse=False,
738+
name=None,
739+
wheel_step=8,
740+
):
719741
self._num_colors = 256 // wheel_step
720742
self._colors = [colorwheel(n % 256) for n in range(0, 512, wheel_step)]
721743
self._color_idx = 0

adafruit_led_animation/helper.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,12 @@ def vertical_strip_gridmap(height, alternating=True):
224224
:param alternating: strips alternate directions in a zigzag
225225
:return: mapper(x, y)
226226
"""
227+
227228
def mapper(x, y):
228229
if alternating and x % 2:
229230
return x * height + (height - 1 - y)
230231
return x * height + y
232+
231233
return mapper
232234

233235

@@ -238,10 +240,12 @@ def horizontal_strip_gridmap(width, alternating=True):
238240
:param alternating: strips alternate directions in a zigzag
239241
:return: mapper(x, y)
240242
"""
243+
241244
def mapper(x, y):
242245
if alternating and y % 2:
243246
return y * width + (width - 1 - x)
244247
return y * width + x
248+
245249
return mapper
246250

247251

@@ -520,8 +524,16 @@ class AnimationSequence:
520524
"""
521525

522526
# pylint: disable=too-many-instance-attributes
523-
def __init__(self, *members, advance_interval=None, auto_clear=False, random_order=False,
524-
auto_reset=False, advance_on_cycle_complete=False, name=None):
527+
def __init__(
528+
self,
529+
*members,
530+
advance_interval=None,
531+
auto_clear=False,
532+
random_order=False,
533+
auto_reset=False,
534+
advance_on_cycle_complete=False,
535+
name=None
536+
):
525537
if advance_interval and advance_on_cycle_complete:
526538
raise ValueError("Cannot use both advance_interval and auto_clear")
527539
self._members = members

0 commit comments

Comments
 (0)