Wgranie zmian do repozytorium

This commit is contained in:
2026-05-10 16:46:04 +02:00
commit f171113450
1607 changed files with 254616 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
#include <Tool.h>
static const char *TOOL = "tool";
bool isI2CDevPresent(uint8_t address) {
Wire.beginTransmission(address);
uint8_t error = Wire.endTransmission();
if (error == 0) {
ESP_LOGI(TOOL, "I2C response from 0x%02X", address);
return true;
} else {
if (error == 4) {
ESP_LOGW(TOOL, "I2C unknown error at 0x%02X", address);
} else {
ESP_LOGI(TOOL, "No I2C device at 0x%02X", address);
}
return false;
}
}
void scanI2C() {
byte error, address;
int nDevices = 0;
ESP_LOGI(TOOL, "I2C start scan");
for (address = 1; address < 127; address++) {
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0) {
char buf[32];
snprintf(buf, sizeof(buf), "I2C device: 0x%02X", address);
ESP_LOGI(TOOL, "%s", buf);
nDevices++;
Watchdog::feed();
}
else if (error == 4) {
ESP_LOGW(TOOL, "I2C error at address: 0x%02X", address);
}
}
if (nDevices == 0) {
ESP_LOGE(TOOL, "I2C no devices found");
} else {
ESP_LOGI(TOOL, "I2C scan finished. Found %d device(s)", nDevices);
}
Watchdog::feed();
}