Skip to content

Commit 0808605

Browse files
authored
Merge pull request #12 from caternuson/disp_fix
External display and time.sleep patches.
2 parents bae9464 + 2f7b1a1 commit 0808605

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

adafruit_turtle.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,16 @@ def __repr__(self):
136136
class turtle(object):
137137
"""A Turtle that can be given commands to draw."""
138138

139-
def __init__(self, display=board.DISPLAY):
139+
def __init__(self, display=None):
140+
if display:
141+
self._display = display
142+
else:
143+
try:
144+
self._display = board.DISPLAY
145+
except AttributeError:
146+
raise RuntimeError("No display available. One must be provided.")
140147
self._logger = logging.getLogger("Turtle")
141148
self._logger.setLevel(logging.INFO)
142-
self._display = display
143149
self._w = self._display.width
144150
self._h = self._display.height
145151
self._x = self._w // 2
@@ -193,9 +199,7 @@ def __init__(self, display=board.DISPLAY):
193199
self.pencolor(Color.WHITE)
194200

195201
self._display.show(self._splash)
196-
self._display.refresh_soon()
197202
gc.collect()
198-
self._display.wait_for_frame()
199203

200204
def _drawturtle(self):
201205
self._turtle_sprite.x = int(self._x - 4)
@@ -298,7 +302,6 @@ def goto(self, x1, y1=None):
298302
self._x = y0
299303
self._y = x0
300304
self._drawturtle()
301-
time.sleep(0.003)
302305
else:
303306
try:
304307
self._plot(int(x0), int(y0), self._pencolor)
@@ -307,7 +310,6 @@ def goto(self, x1, y1=None):
307310
self._x = x0
308311
self._y = y0
309312
self._drawturtle()
310-
time.sleep(0.003)
311313
err -= dy
312314
if err < 0:
313315
y0 += ystep
@@ -804,10 +806,8 @@ def clear(self):
804806
self._fg_bitmap[w, h] = 0
805807
for i, c in enumerate(Color.colors):
806808
self._fg_palette[i + 1] = c ^ 0xFFFFFF
807-
self._display.refresh_soon()
808809
for i, c in enumerate(Color.colors):
809810
self._fg_palette[i + 1] = c
810-
self._display.refresh_soon()
811811
time.sleep(0.1)
812812

813813
def write(self, arg, move=False, align="left", font=("Arial", 8, "normal")):

0 commit comments

Comments
 (0)