Simple test
Ensure your device works with this simple test.
1# SPDX-FileCopyrightText: 2021 Jose David M.
2#
3# SPDX-License-Identifier: MIT
4#############################
5"""
6This is a basic demonstration of a Slider widget.
7"""
8
9import time
10import board
11import displayio
12import adafruit_touchscreen
13from slider import Slider
14
15display = board.DISPLAY
16
17ts = adafruit_touchscreen.Touchscreen(
18 board.TOUCH_XL,
19 board.TOUCH_XR,
20 board.TOUCH_YD,
21 board.TOUCH_YU,
22 calibration=((5200, 59000), (5800, 57000)),
23 size=(display.width, display.height),
24)
25
26# Create the slider
27my_slider = Slider(20, 30)
28
29my_group = displayio.Group()
30my_group.append(my_slider)
31
32# Add my_group to the display
33display.show(my_group)
34
35# Start the main loop
36while True:
37
38 p = ts.touch_point # get any touches on the screen
39
40 if p: # Check each slider if the touch point is within the slider touch area
41 if my_slider.when_inside(p):
42 my_slider.when_selected(p)
43
44 time.sleep(0.05) # touch response on PyPortal is more accurate with a small delay