pixelbuf_pi_animation.player.SimplePixelBufPlayer

This class is able to take Animation objects and render them via any class that inherits from Adafruit's Pixelbuf class.

Adafruit publishes a Python library called Adafruit_CircuitPython_Pixelbuf. This library serves as the base class for many of their LED drivers. PixelBufPlayer is able to take anything that inherits from PixelBuf and use it to render output.

An example of this is using the DotStar driver to handle the actual rendering:

import adafruit_dotstar
import board


num_leds = 11
controller = adafruit_dotstar.DotStar(board.SCLK, board.MOSI, num_leds, pixel_order=adafruit_dotstar.BGR, auto_write=False)
animation = ...
player = PixelBufPlayer(controller)
player.load(animation)
player.play()

This player is the simple and most naive implementation you could imagine. Since the Pi is not a real-time computer, there are no guarantees around timing made. It also makes no attempt to correct for these things as the animation plays on. That will come in another release.

__init__(self, controller) special

Constructor for creating SimplePixelBufPlayer objects. It takes an Adafruit driver that is built on the adafruit_pixelbuf library. :param controller: an Adafruit driver

load(self, animation)

Pass the player the animation to play.

:param animation: the animation to play :return: None

play(self)

Renders the frames to the controller device.

Before calling this method, the user must call load() and pass in the Animation. Once that is done, the user can call this method to start the rendering. This function will parse and read the next frame, send it to the LED controller, and wait the specified amount of time before moving on.

:return: None