More on Stripes

How do we make our own shapes to shift onto the display? How do we make a custom font? How do we come up with those numbers for the slices?

Start by sketching out the shape you want: which pixels should be on and which should be off. Using graph paper helps with this. Remember that it can only be 6 pixels tall. For example, here's a 6 by 6 circle:

Once you have the shape defined, the next step is to look at each column of pixels, and convert them to numbers.

Using the numbers beside each row (which are the values corresponding to each bit), add up each column using 0 if the pixel is off and the corresponding row/bit number if it is on. Like so:

0 + 0 + 4 + 8 +  0 +  0 = 12
0 + 2 + 0 + 0 + 16 +  0 = 18
1 + 0 + 0 + 0 +  0 + 32 = 33
1 + 0 + 0 + 0 +  0 + 32 = 33
0 + 2 + 0 + 0 + 16 +  0 = 18
0 + 0 + 4 + 8 +  0 +  0 = 12

This takes advantage of the fact that a pixel, in this case, can be on or off. That is to say, each pixel corresponds to a single binary bit. By adding up the place values where the bits are 1/on we can arrive at a single number to represent the entire pattern.

If you are unfamiliar with binary, there’s a great tutorial here on Adafruit.

Now we use these along with the shift_into_... functions:

import board
import dotstar_featherwing
import time

wing = dotstar_featherwing.DotstarFeatherwing(board.D13, board.D11)

wing.clear()
for x in [12, 18, 33, 33, 18, 12]:
	wing.shift_into_left(wing.number_to_pixels(x, (0, 64, 0)))
	wing.show()
	time.sleep(0.2)
This guide was first published on Dec 21, 2017. It was last updated on Sep 05, 2018. This page (More on Stripes) was last updated on Dec 20, 2017.