Skip to content

Commit bacf8fe

Browse files
committed
style: code format
Signed-off-by: lbuque <[email protected]>
1 parent 4bd264d commit bacf8fe

25 files changed

+895
-713
lines changed

m5stack/libs/hardware/keyboard/__init__.py

Lines changed: 82 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
kb_asciimap,
1313
)
1414

15-
Point2D = namedtuple('Point2D', ['x', 'y'])
16-
Chart = namedtuple('Chart', ['value', 'x_1', 'x_2'])
17-
KeyValue = namedtuple('KeyValue', ['first', 'second'])
15+
Point2D = namedtuple("Point2D", ["x", "y"])
16+
Chart = namedtuple("Chart", ["value", "x_1", "x_2"])
17+
KeyValue = namedtuple("KeyValue", ["first", "second"])
1818

1919
_X_map_chart = (
2020
Chart(1, 0, 1),
@@ -28,110 +28,109 @@
2828

2929
_key_value_map = (
3030
(
31-
KeyValue(ord('`'), ord('~')),
32-
KeyValue(ord('1'), ord('!')),
33-
KeyValue(ord('2'), ord('@')),
34-
KeyValue(ord('3'), ord('#')),
35-
KeyValue(ord('4'), ord('$')),
36-
KeyValue(ord('5'), ord('%')),
37-
KeyValue(ord('6'), ord('^')),
38-
KeyValue(ord('7'), ord('&')),
39-
KeyValue(ord('8'), ord('*')),
40-
KeyValue(ord('9'), ord('(')),
41-
KeyValue(ord('0'), ord(')')),
42-
KeyValue(ord('-'), ord('_')),
43-
KeyValue(ord('='), ord('+')),
31+
KeyValue(ord("`"), ord("~")),
32+
KeyValue(ord("1"), ord("!")),
33+
KeyValue(ord("2"), ord("@")),
34+
KeyValue(ord("3"), ord("#")),
35+
KeyValue(ord("4"), ord("$")),
36+
KeyValue(ord("5"), ord("%")),
37+
KeyValue(ord("6"), ord("^")),
38+
KeyValue(ord("7"), ord("&")),
39+
KeyValue(ord("8"), ord("*")),
40+
KeyValue(ord("9"), ord("(")),
41+
KeyValue(ord("0"), ord(")")),
42+
KeyValue(ord("-"), ord("_")),
43+
KeyValue(ord("="), ord("+")),
4444
KeyValue(KEY_BACKSPACE, KEY_BACKSPACE),
4545
),
4646
(
4747
KeyValue(KEY_TAB, KEY_TAB),
48-
KeyValue(ord('q'), ord('Q')),
49-
KeyValue(ord('w'), ord('W')),
50-
KeyValue(ord('e'), ord('E')),
51-
KeyValue(ord('r'), ord('R')),
52-
KeyValue(ord('t'), ord('T')),
53-
KeyValue(ord('y'), ord('Y')),
54-
KeyValue(ord('u'), ord('U')),
55-
KeyValue(ord('i'), ord('I')),
56-
KeyValue(ord('o'), ord('O')),
57-
KeyValue(ord('p'), ord('P')),
58-
KeyValue(ord('['), ord('{')),
59-
KeyValue(ord(']'), ord('}')),
60-
KeyValue(ord('\\'), ord('|')),
48+
KeyValue(ord("q"), ord("Q")),
49+
KeyValue(ord("w"), ord("W")),
50+
KeyValue(ord("e"), ord("E")),
51+
KeyValue(ord("r"), ord("R")),
52+
KeyValue(ord("t"), ord("T")),
53+
KeyValue(ord("y"), ord("Y")),
54+
KeyValue(ord("u"), ord("U")),
55+
KeyValue(ord("i"), ord("I")),
56+
KeyValue(ord("o"), ord("O")),
57+
KeyValue(ord("p"), ord("P")),
58+
KeyValue(ord("["), ord("{")),
59+
KeyValue(ord("]"), ord("}")),
60+
KeyValue(ord("\\"), ord("|")),
6161
),
6262
(
6363
KeyValue(KEY_FN, KEY_FN),
6464
KeyValue(KEY_LEFT_SHIFT, KEY_LEFT_SHIFT),
65-
KeyValue(ord('a'), ord('A')),
66-
KeyValue(ord('s'), ord('S')),
67-
KeyValue(ord('d'), ord('D')),
68-
KeyValue(ord('f'), ord('F')),
69-
KeyValue(ord('g'), ord('G')),
70-
KeyValue(ord('h'), ord('H')),
71-
KeyValue(ord('j'), ord('J')),
72-
KeyValue(ord('k'), ord('K')),
73-
KeyValue(ord('l'), ord('L')),
74-
KeyValue(ord(';'), ord(':')),
75-
KeyValue(ord('\''), ord('\"')),
65+
KeyValue(ord("a"), ord("A")),
66+
KeyValue(ord("s"), ord("S")),
67+
KeyValue(ord("d"), ord("D")),
68+
KeyValue(ord("f"), ord("F")),
69+
KeyValue(ord("g"), ord("G")),
70+
KeyValue(ord("h"), ord("H")),
71+
KeyValue(ord("j"), ord("J")),
72+
KeyValue(ord("k"), ord("K")),
73+
KeyValue(ord("l"), ord("L")),
74+
KeyValue(ord(";"), ord(":")),
75+
KeyValue(ord("'"), ord('"')),
7676
KeyValue(KEY_ENTER, KEY_ENTER),
7777
),
7878
(
7979
KeyValue(KEY_LEFT_CTRL, KEY_LEFT_CTRL),
8080
KeyValue(KEY_OPT, KEY_OPT),
8181
KeyValue(KEY_LEFT_ALT, KEY_LEFT_ALT),
82-
KeyValue(ord('z'), ord('Z')),
83-
KeyValue(ord('x'), ord('X')),
84-
KeyValue(ord('c'), ord('C')),
85-
KeyValue(ord('v'), ord('V')),
86-
KeyValue(ord('b'), ord('B')),
87-
KeyValue(ord('n'), ord('N')),
88-
KeyValue(ord('m'), ord('M')),
89-
KeyValue(ord(','), ord('<')),
90-
KeyValue(ord('.'), ord('>')),
91-
KeyValue(ord('/'), ord('?')),
92-
KeyValue(ord(' '), ord(' ')),
82+
KeyValue(ord("z"), ord("Z")),
83+
KeyValue(ord("x"), ord("X")),
84+
KeyValue(ord("c"), ord("C")),
85+
KeyValue(ord("v"), ord("V")),
86+
KeyValue(ord("b"), ord("B")),
87+
KeyValue(ord("n"), ord("N")),
88+
KeyValue(ord("m"), ord("M")),
89+
KeyValue(ord(","), ord("<")),
90+
KeyValue(ord("."), ord(">")),
91+
KeyValue(ord("/"), ord("?")),
92+
KeyValue(ord(" "), ord(" ")),
9393
),
9494
)
9595

9696

9797
class KeysState:
98-
tab = False
99-
fn = False
100-
shift = False
101-
ctrl = False
102-
opt = False
103-
alt = False
104-
delete = False
105-
enter = False
106-
space = False
107-
modifiers = 0
98+
tab = False
99+
fn = False
100+
shift = False
101+
ctrl = False
102+
opt = False
103+
alt = False
104+
delete = False
105+
enter = False
106+
space = False
107+
modifiers = 0
108108

109109
def __init__(self) -> None:
110110
self.word = bytearray(0)
111111
self.hid_keys = bytearray(0)
112112
self.modifier_keys = bytearray(0)
113113

114114
def reset(self):
115-
self.tab = False
116-
self.fn = False
117-
self.shift = False
118-
self.ctrl = False
119-
self.opt = False
120-
self.alt = False
121-
self.delete = False
122-
self.enter = False
123-
self.space = False
124-
self.modifiers = 0
115+
self.tab = False
116+
self.fn = False
117+
self.shift = False
118+
self.ctrl = False
119+
self.opt = False
120+
self.alt = False
121+
self.delete = False
122+
self.enter = False
123+
self.space = False
124+
self.modifiers = 0
125125
self.word = bytearray(0)
126126
self.hid_keys = bytearray(0)
127127
self.modifier_keys = bytearray(0)
128128

129129

130130
class Keyboard:
131-
132131
def __init__(self):
133-
self.output_list = [ Pin(id, Pin.OUT, Pin.PULL_DOWN) for id in (8, 9, 11) ]
134-
self.input_list = [ Pin(id, Pin.IN, Pin.PULL_UP) for id in (13, 15, 3, 4, 5, 6, 7) ]
132+
self.output_list = [Pin(id, Pin.OUT, Pin.PULL_DOWN) for id in (8, 9, 11)]
133+
self.input_list = [Pin(id, Pin.IN, Pin.PULL_UP) for id in (13, 15, 3, 4, 5, 6, 7)]
135134

136135
for pin in self.output_list:
137136
pin.value(0)
@@ -148,20 +147,20 @@ def __init__(self):
148147

149148
@staticmethod
150149
def _set_output(pin_list, output):
151-
output = output & 0B00000111
152-
pin_list[0].value(output & 0B00000001)
153-
pin_list[1].value(output & 0B00000010)
154-
pin_list[2].value(output & 0B00000100)
150+
output = output & 0b00000111
151+
pin_list[0].value(output & 0b00000001)
152+
pin_list[1].value(output & 0b00000010)
153+
pin_list[2].value(output & 0b00000100)
155154

156155
@staticmethod
157156
def _get_input(pin_list):
158-
buffer = 0x00
157+
buffer = 0x00
159158
pin_value = 0x00
160159

161160
for i in range(7):
162161
pin_value = 0x00 if pin_list[i].value() == 1 else 0x01
163162
pin_value = pin_value << i
164-
buffer = buffer | pin_value
163+
buffer = buffer | pin_value
165164

166165
return buffer
167166

@@ -171,11 +170,7 @@ def getKey(self, point: Point2D):
171170
if point.x < 0 or point.y < 0:
172171
return ret
173172

174-
if (
175-
self._keys_state_buffer.ctrl
176-
or self._keys_state_buffer.shift
177-
or self._is_caps_locked
178-
):
173+
if self._keys_state_buffer.ctrl or self._keys_state_buffer.shift or self._is_caps_locked:
179174
ret = _key_value_map[point.x][point.y].second
180175
else:
181176
ret = _key_value_map[point.x][point.y].first
@@ -272,7 +267,7 @@ def updateKeysState(self):
272267
self._key_pos_hid_keys.append(i)
273268
continue
274269

275-
if self.getKeyValue(i).first == ' ':
270+
if self.getKeyValue(i).first == " ":
276271
self._keys_state_buffer.space = True
277272

278273
self._key_pos_hid_keys.append(i)
@@ -283,7 +278,7 @@ def updateKeysState(self):
283278
self._keys_state_buffer.modifier_keys.append(key)
284279

285280
for k in self._keys_state_buffer.modifier_keys:
286-
self._keys_state_buffer.modifiers |= (1 << (k - 0x80))
281+
self._keys_state_buffer.modifiers |= 1 << (k - 0x80)
287282

288283
for i in self._key_pos_hid_keys:
289284
k = self.getKeyValue(i).first

m5stack/libs/hardware/keyboard/asciimap.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
2-
31
SHIFT = 0x80
42

5-
KEY_LEFT_CTRL = 0x80
3+
KEY_LEFT_CTRL = 0x80
64
KEY_LEFT_SHIFT = 0x81
7-
KEY_LEFT_ALT = 0x82
5+
KEY_LEFT_ALT = 0x82
86

9-
KEY_FN = 0xff
7+
KEY_FN = 0xFF
108
KEY_OPT = 0x00
119

12-
KEY_BACKSPACE = 0x2a
13-
KEY_TAB = 0x2b
14-
KEY_ENTER = 0x28
10+
KEY_BACKSPACE = 0x2A
11+
KEY_TAB = 0x2B
12+
KEY_ENTER = 0x28
1513

1614
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
1715
# | NUL | SOH | STX | ETX | EOT | ENQ | ACK | BEL | BS | TAB | LF | VT | FF | CR | SO | SI |
@@ -46,12 +44,13 @@
4644
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
4745
# | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 |
4846
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
49-
kb_asciimap = \
50-
b'\x00\x00\x00\x00\x00\x00\x00\x00\x2a\x2b\x28\x00\x00\x00\x00\x00' \
51-
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' \
52-
b'\x2c\x9e\xb4\xa0\xa1\xa2\xa4\x34\xa6\xa7\xa5\xae\x36\x2d\x37\x38' \
53-
b'\x27\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\xb3\x33\xb6\x2e\xb7\xb8' \
54-
b'\x9f\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92' \
55-
b'\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x2f\x31\x30\xa3\xad' \
56-
b'\x35\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12' \
57-
b'\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\xaf\xb1\xb0\xb5\x00'
47+
kb_asciimap = (
48+
b"\x00\x00\x00\x00\x00\x00\x00\x00\x2a\x2b\x28\x00\x00\x00\x00\x00"
49+
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
50+
b"\x2c\x9e\xb4\xa0\xa1\xa2\xa4\x34\xa6\xa7\xa5\xae\x36\x2d\x37\x38"
51+
b"\x27\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\xb3\x33\xb6\x2e\xb7\xb8"
52+
b"\x9f\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92"
53+
b"\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x2f\x31\x30\xa3\xad"
54+
b"\x35\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12"
55+
b"\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\xaf\xb1\xb0\xb5\x00"
56+
)

m5stack/libs/hardware/matrix_keyboard.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from .keyboard import Keyboard
22
from micropython import schedule
33

4+
45
class MatrixKeyboard(Keyboard):
56
def __init__(self) -> None:
67
super().__init__()

m5stack/libs/image_plus/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from M5 import Widgets
2+
23
try:
34
import urequests as requests
45
except ImportError:

m5stack/libs/label_plus.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from M5 import Widgets
2+
23
try:
34
import urequests as requests
45
except ImportError:

m5stack/libs/m5camera.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
_visible = True
5959

6060

61-
6261
def init(
6362
x, y, width, height, pixformat=RGB565, framesize=FRAME_QVGA, fb_count=2, fb_location=IN_PSRAM
6463
) -> None:

m5stack/libs/module/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
_attrs = {
55
"DualKmeterModule": "dual_kmeter",
66
"Relay4Module": "relay_4",
7-
"Encoder4MotorModule": "encoder4_motor"
7+
"Encoder4MotorModule": "encoder4_motor",
88
}
99

1010
# Lazy loader, effectively does:

0 commit comments

Comments
 (0)