feat: Piezo buzzer melody driver (Issue #253) #257

Merged
sl-jetson merged 1 commits from sl-firmware/issue-253-buzzer into main 2026-03-02 13:22:22 -05:00
Collaborator

Implements STM32F7 non-blocking driver for piezo buzzer on PA8 using TIM1 PWM.

Features:

  • Dynamic frequency control for musical notes
  • 4 predefined melodies: startup, battery warning, error alert, docking chime
  • Non-blocking melody queue with FIFO scheduling
  • Custom melody and simple tone APIs
  • 15 musical notes (C4-C6) with duration presets
  • Rest (silence) notes for composition

API:

  • buzzer_init(), buzzer_play_melody(), buzzer_play_custom(), buzzer_play_tone()
  • buzzer_stop(), buzzer_is_playing(), buzzer_tick()

Testing:

  • 52 passing unit tests
  • Melody timing and frequency transitions
  • Queue management and playback control

Integration:

  • Called at startup and ticked every 10ms in main loop
  • Used for startup jingle, battery warnings, error alerts, success feedback

🤖 Generated with Claude Code

Implements STM32F7 non-blocking driver for piezo buzzer on PA8 using TIM1 PWM. **Features:** - Dynamic frequency control for musical notes - 4 predefined melodies: startup, battery warning, error alert, docking chime - Non-blocking melody queue with FIFO scheduling - Custom melody and simple tone APIs - 15 musical notes (C4-C6) with duration presets - Rest (silence) notes for composition **API:** - buzzer_init(), buzzer_play_melody(), buzzer_play_custom(), buzzer_play_tone() - buzzer_stop(), buzzer_is_playing(), buzzer_tick() **Testing:** - 52 passing unit tests - Melody timing and frequency transitions - Queue management and playback control **Integration:** - Called at startup and ticked every 10ms in main loop - Used for startup jingle, battery warnings, error alerts, success feedback 🤖 Generated with Claude Code
sl-webui added 1 commit 2026-03-02 12:51:58 -05:00
Implements STM32F7 non-blocking driver for piezo buzzer on PA8 using TIM1 PWM.
Plays predefined melodies and custom sequences with melody queue.

Features:
- PA8 TIM1_CH1 PWM output with dynamic frequency control
- Predefined melodies: startup jingle, battery warning, error alert, docking chime
- Non-blocking melody queue with FIFO scheduling (4-slot capacity)
- Custom melody and simple tone APIs
- 15 musical notes (C4-C6) with duration presets
- Rest (silence) notes for composition
- 50% duty cycle for optimal piezo buzzer drive

API Functions:
- buzzer_init(): Configure PA8 PWM and TIM1
- buzzer_play_melody(type): Queue predefined melody
- buzzer_play_custom(notes): Queue custom note sequence
- buzzer_play_tone(freq, duration): Queue simple tone
- buzzer_stop(): Stop playback and clear queue
- buzzer_is_playing(): Query playback status
- buzzer_tick(now_ms): Periodic timing update (10ms recommended)

Test Suite:
- 52 passing unit tests covering:
  * Melody structure and termination
  * Simple and multi-note playback
  * Frequency transitions
  * Queue management
  * Timing accuracy
  * Rest notes in sequences
  * Musical frequency ranges

Integration:
- Called at startup and ticked every 10ms in main loop
- Used for startup jingle, battery warnings, error alerts, success feedback

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
sl-jetson merged commit 5e40504297 into main 2026-03-02 13:22:22 -05: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#257
No description provided.