Skip to content

Instantly share code, notes, and snippets.

@benevpi
Created March 20, 2019 17:20
Show Gist options
  • Save benevpi/8a7d11ad700855cbe7938335b2af2694 to your computer and use it in GitHub Desktop.
Save benevpi/8a7d11ad700855cbe7938335b2af2694 to your computer and use it in GitHub Desktop.
import displayio
import board
from adafruit_display_text.label import Label
from adafruit_bitmap_font import bitmap_font
import time
import adafruit_touchscreen
ts = adafruit_touchscreen.Touchscreen(board.TOUCH_XL, board.TOUCH_XR,
board.TOUCH_YD, board.TOUCH_YU,
calibration=((5200, 59000), (5800, 57000)),
size=(320, 240))
cwd = ("/"+__file__).rsplit('/', 1)[0]
display1 = displayio.Group()
board.DISPLAY.show(display1)
medium_font = cwd+"/fonts/Arial-16.bdf"
glyphs = b'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-,.: '
medium_font = bitmap_font.load_font(medium_font)
medium_font.load_glyphs(glyphs)
test_text = Label(medium_font, max_glyphs=8)
test_text.x = 200
test_text.y = 12
test_text.color = 0xFFFF00
test_text.text = "Hello"
display1.append(test_text)
while True:
for x in range(1,200, 2):
test_text.x = x
p = ts.touch_point
if p:
if p[1] > 120:
test_text.y = test_text.y - 1
else:
test_text.y = test_text.y+1
board.DISPLAY.wait_for_frame()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment