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