The grid of DotStars on the wing is electrically one strand of 72 DotStars.
I’ve written a class that wraps the linear string of pixels into a 6×12 grid, which you create like this:
wing = dotstar_featherwing.DotstarFeatherwing(board.D13, board.D11)
The first argument is the clock pin and the second is the data pin. See the guide for more information on pin selection. An optional third argument is the brightness: from 0.0 to 1.0.
Once you have an instance created, you can start manipulating the pixels. There are the simple things like clear()
and fill(color)
, and show()
.
clear()
turns off all pixels.
fill(color)
sets all pixels to the given color.
show()
updates the physical dotstars to reflect the pixel colors. You will generally have to explicitly call show()
to update the dotstars except for image and text display (which call show()
internally).
At the beginning of your code, it's a good idea to clear()
and show()
to turn off all the dotstars. This way you know you are starting off with a blank display.
Here’s an example of using clear()
, fill()
, and show()
:
import board import dotstar_featherwing import time import random wing = dotstar_featherwing.DotstarFeatherwing(board.D13, board.D11, 0.25) wing.clear() wing.show() while True: color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) wing.fill(color) wing.show() time.sleep(0.25) wing.clear() wing.show() time.sleep(0.25)
This just flashes the entire display in random colors:
The next function is set_color()
which takes a row, column, and color and sets the pixel at the row and column to the color. This example chooses a random pixel (by row and column) and sets it to a random color. It then sets another random pixel to black (i.e. (0, 0, 0)
) thereby turning it off.
import board import dotstar_featherwing import time import random wing = dotstar_featherwing.DotstarFeatherwing(board.D13, board.D11, brightness=0.10) wing.clear() wing.show() while True: row = random.randint(0, 5) column = random.randint(0, 11) color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) wing.set_color(row, column, color) row = random.randint(0, 5) column = random.randint(0, 11) wing.set_color(row, column, (0, 0, 0)) wing.show()
Text editor powered by tinymce.