Skip to content

Commit 4b223c3

Browse files
committed
pylint fixes
1 parent 5ca4316 commit 4b223c3

File tree

5 files changed

+30
-11
lines changed

5 files changed

+30
-11
lines changed

Custom_LED_Animations/rainbow_sweep/rainbowsweep.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88

99
from adafruit_led_animation.animation import Animation
10-
from adafruit_led_animation.color import BLACK, colorwheel
10+
from adafruit_led_animation.color import colorwheel
1111
from adafruit_led_animation import MS_PER_SECOND, monotonic_ms
1212

1313

@@ -30,7 +30,8 @@ class RainbowSweepAnimation(Animation):
3030
DIRECTION_END_TO_START = 1
3131
# pylint: disable=too-many-arguments
3232
def __init__(
33-
self, pixel_object, speed, color, sweep_speed=0.3, period=1, name=None, sweep_direction=DIRECTION_START_TO_END
33+
self, pixel_object, speed, color, sweep_speed=0.3, period=1,
34+
name=None, sweep_direction=DIRECTION_START_TO_END
3435
):
3536
super().__init__(pixel_object, speed, color, name=name)
3637
self._period = period
@@ -112,7 +113,8 @@ def _color_wheel_generator(self):
112113
# if end to start direction
113114
if self.direction == self.DIRECTION_END_TO_START:
114115
# set the current pixels at the end of the strand to the specified color
115-
self.pixel_object[self.sweep_index:] = [self.color] * (len(self.pixel_object) - self.sweep_index)
116+
self.pixel_object[self.sweep_index:] = (
117+
[self.color] * (len(self.pixel_object) - self.sweep_index))
116118

117119
# if start to end direction
118120
elif self.direction == self.DIRECTION_START_TO_END:

Custom_LED_Animations/snake/snake.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
"""
55
SnakeAnimation helper class
66
"""
7+
import random
78
from micropython import const
89

910
from adafruit_led_animation.animation import Animation
1011
from adafruit_led_animation.grid import PixelGrid, HORIZONTAL
11-
import random
12+
1213

1314

1415
class SnakeAnimation(Animation):
@@ -34,7 +35,8 @@ def __init__(self, pixel_object, speed, color, width, height, snake_length=3):
3435
self.snake_length = snake_length
3536

3637
# create a PixelGrid helper to access our strand as a 2D grid
37-
self.pixel_grid = PixelGrid(pixel_object, width, height, orientation=HORIZONTAL, alternating=False)
38+
self.pixel_grid = PixelGrid(pixel_object, width, height,
39+
orientation=HORIZONTAL, alternating=False)
3840

3941
# size variables
4042
self.width = width
@@ -43,6 +45,8 @@ def __init__(self, pixel_object, speed, color, width, height, snake_length=3):
4345
# list that will hold locations of snake segments
4446
self.snake_pixels = []
4547

48+
self.direction = None
49+
4650
# initialize the snake
4751
self._new_snake()
4852

@@ -75,7 +79,8 @@ def _can_move(self, direction):
7579
returns true if the snake can move in the given direction
7680
"""
7781
# location of the next tile if we would move that direction
78-
next_tile = tuple(map(sum, zip(SnakeAnimation.DIRECTION_OFFSETS[direction], self.snake_pixels[0])))
82+
next_tile = tuple(map(sum, zip(
83+
SnakeAnimation.DIRECTION_OFFSETS[direction], self.snake_pixels[0])))
7984

8085
# if the tile is one of the snake segments
8186
if next_tile in self.snake_pixels:
@@ -111,7 +116,8 @@ def _choose_direction(self):
111116
# loop over the copied list of directions to check
112117
while len(directions_to_check) > 0:
113118
# choose a random one from the list and pop it out of the list
114-
possible_direction = directions_to_check.pop(random.randint(0, len(directions_to_check)-1))
119+
possible_direction = directions_to_check.pop(
120+
random.randint(0, len(directions_to_check)-1))
115121
# if we can move the chosen direction
116122
if self._can_move(possible_direction):
117123
# return the chosen direction
@@ -140,7 +146,8 @@ def draw(self):
140146
self.direction = self._choose_direction()
141147

142148
# the location of the next tile where the head of the snake will move to
143-
next_tile = tuple(map(sum, zip(SnakeAnimation.DIRECTION_OFFSETS[self.direction], self.snake_pixels[0])))
149+
next_tile = tuple(map(sum, zip(
150+
SnakeAnimation.DIRECTION_OFFSETS[self.direction], self.snake_pixels[0])))
144151

145152
# insert the next tile at list index 0
146153
self.snake_pixels.insert(0, next_tile)

Custom_LED_Animations/sweep/sweep.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ def __init__(self, pixel_object, speed, color):
3232
# boolean indicating whether we're currently sweeping LEDs on or off
3333
self.sweeping_on = True
3434

35+
self.cycle_complete = False
36+
3537
# This animation supports the cycle complete callback
3638
on_cycle_complete_supported = True
3739

Custom_LED_Animations/zipper/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121

2222
while True:
2323
# call animation to show the next animation frame
24-
zipper.animate()
24+
zipper.animate()

Custom_LED_Animations/zipper/zipper.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class ZipperAnimation(Animation):
1111

12-
def __init__(self, pixel_object, speed, color):
12+
def __init__(self, pixel_object, speed, color, alternate_color=None):
1313
"""
1414
Lights up every other LED from each ends of the strand, passing each
1515
other in the middle and resulting in the full strand being lit at the
@@ -23,13 +23,21 @@ def __init__(self, pixel_object, speed, color):
2323
# Call super class initialization
2424
super().__init__(pixel_object, speed, color)
2525

26+
# if alternate color is None then use single color
27+
if alternate_color is None:
28+
self.alternate_color = color
29+
else:
30+
self.alternate_color = alternate_color
31+
2632
# custom variable to store the current step of the animation
2733
self.current_step = 0
2834

2935
# We're lighting up every other LED, so we have half the strand
3036
# length in steps.
3137
self.last_step = len(pixel_object) // 2
3238

39+
self.cycle_complete = False
40+
3341
# This animation supports the cycle complete callback
3442
on_cycle_complete_supported = True
3543

@@ -46,7 +54,7 @@ def draw(self):
4654
self.pixel_object[self.current_step * 2] = self.color
4755

4856
# Turn on 1 odd indexed pixel starting from the end of the strand
49-
self.pixel_object[-(self.current_step * 2) - 1] = self.color
57+
self.pixel_object[-(self.current_step * 2) - 1] = self.alternate_color
5058
except IndexError:
5159
pass
5260

0 commit comments

Comments
 (0)