Migrate to M5Unified for M5StickC PLUS2 compatibility#14
Open
jamesburton wants to merge 1 commit into
Open
Conversation
jamesburton
commented
May 8, 2026
- Update platformio.ini: env name -> m5stack-stickc-plus2, swap M5StickCPlus library for M5Unified, bump CPU to 240MHz, add PSRAM build flags, increase upload speed to 1500000
- Hold GPIO4 HIGH at startup to power on PLUS2 (no AXP192 PMIC)
- Replace all M5.Lcd with M5.Display (LGFX_Sprite / LGFX API)
- Replace TFT_eSprite with LGFX_Sprite across buddy.cpp/h, character.cpp/h, all 18 src/buddies/*.cpp, and main.cpp
- Replace M5.Axp power/speaker/button-C calls with M5.Power / M5.Speaker / M5.BtnC equivalents
- Update RTC types to m5::rtc_time_t / m5::rtc_date_t with lowercase fields
- Update battery telemetry in xfer.h to M5.Power API
- Add src/idf_component.yml (IDF component manifest)
- Update platformio.ini: env name -> m5stack-stickc-plus2, swap M5StickCPlus library for M5Unified, bump CPU to 240MHz, add PSRAM build flags, increase upload speed to 1500000 - Hold GPIO4 HIGH at startup to power on PLUS2 (no AXP192 PMIC) - Replace all M5.Lcd with M5.Display (LGFX_Sprite / LGFX API) - Replace TFT_eSprite with LGFX_Sprite across buddy.cpp/h, character.cpp/h, all 18 src/buddies/*.cpp, and main.cpp - Replace M5.Axp power/speaker/button-C calls with M5.Power / M5.Speaker / M5.BtnC equivalents - Update RTC types to m5::rtc_time_t / m5::rtc_date_t with lowercase fields - Update battery telemetry in xfer.h to M5.Power API - Add src/idf_component.yml (IDF component manifest)
There was a problem hiding this comment.
Pull request overview
This PR migrates the firmware from the legacy M5StickCPlus APIs to M5Unified to support the M5StickC PLUS2 hardware, updating display/power/RTC handling and build configuration accordingly.
Changes:
- Switch core dependencies and code from
M5StickCPlus/M5.Lcd/TFT_eSpritetoM5Unified/M5.Display/LGFX_Sprite, including power/speaker/button API updates. - Update RTC usage to
m5::rtc_time_t/m5::rtc_date_t(lowercase fields) and adjust battery telemetry toM5.Power. - Update PlatformIO environment/build flags for PLUS2 (CPU speed, PSRAM flags, upload speed) and add an ESP-IDF component manifest.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| platformio.ini | Renames env and switches to M5Unified, adjusts CPU/upload speed, adds PSRAM build flags. |
| src/main.cpp | Migrates display/power/button/RTC usage to M5Unified; adds GPIO4 hold-high startup behavior. |
| src/xfer.h | Updates status telemetry to use M5.Power and switches include to M5Unified. |
| src/data.h | Updates RTC set calls and types to M5Unified RTC structs/APIs. |
| src/character.h | Changes render target type to LGFX_Sprite* and includes M5Unified. |
| src/character.cpp | Migrates to M5Unified/LGFX types and adjusts render target plumbing. |
| src/buddy.h | Changes render target type to LGFX_Sprite* and includes M5Unified. |
| src/buddy.cpp | Migrates to M5Unified/LGFX types and adjusts render target plumbing. |
| src/buddies/axolotl.cpp | Updates includes and sprite extern to M5Unified/LGFX. |
| src/buddies/blob.cpp | Updates includes and sprite extern to M5Unified/LGFX. |
| src/buddies/cactus.cpp | Updates includes and sprite extern to M5Unified/LGFX. |
| src/buddies/capybara.cpp | Updates includes and sprite extern to M5Unified/LGFX. |
| src/buddies/cat.cpp | Updates includes and sprite extern to M5Unified/LGFX. |
| src/buddies/chonk.cpp | Updates includes and sprite extern to M5Unified/LGFX. |
| src/buddies/dragon.cpp | Updates includes and sprite extern to M5Unified/LGFX. |
| src/buddies/duck.cpp | Updates includes and sprite extern to M5Unified/LGFX. |
| src/buddies/ghost.cpp | Updates includes and sprite extern to M5Unified/LGFX. |
| src/buddies/goose.cpp | Updates includes and sprite extern to M5Unified/LGFX. |
| src/buddies/mushroom.cpp | Updates includes and sprite extern to M5Unified/LGFX. |
| src/buddies/octopus.cpp | Updates includes and sprite extern to M5Unified/LGFX. |
| src/buddies/owl.cpp | Updates includes and sprite extern to M5Unified/LGFX. |
| src/buddies/penguin.cpp | Updates includes and sprite extern to M5Unified/LGFX. |
| src/buddies/rabbit.cpp | Updates includes and sprite extern to M5Unified/LGFX. |
| src/buddies/robot.cpp | Updates includes and sprite extern to M5Unified/LGFX. |
| src/buddies/snail.cpp | Updates includes and sprite extern to M5Unified/LGFX. |
| src/buddies/turtle.cpp | Updates includes and sprite extern to M5Unified/LGFX. |
| src/idf_component.yml | Adds ESP-IDF component dependency manifest. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+464
to
+472
| M5.Display.fillRect(0, 0, 115, 90, p.bg); | ||
| buddyRenderTo((LGFX_Sprite*)&M5.Display, activeState); | ||
| } else { | ||
| // Full-frame GIFs paint every pixel (transparent → pal.bg), so a | ||
| // per-tick clear just adds a visible black flash between wipe and | ||
| // last scanline. The entry fillScreen on paintedOrient change | ||
| // already covers the surround. | ||
| characterSetState(activeState); | ||
| characterRenderTo(&M5.Lcd, 57, 45); | ||
| characterRenderTo((LGFX_Sprite*)&M5.Display, 57, 45); |
Comment on lines
32
to
37
| // Render target indirection: defaults to the sprite, but can retarget to | ||
| // M5.Lcd for landscape clock mode (both inherit TFT_eSPI). Coords stay | ||
| // fixed — species hardcode BUDDY_X_CENTER/BUDDY_Y_OVERLAY in their | ||
| // M5.Display for landscape clock mode (both M5GFX and LGFX_Sprite have compatible interfaces). | ||
| // Coords stay fixed — species hardcode BUDDY_X_CENTER/BUDDY_Y_OVERLAY in their | ||
| // particle calls, so retargeting position would only move the body. | ||
| static TFT_eSPI* _tgt = &spr; | ||
| static LGFX_Sprite* _tgt = &spr; | ||
| // 2× on home screen, 1× in peek (PET/INFO) and landscape clock. Species |
| void buddyInvalidate(); | ||
| class TFT_eSPI; | ||
| void buddyRenderTo(TFT_eSPI* tgt, uint8_t personaState); | ||
| void buddyRenderTo(LGFX_Sprite* tgt, uint8_t personaState); |
Comment on lines
+46
to
+47
| // M5.Display for the landscape clock (both M5GFX and LGFX_Sprite can be rendered to). | ||
| static LGFX_Sprite* _tgt = &spr; |
| void characterSetPeek(bool peek); | ||
| class TFT_eSPI; | ||
| void characterRenderTo(TFT_eSPI* tgt, int cx, int cy); | ||
| void characterRenderTo(LGFX_Sprite* tgt, int cx, int cy); |
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.