Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commited48d66

Browse files
committed
fixes keypad driver, a better way
1 parenta805030 commited48d66

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

‎display_configs/LilyGo-TDeck/keyboard_s3.py‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55

66

77
classKeyboard(keypad_framework.KeypadDriver):
8-
def__init__(self,device):# NOQA
8+
def__init__(self,device,debug):# NOQA
99
self._device=device
10-
self._buf=bytearray(1)
11-
self._mv=memoryview(self._buf)
12-
10+
self._debug=debug
1311
super().__init__()
1412

1513
def_get_key(self):
@@ -19,9 +17,7 @@ def _get_key(self):
1917
# lv.KEY.PREV = 0x0B
2018
# lv.KEY.HOME = 0x02
2119
# lv.KEY.END = 0x03
22-
self._device.read(buf=self._mv)
23-
key=self._buf[0]
24-
20+
key=bytearray(self._device.read(1))[0]
2521
ifkey==0x00:# no key
2622
returnNone
2723
elifkey==0x08:# backspace
@@ -31,5 +27,16 @@ def _get_key(self):
3127
elifkey==0x0C:# alt + c
3228
returnNone
3329

30+
ifself._debug:
31+
k=key
32+
# check if key is in human readable ascii range and if it
33+
# is then convert it form it's decimal value to the actual ascii
34+
# key else convert to hex
35+
if127>k>=32:
36+
k=chr(k)
37+
else:
38+
k=hex(k)
39+
print('RAW KEY:',hex(k))
40+
3441
returnself.PRESSED,key
3542

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp