Simple test
Ensure your device works with this simple test.
examples/pixel_mapper_simpletest.py
1# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
2# SPDX-FileCopyrightText: Copyright (c) 2025 Ben Robinson for CodingFlow
3#
4# SPDX-License-Identifier: Unlicense
5import board
6import neopixel
7from adafruit_led_animation import helper
8from adafruit_led_animation.animation.chase import Chase
9from adafruit_led_animation.animation.comet import Comet
10from adafruit_led_animation.animation.rainbowchase import RainbowChase
11from adafruit_led_animation.animation.rainbowcomet import RainbowComet
12from adafruit_led_animation.color import AMBER, JADE
13
14from pixel_mapper import vertical_stacked_panels_mapper
15
16# This example is for a 32x32 matrix made from four 8x32 panels stacked vertically.
17# Each panel uses a snaking (zigzag) layout: columns alternate direction.
18#
19# The matrix is logically split into four 16x16 quadrants:
20# - top_left
21# - top_right
22# - bottom_left
23# - bottom_right
24#
25# The (0,0) origin is at the top-left corner of the matrix.
26
27# Update to match the pin connected to your NeoPixels
28pixel_pin = board.GP2
29
30# Total number of pixels: 4 panels * 8 rows * 32 columns = 1024
31pixel_num = 1024
32
33pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.75, auto_write=False)
34pixels.fill((0, 0, 0))
35
36pixel_wing_bottom_right = helper.PixelMap.horizontal_lines(
37 pixels,
38 16,
39 16,
40 vertical_stacked_panels_mapper(32, 32, panel_height=8, x_offset=16, y_offset=16),
41)
42
43pixel_wing_top_right = helper.PixelMap.horizontal_lines(
44 pixels, 16, 16, vertical_stacked_panels_mapper(32, 32, panel_height=8, x_offset=16)
45)
46
47pixel_wing_bottom_left = helper.PixelMap.horizontal_lines(
48 pixels,
49 16,
50 16,
51 vertical_stacked_panels_mapper(32, 32, panel_height=8, y_offset=16),
52)
53
54pixel_wing_top_left = helper.PixelMap.horizontal_lines(
55 pixels,
56 16,
57 16,
58 vertical_stacked_panels_mapper(32, 32, panel_height=8),
59)
60
61# Create animations for each quadrant
62comet = Comet(pixel_wing_top_left, speed=0.1, color=AMBER, tail_length=6, bounce=True)
63chase = Chase(pixel_wing_bottom_left, speed=0.1, size=3, spacing=6, color=JADE)
64rainbow_chase = RainbowChase(pixel_wing_top_right, speed=0.1, size=3, spacing=2, step=8)
65rainbow_comet = RainbowComet(pixel_wing_bottom_right, speed=0.05, tail_length=7, bounce=True)
66
67# Run animations
68while True:
69 comet.animate()
70 chase.animate()
71 rainbow_chase.animate()
72 rainbow_comet.animate()