Skip to content

Commit

Permalink
fix pinctl and pi5 l298n outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
kizniche committed Feb 3, 2025
1 parent 1a86781 commit 042408b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
3 changes: 2 additions & 1 deletion mycodo/outputs/on_off_pinctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def switch_pin(self, pin, state):
set_opt = "dl"
cmd = f"pinctrl set {pin} {set_opt}"
cmd_return, cmd_error, cmd_status = cmd_output(cmd, user="root")
state_text = 'ON' if state else 'OFF'
self.logger.debug(
f"GPIO {self.options_channels['pin'][0]} set ON with '{cmd}': "
f"GPIO {pin} set {state_text} with '{cmd}': "
f"Status: {cmd_status}, Return: {cmd_return}, Error: {cmd_error}")
24 changes: 22 additions & 2 deletions mycodo/outputs/pump_l298n_pi5.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,29 @@ def initialize(self):
"Check your configuration.")
self.channel_setup[channel] = False
else:
cmd = f"pinctrl set {self.options_channels['pin_1'][channel]} op dl"
cmd_return, cmd_error, cmd_status = cmd_output(cmd, user="root")
self.logger.debug(
f"GPIO {self.options_channels['pin_1'][channel]} setup with '{cmd}': "
f"Status: {cmd_status}, Return: {cmd_return}, Error: {cmd_error}")

cmd = f"pinctrl set {self.options_channels['pin_2'][channel]} op dl"
cmd_return, cmd_error, cmd_status = cmd_output(cmd, user="root")
self.logger.debug(
f"GPIO {self.options_channels['pin_2'][channel]} setup with '{cmd}': "
f"Status: {cmd_status}, Return: {cmd_return}, Error: {cmd_error}")

cmd = f"pinctrl set {self.options_channels['pin_enable'][channel]} op dl"
cmd_return, cmd_error, cmd_status = cmd_output(cmd, user="root")
self.logger.debug(
f"GPIO {self.options_channels['pin_enable'][channel]} setup with '{cmd}': "
f"Status: {cmd_status}, Return: {cmd_return}, Error: {cmd_error}")

self.channel_setup[channel] = True
self.output_setup = True
self.output_states[channel] = False

self.output_setup = True

def output_switch(self, state, output_type=None, amount=None, output_channel=None):
if not self.is_setup():
msg = "Error 101: Device not set up. " \
Expand Down Expand Up @@ -280,6 +299,7 @@ def switch_pin(self, pin, state):
set_opt = "dl"
cmd = f"pinctrl set {pin} {set_opt}"
cmd_return, cmd_error, cmd_status = cmd_output(cmd, user="root")
state_text = 'ON' if state else 'OFF'
self.logger.debug(
f"GPIO {self.options_channels['pin'][0]} set ON with '{cmd}': "
f"GPIO {pin} set {state_text} with '{cmd}': "
f"Status: {cmd_status}, Return: {cmd_return}, Error: {cmd_error}")

1 comment on commit 042408b

@kizniche
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Radical DIY Forum. There might be relevant details there:

https://forum.radicaldiy.com/t/l298n-dc-motor-controller-on-pi-5/2056/6

Please sign in to comment.