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 function isPresent() to check if i2c connection has been established #279

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

Conversation

resterampeberlin
Copy link

@resterampeberlin resterampeberlin commented Mar 6, 2023

The current implementation of RTClib provides no way, to check "on demand" if the i2c device has been connected and initialized. The only way is the return value of the "begin" function.

However, the protected variable "i2c_dev" in the class "RTC_I2C" does contain this information. If it is "NULL", the device has not been initialized.

Therefore, I added a function to "RTC_I2C" to check if this variable is NULL or not. Unfortunately, all classes derived from RTC_I2C must be derived "public". Otherwise, the variable is not visible to code outside the derived classes.

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.

1 participant