-
Notifications
You must be signed in to change notification settings - Fork 1
/
turtle.py
72 lines (63 loc) · 2.12 KB
/
turtle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import board
from adafruit_turtle import Color, turtle
import displayio
from os import getenv
try:
from pydos_ui import Pydos_ui
except:
Pydos_ui = None
try:
from pydos_ui import input
except:
pass
try:
type(envVars)
except:
envVars = {}
if 'display' in dir(Pydos_ui):
display = Pydos_ui.display
elif '_display' in envVars.keys():
display = envVars['_display']
elif 'DISPLAY' in dir(board):
display = board.DISPLAY
else:
try:
import framebufferio
import dotclockframebuffer
except:
import adafruit_ili9341
displayio.release_displays()
if 'TFT_PINS' in dir(board):
sWdth = getenv('PYDOS_TS_WIDTH')
if sWdth == None:
if board.board_id == "makerfabs_tft7":
sWdth = input("What is the resolution Width of the touch screen? (1024/800/...): ")
else:
sWdth = board.TFT_TIMINGS['width']
if 'updateTOML' in dir(Pydos_ui):
Pydos_ui.updateTOML("PYDOS_TS_WIDTH",str(sWdth))
if sWdth == 1024 and "TFT_TIMINGS1024" in dir(board):
disp_bus=dotclockframebuffer.DotClockFramebuffer(**board.TFT_PINS,**board.TFT_TIMINGS1024)
else:
disp_bus=dotclockframebuffer.DotClockFramebuffer(**board.TFT_PINS,**board.TFT_TIMINGS)
display=framebufferio.FramebufferDisplay(disp_bus)
else:
if 'SPI' in dir(board):
spi = board.SPI()
else:
spi = busio.SPI(clock=board.SCK,MOSI=board.MOSI,MISO=board.MISO)
disp_bus=displayio.FourWire(spi,command=board.D10,chip_select=board.D9, \
reset=board.D6)
display=adafruit_ili9341.ILI9341(disp_bus,width=320,height=240)
turtle = turtle(display)
benzsize = min(display.width, display.height) * 0.5
print("Turtle time! Lets draw a rainbow benzene")
colors = (Color.RED, Color.ORANGE, Color.YELLOW, Color.GREEN, Color.BLUE, Color.PURPLE)
turtle.pendown()
start = turtle.pos()
for x in range(benzsize):
turtle.pencolor(colors[x%6])
turtle.forward(x)
turtle.left(59)
input("Press Enter to continue...")
display.root_group = displayio.CIRCUITPYTHON_TERMINAL