allow not-scanning (MCP9600 hates it)

This commit is contained in:
ladyada 2019-10-07 23:13:49 -04:00
parent 5a94ba22da
commit a403ba0dab
3 changed files with 24 additions and 6 deletions

View File

@ -16,13 +16,18 @@ Adafruit_I2CDevice::Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire) {
/*!
* @brief Initializes and does basic address detection
* @param addr_detect Whether we should attempt to detect the I2C address with a scan.
* 99% of sensors/devices don't mind but once in a while, they spaz on a scan!
* @return True if I2C initialized and a device with the addr found
*/
bool Adafruit_I2CDevice::begin(void) {
bool Adafruit_I2CDevice::begin(bool addr_detect) {
_wire->begin();
_begun = true;
if (addr_detect) {
return detected();
}
return true;
}
@ -105,8 +110,21 @@ bool Adafruit_I2CDevice::write(uint8_t *buffer, size_t len, bool stop, uint8_t *
DEBUG_SERIAL.println();
#endif
#ifdef DEBUG_SERIAL
DEBUG_SERIAL.print("Stop: "); DEBUG_SERIAL.println(stop);
#endif
return (_wire -> endTransmission(stop) == 0);
if (_wire->endTransmission(stop) == 0) {
#ifdef DEBUG_SERIAL
DEBUG_SERIAL.println("Sent!");
#endif
return true;
} else {
#ifdef DEBUG_SERIAL
DEBUG_SERIAL.println("Failed to send!");
#endif
return false;
}
}

View File

@ -8,7 +8,7 @@ class Adafruit_I2CDevice {
public:
Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire=&Wire);
uint8_t address(void);
bool begin(void);
bool begin(bool addr_detect=true);
bool detected(void);
bool read(uint8_t *buffer, size_t len, bool stop=true);

View File

@ -1,5 +1,5 @@
name=Adafruit BusIO
version=1.0.4
version=1.0.5
author=Adafruit
maintainer=Adafruit <info@adafruit.com>
sentence=This is a library for abstracting away UART, I2C and SPI interfacing