Skip to content

Commit cba254f

Browse files
committed
going for v0.3.0
1 parent 8f051c1 commit cba254f

20 files changed

Lines changed: 55 additions & 117 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ l.enableFeedback("fa")
5858
l.offColor(RGB_COLOR(0xcc, 0xcc, 0xcc))
5959
while True:
6060
feedback = l.getFeedback()
61-
if feedback != None:
61+
if feedback is not None:
6262
print("l FB: {}: {},{}".format(feedback.type, feedback.x, feedback.y))
6363
l.toggle(feedback.x, feedback.y)
6464
```

dumbdisplay/_ddimpl.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def release(self):
146146
tunnels = set(self._tunnels)
147147
for tunnel in tunnels:
148148
tunnel.release()
149-
if self._io != None:
149+
if self._io is not None:
150150
self._io.close()
151151
self._io = None
152152
self._connected = False
@@ -243,19 +243,19 @@ def _sendSpecial(self, special_type: str, special_id: str, special_command: str,
243243
self._io.print(special_type)
244244
self._io.print('.')
245245
self._io.print(special_id)
246-
if special_command != None:
246+
if special_command is not None:
247247
self._io.print(':')
248248
self._io.print(special_command)
249249
self._io.print('>')
250-
if special_data != None:
250+
if special_data is not None:
251251
self._io.print(special_data)
252252
self._io.print('\n')
253253
#self.switchDebugLed(False)
254254
def _sendCommand(self, layer_id: str, command: str, *params):
255255
self._checkForFeedback()
256256
#self.switchDebugLed(True)
257257
try:
258-
if layer_id != None:
258+
if layer_id is not None:
259259
self._io.print(layer_id)
260260
self._io.print('.')
261261
self._io.print(command)
@@ -276,7 +276,7 @@ def _sendCommand(self, layer_id: str, command: str, *params):
276276

277277
def _checkForFeedback(self):
278278
feedback = self._readFeedback()
279-
if feedback != None:
279+
if feedback is not None:
280280
if len(feedback) > 0:
281281
if feedback[0:1] == '<':
282282
self._onFeedbackKeepAlive()
@@ -309,7 +309,7 @@ def _checkForFeedback(self):
309309
data = "???" + command + "???"
310310
#print("##" + str(final) + "/" + str(command) + "/" + str(data))####
311311
tunnel = self._tunnels.get(tid)
312-
if tunnel != None:
312+
if tunnel is not None:
313313
tunnel._handleInput(data, final)
314314
except:
315315
pass
@@ -326,7 +326,7 @@ def _checkForFeedback(self):
326326
x = int(feedback[0:idx])
327327
y = int(feedback[idx + 1:])
328328
layer = self._layers.get(lid)
329-
if layer != None:
329+
if layer is not None:
330330
layer._handleFeedback(type, x, y)
331331
except:
332332
pass

dumbdisplay/_ddio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
def io4Inet(port: int = DD_DEF_PORT) -> DDInputOutput:
1010
return DDIOInet(port)
1111

12-
def io4Wifi(ssid: str, password: str, port: int = DD_DEF_PORT) -> DDInputOutput:
12+
def io4Wifi(ssid: str = None, password: str = None, port: int = DD_DEF_PORT) -> DDInputOutput:
1313
return DDIOWifi(ssid, password, port)
1414

1515
def io4WifiOrInet(ssid: str, password: str, port: int = DD_DEF_PORT) -> DDInputOutput:

dumbdisplay/_ddio_ble.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ def preconnect(self):
1919
self._register()
2020
self._advertiser()
2121
while True:
22-
if self._data != None:
22+
if self._data is not None:
2323
break
2424
time.sleep_ms(500)
2525
print('... BLE connected')
2626
def available(self):
27-
return self._data != None and len(self._data) > 0
27+
return self._data is not None and len(self._data) > 0
2828
def read(self):
2929
return self._data.pop(0)
3030
def print(self, s):
@@ -37,7 +37,7 @@ def print(self, s):
3737
self.ble.gatts_notify(0, self._tx, b)
3838
#print(b)
3939
def close(self):
40-
if self._conn_handle != None:
40+
if self._conn_handle is not None:
4141
self.ble.gap_disconnect(self._conn_handle)
4242
self._conn_handle = None
4343
self._data = None
@@ -91,7 +91,7 @@ def _ble_irq(self, event, data):
9191
#message = buffer.decode('UTF-8')[:-1]
9292
message = buffer.decode('UTF-8').strip()
9393
#print(message)
94-
if (self._data != None):
94+
if (self._data is not None):
9595
self._data.append(message + '\n')
9696
#print(str(len(self._data)))
9797

dumbdisplay/_ddio_socket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def print(self, s):
5353
# raise e
5454
#self.conn.sendall(data)
5555
def close(self):
56-
if self.conn != None:
56+
if self.conn is not None:
5757
self.conn.close()
5858
self.sock.close()
5959
self.conn = None

dumbdisplay/_ddio_uart.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66

77

88
class DDIOUart(DDInputOutput):
9-
# def __init__(self, id, baudrate = 115200, tx = None, rx = None):
10-
# '''if specify tx, must also specify rx'''
11-
# super().__init__()
12-
# self.uart = UART(id, baudrate)
13-
# if tx != None:
14-
# self.uart.init(baudrate, tx = tx, rx = rx)
159
def __init__(self, uart):
1610
super().__init__()
1711
self.uart = uart
@@ -36,12 +30,4 @@ def io4DefUart(id, baudrate, rx):
3630
uart = UART(id, baudrate)
3731
return DDIOUart(uart)
3832

39-
# def io4Uart(id, baudrate = 115200, tx = None, rx = None):
40-
# '''if specify tx, must also specify rx'''
41-
# uart = UART(id, baudrate)
42-
# if tx != None:
43-
# uart.init(baudrate, tx = tx, rx = rx)
44-
# return DDIOUart(id, baudrate, tx, rx)
45-
# def io4IpcoUart(uart):
46-
# return DDIOUart(uart)
4733

dumbdisplay/_ddio_wifi.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
class DDIOWifi(DDIOSocket):
77
def __init__(self, ssid, password, port = DD_DEF_PORT):
88
super().__init__(port)
9-
print('connecting WIFI ... {} ...'.format(ssid))
109
station = network.WLAN(network.STA_IF)
1110
if not station.isconnected():
11+
print('connecting WIFI ... {} ...'.format(ssid))
12+
if ssid is None:
13+
raise Exception('SSID not provided')
1214
station.active(True)
1315
station.connect(ssid, password)
1416
while not station.isconnected():

dumbdisplay/_ddlayer.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -64,28 +64,28 @@ def noBorder(self):
6464
self.dd._sendCommand(self.layer_id, "border")
6565
def padding(self, left, top = None, right = None, bottom = None):
6666
'''see border() for size unit'''
67-
if top == None and right == None and bottom == None:
67+
if top is None and right is None and bottom is None:
6868
self.dd._sendCommand(self.layer_id, "padding", str(left))
6969
else:
70-
if top == None:
70+
if top is None:
7171
top = left
72-
if right == None:
72+
if right is None:
7373
right = left
74-
if bottom == None:
74+
if bottom is None:
7575
bottom = top
7676
self.dd._sendCommand(self.layer_id, "padding", str(left), str(top), str(right), str(bottom))
7777
def noPadding(self):
7878
self.dd._sendCommand(self.layer_id, "padding")
7979
def margin(self, left, top = None, right = None, bottom = None):
8080
'''see border() for size unit'''
81-
if top == None and right == None and bottom == None:
81+
if top is None and right is None and bottom is None:
8282
self.dd._sendCommand(self.layer_id, "margin", str(left))
8383
else:
84-
if top == None:
84+
if top is None:
8585
top = left
86-
if right == None:
86+
if right is None:
8787
right = left
88-
if bottom == None:
88+
if bottom is None:
8989
bottom = top
9090
self.dd._sendCommand(self.layer_id, "margin", str(left), str(top), str(right), str(bottom))
9191
def noMargin(self):
@@ -158,20 +158,11 @@ def reorderLayer(self, how: str):
158158

159159
def _handleFeedback(self, type, x, y):
160160
#print("RAW FB: " + self.layer_id + '.' + type + ':' + str(x) + ',' + str(y))
161-
if self._feedback_handler != None:
161+
if self._feedback_handler is not None:
162162
self._feedback_handler(self, type, x, y)
163163
else:
164164
self._feedbacks.append((type, x, y))
165165
# self._shipFeedbacks()
166-
# def _shipFeedbacks(self):
167-
# if self._feedback_handler != None:
168-
# feedbacks = self._feedbacks.copy()
169-
# self._feedbacks.clear()
170-
# for (type, x, y) in feedbacks:
171-
# self._feedback_handler.handleFeedback(type, x, y)
172-
# # else:
173-
# # for (type, x, y) in self.feedbacks:
174-
# # print("unhandled FB: " + self.layer_id + '.' + type + ':' + str(x) + ',' + str(y))
175166

176167

177168

dumbdisplay/_ddlayer_plotter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ def __init__(self, dd, width, height, pixels_per_second = 10):
1515
super().__init__(dd, layer_id)
1616
def label(self, no_key_label = None, **key_label_pairs):
1717
'''set labels of keys; if key has no label, the key will be the label'''
18-
if no_key_label != None:
18+
if no_key_label is not None:
1919
self.dd._sendCommand(self.layer_id, "label", "", str(no_key_label))
2020
for (key, lab) in key_label_pairs.items():
2121
self.dd._sendCommand(self.layer_id, "label", key, str(lab))
2222
def set(self, no_key_value = None, **key_value_pairs):
2323
'''set values with multiple key value pairs; value should be numeric'''
2424
params = []
25-
if no_key_value != None:
25+
if no_key_value is not None:
2626
params.append("")
2727
params.append(str(no_key_value))
2828
for (k, v) in key_value_pairs.items():

dumbdisplay/_dumbdisplay.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ def build(self):
2424
return self._build_layout()
2525
def pin(self, dd):
2626
layout_spec = self._build_layout()
27-
if layout_spec != None:
27+
if layout_spec is not None:
2828
dd.configAutoPin(layout_spec)
2929
def _build_layout(self):
3030
layout_spec = None
3131
for layer in self.layers:
32-
if layout_spec == None:
32+
if layout_spec is None:
3333
layout_spec = ''
3434
else:
3535
layout_spec += '+'
3636
if type(layer) == DDAutoPin:
3737
layout_spec += layer._build_layout()
3838
else:
3939
layout_spec += layer.layer_id
40-
if layout_spec != None:
40+
if layout_spec is not None:
4141
layout_spec = str(self.orientation) + '(' + layout_spec + ")"
4242
return layout_spec
4343

@@ -124,15 +124,6 @@ def notone(self):
124124

125125

126126

127-
# def toggleDebugLed(self):
128-
# if self.debug_led != None:
129-
# self.debug_led.value(not self.debug_led.value())
130-
# def switchDebugLed(self, on):
131-
# if self.debug_led != None:
132-
# if on:
133-
# self.debug_led.on()
134-
# else:
135-
# self.debug_led.off()
136127
def onDetectedDisconnect(self, for_ms: int):
137128
if self.reset_machine_if_detected_disconnect_for_s and for_ms >= (1000 * self.reset_machine_if_detected_disconnect_for_s):
138129
print("xxxxxxxxx")

0 commit comments

Comments
 (0)