Added dontInitialize flag

This commit is contained in:
Francesco Stefanni 2021-08-02 15:29:31 +02:00
parent 8d48fd2708
commit a0958735cf
2 changed files with 4 additions and 3 deletions

View file

@ -50,17 +50,18 @@ Adafruit_SHTC3::~Adafruit_SHTC3(void) {
* Initialises the I2C bus, and assigns the I2C address to us. * Initialises the I2C bus, and assigns the I2C address to us.
* *
* @param theWire The I2C bus to use, defaults to &Wire * @param theWire The I2C bus to use, defaults to &Wire
* @param dontInitialize Whether initialize the given TwoWire object.
* *
* @return True if initialisation was successful, otherwise False. * @return True if initialisation was successful, otherwise False.
*/ */
bool Adafruit_SHTC3::begin(TwoWire *theWire) { bool Adafruit_SHTC3::begin(TwoWire *theWire, const bool dontInitialize) {
if (i2c_dev) { if (i2c_dev) {
delete i2c_dev; // remove old interface delete i2c_dev; // remove old interface
} }
i2c_dev = new Adafruit_I2CDevice(SHTC3_DEFAULT_ADDR, theWire); i2c_dev = new Adafruit_I2CDevice(SHTC3_DEFAULT_ADDR, theWire);
if (!i2c_dev->begin()) { if (!i2c_dev->begin(true, dontInitialize)) {
return false; return false;
} }

View file

@ -97,7 +97,7 @@ public:
Adafruit_SHTC3(void); Adafruit_SHTC3(void);
~Adafruit_SHTC3(void); ~Adafruit_SHTC3(void);
bool begin(TwoWire *theWire = &Wire); bool begin(TwoWire *theWire = &Wire, const bool dontInitialize = false);
uint16_t readID(void); uint16_t readID(void);
void reset(void); void reset(void);
void sleep(bool sleepmode); void sleep(bool sleepmode);