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

Add a way to remap I2C1 pins after construction of standard Wire instance #726

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

gmcn42
Copy link

@gmcn42 gmcn42 commented Dec 5, 2019

Normally there is no way to edit the dev_flags variable after Wire has been constructed. It is sometimes helpful to do so though. Example: u8g2 uses the builtin Wire instance to communicate with I2C displays which is normally set to the standard pins.

Using the added functions from this PR it is possible to:

//during setup():
uint8_t df = Wire.getDevFlags();
df |= I2C_REMAP;
Wire.setDevFlags(df);

After that u8g2 will nicely communicate with an I2C display connected to the alternate pins.

Normally there is no way to edit the dev_flags variable after Wire has been constructed. It is sometimes helpful to do so though. Example: u8g2 uses the builtin Wire instance to communicate with I2C displays which is normally set to the standard pins.

Using the added functions from this PR it is possible to:

//during setup():
uint8_t df = Wire.getDevFlags();
df |= I2C_REMAP;
Wire.setDevFlags(df);

After that u8g2 will nicely communicate with an I2C display connected to the alternate pins.
Normally there is no way to edit the dev_flags variable after Wire has been constructed. It is sometimes helpful to do so though. Example: u8g2 uses the builtin Wire instance to communicate with I2C displays which is normally set to the standard pins.

Using the added functions from this PR it is possible to:

//during setup():
uint8_t df = Wire.getDevFlags();
df |= I2C_REMAP;
Wire.setDevFlags(df);

After that u8g2 will nicely communicate with an I2C display connected to the alternate pins.
@stevstrong2
Copy link
Contributor

@gmcn42 ,
could you eventually define these functions in the header file only, so that the Wire.cpp remains untouched?

@gmcn42
Copy link
Author

gmcn42 commented Jan 6, 2020

Sure. Amended PR.

@stevstrong
Copy link
Collaborator

I think there is a small mistake, the input parameter should be df if I'm not wrong.
Can you please correct that?

@stevstrong stevstrong added the wait for OP answer Waiting for a reply from the original poster label Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wait for OP answer Waiting for a reply from the original poster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants