Skip to content

feat(t-deck): audible detection alerts via I2S speaker - #5

Open
thehappydinoa wants to merge 2 commits into
mainfrom
claude/flipper-inspired-features
Open

thehappydinoa wants to merge 2 commits into
mainfrom
claude/flipper-inspired-features

Conversation

@thehappydinoa

Copy link
Copy Markdown
Owner

Flipper-style audio cues on the T-Deck's MAX98357A I²S speaker — a confidence-tiered chirp on each Flock detection plus a power-up chirp, so the operator gets eyes-up alerting while driving.

Scope: audio only. The home menu and saved-sessions browser (also discussed) are intentionally left for follow-up PRs. The branch also carries an earlier commit (docs: Flipper-inspired feature proposal) that frames this work.

What's here

  • tone_synth.{h,cpp} — pure 16-bit PCM tone/cue synthesis (square wave + raised-cosine anti-click envelope). No hardware deps → host-unit-testable. Cues: HIGH = rising triple-beep, MED = two-note ping, LOW = single blip, plus boot.
  • audio.{h,cpp} — I²S driver behind FD_ENABLE_AUDIO. Plays cues on a background FreeRTOS task (queue depth 1, drops overlaps) so the scan loop never blocks. No-op static inline stubs when disabled keep call sites clean on non-T-Deck builds.
  • Hookserial_out_emit() fires audio_alert(flock_det_confidence(...)) next to the existing display_note(); only wifi/ble detections reach it.
  • sound on|off|test serial command for runtime control.
  • Pins: I²S WS/BCK/DOUT in tdeck_board.h; -DFD_ENABLE_AUDIO on env:t-deck; README documents the feature + commands.

Hardware note

The T-Deck has a speaker (MAX98357A I²S amp), not a piezo buzzer — hence PCM-over-I²S rather than tone(). GPIO7 (I²S BCK) overlaps a vestigial OLED_SDA=7 in pin_spec.py that the T-Deck never consumes (it uses FD_ENABLE_TDECK_UI). Harmless today; flagged in a code comment. Happy to scrub it from pin_spec.py in a follow-up.

Tests

  • New tests/test_tone_synth.py host-compiles the synth core and checks sample counts, envelope/peak scaling, buffer-cap safety, and silent rests.
  • 159 Python tests pass. The disabled-build stub path also compiles + links cleanly.
  • ⚠️ Not flashed — no PlatformIO/hardware in this environment. First on-device check: power-up chirp, then sound test → HIGH cue.

https://claude.ai/code/session_01J5wD9G5ms5hPL3rGZsieWC


Generated by Claude Code

claude added 2 commits June 2, 2026 19:50
Design exploration ranking which Flipper interface/feature ideas are worth
bringing to the flockdar T-Deck firmware (main menu, audio/haptic alert cues,
saved-session browser, RSSI detector screen, mini-map, settings, etc.), with
what's already built and what's explicitly out of scope (Sub-GHz/IR/NFC — no
radios for it; flockdar is a passive detector). Proposal only, no code.
Add Flipper-style audio cues on the T-Deck's MAX98357A I2S speaker — a
confidence-tiered chirp on each Flock detection plus a power-up chirp, so the
operator gets eyes-up alerting while driving.

- tone_synth.{h,cpp}: pure 16-bit PCM tone/cue synthesis (square wave with a
  raised-cosine anti-click envelope). No hardware deps -> host-unit-testable.
  Cues: HIGH = rising triple-beep, MED = two-note ping, LOW = single blip, boot.
- audio.{h,cpp}: I2S driver (FD_ENABLE_AUDIO). Plays cues on a background task
  (queue depth 1, drops overlaps) so the scan loop never blocks. No-op inline
  stubs when disabled, so call sites stay clean on non-T-Deck builds.
- Hook: serial_out_emit() fires audio_alert(flock_det_confidence(...)) next to
  the existing display_note(); only wifi/ble detections reach it.
- serial_cmd: `sound on|off|test` runtime control.
- pins: I2S WS/BCK/DOUT in tdeck_board.h (note GPIO7 BCK overlaps the vestigial
  pin_spec OLED_SDA=7, which the T-Deck never consumes).
- platformio: -DFD_ENABLE_AUDIO on env:t-deck. README documents the feature.
- tests/test_tone_synth.py: host cross-check of sample counts, envelope/peak,
  buffer-cap safety, and silent rests (159 Python tests pass; compiles clean,
  incl. the disabled-build stub path).
@thehappydinoa
thehappydinoa force-pushed the claude/flipper-inspired-features branch from ea03a41 to 1eae4da Compare June 2, 2026 23:50
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