Skip to content

Commit 74b0f6c

Browse files
committed
Docs, pylint.
1 parent 5c90cfa commit 74b0f6c

File tree

16 files changed

+258
-55
lines changed

16 files changed

+258
-55
lines changed

adafruit_led_animation/animation/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
`adafruit_led_animation.animation`
2525
================================================================================
2626
27-
Animation base class, and basic animations for CircuitPython helper library for LED animations.
27+
Animation base class for CircuitPython helper library for LED animations.
2828
2929
* Author(s): Roy Hooper, Kattni Rembor
3030
@@ -46,9 +46,7 @@
4646
__version__ = "0.0.0-auto.0"
4747
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_LED_Animation.git"
4848

49-
from time import monotonic_ns
50-
51-
from adafruit_led_animation import NANOS_PER_SECOND
49+
from adafruit_led_animation import NANOS_PER_SECOND, monotonic_ns
5250

5351

5452
class Animation:

adafruit_led_animation/animation/blink.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,24 @@
2424
`adafruit_led_animation.animation.blink`
2525
================================================================================
2626
27-
TODO
27+
Blink animation for CircuitPython helper library for LED animations.
2828
2929
* Author(s): Roy Hooper, Kattni Rembor
3030
31+
Implementation Notes
32+
--------------------
33+
34+
**Hardware:**
35+
36+
* `Adafruit NeoPixels <https://www.adafruit.com/category/168>`_
37+
* `Adafruit DotStars <https://www.adafruit.com/category/885>`_
38+
39+
**Software and Dependencies:**
40+
41+
* Adafruit CircuitPython firmware for the supported boards:
42+
https://circuitpython.org/downloads
43+
44+
3145
"""
3246

3347
from adafruit_led_animation.animation.colorcycle import ColorCycle

adafruit_led_animation/animation/chase.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,24 @@
2424
`adafruit_led_animation.animation.chase`
2525
================================================================================
2626
27-
TODO
27+
Theatre chase animation for CircuitPython helper library for LED animations.
2828
2929
* Author(s): Roy Hooper, Kattni Rembor
3030
31+
Implementation Notes
32+
--------------------
33+
34+
**Hardware:**
35+
36+
* `Adafruit NeoPixels <https://www.adafruit.com/category/168>`_
37+
* `Adafruit DotStars <https://www.adafruit.com/category/885>`_
38+
39+
**Software and Dependencies:**
40+
41+
* Adafruit CircuitPython firmware for the supported boards:
42+
https://circuitpython.org/downloads
43+
44+
3145
"""
3246

3347
from math import ceil

adafruit_led_animation/animation/colorcycle.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,24 @@
2424
`adafruit_led_animation.animation.colorcycle`
2525
================================================================================
2626
27-
TODO
27+
Color cycle animation for CircuitPython helper library for LED animations.
2828
2929
* Author(s): Roy Hooper, Kattni Rembor
3030
31+
Implementation Notes
32+
--------------------
33+
34+
**Hardware:**
35+
36+
* `Adafruit NeoPixels <https://www.adafruit.com/category/168>`_
37+
* `Adafruit DotStars <https://www.adafruit.com/category/885>`_
38+
39+
**Software and Dependencies:**
40+
41+
* Adafruit CircuitPython firmware for the supported boards:
42+
https://circuitpython.org/downloads
43+
44+
3145
"""
3246

3347
from adafruit_led_animation.animation import Animation

adafruit_led_animation/animation/comet.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,24 @@
2424
`adafruit_led_animation.animation.comet`
2525
================================================================================
2626
27-
TODO
27+
Comet animation for CircuitPython helper library for LED animations.
2828
2929
* Author(s): Roy Hooper, Kattni Rembor
3030
31+
Implementation Notes
32+
--------------------
33+
34+
**Hardware:**
35+
36+
* `Adafruit NeoPixels <https://www.adafruit.com/category/168>`_
37+
* `Adafruit DotStars <https://www.adafruit.com/category/885>`_
38+
39+
**Software and Dependencies:**
40+
41+
* Adafruit CircuitPython firmware for the supported boards:
42+
https://circuitpython.org/downloads
43+
44+
3145
"""
3246

3347
from adafruit_led_animation.animation import Animation

