From 7f539dfabacb94523d97cb5a7a5f64eb9cc3ff6c Mon Sep 17 00:00:00 2001 From: ainyan03 <205502311+ainyan03@users.noreply.github.com> Date: Fri, 28 Aug 2026 07:39:07 +0000 Subject: [PATCH] Follow the IOExpander_Base pull API of M5Unified 0.2.21 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. --- library.json | 2 +- library.properties | 2 +- src/M5StamPLC.cpp | 6 +++--- src/modules/M5StamPLC_AC.cpp | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/library.json b/library.json index 8c51e55..5419d6f 100644 --- a/library.json +++ b/library.json @@ -10,7 +10,7 @@ "url": "https://github.com/M5Stack/M5StamPLC.git" }, "dependencies": { - "M5Unified": "*", + "M5Unified": ">=0.2.21", "M5GFX": "*" }, "version": "1.2.0", diff --git a/library.properties b/library.properties index 87c2f0f..f0754ff 100644 --- a/library.properties +++ b/library.properties @@ -8,4 +8,4 @@ category=Device Control url=https://github.com/m5stack/M5StamPLC.git architectures=esp32 includes=src,src/utils -depends=M5Unified \ No newline at end of file +depends=M5Unified (>=0.2.21) \ No newline at end of file diff --git a/src/M5StamPLC.cpp b/src/M5StamPLC.cpp index b8a76c7..ef937e5 100644 --- a/src/M5StamPLC.cpp +++ b/src/M5StamPLC.cpp @@ -61,15 +61,15 @@ void M5_STAMPLC::io_expander_a_init() // Status light init ioe.setDirection(4, true); - ioe.setPullMode(4, false); + ioe.setPullMode(4, m5::IOExpander_Base::pull_down); ioe.setHighImpedance(4, true); ioe.setDirection(5, true); - ioe.setPullMode(5, false); + ioe.setPullMode(5, m5::IOExpander_Base::pull_down); ioe.setHighImpedance(5, true); ioe.setDirection(6, true); - ioe.setPullMode(6, false); + ioe.setPullMode(6, m5::IOExpander_Base::pull_down); ioe.setHighImpedance(6, true); ioe.resetIrq(); diff --git a/src/modules/M5StamPLC_AC.cpp b/src/modules/M5StamPLC_AC.cpp index 2d70426..af20e81 100644 --- a/src/modules/M5StamPLC_AC.cpp +++ b/src/modules/M5StamPLC_AC.cpp @@ -32,13 +32,13 @@ bool M5StamPLC_AC::begin() // AC relay _ioe->setDirection(_pin_relay, true); - _ioe->setPullMode(_pin_relay, false); + _ioe->setPullMode(_pin_relay, m5::IOExpander_Base::pull_down); _ioe->setHighImpedance(_pin_relay, false); // Status light auto setup_status_light_pin = [](m5::PI4IOE5V6408_Class* ioe, uint8_t pin) { ioe->setDirection(pin, true); - ioe->setPullMode(pin, true); + ioe->setPullMode(pin, m5::IOExpander_Base::pull_up); ioe->setHighImpedance(pin, false); ioe->digitalWrite(pin, true); };