Skip to content

Commit e866c51

Browse files
committed
Add support for a gauntlet game
1 parent 9c781af commit e866c51

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

dotstar_featherwing/dotstar_featherwing.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import adafruit_dotstar
3333
import time
3434

35-
class DotstarFeatherwing(object):
35+
class DotstarFeatherwing:
3636
"""Test, Image, and Animation support for the DotStar featherwing"""
3737

3838
blank_stripe = [(0, 0, 0),
@@ -99,27 +99,40 @@ def shift_into_left(self, stripe):
9999
self.display[rightmost + self.columns - 1] = stripe[r]
100100

101101

102-
def shift_into_right(self, stripe):
102+
def shift_into_right(self, stripe):
103103
""" Shift a column of pixels into the rightside of the display.
104104
105105
:param [(int, int, int)] stripe: A column of pixel colors. The first at the top.
106106
"""
107107
for r in range(self.rows):
108108
leftmost = ((r + 1) * self.columns) - 1
109109
for c in range(self.columns - 1):
110-
self.display[leftmost - c] = self.display[(leftmost - c) -1]
110+
self.display[leftmost - c] = self.display[(leftmost - c) - 1]
111111
self.display[(leftmost - self.columns) + 1] = stripe[r]
112112

113113

114-
def number_to_pixels(self, x, color):
114+
def shift_into_top(self, stripe, offset=0):
115+
""" Shift a column of pixels into the rightside of the display.
116+
117+
:param [(int, int, int)] stripe: A column of pixel colors. The first at the top.
118+
:param int offset: The offset into stripe of the first pixel value to take.
119+
"""
120+
for c in range(self.columns):
121+
bottommost = (self.rows - 1) * self.columns
122+
for r in range(self.rows - 1):
123+
self.display[bottommost + c - (r * self.columns)] = self.display[bottommost + c - ((r + 1) * self.columns)]
124+
self.display[c] = stripe[c + offset]
125+
126+
127+
def number_to_pixels(self, x, color, bit_count=6):
115128
"""Convert an integer (0..63) into an array of 6 pixels.
116129
117130
:param int x: integer to convert into binary pixel values; LSB is topmost.
118131
:param (int, int, int) color: the color to set "on" pixels to
119132
"""
120133
val = x
121134
pixels = []
122-
for b in range(self.rows):
135+
for b in range(bit_count):
123136
if val & 1 == 0:
124137
pixels.append((0, 0, 0))
125138
else:

0 commit comments

Comments
 (0)