Skip to content

Commit a306d01

Browse files
authored
Flake8 compliance
... and a bugfix, thanks to flake8... so mad that it actually helped
1 parent 3670a2f commit a306d01

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

buildhat/colordistance.py

+19-19
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ def wait_for_new_color(self):
202202

203203
@property
204204
def ir_channel(self):
205+
"""Get the IR channel for message transmission"""
205206
return self._ir_channel
206207

207208
@ir_channel.setter
@@ -217,20 +218,15 @@ def ir_channel(self, channel=1):
217218
elif check_chan < 1:
218219
check_chan = 1
219220
# Internally: 0-3
220-
self._ir_channel = int(check_chan)-1
221+
self._ir_channel = int(check_chan) - 1
221222

222223
@property
223224
def ir_address(self):
224-
"""
225-
IR Address space of 0x0 for default PoweredUp or 0x1 for extra space
226-
"""
225+
"""IR Address space of 0x0 for default PoweredUp or 0x1 for extra space"""
227226
return self._ir_address
228227

229228
def toggle_ir_toggle(self):
230-
"""
231-
Toggle the IR toggle bit
232-
233-
"""
229+
"""Toggle the IR toggle bit"""
234230
# IYKYK, because the RC documents are not clear
235231
if self._ir_toggle:
236232
self._ir_toggle = 0x0
@@ -241,7 +237,8 @@ def toggle_ir_toggle(self):
241237
def send_ir_sop(self, port, mode):
242238
"""
243239
Send an IR message via Power Functions RC Protocol in Single Output PWM mode
244-
https://www.philohome.com/pf/pf.htm
240+
241+
PF IR RC Protocol documented at https://www.philohome.com/pf/pf.htm
245242
246243
Port B is blue
247244
@@ -297,7 +294,8 @@ def send_ir_sop(self, port, mode):
297294
def send_ir_socstid(self, port, mode):
298295
"""
299296
Send an IR message via Power Functions RC Protocol in Single Output Clear/Set/Toggle/Increment/Decrement mode
300-
https://www.philohome.com/pf/pf.htm
297+
298+
PF IR RC Protocol documented at https://www.philohome.com/pf/pf.htm
301299
302300
Valid values for mode are:
303301
0x0: Toggle full Clockwise/Forward (Stop to Clockwise, Clockwise to Stop, Counterclockwise to Clockwise)
@@ -320,7 +318,6 @@ def send_ir_socstid(self, port, mode):
320318
:param port: 'A' or 'B'
321319
:param mode: 0-15 indicating the port's mode to set
322320
"""
323-
324321
escape_modeselect = 0x0
325322
escape = escape_modeselect
326323

@@ -352,7 +349,8 @@ def send_ir_socstid(self, port, mode):
352349
def send_ir_combo_pwm(self, port_b_mode, port_a_mode):
353350
"""
354351
Send an IR message via Power Functions RC Protocol in Combo PWM mode
355-
https://www.philohome.com/pf/pf.htm
352+
353+
PF IR RC Protocol documented at https://www.philohome.com/pf/pf.htm
356354
357355
Valid values for the modes are:
358356
0x0 Float
@@ -375,7 +373,6 @@ def send_ir_combo_pwm(self, port_b_mode, port_a_mode):
375373
:param port_b_mode: 0-15 indicating the command to send to port B
376374
:param port_a_mode: 0-15 indicating the command to send to port A
377375
"""
378-
379376
escape_combo_pwm = 0x1
380377
escape = escape_combo_pwm
381378

@@ -387,7 +384,8 @@ def send_ir_combo_pwm(self, port_b_mode, port_a_mode):
387384
def send_ir_combo_direct(self, port_b_output, port_a_output):
388385
"""
389386
Send an IR message via Power Functions RC Protocol in Combo Direct mode
390-
https://www.philohome.com/pf/pf.htm
387+
388+
PF IR RC Protocol documented at https://www.philohome.com/pf/pf.htm
391389
392390
Valid values for the output variables are:
393391
0x0: Float output
@@ -419,7 +417,8 @@ def send_ir_combo_direct(self, port_b_output, port_a_output):
419417
def send_ir_extended(self, mode):
420418
"""
421419
Send an IR message via Power Functions RC Protocol in Extended mode
422-
https://www.philohome.com/pf/pf.htm
420+
421+
PF IR RC Protocol documented at https://www.philohome.com/pf/pf.htm
423422
424423
Valid values for the mode are:
425424
0x0: Brake Port A (timeout)
@@ -450,7 +449,8 @@ def send_ir_extended(self, mode):
450449
def send_ir_single_pin(self, port, pin, mode, timeout):
451450
"""
452451
Send an IR message via Power Functions RC Protocol in Single Pin mode
453-
https://www.philohome.com/pf/pf.htm
452+
453+
PF IR RC Protocol documented at https://www.philohome.com/pf/pf.htm
454454
455455
Valid values for the mode are:
456456
0x0: No-op
@@ -490,7 +490,7 @@ def send_ir_single_pin(self, port, pin, mode, timeout):
490490

491491
if pin != 1 and pin != 2:
492492
return False
493-
pin_value = pin-1
493+
pin_value = pin - 1
494494

495495
if mode > 0x3 or mode < 0x0:
496496
return False
@@ -499,7 +499,7 @@ def send_ir_single_pin(self, port, pin, mode, timeout):
499499
nibble2 = (self._ir_address << 3) | ir_mode
500500
nibble3 = (output_port << 3) | (pin_value << 3) | mode
501501

502-
return self._send_ir_nibbles(nibble1, nibble2, mode)
502+
return self._send_ir_nibbles(nibble1, nibble2, nibble3)
503503

504504
def _send_ir_nibbles(self, nibble1, nibble2, nibble3):
505505

@@ -516,7 +516,7 @@ def _send_ir_nibbles(self, nibble1, nibble2, nibble3):
516516
if nibble1 < 0x0 or nibble2 < 0x0 or nibble3 < 0x0:
517517
return False
518518

519-
byte_two = (nibble2 << 4) | nibble3
519+
byte_two = (nibble2 << 4) | nibble3
520520

521521
data = bytearray(3)
522522
data[0] = (0xc << 4) | mode

0 commit comments

Comments
 (0)