Skip to content

Commit 51c0478

Browse files
authored
Merge pull request #2392 from jepler/scorpio-tree
Add code for the sciorpio holiday tree project
2 parents 05d9d09 + 09b70d7 commit 51c0478

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

CircuitPython_Scorpio_Tree/code.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# SPDX-FileCopyrightText: 2023 Jeff Epler for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
3+
import board
4+
from adafruit_led_animation.animation.chase import Chase
5+
from adafruit_led_animation.animation.comet import Comet
6+
from adafruit_led_animation.animation.rainbow import Rainbow
7+
from adafruit_led_animation.color import (JADE, RED, WHITE)
8+
from adafruit_led_animation.group import AnimationGroup
9+
from adafruit_led_animation.sequence import AnimationSequence
10+
from adafruit_neopxl8 import NeoPxl8
11+
from adafruit_pixelmap import PixelMap
12+
13+
strand_length = 30
14+
pixel_brightness = 0.8
15+
num_strands = 8
16+
17+
num_pixels = num_strands * strand_length
18+
pixels = NeoPxl8(board.NEOPIXEL0, num_pixels, auto_write=False, brightness=pixel_brightness)
19+
20+
def strand(n):
21+
return PixelMap(
22+
pixels,
23+
tuple(range(n * strand_length, (n + 1) * strand_length)),
24+
individual_pixels=True,
25+
)
26+
27+
pixel_strip_A = strand(0)
28+
pixel_strip_B = strand(1)
29+
pixel_strip_C = strand(2)
30+
pixel_strip_D = strand(3)
31+
pixel_strip_E = strand(4)
32+
pixel_strip_F = strand(5)
33+
pixel_strip_G = strand(6)
34+
pixel_strip_H = strand(7)
35+
36+
animations = AnimationSequence(
37+
AnimationGroup(
38+
Rainbow(pixel_strip_A, speed=0.01, period=7),
39+
Rainbow(pixel_strip_B, speed=0.01, period=7),
40+
Rainbow(pixel_strip_C, speed=0.01, period=7),
41+
Rainbow(pixel_strip_D, speed=0.01, period=7),
42+
Rainbow(pixel_strip_E, speed=0.01, period=7),
43+
Rainbow(pixel_strip_F, speed=0.01, period=7),
44+
Rainbow(pixel_strip_G, speed=0.01, period=7),
45+
Rainbow(pixel_strip_H, speed=0.01, period=7),
46+
),
47+
AnimationGroup(
48+
Chase(pixel_strip_A, speed=0.05, color=WHITE, spacing=5, size=8),
49+
Chase(pixel_strip_B, speed=0.05, color=RED, spacing=4, size=4),
50+
Chase(pixel_strip_C, speed=0.05, color=RED, spacing=4, size=8),
51+
Chase(pixel_strip_D, speed=0.05, color=JADE, spacing=5, size=5),
52+
Chase(pixel_strip_E, speed=0.05, color=WHITE, spacing=5, size=5),
53+
Chase(pixel_strip_F, speed=0.05, color=RED, spacing=4, size=5),
54+
Chase(pixel_strip_G, speed=0.05, color=JADE, spacing=3, size=4),
55+
Chase(pixel_strip_H, speed=0.05, color=RED, spacing=4, size=8),
56+
sync=False,
57+
),
58+
AnimationGroup(
59+
Comet(pixel_strip_A, 0.01, color=WHITE, tail_length=12, bounce=True),
60+
Comet(pixel_strip_B, 0.01, color=RED, tail_length=12, reverse=True),
61+
Comet(pixel_strip_C, 0.01, color=RED, tail_length=12, bounce=True),
62+
Comet(pixel_strip_D, 0.01, color=JADE, tail_length=12, reverse=True),
63+
Comet(pixel_strip_E, 0.01, color=WHITE, tail_length=12, bounce=True),
64+
Comet(pixel_strip_F, 0.01, color=RED, tail_length=12, reverse=True),
65+
Comet(pixel_strip_G, 0.01, color=JADE, tail_length=12, bounce=True),
66+
Comet(pixel_strip_H, 0.01, color=RED, tail_length=12, reverse=True),
67+
sync=True,
68+
),
69+
advance_interval=9,
70+
auto_clear=True,
71+
)
72+
73+
while True:
74+
animations.animate()

0 commit comments

Comments
 (0)