Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# Scales the cursor up when the PyBadge/PyGamer is tapped.
# Scales the cursor down when the A button is clicked.
import time
import board
import busio
import digitalio
import displayio
import adafruit_lis3dh
from adafruit_cursorcontrol.cursorcontrol import Cursor
from adafruit_cursorcontrol.cursorcontrol_cursormanager import CursorManager
# Hardware I2C setup
i2c = busio.I2C(board.SCL, board.SDA)
int1 = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT)
lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c, address=0x19, int1=int1)
# Set range of accelerometer (can be RANGE_2_G, RANGE_4_G, RANGE_8_G or RANGE_16_G).
lis3dh.range = adafruit_lis3dh.RANGE_8_G
# Set Tap Detection
lis3dh.set_tap(1, 60)
# Create the display
display = board.DISPLAY
# Create the display context
splash = displayio.Group(max_size=5)
# initialize the mouse cursor object
mouse_cursor = Cursor(display, display_group=splash)
# initialize the cursormanager
cursor = CursorManager(mouse_cursor)
# show displayio group
while True:
if lis3dh.tapped:
if cursor.is_clicked:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.