Skip to content

Add GPIO collision detector client#146

Merged
beniroquai merged 1 commit into
masterfrom
mergemaster
Jul 2, 2026
Merged

Add GPIO collision detector client#146
beniroquai merged 1 commit into
masterfrom
mergemaster

Conversation

@beniroquai

Copy link
Copy Markdown
Contributor

Adds a new GPIO helper for the CAN GPIO slave, including status polling, configuration commands, and async event callbacks. Wire it into UC2Client so the GPIO interface is initialized alongside the other device modules.

Adds a new `GPIO` helper for the CAN GPIO slave, including status polling, configuration commands, and async event callbacks. Wire it into `UC2Client` so the GPIO interface is initialized alongside the other device modules.
Copilot AI review requested due to automatic review settings July 2, 2026 10:09
@beniroquai beniroquai merged commit 299dba2 into master Jul 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new GPIO/collision-detector client module and wires it into UC2Client so consumers can poll status, configure thresholds/sensitivity/reference, and receive async collision/E-stop events via callbacks.

Changes:

  • Added uc2rest/gpio.py implementing GPIO status polling (/gpio_get), configuration (/gpio_act), and async event callbacks.
  • Initialized the new GPIO helper in UC2Client alongside other device modules.
  • Added an inline JSON example comment in motor.set_joystick_direction().

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
uc2rest/UC2Client.py Imports and initializes the new GPIO helper during client construction.
uc2rest/motor.py Adds an inline payload example comment for joystick direction configuration.
uc2rest/gpio.py New GPIO/collision-detector client with polling, configuration helpers, and serial callback plumbing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread uc2rest/gpio.py
Comment on lines +54 to +66
gpio = data.get("gpio", None)
if not isinstance(gpio, dict):
return
self.status.update(gpio)

for cb in self._status_callbacks:
try:
cb(dict(self.status))
except Exception as e:
print(f"Error in gpio status callback: {e}")

if gpio.get("event", 0):
for cb in self._collision_callbacks:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants