Simple test

Ensure your device works with this simple test.

examples/cursorcontrol_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4import time
 5
 6import board
 7import displayio
 8
 9from adafruit_cursorcontrol.cursorcontrol import Cursor
10from adafruit_cursorcontrol.cursorcontrol_cursormanager import CursorManager
11
12# Create the display
13display = board.DISPLAY
14
15# Create the display context
16splash = displayio.Group()
17
18# initialize the mouse cursor object
19mouse_cursor = Cursor(display, display_group=splash)
20
21# initialize the cursormanager
22cursor = CursorManager(mouse_cursor)
23
24# show displayio group
25display.root_group = splash
26
27while True:
28    cursor.update()
29    if cursor.is_clicked:
30        if mouse_cursor.hidden:
31            mouse_cursor.show()
32        else:
33            mouse_cursor.hide()
34    time.sleep(0.01)