Skip to content

Fix PI4IOE5V6408 initialization and checked input reads - #402

Merged
lovyan03 merged 1 commit into
m5stack:developfrom
ainyan03:pi4ioe_fix
Oct 14, 2026
Merged

lovyan03 merged 1 commit into
m5stack:developfrom
ainyan03:pi4ioe_fix

Conversation

@ainyan03

@ainyan03 ainyan03 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

What changes

  • begin() never set the initialized flag, so isEnabled() always returned false for a PI4IOE5V6408. It now records whether the device ID register (0x01) could be read and is non-zero. The check runs on every call, so a changed port or address is probed again.
  • getInputLevel() was not overridden, so it always reported a failure. It now reads the input status register (0x0F) with error checking, the same way as M5IOE1_Class. On an invalid pin, a null pointer or an I2C failure it returns false and leaves *level untouched.

Other methods are unchanged.

Checked

  • Hardware, Tab5 (two PI4IOE5V6408 at 0x43 / 0x44), for each expander: isEnabled(), begin(), and getInputLevel() compared with digitalRead() on all 8 pins, plus an invalid pin and a null pointer.
Before After
isEnabled() after M5.begin() false true
getInputLevel(), pins 0-7 false (failure) on every pin true, level equals digitalRead()
invalid pin / null false, output untouched false, output untouched
  • Builds with Arduino 2.0.x (ESP-IDF 4.4) / 3.x and ESP-IDF 5.1 to 6.1 across ESP32, S3, C3, C5, C6, C61, H2 and P4.

begin() never set the initialized flag, so isEnabled() always returned false.
It now records whether the device ID register could be read (and is non-zero)
on every call, so a changed port or address is checked again.

getInputLevel() was not overridden and always reported failure. It now reads
the input status register (0x0F) with error checking and leaves the output
untouched on failure, matching M5IOE1.
@lovyan03
lovyan03 merged commit 664220b into m5stack:develop Oct 14, 2026
30 checks passed
@ainyan03
ainyan03 deleted the pi4ioe_fix branch October 14, 2026 08:05
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.

2 participants