Skip to content

Commit 042408b

Browse files
committed
fix pinctl and pi5 l298n outputs
1 parent 1a86781 commit 042408b

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

mycodo/outputs/on_off_pinctrl.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ def switch_pin(self, pin, state):
206206
set_opt = "dl"
207207
cmd = f"pinctrl set {pin} {set_opt}"
208208
cmd_return, cmd_error, cmd_status = cmd_output(cmd, user="root")
209+
state_text = 'ON' if state else 'OFF'
209210
self.logger.debug(
210-
f"GPIO {self.options_channels['pin'][0]} set ON with '{cmd}': "
211+
f"GPIO {pin} set {state_text} with '{cmd}': "
211212
f"Status: {cmd_status}, Return: {cmd_return}, Error: {cmd_error}")

mycodo/outputs/pump_l298n_pi5.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,29 @@ def initialize(self):
167167
"Check your configuration.")
168168
self.channel_setup[channel] = False
169169
else:
170+
cmd = f"pinctrl set {self.options_channels['pin_1'][channel]} op dl"
171+
cmd_return, cmd_error, cmd_status = cmd_output(cmd, user="root")
172+
self.logger.debug(
173+
f"GPIO {self.options_channels['pin_1'][channel]} setup with '{cmd}': "
174+
f"Status: {cmd_status}, Return: {cmd_return}, Error: {cmd_error}")
175+
176+
cmd = f"pinctrl set {self.options_channels['pin_2'][channel]} op dl"
177+
cmd_return, cmd_error, cmd_status = cmd_output(cmd, user="root")
178+
self.logger.debug(
179+
f"GPIO {self.options_channels['pin_2'][channel]} setup with '{cmd}': "
180+
f"Status: {cmd_status}, Return: {cmd_return}, Error: {cmd_error}")
181+
182+
cmd = f"pinctrl set {self.options_channels['pin_enable'][channel]} op dl"
183+
cmd_return, cmd_error, cmd_status = cmd_output(cmd, user="root")
184+
self.logger.debug(
185+
f"GPIO {self.options_channels['pin_enable'][channel]} setup with '{cmd}': "
186+
f"Status: {cmd_status}, Return: {cmd_return}, Error: {cmd_error}")
187+
170188
self.channel_setup[channel] = True
171-
self.output_setup = True
172189
self.output_states[channel] = False
173190

191+
self.output_setup = True
192+
174193
def output_switch(self, state, output_type=None, amount=None, output_channel=None):
175194
if not self.is_setup():
176195
msg = "Error 101: Device not set up. " \
@@ -280,6 +299,7 @@ def switch_pin(self, pin, state):
280299
set_opt = "dl"
281300
cmd = f"pinctrl set {pin} {set_opt}"
282301
cmd_return, cmd_error, cmd_status = cmd_output(cmd, user="root")
302+
state_text = 'ON' if state else 'OFF'
283303
self.logger.debug(
284-
f"GPIO {self.options_channels['pin'][0]} set ON with '{cmd}': "
304+
f"GPIO {pin} set {state_text} with '{cmd}': "
285305
f"Status: {cmd_status}, Return: {cmd_return}, Error: {cmd_error}")

0 commit comments

Comments
 (0)