Skip to content

Commit 990d3f7

Browse files
committed
move usb_is_connected to util.py
1 parent 2654338 commit 990d3f7

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

keyboard/__init__.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from .hid import HID
1616
from .model import Matrix, COORDS, Backlight, battery_level
1717
from .action_code import *
18+
from .util import usb_is_connected
1819

1920

2021
# fmt: off
@@ -32,16 +33,6 @@ def key_name(key):
3233
return KEY_NAME[COORDS[key]]
3334

3435

35-
@micropython.asm_thumb
36-
def mem(r0):
37-
"""Read memory from the address"""
38-
ldr(r0, [r0, 0])
39-
40-
41-
def usb_is_connected():
42-
return mem(0x40000438) == 0x3
43-
44-
4536
def reset_into_bootloader():
4637
microcontroller.on_next_reset(microcontroller.RunMode.BOOTLOADER)
4738
microcontroller.reset()

keyboard/util.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
@micropython.asm_thumb
3+
def mem(r0):
4+
"""Read memory from the address"""
5+
ldr(r0, [r0, 0])
6+
7+
8+
def usb_is_connected():
9+
return mem(0x40000438) == 0x3

0 commit comments

Comments
 (0)