#pragma once #include #include 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) { Serial.print("I2C device found at address 0x"); if (address<16) Serial.print("0"); Serial.print(address,HEX); Serial.println(); } else if (error==4) { Serial.print("Unknown error at address 0x"); if (address<16) Serial.print("0"); Serial.println(address,HEX); } } if (post_delay) { // Let the bus settle before doing anything else. delay(10); } } }