Open uutzinger opened 2 years ago
An alternate Wire instance can be provided as a parameter to the constructor.
Do you have an actual use case where the sensor changes what pins it is connected to after initial setup? Or some other specific use case requiring dynamically changing the Wire instance?
in most Arduino libraries its possible to change the wire port after the sensor structure has been created. For example the main program initialized the sensor with: Adafruit_BME680 bme680;
Then the main program is searching for the sensor on the available wire interfaces. Then we provide that wire interface to the driver which keeps it in the _wire variable.
Either we provide opportunity to set wire interface in begin() function or with the proposed change in the file Adafruit_BME689.h by adding the following line:
void setWire(TwoWire *theWire = &Wire) {_wire = theWire;}
which exposed the private variable _wire.