#pragma once #include #include #include "log.h" namespace ocularium { inline void scan(TwoWire& wire, bool post_delay = true) { for(auto address = 1; address < 127; address++) { wire.beginTransmission(address); const uint8_t error = wire.endTransmission(); if (error == 0) { LOGGER.print("I2C device found at address 0x"); if (address<16) LOGGER.print("0"); LOGGER.print(address,HEX); LOGGER.println(); } else if (error==4) { LOGGER.print("Unknown error at address 0x"); if (address<16) LOGGER.print("0"); LOGGER.println(address,HEX); } } if (post_delay) { // Let the bus settle before doing anything else. delay(10); } } }