# SPDX-FileCopyrightText: 2019 John Edgar Park for Adafruit Industries # # SPDX-License-Identifier: MIT # The following Turtle Gizmo Setup is copied from examples at # https://learn.adafruit.com/turtle-graphics-gizmo/ by John Park. #==| Turtle Gizmo Setup start |======================================== import board import busio import displayio from adafruit_st7789 import ST7789 from adafruit_turtle import turtle displayio.release_displays() spi = busio.SPI(board.SCL, MOSI=board.SDA) display_bus = displayio.FourWire(spi, command=board.TX, chip_select=board.RX) display = ST7789(display_bus, width=240, height=240, rowstart=80, backlight_pin=board.A3, rotation=180) turtle = turtle(display) #==| Turtle Gizmo Setup end |========================================= from time import sleep # The following values display a square. Moving the corners # away from the origin by 1/50th of a pixel in the x and y # directions eliminates the square. So these values show # the valid plot range. The x range is ~240 (good) but the y # range is ~241 (bad). This is ISSUE #1. xmin = -120.5 # left side ymax = 120.5 # top xmax = 119.49 # right side ymin = -120.5 # bottom print("xmax-xmin, ymax-ymin =", xmax-xmin, ymax-ymin) # ISSUE #2 is that changing turtle heading changes where # goto() draws a line. Instead of first plotting a square # and then a blank screen, uncommenting this line first # plots a square missing its bottom, then only the right # side of a square. #turtle.setheading(90) while True: for i in range(2): xmn = xmin - i/50 xmx = xmax + i/50 ymn = ymin - i/50 ymx = ymax + i/50 turtle.penup() turtle.goto(xmn, ymn) turtle.pendown() turtle.goto(xmn, ymx) # left side turtle.goto(xmx, ymx) # top turtle.goto(xmx, ymn) # right side turtle.goto(xmn, ymn) # bottom sleep(1) turtle.clear()