Skip to content

Commit 9ddbc5b

Browse files
committed
Various tweaks
1 parent 8cf8422 commit 9ddbc5b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

dotstar_featherwing.py

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

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

3838
blank_stripe = [(0, 0, 0),
@@ -90,27 +90,25 @@ def set_color(self, row, column, color):
9090
def shift_into_left(self, stripe):
9191
""" Shift a column of pixels into the left side of the display.
9292
93-
:param [(int, int, int)] stripe: A column of pixel colors
93+
:param [(int, int, int)] stripe: A column of pixel colors. The first at the top.
9494
"""
9595
for r in range(self.rows):
9696
rightmost = r * self.columns
9797
for c in range(self.columns - 1):
9898
self.display[rightmost + c] = self.display[rightmost + c + 1]
9999
self.display[rightmost + self.columns - 1] = stripe[r]
100-
self.display.show()
101100

102101

103102
def shift_into_right(self, stripe):
104103
""" Shift a column of pixels into the rightside of the display.
105104
106-
:param [(int, int, int)] stripe: A column of pixel colors
105+
:param [(int, int, int)] stripe: A column of pixel colors. The first at the top.
107106
"""
108107
for r in range(self.rows):
109108
leftmost = ((r + 1) * self.columns) - 1
110109
for c in range(self.columns - 1):
111110
self.display[leftmost - c] = self.display[(leftmost - c) -1]
112111
self.display[(leftmost - self.columns) + 1] = stripe[r]
113-
self.display.show()
114112

115113

116114
def number_to_pixels(self, x, color):
@@ -153,8 +151,10 @@ def shift_in_character(self, font, c, color=(0x00, 0x40, 0x00), delay=0.2):
153151
matrix = self.character_to_numbers(font, 'UNKNOWN')
154152
for stripe in matrix:
155153
self.shift_into_right(self.number_to_pixels(stripe, color))
154+
self.show()
156155
time.sleep(delay)
157156
self.shift_into_right(self.blank_stripe)
157+
self.show()
158158
time.sleep(delay)
159159

160160

@@ -203,13 +203,17 @@ def display_animation(self, animation, colors, count=1, delay=0.1):
203203
204204
:param [[string]] animation: a list of textual bitmaps, each as described in display_colored_image
205205
:param {char -> (int, int, int)} colors: a map of characters in the image data to colors to use
206+
:param int count: the number of times to play the animation
206207
:param float delay: the amount of time (seconds) to wait between frames
207208
"""
208209
self.clear()
210+
first_frame = True
209211
while count > 0:
210212
for frame in animation:
213+
if not first_frame:
214+
time.sleep(delay)
215+
first_frame = False
211216
self.display_colored_image(frame, colors)
212-
time.sleep(delay)
213217
count = count - 1
214218

215219

0 commit comments

Comments
 (0)