Skip to content

Fix Pybadge no attribute error #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 5, 2019
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
7 changes: 4 additions & 3 deletions adafruit_cursorcontrol/cursorcontrol_cursormanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
# PyBadge & PyGamer
PYBADGE_BUTTON_A = const(2)

class CursorManager(object):
class CursorManager():
"""Simple interaction user interface interaction for Adafruit_CursorControl.

:param adafruit_cursorcontrol cursor: The cursor object we are using.
Expand All @@ -51,8 +51,6 @@ def __init__(self, cursor):
self._cursor = cursor
self._is_clicked = False
self._init_hardware()
self._center_x = self._joystick_x.value
self._center_y = self._joystick_y.value

def __enter__(self):
return self
Expand Down Expand Up @@ -89,6 +87,9 @@ def _init_hardware(self):
self._joystick_x = analogio.AnalogIn(board.JOYSTICK_X)
self._joystick_y = analogio.AnalogIn(board.JOYSTICK_Y)
self._pad_btns = {"btn_a": PYBADGE_BUTTON_A}
# Sample the center points of the joystick
self._center_x = self._joystick_x.value
self._center_y = self._joystick_y.value
else:
raise AttributeError(
"Board must have a D-Pad or Joystick for use with CursorManager!"
Expand Down