Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions adafruit_cursorcontrol/cursorcontrol_cursormanager.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
__version__ = "0.0.0+auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_CursorControl.git"


# PyBadge
PYBADGE_BUTTON_LEFT = const(7)
PYBADGE_BUTTON_UP = const(6)
Expand All @@ -41,18 +40,23 @@ class CursorManager:
"""Simple interaction user interface interaction for Adafruit_CursorControl.

:param Cursor cursor: The cursor object we are using.
:param ShiftRegisterKeys shift_register_keys: Optional initialized ShiftRegisterKeys object
to use instead of having CursorManager initialize and control it.
"""

# pylint: disable=too-many-instance-attributes

def __init__(self, cursor: Cursor) -> None:
def __init__(
self, cursor: Cursor, shift_register_keys: Optional[ShiftRegisterKeys] = None
) -> None:
self._cursor = cursor
self._is_clicked = False
self._is_alt_clicked = False
self._is_select_clicked = False
self._is_start_clicked = False
self._pad_states = 0
self._event = Event()
self._pad = shift_register_keys
self._init_hardware()

def __enter__(self) -> "CursorManager":
Expand Down Expand Up @@ -112,13 +116,14 @@ def _init_hardware(self) -> None:
raise AttributeError(
"Board must have a D-Pad or Joystick for use with CursorManager!"
)
self._pad = ShiftRegisterKeys(
clock=board.BUTTON_CLOCK,
data=board.BUTTON_OUT,
latch=board.BUTTON_LATCH,
key_count=8,
value_when_pressed=True,
)
if self._pad is None:
self._pad = ShiftRegisterKeys(
clock=board.BUTTON_CLOCK,
data=board.BUTTON_OUT,
latch=board.BUTTON_LATCH,
key_count=8,
value_when_pressed=True,
)

@property
def is_clicked(self) -> bool:
Expand Down