Follow the IOExpander_Base API of M5Unified 0.2.21 - #8
Merged
Conversation
M5Unified 0.2.21 changed the IOExpander_Base virtuals: the mutating methods now return the write status as bool, setPullMode() takes gpio_pull_t and enablePull() was removed. PY32IOExpander_Class still declared the old signatures with override, so the library no longer compiled (m5stack/M5Unified#346). Move the register access into version independent private helpers that return the I2C status and validate the pin, and select the override set from M5UNIFIED_VERSION_* so the library builds against both 0.2.20 and 0.2.21. The pull mode call sites use the gpio_pull_t enum, which is provided locally for the old API.
ainyan03
force-pushed
the
ioexpander_m5unified_0_2_21
branch
from
August 28, 2026 04:39
96bc0bc to
342f0a1
Compare
Contributor
Author
|
CI status of this PR:
The re-run needs a maintainer approval since the PR comes from a fork. |
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.
Problem
M5Unified 0.2.21 changed the
IOExpander_Baseinterface thatPY32IOExpander_Classderives from: the mutating methods now return the write status asbool,setPullMode()takes agpio_pull_t(pull_none/pull_up/pull_down) instead of a bool, andenablePull()was removed from the base class. StackChan-BSP 1.1.0 still declares the old signatures withoverride, so it no longer compiles against 0.2.21 (m5stack/M5Unified#346):Change
overridedeclarations fromM5UNIFIED_VERSION_*, so the library builds against both M5Unified 0.2.20 (old interface) and 0.2.21 and later (new interface).PY32IOExpander_Classsource compatible on both versions:setPullMode(pin, bool)andenablePull(pin, bool)remain callable (as plain members on 0.2.21+), and thegpio_pull_tenum is provided locally on the old interface sosetPullMode(pin, PY32IOExpander_Class::pull_up)works everywhere. The internal call sites inM5StackChan.cppuse the enum.setHighImpedance(true)still switches the pin to input with both pulls disabled,setPullMode(pin, true)still means pull-up.Verification
Compiled a sketch that calls
M5StackChan.begin()plus the old-style and enum-style pull/drive calls, with PlatformIO (pioarduino 55.03.34,m5stack-cores3, Arduino) against:Fixes the build error reported in m5stack/M5Unified#346.