adafruit_led_animation/animation/pulse.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,24 @@
2424
`adafruit_led_animation.animation.pulse`
2525
================================================================================
2626
27-
TODO
27+
Pulse animation for CircuitPython helper library for LED animations.
2828
2929
* Author(s): Roy Hooper, Kattni Rembor
3030
31+
Implementation Notes
32+
--------------------
33+
34+
**Hardware:**
35+
36+
* `Adafruit NeoPixels <https://www.adafruit.com/category/168>`_
37+
* `Adafruit DotStars <https://www.adafruit.com/category/885>`_
38+
39+
**Software and Dependencies:**
40+
41+
* Adafruit CircuitPython firmware for the supported boards:
42+
https://circuitpython.org/downloads
43+
44+
3145
"""
3246

3347
from adafruit_led_animation.animation import Animation

adafruit_led_animation/animation/rainbow.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
`adafruit_led_animation.animation.rainbow`
2525
================================================================================
2626
27-
Rainbow animations for CircuitPython helper library for LED animations.
28-
TODO
27+
Rainbow animation for CircuitPython helper library for LED animations.
2928
3029
* Author(s): Roy Hooper, Kattni Rembor
3130
@@ -52,7 +51,6 @@
5251
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_LED_Animation.git"
5352

5453

55-
5654
class Rainbow(Animation):
5755
"""
5856
The classic rainbow color wheel.
@@ -62,11 +60,14 @@ class Rainbow(Animation):
6260
:param float period: Period to cycle the rainbow over in seconds. Default 5.
6361
:param float step: Color wheel step. Default 1.
6462
:param str name: Name of animation (optional, useful for sequences and debugging).
65-
:param bool precompute_rainbow: Whether to precompute the rainbow. Uses more memory. (default True).
63+
:param bool precompute_rainbow: Whether to precompute the rainbow. Uses more memory.
64+
(default True).
6665
"""
6766

6867
# pylint: disable=too-many-arguments
69-
def __init__(self, pixel_object, speed, period=5, step=1, name=None, precompute_rainbow=True):
68+
def __init__(
69+
self, pixel_object, speed, period=5, step=1, name=None, precompute_rainbow=True
70+
):
7071
super().__init__(pixel_object, speed, BLACK, name=name)
7172
self._period = period
7273
self._step = step
@@ -77,6 +78,7 @@ def __init__(self, pixel_object, speed, period=5, step=1, name=None, precompute_
7778
self.generate_rainbow()
7879

7980
def generate_rainbow(self):
81+
"""Generates the rainbow."""
8082
self.colors = []
8183
i = 0
8284
while i < 256:
@@ -108,8 +110,7 @@ def _color_wheel_generator(self):
108110
else:
109111
wheel_index = int((pos / period) * 256)
110112
self.pixel_object[:] = [
111-
colorwheel((i + wheel_index) % 255)
112-
for i in range(num_pixels)
113+
colorwheel((i + wheel_index) % 255) for i in range(num_pixels)
113114
]
114115
self._wheel_index = wheel_index
115116
self.show()
@@ -124,10 +125,14 @@ def _draw_precomputed(self, num_pixels, wheel_index):
124125
num = num_pixels - i
125126
if wheel_index + num > len(self.colors):
126127
colors_left = len(self.colors) - wheel_index
127-
self.pixel_object[i:i + colors_left] = self.colors[wheel_index:]
128-
self.pixel_object[i + colors_left:i + num] = self.colors[:num - colors_left]
128+
self.pixel_object[i : i + colors_left] = self.colors[wheel_index:]
129+
self.pixel_object[i + colors_left : i + num] = self.colors[
130+
: num - colors_left
131+
]
129132
else:
130-
self.pixel_object[i:i + num] = self.colors[wheel_index:wheel_index + num]
133+
self.pixel_object[i : i + num] = self.colors[
134+
wheel_index : wheel_index + num
135+
]
131136

132137
def draw(self):
133138
next(self._generator)

adafruit_led_animation/animation/rainbowchase.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,24 @@
2424
`adafruit_led_animation.animation.rainbowchase`
2525
================================================================================
2626
27-
TODO
27+
Rainbow chase animation for CircuitPython helper library for LED animations.
2828
2929
* Author(s): Roy Hooper, Kattni Rembor
3030
31+
Implementation Notes
32+
--------------------
33+
34+
**Hardware:**
35+
36+
* `Adafruit NeoPixels <https://www.adafruit.com/category/168>`_
37+
* `Adafruit DotStars <https://www.adafruit.com/category/885>`_
38+
39+
**Software and Dependencies:**
40+
41+
* Adafruit CircuitPython firmware for the supported boards:
42+
https://circuitpython.org/downloads
43+
44+
3145
"""
3246

3347
from adafruit_led_animation.color import colorwheel

adafruit_led_animation/animation/rainbowcomet.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,24 @@
2424
`adafruit_led_animation.animation.rainbowcomet`
2525
================================================================================
2626
27-
TODO
27+
Rainbow comet for CircuitPython helper library for LED animations.
2828
2929
* Author(s): Roy Hooper, Kattni Rembor
3030
31+
Implementation Notes
32+
--------------------
33+
34+
**Hardware:**
35+
36+
* `Adafruit NeoPixels <https://www.adafruit.com/category/168>`_
37+
* `Adafruit DotStars <https://www.adafruit.com/category/885>`_
38+
39+
**Software and Dependencies:**
40+
41+
* Adafruit CircuitPython firmware for the supported boards:
42+
https://circuitpython.org/downloads
43+
44+
3145
"""
3246

3347
from adafruit_led_animation.animation.comet import Comet

adafruit_led_animation/animation/rainbowsparkle.py

Lines changed: 58 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,56 +21,96 @@
2121
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
# THE SOFTWARE.
2323
"""
24-
`adafruit_led_animation.animation.rainbowcomet`
24+
`adafruit_led_animation.animation.rainbowsparkle`
2525
================================================================================
2626
27-
TODO
27+
Rainbow sparkle for CircuitPython helper library for LED animations.
2828
2929
* Author(s): Roy Hooper, Kattni Rembor
3030
31+
Implementation Notes
32+
--------------------
33+
34+
**Hardware:**
35+
36+
* `Adafruit NeoPixels <https://www.adafruit.com/category/168>`_
37+
* `Adafruit DotStars <https://www.adafruit.com/category/885>`_
38+
39+
**Software and Dependencies:**
40+
41+
* Adafruit CircuitPython firmware for the supported boards:
42+
https://circuitpython.org/downloads
43+
3144
"""
3245

3346
import random
34-
3547
from adafruit_led_animation.animation.rainbow import Rainbow
3648

3749

3850
class RainbowSparkle(Rainbow):
51+
"""Rainbow sparkle animation.
52+
53+
:param pixel_object: The initialised LED object.
54+
:param float speed: Animation refresh rate in seconds, e.g. ``0.1``.
55+
:param float period: Period to cycle the rainbow over in seconds. Default 5.
56+
:param float step: Color wheel step. Default 1.
57+
:param str name: Name of animation (optional, useful for sequences and debugging).
58+
:param float background_brightness: The brightness of the background rainbow. Defaults to
59+
``0.2`` or 20 percent.
60+
:param bool precompute_rainbow: Whether to precompute the rainbow. Uses more memory.
61+
(default True).
62+
"""
3963

40-
def __init__(self, pixel_object, speed, period=5, num_sparkles=None, step=1, name=None,
41-
bg_brightness=0.2):
64+
# pylint: disable=too-many-arguments
65+
def __init__(
66+
self,
67+
pixel_object,
68+
speed,
69+
period=5,
70+
num_sparkles=None,
71+
step=1,
72+
name=None,
73+
background_brightness=0.2,
74+
):
4275
self._num_sparkles = num_sparkles
4376
if num_sparkles is None:
4477
self._num_sparkles = max(1, int(len(pixel_object) / 20))
4578
self._sparkle_duration = 2
46-
self._bg_brightness = bg_brightness
79+
self._background_brightness = background_brightness
4780
self._bright_colors = None
48-
super().__init__(pixel_object=pixel_object, speed=speed, period=period, step=step, name=name,
49-
precompute_rainbow=True)
81+
super().__init__(
82+
pixel_object=pixel_object,
83+
speed=speed,
84+
period=period,
85+
step=step,
86+
name=name,
87+
precompute_rainbow=True,
88+
)
5089

51-
def generate_rainbow(self, step=1):
90+
def generate_rainbow(self):
5291
super().generate_rainbow()
5392
self._bright_colors = self.colors[:]
5493
for i, color in enumerate(self.colors):
5594
if isinstance(self.colors[i], int):
5695
self.colors[i] = (
57-
int(self._bg_brightness * ((color & 0xff0000) >> 16)),
58-
int(self._bg_brightness * ((color & 0xff00) >> 8)),
59-
int(self._bg_brightness * (color & 0xff))
96+
int(self._background_brightness * ((color & 0xFF0000) >> 16)),
97+
int(self._background_brightness * ((color & 0xFF00) >> 8)),
98+
int(self._background_brightness * (color & 0xFF)),
6099
)
61100
else:
62101
self.colors[i] = (
63-
int(self._bg_brightness * color[0]),
64-
int(self._bg_brightness * color[1]),
65-
int(self._bg_brightness * color[2])
102+
int(self._background_brightness * color[0]),
103+
int(self._background_brightness * color[1]),
104+
int(self._background_brightness * color[2]),
66105
)
67106

68107
def show(self):
69108
pixels = [
70-
random.randint(0, len(self.pixel_object)-1)
109+
random.randint(0, len(self.pixel_object) - 1)
71110
for n in range(self._num_sparkles)
72111
]
73112
for pixel in pixels:
74-
bc = (self._wheel_index + pixel) % len(self._bright_colors)
75-
self.pixel_object[pixel] = self._bright_colors[bc]
113+
self.pixel_object[pixel] = self._bright_colors[
114+
(self._wheel_index + pixel) % len(self._bright_colors)
115+
]
76116
super().show()

0 commit comments

Comments
 (0)