Starting at line (1) in the following code, we have the imports. We will be using a Python deque collection instance (I'll just refer to is as an array for simplicity) to model in-memory the APA102 LED strip—we will build up and manipulate the order of colors we want each individual LED on to display in this array before applying it to the LED strip. We then import the getrgb function from the PIL library for working with color formats (as we did in the preceding RGB LED example):
# ...truncated...
from collections import deque # (1)
from PIL.ImageColor import getrgb
from luma.core.render import canvas
from luma.led_matrix.device import apa102
from luma.core.interface.serial import spi, bitbang
Lastly, the three luma imports are for the APA102 LED strip control. Luma is a mature high-level library for working with a range of common display devices using Python. It has support for LCDs, LED strips...