Skip to content

Commit 3df4d26

Browse files
committed
add back atexit_callback()
1 parent a7124f0 commit 3df4d26

File tree

1 file changed

+13
-0
lines changed
  • Metro/Metro_RP2350_Memory/memory_game

1 file changed

+13
-0
lines changed

Metro/Metro_RP2350_Memory/memory_game/code.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import supervisor
1919
import terminalio
2020
import usb.core
21+
import atexit
2122
from adafruit_fruitjam.peripherals import request_display_config
2223
import adafruit_usb_host_descriptors
2324
from adafruit_pathlib import Path
@@ -323,6 +324,18 @@ def update_score_text():
323324
# set configuration on the mouse so we can use it
324325
mouse.set_configuration()
325326

327+
def atexit_callback():
328+
"""
329+
re-attach USB devices to kernel if needed.
330+
:return:
331+
"""
332+
print("inside atexit callback")
333+
if mouse_was_attached and not mouse.is_kernel_driver_active(0):
334+
mouse.attach_kernel_driver(0)
335+
336+
337+
atexit.register(atexit_callback)
338+
326339
# Buffer to hold data read from the mouse
327340
# Boot mice have 4 byte reports
328341
buf = array.array("b", [0] * 4)

0 commit comments

Comments
 (0)