Skip to content

Follow the IOExpander_Base pull API of M5Unified 0.2.21 - #25

Open
ainyan03 wants to merge 1 commit into
m5stack:mainfrom
ainyan03:ioexpander_m5unified_0_2_21
Open

ainyan03 wants to merge 1 commit into
m5stack:mainfrom
ainyan03:ioexpander_m5unified_0_2_21

Conversation

@ainyan03

@ainyan03 ainyan03 commented Aug 28, 2026 •

Copy link
Copy Markdown

Problem

M5Unified 0.2.21 changed the IOExpander_Base pull API: setPullMode(pin, bool) and enablePull(pin, bool) were replaced by setPullMode(pin, gpio_pull_t) (pull_none / pull_up / pull_down). M5StamPLC 1.2.0 calls the old form in five places, so it no longer compiles against the current M5Unified release:

src/M5StamPLC.cpp:64:24: error: cannot convert 'bool' to 'm5::IOExpander_Base::gpio_pull_t'
src/modules/M5StamPLC_AC.cpp:35:35: error: cannot convert 'bool' to 'm5::IOExpander_Base::gpio_pull_t'
...

(Same class of problem as m5stack/StackChan-BSP#12 for StackChan-BSP.)

Change

  • Call the new API directly: setPullMode(pin, false) → pull_down, setPullMode(pin, true) → pull_up.
  • Declare the requirement in the library metadata: depends=M5Unified (>=0.2.21) in library.properties and "M5Unified": ">=0.2.21" in library.json, so the Library Manager and PlatformIO install a matching M5Unified instead of failing at compile time.

The register state is unchanged: the old bool form only wrote the PI4IOE5V6408 pull-select register (0x0D) and relied on the pull-enable register (0x0B) being at its reset default (all enabled) during init; pull_up / pull_down write the same select bit and set the enable bit that was already set. M5.begin() does not touch the pull state of pins 4–6 before io_expander_a_init(), and the AC module's expander is freshly constructed.

Verification

Compiled a sketch calling M5StamPLC.begin() with PlatformIO (pioarduino 55.03.34, m5stack-stamps3, Arduino) against M5Unified 0.2.21 (develop) + M5GFX 0.2.28: fails on the unmodified library with the errors above, builds with this change. clang-format --dry-run reports no differences for the touched files.

Note on the Build Examples workflow

It cannot validate this change at the moment: with the current m5stack:esp32 "latest" core (esp32s3-libs 3.3.9) every example already fails on main in the SDK's esp-modbus header (mb_port_types.h:118: ISO C++ forbids declaration of '_Atomic'), reached through M5StamPLC.h → mbcontroller.h, before any library code is compiled (the last green run used esp32s3-libs 3.3.7). I reproduced that on my fork for both main and this branch (identical failure). That is a core/SDK problem independent of this PR; pinning the core version in the workflow would be a separate change. clang-format Check passes on this branch.

M5Unified 0.2.21 replaced IOExpander_Base::setPullMode(pin, bool) with
setPullMode(pin, gpio_pull_t), so the library no longer compiled against it
("cannot convert bool to m5::IOExpander_Base::gpio_pull_t" in M5StamPLC.cpp
and modules/M5StamPLC_AC.cpp).

Call the new form (false -> pull_down, true -> pull_up) and require
M5Unified >= 0.2.21 in library.properties / library.json so the dependency
is resolved by the Library Manager and PlatformIO. The old bool form only
selected the pull direction and left the pull enable bit at its reset
default (enabled) during init, so pull_up / pull_down keep the same register
state.
@ainyan03
ainyan03 force-pushed the ioexpander_m5unified_0_2_21 branch from 1995388 to 7f539df Compare August 28, 2026 07:39
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.

1 participant