Skip to main content

Pixel Mapper for Adafruit_CircuitPython_LED_Animation

Project description

Introduction

Discord Build Status Code Style: Ruff Demo animation

Pixel Mapper for Adafruit_CircuitPython_LED_Animation

This library provides custom pixel mappers for use with the Adafruit CircuitPython LED Animation library.

The built-in mappers only support arranging multiple matrices in the direction the internal LED strip is physically wired. This library extends that functionality by allowing you to stack panels vertically or horizontally, regardless of wiring direction.

You can also apply optional x and y offsets, making it easier to treat sections of a larger matrix as independent regions — without manually defining complex pixel maps.

Key Features

Combine multiple LED panels into vertical or horizontal matrix layouts

Support for snaking layouts (e.g. zigzag wiring patterns)

Optional x/y offsets for sub-matrix mapping

Compatible with Adafruit’s CircuitPython LED Animation library

Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle or individual libraries can be installed using circup.

Installing from PyPI

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:

pip3 install circuitpython-pixel-mapper

To install system-wide (this may be required in some cases):

sudo pip3 install circuitpython-pixel-mapper

To install in a virtual environment in your current project:

mkdir project-name && cd project-name
python3 -m venv .venv
source .env/bin/activate
pip3 install circuitpython-pixel-mapper

Installing to a Connected CircuitPython Device with Circup

Make sure that you have circup installed in your Python environment. Install it with the following command if necessary:

pip3 install circup

With circup installed and your CircuitPython device connected use the following command to install:

circup install pixel_mapper

Or the following command to update an existing version:

circup update

Usage Example

import board
import neopixel

from adafruit_led_animation import helper
from adafruit_led_animation.animation.chase import Chase
from adafruit_led_animation.animation.comet import Comet
from adafruit_led_animation.animation.rainbowchase import RainbowChase
from adafruit_led_animation.animation.rainbowcomet import RainbowComet
from adafruit_led_animation.color import AMBER, JADE, PURPLE, RED, GREEN, BLUE,OLD_LACE,ORANGE
from pixel_mapper import vertical_stacked_panels_mapper

# Update to match the pin connected to your NeoPixels
pixel_pin = board.GP2
# Update to match the number of NeoPixels you have connected
pixel_num = 1024

pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.75, auto_write=False)
pixels.fill((0, 0, 0))

pixel_wing_top_left = helper.PixelMap.horizontal_lines(
    pixels,
    16,
    16,
    vertical_stacked_panels_mapper(32, 32, panel_height=8, reverse=True, x_offset=16, y_offset=16),
)

pixel_wing_botom_left = helper.PixelMap.horizontal_lines(
    pixels,
    16,
    16,
    vertical_stacked_panels_mapper(32, 32, panel_height=8, reverse=True, x_offset=16)
)

pixel_wing_top_right = helper.PixelMap.horizontal_lines(
    pixels,
    16,
    16,
    vertical_stacked_panels_mapper(32, 32, panel_height=8, reverse=True, y_offset=16),
)

pixel_wing_botom_right = helper.PixelMap.horizontal_lines(
    pixels,
    16,
    16,
    vertical_stacked_panels_mapper(32, 32, panel_height=8, reverse=True)
)

comet = Comet(pixel_wing_top_left, speed=0.1, color=AMBER, tail_length=6, bounce=True)
chase = Chase(pixel_wing_botom_left, speed=0.1, size=3, spacing=6, color=JADE)
rainbow_chase = RainbowChase(pixel_wing_top_right, speed=0.1, size=3, spacing=2, step=8)
rainbow_comet = RainbowComet(pixel_wing_botom_right, speed=0.05, tail_length=7, bounce=True)

while True:
    comet.animate()
    chase.animate()
    rainbow_chase.animate()
    rainbow_comet.animate()

Documentation

API documentation for this library can be found on Read the Docs.

For information on building library documentation, please check out this guide.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

circuitpython_pixel_mapper-1.0.4.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

circuitpython_pixel_mapper-1.0.4-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file circuitpython_pixel_mapper-1.0.4.tar.gz.

File metadata

File hashes

Hashes for circuitpython_pixel_mapper-1.0.4.tar.gz
Algorithm Hash digest
SHA256 07b6406dcd222acf8b4753909272f524c4e8474e7827bc6fbd49050ee22db445
MD5 367109057f6ee4be345fedee8e812e05
BLAKE2b-256 ba56cfa8f4f6a576c0aa4a1b2a3d716f5b1b0216f8c9db6d33ed3102e11cc0c6

See more details on using hashes here.

File details

Details for the file circuitpython_pixel_mapper-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for circuitpython_pixel_mapper-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 381734c4f71b382568a0082fdc392d2ef180b464acb56d4485c412f390191900
MD5 d443c3e4c89619ad32ab8500a98a3e5f
BLAKE2b-256 7548bc4f563d461bba656073b04b195ee5a2ca43e3964cb01eaa18e89b3f3f86

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page