File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed
display_configs/LilyGo-TDeck Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change 55
66
77class Keyboard (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 if key == 0x00 : # no key
2622 return None
2723 elif key == 0x08 : # backspace
@@ -31,5 +27,16 @@ def _get_key(self):
3127 elif key == 0x0C : # alt + c
3228 return None
3329
30+ if self ._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+ if 127 > k >= 32 :
36+ k = chr (k )
37+ else :
38+ k = hex (k )
39+ print ('RAW KEY:' , hex (k ))
40+
3441 return self .PRESSED , key
3542
You can’t perform that action at this time.
0 commit comments