Port M5StickC Plus to M5Unified library stack with corrected Plus2 inheritance#237
Conversation
ulno
left a comment
There was a problem hiding this comment.
@copilot there seems to be a small hickup in the inheritence induced by the base links. Maybe it would be easier to port bothj m5stivkc plus and plus2 to the unified library directly or at least fix the direction of links here.
| @@ -0,0 +1,24 @@ | |||
| #ifndef _PLATFORM_EXTRAS_H_ | |||
There was a problem hiding this comment.
Creating this file in m5stickc_plus and relinking the base from m5tickc_plus2 here will make this file show up in teh platformio-build directory for the m5stickc_plus2. This will break its built. So if we implement it like this m5stickc_plus2 would need to be the base for m5stickc_plus
There was a problem hiding this comment.
Fixed in commit Fix inheritance chain: Plus2 as base for Plus. The chain is now reversed as suggested:
m5stickc_plus2/base→../m5stickc(restored to original)m5stickc_plus/base→../m5stickc_plus2(new)
Full chain: m5stickc_plus → m5stickc_plus2 → m5stickc → esp32
All device source files (dev_display, dev_imu, dev_mic, dev_sleep_mgr) now live in m5stickc_plus2/src/ where they belong. m5stickc_plus/src/ contains only the board-specific overrides: pins.h and platform_extras.h (the M5Unified compatibility layer that maps StickCP2 → M5). Plus2's platform_extras.h will never see Plus's M5Unified header.
The inheritance direction is fixed. The new chain is |
Feature Request
Description
Modernizes M5StickC Plus board support to use the
M5Unifiedall-in-one library (same API surface as Plus2'sStickCP2.*), restructures the inheritance chain so Plus inherits from Plus2, and places all shared device implementations in the Plus2 layer.Motivation
M5StickC Plus was stuck on the legacy
M5StickCPlus@^0.1.0library with no microphone support, while Plus2 had a full modern device stack (display,IMU,mic,sleep_mgr) usingStickCP2.*. The two boards share the same ESP32-PICO-D4 SoC, MPU6886 IMU, and PDM mic — there was no reason for duplicate implementations.Changes Made
Inheritance chain
m5stickc_plus/basesymlink changed:../m5stickc→../m5stickc_plus2m5stickc_plus2/basesymlink remains:../m5stickc(unchanged from original)m5stickc_plus → m5stickc_plus2 → m5stickc → esp32M5StickC Plus2 — device source files (canonical location)
dev_mic_m5stickc.{h,cpp}— PDM microphone, 16 kHz mono PCM, 1024-sample MQTT binary payloadsdev_display_m5stickc.{h,cpp},dev_imu_m5stickc.{h,cpp},dev_sleep_mgr.{h,cpp}— full device stack using nativeStickCP2.*APIM5StickC Plus — board-specific overrides only
platform_extras.h: includesM5Unified.h, defines#define StickCP2 M5so all inherited device sources useStickCP2.*uniformly on both boardspins.h: Plus-specific pin assignmentsHow the compatibility layer works
Library & config
esp/platformio.ini[env:m5stickc_plus]:m5stack/M5StickCPlus@^0.1.0→m5stack/M5Unified@^2.1.1m5stickc/src/platform_includes.h:ENV_M5STICKC_PLUSbranch updated to includeM5Unified.hDocumentation
doc/node_help/m5stickc_mic.rst: new device reference (MQTT topic, recording params, Python/shell examples)doc/projects_help/m5stickc.rst: new "M5StickC Plus" section with board name, device table,setup.cppexample, and hardware spec tableTesting
Verified via code review and static analysis (CodeQL — 0 alerts). Hardware build verification against physical M5StickC Plus / Plus2 boards is recommended before merge.
Additional Notes
M5UnifiedprovidesM5.Lcdas an alias forM5.Display, so the handful ofM5.Lcd.*calls remaining in the display header continue to compile correctly on both boards without modification.The inheritance direction (Plus2 as base for Plus) ensures that Plus2's build directory never includes Plus's
platform_extras.h(which depends onM5Unified), preventing a build break for Plus2 which uses theM5StickCPlus2library.Original prompt
Port the M5StickC Plus board support in
iotempire/iotempowerto the newer unified M5StickC Plus2-style library stack, while preserving IoTempower’s inheritance-based node-type architecture and documentation conventions.Repository:
iotempire/iotempowerBase branch:
masterContext and constraints
basesymlinks. The user wantsm5stickc_plus2to inherit fromm5stickc_plus, so move shared M5StickC Plus2-specific implementation down intolib/node_types/m5stickc_plus/and makelib/node_types/m5stickc_plus2/basepoint tom5stickc_plus.doc/architecture.rst: declarative device definitions, generated dependencies fromdevices.ini, and board-specific overrides in node type directories.M5StickCPlus2.h,StickCP2.*). The request is to modernize M5StickC Plus support to use the corresponding modern all-in-one library approach and support both Plus and Plus2 architectures cleanly.Relevant current files / observations
lib/node_types/m5stickc_plus2/src/dev_mic_m5stickc.cppand.hcontain microphone support that should be ported tom5stickc_plus.lib/node_types/m5stickc_plus2/src/dev_display_m5stickc.cpp/.h,dev_imu_m5stickc.cpp/.h,dev_sleep_mgr.cpp/.h, andplatform_extras.hare Plus2-specific implementations usingStickCP2and the new-style all-in-one library.lib/node_types/m5stickc_plus/src/currently appears minimal (e.g. onlypins.h), so Plus2 currently overrides more behavior than Plus.lib/node_types/m5stickc_plus/src/pins.hdiffers from Plus2 pins: Plus usesONBOARDLED 10,IR 9; Plus2 usesBUTTON_LEFT/BUTTON_POWER,ONBOARDLED 19,IR 19.lib/node_types/m5stickc/src/dev_display_m5stickc.*anddev_imu_m5stickc.*and currently use older APIs likeM5.begin,M5.Lcd,M5.IMU.lib/node_types/esp/devices.inialready definesm5stickc_display,m5stickc_imu,m5stickc_mic, andsleep_mgrdevice entries; board-specificdevices.inilikely controls imported libraries / overrides.doc/node_help/sleep_mgr.rstexists as a model for device docs;doc/projects_help/m5stickc.rstis a model for board/project docs.Requested work
Rework board inheritance:
lib/node_types/m5stickc_plus2/baseso Plus2 inherits fromm5stickc_plusinstead of inheriting directly from the older ancestor.Move/port shared modern M5StickC support into
lib/node_types/m5stickc_plus/:dev_mic_m5stickc.cppanddev_mic_m5stickc.hfrom Plus2.Modernize
m5stickc_plusboard configuration:lib/node_types/m5stickc_plus/srcas needed to use the newer all-in-one device library approach similar to Plus2, but for the M5StickC Plus hardware.lib/node_types/m5stickc_plus/platformio.iniandlib/node_types/m5stickc_plus/devices.inito import/use the modern libraries corresponding to the new implementation.m5stickc_plus2platform/config files as needed so they inherit shared configuration correctly and continue to build.Keep Plus2 working:
Documentation:
doc/node_help/for the microphone device (m5stickc_mic) following repository conventions.doc/projects_help/m5stickc.rstis a likely place or a new Plus-specific doc if that is more consistent.setup.cppDSL style (device names unquoted, MQTT automatic, etc.).Implementation guidance
M5StickC_Display,M5StickC_IMU,M5StickC_Mic,SleepManager) unless a ...This pull request was created from Copilot chat.