@@ -98,9 +98,14 @@ void I2CManagerClass::begin(void) {
9898
9999 // Now initialise I2C
100100 _initialise ();
101+ scanForDevices (&USB_SERIAL);
102+ }
103+ }
101104
105+ void I2CManagerClass::scanForDevices (Print* stream) {
106+ StringFormatter::send (stream, F (" <* Scanning I2C bus for devices...\n " ));
102107 #if defined(I2C_USE_WIRE)
103- DIAG ( F (" I2CManager: Using Wire library" ));
108+ StringFormatter::send (stream, F (" I2CManager: Using Wire library\n " ));
104109 #endif
105110
106111 // Probe and list devices. Use standard mode
@@ -123,7 +128,7 @@ void I2CManagerClass::begin(void) {
123128 for (uint8_t addr=0x08 ; addr<0x78 ; addr++) {
124129 if (exists (addr)) {
125130 found = true ;
126- DIAG ( F (" I2C Device found at 0x%x, %S?" ), addr, guessI2CDeviceType (addr));
131+ StringFormatter::send (stream, F (" Device found at 0x%x, %S?\n " ), addr, guessI2CDeviceType (addr));
127132 }
128133 }
129134
@@ -148,7 +153,7 @@ void I2CManagerClass::begin(void) {
148153 // Device responds when subbus selected but not when
149154 // subbus disabled - ergo it must be on subbus!
150155 found = true ;
151- DIAG ( F (" I2C Device found at {I2CMux_%d,SubBus_%d,0x%x}, %S?" ),
156+ StringFormatter::send (stream, F (" Device found at {I2CMux_%d,SubBus_%d,0x%x}, %S?\n " ),
152157 muxNo, subBus, addr, guessI2CDeviceType (addr));
153158 }
154159 // Re-select subbus
@@ -165,11 +170,10 @@ void I2CManagerClass::begin(void) {
165170 }
166171 }
167172#endif
168- if (! found) DIAG ( F (" No I2C Devices found" ));
173+ StringFormatter::send (stream, found? F ( " *> \n " ): F (" No I2C Devices found\n *> \n " ));
169174 _setClock (_clockSpeed);
170175 setTimeout (originalTimeout); // set timeout back to original
171176 }
172- }
173177
174178// Set clock speed to the lowest requested one. If none requested,
175179// the Wire default is 100kHz.
0 commit comments