|
6 | 6 | #include "M5ModuleQRCode.h" |
7 | 7 | #include "debug.h" |
8 | 8 |
|
| 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 | + |
9 | 22 | #define CHANNEL_QRCODE_POWER_EN 0 |
10 | 23 | #define CHANNEL_QRCODE_TRIG 4 |
11 | 24 |
|
@@ -64,13 +77,11 @@ bool M5ModuleQRCode::_init_pi4ioe5v6408() |
64 | 77 | _LOG_DEBUG("pi4ioe5v6408 found at 0x%02x\n", _config.pi4ioe5v6408_addr); |
65 | 78 |
|
66 | 79 | _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); |
69 | 81 | _pi4ioe5v6408->setHighImpedance(CHANNEL_QRCODE_POWER_EN, false); |
70 | 82 |
|
71 | 83 | _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); |
74 | 85 | _pi4ioe5v6408->setHighImpedance(CHANNEL_QRCODE_TRIG, false); |
75 | 86 |
|
76 | 87 | return true; |
|
0 commit comments