Hardware button: park/disarm on single press, re-arm on 2 short + 1 long press #682

Closed
opened 2026-03-17 22:35:16 -04:00 by seb · 0 comments
Owner

Feature

Add physical button support on Mamba F7 MK2 for safe parking and re-arming without USB/RC.

Button mapping

  • 1 press (short): Suspend balance loop → PARKED state (motors idle, robot can be held/set down)
  • 2 short + 1 long press: Re-arm balance loop (same pitch check as normal arm)

Hardware

  • Use existing BOOT button (used for DFU) — only active when powered on normally
  • Or use a dedicated GPIO pad — check available pads on Mamba F7 MK2
  • Debounce: 50ms

States

DISARMED → (A cmd or 2s+1l) → ARMED (balance running)
ARMED → (1 press) → PARKED (motors zero, PID suspended, holds position)
PARKED → (2s+1l) → ARMED
any state → (estop / tip over) → DISARMED

Implementation

  • Add BALANCE_PARKED state to balance FSM
  • In PARKED: send zero current to VESCs via CAN, do not run PID
  • Button ISR on GPIO EXTI: track press count + duration in ring buffer
  • Pattern detector in main loop (50Hz): match 2 short (<500ms) + 1 long (>800ms) within 3s window
  • Buzzer feedback: 1 beep = parked, 3 beeps = armed
  • LED feedback: solid = armed, slow blink = parked, fast blink = disarmed

Notes

  • BOOT button on STM32F7 is PA0 (BOOT0 pin) — may conflict with DFU
  • Better: use user button if available, or PA0/UART4_TX pad (check Mamba F7 MK2 pinout)
  • Must not interfere with DFU boot sequence
## Feature Add physical button support on Mamba F7 MK2 for safe parking and re-arming without USB/RC. ## Button mapping - **1 press (short):** Suspend balance loop → PARKED state (motors idle, robot can be held/set down) - **2 short + 1 long press:** Re-arm balance loop (same pitch check as normal arm) ## Hardware - Use existing BOOT button (used for DFU) — only active when powered on normally - Or use a dedicated GPIO pad — check available pads on Mamba F7 MK2 - Debounce: 50ms ## States ``` DISARMED → (A cmd or 2s+1l) → ARMED (balance running) ARMED → (1 press) → PARKED (motors zero, PID suspended, holds position) PARKED → (2s+1l) → ARMED any state → (estop / tip over) → DISARMED ``` ## Implementation - Add `BALANCE_PARKED` state to balance FSM - In PARKED: send zero current to VESCs via CAN, do not run PID - Button ISR on GPIO EXTI: track press count + duration in ring buffer - Pattern detector in main loop (50Hz): match 2 short (<500ms) + 1 long (>800ms) within 3s window - Buzzer feedback: 1 beep = parked, 3 beeps = armed - LED feedback: solid = armed, slow blink = parked, fast blink = disarmed ## Notes - BOOT button on STM32F7 is PA0 (BOOT0 pin) — may conflict with DFU - Better: use user button if available, or PA0/UART4_TX pad (check Mamba F7 MK2 pinout) - Must not interfere with DFU boot sequence
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

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