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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/RTClib.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,13 @@ class TimeSpan {
*/
/**************************************************************************/
class RTC_I2C {
public:
/*!
@brief Check if I2C device is present
@return true if present, false otherwise
*/
bool isPresent(void) { return i2c_dev != NULL; };

protected:
/*!
@brief Convert a binary coded decimal value to binary. RTC stores
Expand All @@ -348,7 +355,7 @@ class RTC_I2C {
@brief RTC based on the DS1307 chip connected via I2C and the Wire library
*/
/**************************************************************************/
class RTC_DS1307 : RTC_I2C {
class RTC_DS1307 : public RTC_I2C {
public:
bool begin(TwoWire *wireInstance = &Wire);
void adjust(const DateTime &dt);
Expand All @@ -367,7 +374,7 @@ class RTC_DS1307 : RTC_I2C {
@brief RTC based on the DS3231 chip connected via I2C and the Wire library
*/
/**************************************************************************/
class RTC_DS3231 : RTC_I2C {
class RTC_DS3231 : public RTC_I2C {
public:
bool begin(TwoWire *wireInstance = &Wire);
void adjust(const DateTime &dt);
Expand Down Expand Up @@ -403,7 +410,7 @@ class RTC_DS3231 : RTC_I2C {
@brief RTC based on the PCF8523 chip connected via I2C and the Wire library
*/
/**************************************************************************/
class RTC_PCF8523 : RTC_I2C {
class RTC_PCF8523 : public RTC_I2C {
public:
bool begin(TwoWire *wireInstance = &Wire);
void adjust(const DateTime &dt);
Expand All @@ -430,7 +437,7 @@ class RTC_PCF8523 : RTC_I2C {
@brief RTC based on the PCF8563 chip connected via I2C and the Wire library
*/
/**************************************************************************/
class RTC_PCF8563 : RTC_I2C {
class RTC_PCF8563 : public RTC_I2C {
public:
bool begin(TwoWire *wireInstance = &Wire);
bool lostPower(void);
Expand Down