|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
#include <SensorRtcHelper.hpp>
Public Member Functions | |
| SensorRtcHelper () | |
| ~SensorRtcHelper () | |
| void | setRtcDrvModel (SensorRTCType model) |
| Set the model of the RTC (real-time clock) driver. | |
| bool | begin (SensorCommCustom::CustomCallback callback) |
| Initialize the RTC driver using a custom callback. | |
| 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. | |
| const char * | getChipName () |
| Get the name of the RTC chip. | |
| virtual void | setDateTime (RTC_DateTime datetime)=0 |
| Set the date and time of the RTC using an RTC_DateTime object. | |
| void | setDateTime (uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second) |
| Set the date and time of the RTC using individual values. | |
| virtual RTC_DateTime | getDateTime ()=0 |
| Get the current date and time from the RTC. | |
| void | getDateTime (struct tm *info) |
| Retrieve the current date and time from the RTC (Real-Time Clock) and populate a struct tm object. | |
Public Member Functions inherited from SensorRTC | |
| virtual void | reset () |
| Reset the RTC. | |
| void | getDateTime (struct tm *info) |
| Retrieve the current date and time from the RTC (Real-Time Clock) and populate a struct tm object. | |
| void | setDateTime (uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second) |
| Set the date and time of the RTC using individual values. | |
| const char * | strftime (DateTimeFormat style=DT_FMT_YMD_HMS_WEEK) |
| Format the current date and time according to the specified style. | |
| time_t | hwClockRead (const timezone *tz=NULL) |
| Read the time from the RTC (Real-Time Clock) and write it to the system clock. | |
| int | hwClockWrite () |
| Write the current system time to the RTC clock chip. | |
| uint32_t | getDayOfWeek (uint32_t day, uint32_t month, uint32_t year) |
| Calculate the day of the week for a given date using Zeller's congruence. | |
| uint8_t | getNextMonth (uint8_t curMonth) |
| Get the next month based on the current month. | |
| uint16_t | getNextYear (uint16_t curYear) |
| Get the next year based on the current year. | |
| uint32_t | getLeapYear (uint32_t year) |
| Determine whether a given year is a leap year. | |
| uint8_t | getDaysInMonth (uint8_t month, uint16_t year) |
| Get the number of days in a given month of a specific year, considering leap years. | |
| void | convertUtcToTimezone (int &year, int &month, int &day, int &hour, int &minute, int &second, int timezoneOffsetSeconds) |
| Convert UTC time represented by individual values to the time in the specified timezone. | |
| void | convertUtcToTimezone (struct tm &utcTime, int timezoneOffsetSeconds) |
| Overloaded function to convert UTC time represented by a struct tm object to the time in the specified timezone. | |
Additional Inherited Members | |
Static Public Member Functions inherited from SensorRTC | |
| static uint8_t | BCD2DEC (uint8_t val) |
| Convert a Binary Coded Decimal (BCD) number to a decimal number. | |
| static uint8_t | DEC2BCD (uint8_t val) |
| Convert a decimal number to a Binary Coded Decimal (BCD) number. | |
Definition at line 53 of file time/SensorRtcHelper.hpp.
| SensorRtcHelper::SensorRtcHelper | ( | ) |
Definition at line 49 of file SensorRtcHelper.cpp.
| SensorRtcHelper::~SensorRtcHelper | ( | ) |
Definition at line 54 of file SensorRtcHelper.cpp.
|
virtual |
Initialize the RTC driver using a custom callback.
This method allows the user to initialize the RTC driver using a custom callback function. The callback can be used to perform custom communication or configuration operations.
| callback | A pointer to the custom callback function. |
Implements SensorRTC.
Definition at line 127 of file SensorRtcHelper.cpp.
References i, RtcDrv_PCF85063, and RtcDrv_UNKNOWN.
Referenced by setup().
|
virtual |
Get the name of the RTC chip.
Implements SensorRTC.
Definition at line 154 of file SensorRtcHelper.cpp.
Referenced by setup().
|
virtual |
Get the current date and time from the RTC device.
This method retrieves the current date and time from the RTC device and returns it as an RTC_DateTime object.
Implements SensorRTC.
Definition at line 149 of file SensorRtcHelper.cpp.
Referenced by loop().
|
virtual |
Get the current date and time from the RTC.
This is a pure virtual function that derived classes must implement. It retrieves the current date and time from the RTC and returns them as an RTC_DateTime object.
Implements SensorRTC.
|
inline |
Retrieve the current date and time from the RTC (Real-Time Clock) and populate a struct tm object.
This function fetches the current date and time information from the RTC device. It then fills the provided struct tm object with the corresponding values. The struct tm object is a standard C structure used to represent date and time components, such as year, month, day, hour, minute, and second.
| info | A pointer to a struct tm object where the retrieved date and time information will be stored. This pointer must not be a null pointer |
struct tm object is the number of years since 1900. The month value ranges from 0 (January) to 11 (December). The day value represents the day of the month, starting from 1. The hour value ranges from 0 to 23, the minute and second values range from 0 to 59. Definition at line 335 of file SensorRTC.h.
|
virtual |
Set the date and time on the RTC device.
This method sets the specified date and time on the RTC device.
| datetime | An RTC_DateTime object containing the date and time to set. |
Implements SensorRTC.
Definition at line 144 of file SensorRtcHelper.cpp.
|
virtual |
Set the date and time of the RTC using an RTC_DateTime object.
This is a pure virtual function that derived classes must implement. It allows setting the RTC's date and time using a single RTC_DateTime object.
| datetime | An RTC_DateTime object containing the date and time information to set on the RTC. |
Implements SensorRTC.
|
inline |
Set the date and time of the RTC using individual values.
| year | The year to set on the RTC. It's usually a 16 - bit unsigned integer. |
| month | The month to set on the RTC, ranging from 1 (January) to 12 (December). |
| day | The day of the month to set on the RTC, ranging from 1 to 31, depending on the month and leap year. |
| hour | The hour to set on the RTC, ranging from 0 to 23. |
| minute | The minute to set on the RTC, ranging from 0 to 59. |
| second | The second to set on the RTC, ranging from 0 to 59. |
Definition at line 351 of file SensorRTC.h.
| void SensorRtcHelper::setRtcDrvModel | ( | SensorRTCType | model | ) |
Set the model of the RTC (real-time clock) driver.
This method is used to specify the type of RTC driver model that the system should use. If not set, the chip type is automatically determined by register information by default.
| model | An enumeration value of the SensorRTCType type, indicating a specific RTC driver model. Possible values include RtcDrv_UNKNOWN (unknown model), RtcDrv_PCF85063 (PCF85063 model), RtcDrv_PCF8563 (PCF8563 model), etc. |
Definition at line 59 of file SensorRtcHelper.cpp.