Skip to content

Commit fbe306b

Browse files
committed
Tweaks, doc string added.
1 parent f028cf4 commit fbe306b

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

QT_Py_NeoPixels/QT_Py_NeoPixel_Animations.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Basic NeoPixel LED animations for the QT Py."""
12
import time
23
import board
34
import neopixel
@@ -13,25 +14,6 @@
1314
pixels.brightness = 0.2
1415

1516

16-
def color_wipe(color, wait):
17-
"""Color wipe animation. Wipes across all pixels."""
18-
for pixel in range(num_pixels):
19-
pixels[pixel] = color
20-
time.sleep(wait)
21-
pixels.show()
22-
time.sleep(0.5)
23-
24-
25-
def rainbow_cycle(wait):
26-
"""Rainbow cycle animation. Cycles across all pixels."""
27-
for color_index in range(255):
28-
for pixel in range(num_pixels):
29-
pixel_index = (pixel * 256 // num_pixels) + color_index
30-
pixels[pixel] = adafruit_pypixelbuf.colorwheel(pixel_index & 255)
31-
pixels.show()
32-
time.sleep(wait)
33-
34-
3517
def blink(color, wait):
3618
"""Blink animation. Blinks all pixels."""
3719
pixels.fill(color)
@@ -65,6 +47,25 @@ def chase(color, spacing=3, iteration_step=1):
6547
pixels[pixel + chase_pixel] = (0, 0, 0)
6648

6749

50+
def color_wipe(color, wait):
51+
"""Color wipe animation. Wipes across all pixels."""
52+
for pixel in range(num_pixels):
53+
pixels[pixel] = color
54+
time.sleep(wait)
55+
pixels.show()
56+
time.sleep(0.5)
57+
58+
59+
def rainbow_cycle(wait):
60+
"""Rainbow cycle animation. Cycles across all pixels."""
61+
for color_index in range(255):
62+
for pixel in range(num_pixels):
63+
pixel_index = (pixel * 256 // num_pixels) + color_index
64+
pixels[pixel] = adafruit_pypixelbuf.colorwheel(pixel_index & 255)
65+
pixels.show()
66+
time.sleep(wait)
67+
68+
6869
RED = (255, 0, 0)
6970
YELLOW = (255, 150, 0)
7071
GREEN = (0, 255, 0)

0 commit comments

Comments
 (0)