Simple test

Ensure your device works with this simple test.

examples/pixelmap_simpletest.py
 1# SPDX-FileCopyrightText: 2022 Tim Cocks for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4"""
 5This example shows usage of the PixelMap helper to easily treat a single strip as a horizontal or
 6vertical grid for animation purposes.
 7
 8For NeoPixel FeatherWing. Update pixel_pin and pixel_num to match your wiring if using
 9a different form of NeoPixels. Note that if you are using a number of pixels other than 32, you
10will need to alter the PixelMap values as well for this example to work.
11
12This example does not work on SAMD21 (M0) boards.
13"""
14
15import time
16
17import board
18import neopixel
19
20from adafruit_pixelmap import PixelMap, horizontal_strip_gridmap
21
22# board.NEOPIXEL is the pin on the NeoTrellis M4.
23# Update to match the pin that your neopixels are connected to.
24pixel_pin = board.NEOPIXEL
25
26# Update to match the number of NeoPixels you have connected
27pixel_num = 32
28
29pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.1, auto_write=True)
30
31pixel_wing_vertical = PixelMap.vertical_lines(
32    pixels, 8, 4, horizontal_strip_gridmap(8, alternating=False)
33)
34pixel_wing_horizontal = PixelMap.horizontal_lines(
35    pixels, 8, 4, horizontal_strip_gridmap(8, alternating=False)
36)
37
38for i, row in enumerate(pixel_wing_horizontal):
39    pixels.fill(0x00000)
40    pixel_wing_horizontal[i] = 0x00FF00
41    time.sleep(0.3)
42
43for i, col in enumerate(pixel_wing_vertical):
44    pixels.fill(0x00000)
45    pixel_wing_vertical[i] = 0xFF00FF
46    time.sleep(0.3)
47
48while True:
49    pass