Skip to content

Commit 9283648

Browse files
committed
Refactor supervisor module check
1 parent e8a9def commit 9283648

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

adafruit_usb_host_mouse/__init__.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@
2929
# * Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
3030
"""
3131

32-
try:
33-
import supervisor
34-
except ImportError:
35-
BLINKA = True
36-
else:
37-
BLINKA = False
38-
3932
import array
4033
from traceback import print_exception
4134

@@ -223,16 +216,18 @@ def __init__( # noqa: PLR0913, too many args
223216
which buttons are currently pressed."""
224217

225218
if tilegrid is not None:
226-
if not BLINKA:
219+
try:
220+
import supervisor
221+
except ImportError:
222+
self.tilegrid.x, self.tilegrid.y = 0
223+
else:
227224
self.display_size = (
228225
supervisor.runtime.display.width,
229226
supervisor.runtime.display.height,
230227
)
231228
self.tilegrid.x, self.tilegrid.y = (
232229
x // 2 for x in self.display_size
233230
) # center cursor in display
234-
else:
235-
self.tilegrid.x, self.tilegrid.y = 0
236231
else:
237232
self._x, self._y = 0, 0
238233

0 commit comments

Comments
 (0)