30#include "../SensorBuildOpt.h"
31#if !SENSORLIB_EXCLUDE_RTC
35SensorRtcHelper::DriverCreator SensorRtcHelper::driverCreators[SensorRtcHelper::driverCreatorMaxNum] = {
37#if !SENSORLIB_EXCLUDE_PCF85063
38 []() -> std::unique_ptr<SensorRTC> {
return std::make_unique<SensorPCF85063>(); },
42#if !SENSORLIB_EXCLUDE_PCF8563
43 []() -> std::unique_ptr<SensorRTC> {
return std::make_unique<SensorPCF8563>(); },
71 if (_drv && _drv->begin(wire, sda, scl)) {
83#elif defined(ESP_PLATFORM)
85#if defined(SENSORLIB_USE_I2C_LEGACY)
92 if (_drv && _drv->begin(port_num, sda, scl)) {
108 bool success =
false;
112 if (_drv && _drv->begin(handle)) {
129 bool success =
false;
132 if (_drv && _drv->begin(callback)) {
146 _drv->setDateTime(datetime);
151 return _drv->getDateTime();
156 return _drv->getChipName();
159std::unique_ptr<SensorRTC> SensorRtcHelper::createDriver(
SensorRTCType type)
161 if (type <
sizeof(driverCreators) /
sizeof(driverCreators[0])) {
162 if (driverCreators[type]) {
163 return driverCreators[type]();
bool(*)(uint8_t addr, uint8_t reg, uint8_t *buf, size_t len, bool writeReg, bool isWrite) CustomCallback
const char * getChipName()
Get the name of the RTC chip.
void setDateTime(RTC_DateTime datetime)
Set the date and time on the RTC device.
RTC_DateTime getDateTime()
Get the current date and time from the RTC device.
bool begin(SensorCommCustom::CustomCallback callback)
Initialize the RTC driver using a custom callback.
void setRtcDrvModel(SensorRTCType model)
Set the model of the RTC (real-time clock) driver.
SensorRTCType
Enumeration of different RTC (Real-Time Clock) driver types.