Skip to content

Commit faea95b

Browse files
committed
Follow the IOExpander_Base pull API of M5Unified 0.2.21
M5Unified 0.2.21 replaced IOExpander_Base::setPullMode(pin, bool) and enablePull(pin, bool) with setPullMode(pin, gpio_pull_t), so the library no longer compiled against it. Select the pull-up setup form from M5UNIFIED_VERSION_* so the library builds against both 0.2.20 and 0.2.21; the register state (pull-up selected and enabled) is the same in both forms.
1 parent 373a816 commit faea95b

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

src/M5ModuleQRCode.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@
66
#include "M5ModuleQRCode.h"
77
#include "debug.h"
88

9+
// M5Unified 0.2.21 replaced setPullMode(pin, bool) + enablePull(pin, bool) with
10+
// setPullMode(pin, gpio_pull_t); keep the pull-up setup building on both.
11+
#if defined(M5UNIFIED_VERSION_MAJOR) && ((M5UNIFIED_VERSION_MAJOR > 0) || (M5UNIFIED_VERSION_MINOR > 2) || \
12+
(M5UNIFIED_VERSION_MINOR == 2 && M5UNIFIED_VERSION_PATCH >= 21))
13+
#define M5MODULE_QRCODE_SET_PULL_UP(ioe, pin) (ioe)->setPullMode((pin), m5::IOExpander_Base::pull_up)
14+
#else
15+
#define M5MODULE_QRCODE_SET_PULL_UP(ioe, pin) \
16+
do { \
17+
(ioe)->setPullMode((pin), true); \
18+
(ioe)->enablePull((pin), true); \
19+
} while (0)
20+
#endif
21+
922
#define CHANNEL_QRCODE_POWER_EN 0
1023
#define CHANNEL_QRCODE_TRIG 4
1124

@@ -64,13 +77,11 @@ bool M5ModuleQRCode::_init_pi4ioe5v6408()
6477
_LOG_DEBUG("pi4ioe5v6408 found at 0x%02x\n", _config.pi4ioe5v6408_addr);
6578

6679
_pi4ioe5v6408->setDirection(CHANNEL_QRCODE_POWER_EN, true);
67-
_pi4ioe5v6408->setPullMode(CHANNEL_QRCODE_POWER_EN, true);
68-
_pi4ioe5v6408->enablePull(CHANNEL_QRCODE_POWER_EN, true);
80+
M5MODULE_QRCODE_SET_PULL_UP(_pi4ioe5v6408, CHANNEL_QRCODE_POWER_EN);
6981
_pi4ioe5v6408->setHighImpedance(CHANNEL_QRCODE_POWER_EN, false);
7082

7183
_pi4ioe5v6408->setDirection(CHANNEL_QRCODE_TRIG, true);
72-
_pi4ioe5v6408->setPullMode(CHANNEL_QRCODE_TRIG, true);
73-
_pi4ioe5v6408->enablePull(CHANNEL_QRCODE_TRIG, true);
84+
M5MODULE_QRCODE_SET_PULL_UP(_pi4ioe5v6408, CHANNEL_QRCODE_TRIG);
7485
_pi4ioe5v6408->setHighImpedance(CHANNEL_QRCODE_TRIG, false);
7586

7687
return true;

0 commit comments

Comments
 (0)