Skip to content

Add function isPresent() to check if i2c connection has been established#279

Open
resterampeberlin wants to merge 1 commit intoadafruit:masterfrom
resterampeberlin:master
Open

Add function isPresent() to check if i2c connection has been established#279
resterampeberlin wants to merge 1 commit intoadafruit:masterfrom
resterampeberlin:master

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