Skip to content

Commit

Permalink
Flake8 compliance
Browse files Browse the repository at this point in the history
... and a bugfix, thanks to flake8... so mad that it actually helped
  • Loading branch information
mutesplash authored Dec 4, 2023
1 parent 3670a2f commit a306d01
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions buildhat/colordistance.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def wait_for_new_color(self):

@property
def ir_channel(self):
"""Get the IR channel for message transmission"""
return self._ir_channel

@ir_channel.setter
Expand All @@ -217,20 +218,15 @@ def ir_channel(self, channel=1):
elif check_chan < 1:
check_chan = 1
# Internally: 0-3
self._ir_channel = int(check_chan)-1
self._ir_channel = int(check_chan) - 1

@property
def ir_address(self):
"""
IR Address space of 0x0 for default PoweredUp or 0x1 for extra space
"""
"""IR Address space of 0x0 for default PoweredUp or 0x1 for extra space"""
return self._ir_address

def toggle_ir_toggle(self):
"""
Toggle the IR toggle bit
"""
"""Toggle the IR toggle bit"""
# IYKYK, because the RC documents are not clear
if self._ir_toggle:
self._ir_toggle = 0x0
Expand All @@ -241,7 +237,8 @@ def toggle_ir_toggle(self):
def send_ir_sop(self, port, mode):
"""
Send an IR message via Power Functions RC Protocol in Single Output PWM mode
https://www.philohome.com/pf/pf.htm
PF IR RC Protocol documented at https://www.philohome.com/pf/pf.htm
Port B is blue
Expand Down Expand Up @@ -297,7 +294,8 @@ def send_ir_sop(self, port, mode):
def send_ir_socstid(self, port, mode):
"""
Send an IR message via Power Functions RC Protocol in Single Output Clear/Set/Toggle/Increment/Decrement mode
https://www.philohome.com/pf/pf.htm
PF IR RC Protocol documented at https://www.philohome.com/pf/pf.htm
Valid values for mode are:
0x0: Toggle full Clockwise/Forward (Stop to Clockwise, Clockwise to Stop, Counterclockwise to Clockwise)
Expand All @@ -320,7 +318,6 @@ def send_ir_socstid(self, port, mode):
:param port: 'A' or 'B'
:param mode: 0-15 indicating the port's mode to set
"""

escape_modeselect = 0x0
escape = escape_modeselect

Expand Down Expand Up @@ -352,7 +349,8 @@ def send_ir_socstid(self, port, mode):
def send_ir_combo_pwm(self, port_b_mode, port_a_mode):
"""
Send an IR message via Power Functions RC Protocol in Combo PWM mode
https://www.philohome.com/pf/pf.htm
PF IR RC Protocol documented at https://www.philohome.com/pf/pf.htm
Valid values for the modes are:
0x0 Float
Expand All @@ -375,7 +373,6 @@ def send_ir_combo_pwm(self, port_b_mode, port_a_mode):
:param port_b_mode: 0-15 indicating the command to send to port B
:param port_a_mode: 0-15 indicating the command to send to port A
"""

escape_combo_pwm = 0x1
escape = escape_combo_pwm

Expand All @@ -387,7 +384,8 @@ def send_ir_combo_pwm(self, port_b_mode, port_a_mode):
def send_ir_combo_direct(self, port_b_output, port_a_output):
"""
Send an IR message via Power Functions RC Protocol in Combo Direct mode
https://www.philohome.com/pf/pf.htm
PF IR RC Protocol documented at https://www.philohome.com/pf/pf.htm
Valid values for the output variables are:
0x0: Float output
Expand Down Expand Up @@ -419,7 +417,8 @@ def send_ir_combo_direct(self, port_b_output, port_a_output):
def send_ir_extended(self, mode):
"""
Send an IR message via Power Functions RC Protocol in Extended mode
https://www.philohome.com/pf/pf.htm
PF IR RC Protocol documented at https://www.philohome.com/pf/pf.htm
Valid values for the mode are:
0x0: Brake Port A (timeout)
Expand Down Expand Up @@ -450,7 +449,8 @@ def send_ir_extended(self, mode):
def send_ir_single_pin(self, port, pin, mode, timeout):
"""
Send an IR message via Power Functions RC Protocol in Single Pin mode
https://www.philohome.com/pf/pf.htm
PF IR RC Protocol documented at https://www.philohome.com/pf/pf.htm
Valid values for the mode are:
0x0: No-op
Expand Down Expand Up @@ -490,7 +490,7 @@ def send_ir_single_pin(self, port, pin, mode, timeout):

if pin != 1 and pin != 2:
return False
pin_value = pin-1
pin_value = pin - 1

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

return self._send_ir_nibbles(nibble1, nibble2, mode)
return self._send_ir_nibbles(nibble1, nibble2, nibble3)

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

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

byte_two = (nibble2 << 4) | nibble3
byte_two = (nibble2 << 4) | nibble3

data = bytearray(3)
data[0] = (0xc << 4) | mode
Expand Down

0 comments on commit a306d01

Please sign in to comment.