adafruit_cursorcontrol.cursorcontrol

Mouse cursor for interaction with CircuitPython UI elements.

  • Author(s): Brent Rubell

Implementation Notes

Software and Dependencies:

class adafruit_cursorcontrol.cursorcontrol.Cursor(display: displayio.Display | None = None, display_group: displayio.Group | None = None, bmp: displayio.Bitmap | None = None, is_hidden: bool = False, cursor_speed: int = 5, scale: int = 1)

Mouse cursor interaction for CircuitPython.

Parameters:
  • display (Display) – CircuitPython display object.

  • display_group (Group) – CircuitPython group object to append the cursor to.

  • bmp (Bitmap) – CircuitPython bitmap object to use as the cursor

  • is_hidden (bool) – Cursor is hidden on init.

  • cursor_speed (int) – Speed of the cursor, in pixels.

  • scale (int) – Scale amount for the cursor in both directions.

Example for creating a cursor layer

from adafruit_cursorcontrol import Cursor
# Create the display
display = board.DISPLAY

# Create the display context
splash = displayio.Group()

# initialize the mouse cursor object
mouse_cursor = Cursor(display, display_group=splash)
property cursor_bitmap: displayio.Bitmap

Return the cursor bitmap.

deinit() None

deinitializes the cursor object.

generate_cursor(bmp: displayio.Bitmap) None

Generates a cursor icon

Parameters:

bmp (Bitmap) – A Bitmap to use for the cursor

property hidden: bool

Returns True if the cursor is hidden or visible on the display.

hide() None

Hide the cursor.

property scale: int

Returns the cursor’s scale amount as an integer.

show() None

Show the cursor.

property speed: int

Returns the cursor’s speed, in pixels.

property x: int

Returns the cursor’s x-coordinate.

property y: int

Returns the cursor’s y-coordinate.

adafruit_cursorcontrol.cursorcontrol_cursormanager

Simple interaction user interface interaction for Adafruit_CursorControl. * Author(s): Brent Rubell

class adafruit_cursorcontrol.cursorcontrol_cursormanager.CursorManager(cursor: Cursor)

Simple interaction user interface interaction for Adafruit_CursorControl.

Parameters:

cursor (Cursor) – The cursor object we are using.

deinit() None

Deinitializes a CursorManager object.

property is_alt_clicked: bool

Returns True if the cursor B button was pressed during previous call to update()

property is_clicked: bool

Returns True if the cursor A button was pressed during previous call to update()

property is_select_clicked: bool

Returns True if the Select button was pressed during previous call to update()

property is_start_clicked: bool

Returns True if the Start button was pressed during previous call to update()

update() None

Updates the cursor object.

class adafruit_cursorcontrol.cursorcontrol_cursormanager.DebouncedCursorManager(cursor: Cursor, debounce_interval: float = 0.01)

Simple user interface interaction for Adafruit_CursorControl. This subclass provide a debounced version on the A, B, Start or Select buttons and provides queries for when the buttons are just pressed, and just released, as well their current state. “Just” in this context means “since the previous call to update.”

Parameters:

cursor (Cursor) – The cursor object we are using.

property alt_held: bool

Returns True if the cursor B button is currently being held

property alt_released: bool

Returns True if the cursor B button was released during previous call to update()

property held: bool

Returns True if the cursor A button is currently being held

property is_alt_clicked: bool

Returns True if the cursor B button was pressed during previous call to update()

property is_clicked: bool

Returns True if the cursor A button was pressed during previous call to update()

property is_select_clicked: bool

Returns True if the Select button was pressed during previous call to update()

property is_start_clicked: bool

Returns True if the Start button was pressed during previous call to update()

property released: bool

Returns True if the cursor A button was released during previous call to update()

property select_held: bool

Returns True if the cursor Select is currently being held

property select_released: bool

Returns True if the cursor Select button was released during previous call to update()

property start_held: bool

Returns True if the cursor Start button is currently being held

property start_released: bool

Returns True if the cursor Start button was released during previous call to update()

update() None

Updates the cursor object.