feat(m5stack-cardputer): Add BSP component for M5Stack Cardputer#666
Open
finger563 wants to merge 11 commits into
Open
feat(m5stack-cardputer): Add BSP component for M5Stack Cardputer#666finger563 wants to merge 11 commits into
finger563 wants to merge 11 commits into
Conversation
|
✅Static analysis result - no issues found! ✅ |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new ESPP board support package component for the M5Stack Cardputer (K132) and Cardputer ADV (ESP32-S3), including runtime variant detection, integrated peripherals (display/keyboard/audio/mic/uSD/LED/battery/button), an LVGL example app, and corresponding docs + CI registry integration.
Changes:
- Introduces
espp::M5StackCardputerBSP implementation (display, keyboard for both variants, audio output, microphone input, uSD, RGB LED, battery voltage, button, internal I2C accessor). - Adds a keyboard-driven LVGL example (text editor + key-click beeps + LED cycling + battery status).
- Registers the new component in docs (Sphinx + Doxygen) and CI workflows (build matrix + component upload list).
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| doc/en/dev_boards/m5stack/m5stack_cardputer.rst | New dev-board documentation page for Cardputer + ADV. |
| doc/en/dev_boards/m5stack/m5stack_cardputer_example.md | Includes the example README into the docs site. |
| doc/en/dev_boards/m5stack/index.rst | Adds Cardputer page to the M5Stack boards index. |
| doc/Doxyfile | Registers the component header + example for Doxygen. |
| components/m5stack-cardputer/CMakeLists.txt | New component build registration and dependencies. |
| components/m5stack-cardputer/Kconfig | Adds configurable task stacks/priorities/affinity for BSP tasks. |
| components/m5stack-cardputer/README.md | Component overview and feature documentation. |
| components/m5stack-cardputer/idf_component.yml | Component Manager manifest metadata and dependencies. |
| components/m5stack-cardputer/include/m5stack-cardputer.hpp | Public BSP API (singleton, peripherals, variant detection, keyboard mapping, etc.). |
| components/m5stack-cardputer/src/m5stack-cardputer.cpp | Core BSP implementation (button/LED, ES8311 init, battery readout). |
| components/m5stack-cardputer/src/display.cpp | LCD + LVGL display initialization and helpers. |
| components/m5stack-cardputer/src/keyboard.cpp | Runtime variant probe, keyboard init, matrix scan + TCA8418 FIFO handling. |
| components/m5stack-cardputer/src/audio.cpp | I2S speaker path + ADV codec bring-up and playback task. |
| components/m5stack-cardputer/src/microphone.cpp | PDM mic (original) and I2S codec ADC mic (ADV) recording task. |
| components/m5stack-cardputer/src/sdcard.cpp | Dedicated SPI uSD card mount helper. |
| components/m5stack-cardputer/example/CMakeLists.txt | Example project CMake with component wiring. |
| components/m5stack-cardputer/example/sdkconfig.defaults | Example defaults (LVGL, USB-Serial-JTAG console, etc.). |
| components/m5stack-cardputer/example/README.md | Example usage guide and controls. |
| components/m5stack-cardputer/example/main/CMakeLists.txt | Example “main” component registration. |
| components/m5stack-cardputer/example/main/m5stack_cardputer_example.cpp | Example app main: initializes peripherals + GUI + callbacks. |
| components/m5stack-cardputer/example/main/gui.hpp | Example GUI class interface and task pattern. |
| components/m5stack-cardputer/example/main/gui.cpp | Example LVGL UI implementation and thread-safe helpers. |
| .github/workflows/build.yml | Adds Cardputer example to CI build matrix (esp32s3). |
| .github/workflows/upload_components.yml | Adds m5stack-cardputer to component upload workflow. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…call_once variant() and internal_i2c() lazily detect the board variant; the previous atomic-flag double-check let two concurrent first callers both probe the I2C bus. Funnel both through a shared std::once_flag so the detection runs exactly once and concurrent callers block until it completes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…pport - battery_soc(): estimate the battery state of charge (0-100%) from the measured voltage via a piecewise-linear 1S lithium-ion discharge curve (documented as an approximation since the voltage sags under load) - initialize_imu() / imu(): bring up the Cardputer ADV's BMI270 on the internal I2C bus using the espp bmi270 driver (with optional orientation filter and configurable ImuConfig); fails with a clear error on the original Cardputer, which has no IMU - Example: status bar now shows voltage and state of charge; on the ADV a top-right overlay shows live accelerometer / gyroscope readings updated at 10 Hz Clean-built with ESP-IDF for esp32s3. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…unked config upload) The BMI270 init failed on hardware: the driver uploads its 8kB config blob, which by default is written in a single I2C transaction that exceeds the internal I2C bus timeout. Upload it in 128-byte bursts instead, and probe both possible I2C addresses (0x68/0x69) to find the device rather than assuming the SDO strap. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… example - fn+1 (F1) toggles a centered popup listing the controls; fn+2 (F2) toggles the IMU overlay visibility (IMU updates pause while hidden) - The controls are defined once (Gui::HELP_TEXT), shown in the popup, and printed to the log at startup - Document the new controls in the example README Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add espp::M5StackCardputer, a board support package for the M5Stack
Cardputer (K132), an ESP32-S3 StampS3-based card computer with a 56-key
QWERTY keyboard. All GPIO assignments are verified against the official
M5Cardputer / M5Unified / M5GFX sources and the M5Stack documentation.
Display: 1.14" 240x135 IPS (ST7789V2) @ 40MHz SPI with LVGL via
espp::Display, PWM backlight, panel offsets (40, 52) for the centered
window in the controller RAM
Microphone: SPM1423 PDM with a recording task delivering 16-bit mono
samples to a callback; mutually exclusive with the speaker (shared
GPIO 43), enforced at initialization
uSD card: SPI mode on a dedicated bus, mounted at /sdcard
RGB LED (WS2812 via espp::Neopixel), battery voltage (2:1 divider into
ADC1), G0/BOOT button via espp::Interrupt, IR TX / Grove pin accessors
Example: keyboard-driven text editor using the standard per-example
Gui class pattern, with key-click beeps, LED color cycling on G0, and
battery voltage in the status bar
Registered in build.yml (esp32s3), upload_components.yml, Doxyfile,
and the m5stack dev-boards docs
Detect the variant at runtime by probing for the TCA8418; expose
variant() / variant_name() and an internal_i2c() accessor (the ADV bus
also hosts a BMI270 IMU at 0x68, usable with the espp bmi270 component)
ADV keyboard path: configure the TCA8418 as a 7x8 keypad and drain its
key-event FIFO from the same scanner task, mapping controller key
numbers onto the same logical 4x14 grid so both variants deliver
identical KeyEvents (mapping verified against M5Stack's remap chart and
an independent ESP-IDF implementation)
ADV audio: minimal ES8311 DAC bring-up (BCLK-derived clock) after I2S
enable in initialize_sound(); ADV microphone: standard I2S from the
codec ADC (ASDOUT on GPIO 46) with ES8311 ADC bring-up, replacing the
PDM path used on the original
Motivation and Context
The M5Stack Cardputer is a unique ESP32-S3-based board with a built-in keyboard, display, and audio capabilities. This BSP component provides a standardized interface for developers to utilize the board's features in their applications, enabling easier development of keyboard-driven interfaces, audio playback, and microphone input.
The Cardputer ADV replaces the original's 74HC138 GPIO-matrix keyboard
with a TCA8418 I2C keyboard controller (0x34 on an internal I2C bus at
GPIO 8/9, the pins the original used as demux address lines), and routes
the same I2S speaker/microphone pins through an ES8311 codec instead of
the NS4168 amp / SPM1423 PDM mic.
How has this been tested?
m5stack-cardputer/exampleon the ADV variant, verify keyboard input, audio playback, microphone recording, and display output.Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):
Types of changes
Checklist:
Software
.github/workflows/build.ymlfile to add my new test to the automated cloud build github action.