Simple test

Ensure your device works with this simple test.

examples/tm1814_simpletest.py
 1# SPDX-FileCopyrightText: Copyright (c) 2024 Jeff Epler for Adafruit Industries
 2#
 3# SPDX-License-Identifier: Unlicense
 4
 5import board
 6import rainbowio
 7import supervisor
 8
 9from adafruit_tm1814 import TM1814PixelBackground
10
11# The pin where the LED strip data line is connected
12TM1814 = board.A0
13# The number of TM1814 controllers. Note that sometimes one "pixel" controls
14# more than one LED package.
15#
16# One common configuration is 3 LED packages & 1
17# controller per 50mm, giving 100 TM1814 controllers (300 LED packages) in 5
18# meters of LED strip.
19NUM_PIXELS = 100
20pixels = TM1814PixelBackground(TM1814, NUM_PIXELS, brightness=0.1)
21
22# Cycle the rainbow at about 1 cycle every 4 seconds
23while True:
24    pixels.fill(rainbowio.colorwheel(supervisor.ticks_ms() // 16))

LED Animations

This library works with the LED animation library. This example shows a sequence of rainbow animations

examples/tm1814_led_animation.py
 1# SPDX-FileCopyrightText: Copyright (c) 2024 Jeff Epler for Adafruit Industries
 2#
 3# SPDX-License-Identifier: Unlicense
 4
 5import board
 6import rainbowio
 7import supervisor
 8from adafruit_led_animation.animation.rainbow import Rainbow
 9from adafruit_led_animation.animation.rainbowchase import RainbowChase
10from adafruit_led_animation.animation.rainbowcomet import RainbowComet
11from adafruit_led_animation.animation.rainbowsparkle import RainbowSparkle
12from adafruit_led_animation.sequence import AnimationSequence
13
14from adafruit_tm1814 import TM1814PixelBackground
15
16# The pin where the LED strip data line is connected
17TM1814 = board.A0
18# The number of TM1814 controllers. Note that sometimes one "pixel" controls
19# more than one LED package.
20#
21# One common configuration is 3 LED packages & 1 controller per 50mm, giving
22# 100 TM1814 controllers (300 LED packages) in 5 meters of LED strip.
23NUM_PIXELS = 100
24pixels = TM1814PixelBackground(TM1814, NUM_PIXELS, brightness=0.1)
25
26# Perform a rainbow animation sequence
27rainbow = Rainbow(pixels, speed=0.1, period=2)
28rainbow_chase = RainbowChase(pixels, speed=0.1, size=5, spacing=3)
29rainbow_comet = RainbowComet(pixels, speed=0.1, tail_length=7, bounce=True)
30rainbow_sparkle = RainbowSparkle(pixels, speed=0.1, num_sparkles=15)
31
32
33animations = AnimationSequence(
34    rainbow,
35    rainbow_chase,
36    rainbow_comet,
37    rainbow_sparkle,
38    advance_interval=5,
39    auto_clear=True,
40)
41
42while True:
43    animations.animate()