feat: Hardware button park/disarm/re-arm (Issue #682) #688

Merged
sl-jetson merged 1 commits from sl-firmware/issue-682-hw-button into main 2026-03-18 08:21:56 -04:00
Collaborator

Summary

  • Adds hw_button driver on PC2 (active-low, 20ms debounce) with gesture detection
  • New BALANCE_PARKED state: PID frozen, motors off, quick re-arm via combo
  • FC_BTN (0x404) CAN frame sent to Orin on each event (PARKED/UNPARKED/UNPARK_FAILED)
  • 11 unit tests, 1016 assertions — all pass

Gestures

Gesture Event Action
Single short press + 500ms quiet BTN_EVENT_PARK ARMED → PARKED, amber LED
SHORT+SHORT+LONG (within 3s) BTN_EVENT_REARM_COMBO PARKED → ARMED if pitch < 20°

Test plan

  • gcc -I include -I test/stubs -DTEST_HOST -o /tmp/test_hw_button test/test_hw_button.c && /tmp/test_hw_button → 1016 passed, 0 failed
  • pio run firmware build passes
  • Single press while armed → robot parks, yellow LED
  • SHORT+SHORT+LONG while parked → robot re-arms, green LED
  • SHORT+SHORT+LONG while armed → no action (combo only works from PARKED)
  • Orin receives FC_BTN (0x404) CAN frames on each event

🤖 Generated with Claude Code

## Summary - Adds `hw_button` driver on PC2 (active-low, 20ms debounce) with gesture detection - New `BALANCE_PARKED` state: PID frozen, motors off, quick re-arm via combo - FC_BTN (0x404) CAN frame sent to Orin on each event (PARKED/UNPARKED/UNPARK_FAILED) - 11 unit tests, 1016 assertions — all pass ## Gestures | Gesture | Event | Action | |---|---|---| | Single short press + 500ms quiet | `BTN_EVENT_PARK` | ARMED → PARKED, amber LED | | SHORT+SHORT+LONG (within 3s) | `BTN_EVENT_REARM_COMBO` | PARKED → ARMED if pitch < 20° | ## Test plan - [ ] `gcc -I include -I test/stubs -DTEST_HOST -o /tmp/test_hw_button test/test_hw_button.c && /tmp/test_hw_button` → 1016 passed, 0 failed - [ ] `pio run` firmware build passes - [ ] Single press while armed → robot parks, yellow LED - [ ] SHORT+SHORT+LONG while parked → robot re-arms, green LED - [ ] SHORT+SHORT+LONG while armed → no action (combo only works from PARKED) - [ ] Orin receives FC_BTN (0x404) CAN frames on each event 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sl-jetson added 1 commit 2026-03-18 08:10:30 -04:00
Add hw_button driver (PC2 active-low, 20ms debounce) with gesture detection:
- Single short press + 500ms quiet -> BTN_EVENT_PARK
- SHORT+SHORT+LONG combo (within 3s) -> BTN_EVENT_REARM_COMBO

New BALANCE_PARKED state: PID frozen, motors off, quick re-arm via button
combo without the 3-second arm interlock required from DISARMED.

FC_BTN (0x404) CAN frame sent to Orin on each event:
  event_id 1=PARKED, 2=UNPARKED, 3=UNPARK_FAILED (pitch > 20 deg)

Includes 11 unit tests (1016 assertions) exercising debounce, bounce
rejection, short/long classification, sequence detection, and timeout.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sl-jetson merged commit 441c56b1d9 into main 2026-03-18 08:21:56 -04:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: seb/saltylab-firmware#688
No description provided.