Skip to content

Commit 37c62c0

Browse files
committed
Modify the scanning method for PI4 address
1 parent d4173f7 commit 37c62c0

1 file changed

Lines changed: 12 additions & 19 deletions

File tree

src/M5ModuleQRCode.cpp

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,34 +42,27 @@ bool M5ModuleQRCode::_init_pi4ioe5v6408()
4242
}
4343

4444
// Probe device
45-
bool is_found = false;
46-
for (int i = 0; i < 3; i++) {
47-
bool result[128];
48-
_config.i2c->scanID(result);
49-
if (result[_config.pi4ioe5v6408_addr]) {
50-
is_found = true;
51-
_LOG_DEBUG("pi4ioe5v6408 found at 0x%02x\n", _config.pi4ioe5v6408_addr);
52-
break;
53-
}
54-
_LOG_ERROR("pi4ioe5v6408 not found at 0x%02x, retry %d\n", _config.pi4ioe5v6408_addr, i);
55-
delay(500);
56-
}
57-
if (!is_found) {
58-
_LOG_ERROR("pi4ioe5v6408 not found\n");
59-
return false;
60-
}
61-
6245
if (_pi4ioe5v6408 != nullptr) {
6346
delete _pi4ioe5v6408;
6447
_pi4ioe5v6408 = nullptr;
6548
}
6649

67-
_pi4ioe5v6408 = new m5::PI4IOE5V6408_Class(_config.pi4ioe5v6408_addr, 100000, _config.i2c);
50+
_pi4ioe5v6408 = new m5::PI4IOE5V6408_Class(_config.pi4ioe5v6408_addr, 100000, = _config.i2c);
51+
52+
if (_pi4ioe5v6408 == nullptr) {
53+
_LOG_ERROR("pi4ioe5v6408 malloc failed\n");
54+
return false;
55+
}
56+
6857
if (!_pi4ioe5v6408->begin()) {
69-
_LOG_ERROR("init pi4ioe5v6408 failed\n");
58+
_LOG_ERROR("pi4ioe5v6408 not found at 0x%02x\n", _config.pi4ioe5v6408_addr);
59+
delete _pi4ioe5v6408;
60+
_pi4ioe5v6408 = nullptr;
7061
return false;
7162
}
7263

64+
_LOG_DEBUG("pi4ioe5v6408 found at 0x%02x\n", _config.pi4ioe5v6408_addr);
65+
7366
_pi4ioe5v6408->setDirection(CHANNEL_QRCODE_POWER_EN, true);
7467
_pi4ioe5v6408->setPullMode(CHANNEL_QRCODE_POWER_EN, true);
7568
_pi4ioe5v6408->enablePull(CHANNEL_QRCODE_POWER_EN, true);

0 commit comments

Comments
 (0)