Skip to content

feat(m5stack-cardputer): Better mic+speaker support and update example accordingly#671

Merged
finger563 merged 3 commits into
mainfrom
feat/cardputer-full-duplex-audio
Jul 19, 2026
Merged

feat(m5stack-cardputer): Better mic+speaker support and update example accordingly#671
finger563 merged 3 commits into
mainfrom
feat/cardputer-full-duplex-audio

Conversation

@finger563

Copy link
Copy Markdown
Contributor

Description

  • Update the M5Stack Cardputer ADV audio driver to support full-duplex operation, allowing simultaneous use of the speaker and microphone. This includes changes to the I2S configuration, ES8311 codec initialization, and example code for recording and playback.

Motivation and Context

Previous versions of the M5Stack Cardputer driver did not support full-duplex audio operation, which limited the functionality of the device. This update enables users to record and play back audio simultaneously, enhancing the capabilities of the Cardputer ADV.

How has this been tested?

Build and run the updated driver on an M5Stack Cardputer ADV. Test the recording and playback functionality using the provided example code, ensuring that audio is captured and played back correctly without distortion or static.

Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Hardware (schematic, board, system design) change
  • Software change

Checklist:

  • My change requires a change to the documentation.
  • I have added / updated the documentation related to this change via either README or WIKI

Software

  • I have added tests to cover my changes.
  • I have updated the .github/workflows/build.yml file to add my new test to the automated cloud build github action.
  • All new and existing tests passed.
  • My code follows the code style of this project.

Copilot AI review requested due to automatic review settings July 19, 2026 14:55
@github-actions

github-actions Bot commented Jul 19, 2026

Copy link
Copy Markdown

✅Static analysis result - no issues found! ✅

Comment thread components/m5stack-cardputer/src/microphone.cpp Fixed

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 full-duplex audio support for the M5Stack Cardputer ADV variant by sharing a single I2S bus between speaker (DAC) and microphone (ADC) via the ES8311 codec, and updates documentation + the example app to demonstrate simultaneous record/playback.

Changes:

  • Implement shared ADV full-duplex I2S channel allocation and stereo-slot RX capture with in-task mono compaction.
  • Refactor ES8311 init so shared/common registers are written once and both DAC/ADC paths can coexist.
  • Update public docs and the example (record/playback controls + optional PSRAM buffer preference) to match the new behavior.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
components/m5stack-cardputer/src/microphone.cpp Uses shared ADV I2S RX channel for full-duplex; compacts stereo capture to mono for ADC slot.
components/m5stack-cardputer/src/m5stack-cardputer.cpp Adds common ES8311 init path and adjusts codec init sequences for DAC/ADC coexistence.
components/m5stack-cardputer/src/audio.cpp Introduces ADV shared full-duplex I2S setup; updates buffering and play_audio API to return queued bytes.
components/m5stack-cardputer/README.md Updates component note to reflect full-duplex support on ADV and shared sample-rate behavior.
components/m5stack-cardputer/include/m5stack-cardputer.hpp Documents ADV full-duplex constraints; updates play_audio return type and buffer sizing logic.
components/m5stack-cardputer/example/sdkconfig.defaults Enables SPIRAM support (ignore-not-found) so example can prefer PSRAM when present.
components/m5stack-cardputer/example/README.md Documents new ADV record/playback controls and limitations on original Cardputer.
components/m5stack-cardputer/example/main/m5stack_cardputer_example.cpp Adds mic recording + playback streaming logic and UI controls for ADV.
components/m5stack-cardputer/example/main/gui.hpp Updates on-device help text for new recording/playback controls.

Comment thread components/m5stack-cardputer/src/m5stack-cardputer.cpp Outdated
Comment thread components/m5stack-cardputer/src/audio.cpp
finger563 and others added 2 commits July 19, 2026 11:06
- compute the microphone RX buffer size in size_t to avoid int overflow
  before conversion (CodeQL)
- replace std::all_of over the ES8311 register tables with plain loops to
  avoid relying on transitive <algorithm> includes
- handle xStreamBufferCreate() allocation failure in initialize_sound(),
  tearing down the just-created I2S channel(s) instead of crashing in
  xStreamBufferReset()

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… satisfy cppcheck

cppcheck's useStlAlgorithm check flags the raw loops the previous review
asked for; use std::all_of again but with explicit <algorithm> / <iterator>
includes so the build does not rely on transitive includes either.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@finger563
finger563 merged commit 9d33426 into main Jul 19, 2026
130 checks passed
@finger563
finger563 deleted the feat/cardputer-full-duplex-audio branch July 19, 2026 19:27
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.

3 participants