Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting wire port after sensor has been created #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

uutzinger
Copy link

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.

@caternuson
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants