LoomRTC class
Abstract base class of RTC modules.
Contents
Base classes
- class LoomModule
- Abstract root of Loom component modules inheritance hierarchy.
Derived classes
- class Loom_DS3231
- DS3231 RTC module.
- class Loom_PCF8523
- PCF8523 RTC module.
Public types
Protected variables
- TimeZone timezone
- The TimeZone to use.
- bool use_local_time
- Whether or not use local time, else UTC time.
- bool converted
- Whether or not converted daylight saving / summer time or not.
- DateTime local_time
- DateTime variable for the Local Time.
- char local_datestring
- Latest saved string of Local Date (year/month/day)
- char local_timestring
- Latest saved string of Local time (hour:minute:second)
- char datestring
- Latest saved string of the Date (year/month/day)
- char timestring
- Latest saved string of the time (hour:minute:second)
CONSTRUCTORS / DESTRUCTOR
-
LoomRTC(LoomManager* manager,
const char* module_name,
const LoomModule::
Type module_type, TimeZone timezone, const bool use_local_time, const bool custom_time) - Constructor.
- ~LoomRTC() defaulted virtual
- Destructor.
OPERATION
- void package(JsonObject json) override
- Adds a timestamp to the provided data Json.
- auto now() const -> DateTime pure virtual
- Get DateTime of current time.
- void time_adjust(const DateTime time, const bool is_utc = true)
- Set time to provided timezone.
- void get_timestamp(char* header, char* timestamp, const char delimiter, const uint8_t format = 3)
- Get timestamp.
- void set_alarm(DateTime time) pure virtual
- Set an alarm to go off at the specified time.
- void set_alarm(const TimeSpan duration)
- Set an alarm for a duration.
- void clear_alarms() pure virtual
- Clear alarms.
PRINT INFORMATION
- void print_config() const override
- Display the configuration settings of the module.
- void print_state() const override
- Display current state of the module.
- void print_time(const bool verbose = false)
- Print the current time.
- static void print_DateTime(DateTime time)
- Print an arbitrary DateTime object.
GETTERS
- auto get_datestring() -> const char*
- Get the pin the RTC interrupt is assumed to be connected to.
- void get_datestring(char* buf)
- Get string of date.
- auto get_timestring() -> const char*
- Get string of time.
- void get_timestring(char* buf)
- Get string of time.
- auto get_weekday() -> const char*
- Get string of weekday.
- void get_weekday(char* buf)
- Get string of weekday.
MISCELLANEOUS
- void link_device_manager(LoomManager* LM) override
- Add pointer back to device manager.
- static auto enum_timezone_string(const TimeZone t) -> char*
- Get string of name associated with time zone enum.
- void init() protected
- Initialize RTC.
- void _adjust(const DateTime time) protected pure virtual
- Begin auxiliary function that subclasses need to implement.
- auto _begin() -> bool protected pure virtual
- Begin auxiliary function that subclasses need to implement.
- auto _initialized() -> bool protected pure virtual
- Initialization auxiliary function that subclasses need to implement.
- void read_rtc() protected
- Read the RTC, update time and date strings.
- void local_rtc() protected
- Read local time if local time is enable to read It will be updated on contents array in the data json.
- void set_rtc_to_compile_time() protected
- Set the RTC time to compile time.
- void set_rtc_to_computer_time() protected
- Set the RTC time to computer time by user input if the board is connected to computer.
- void convert_local_to_utc(const bool to_utc = true) protected
- Convert time between local and UTC.
- auto rtc_validity_check() -> bool protected
- Check if current RTC time is valid (not necessarily correct)
- auto convert_daylight_to_standard(DateTime local_time) -> DateTime protected
- Convert time between daylight saving time and standard time.
- auto us_daylight_to_standard(DateTime local_time) -> DateTime protected
- Convert the time in the US daylight saving and standard.
- auto eu_daylight_to_standard(DateTime local_time) -> DateTime protected
- Convert the time in the EU summer time and standard.
Function documentation
LoomRTC:: LoomRTC(LoomManager* manager,
const char* module_name,
const LoomModule:: Type module_type,
TimeZone timezone,
const bool use_local_time,
const bool custom_time)
Constructor.
Parameters | |
---|---|
manager | |
module_name in | Name of the module (provided by derived classes) |
module_type in | Type of the module (provided by derived classes) |
timezone in | Which timezone device is in |
use_local_time in | True for local time, false for UTC time |
custom_time in | True for user input time, false otherwise |
void LoomRTC:: package(JsonObject json) override
Adds a timestamp to the provided data Json.
Parameters | |
---|---|
json out | Object to add timestamp to |
void LoomRTC:: time_adjust(const DateTime time,
const bool is_utc = true)
Set time to provided timezone.
Parameters | |
---|---|
time in | Time to set to |
is_utc in | True if 'time' is in UTC, false if local |
void LoomRTC:: get_timestamp(char* header,
char* timestamp,
const char delimiter,
const uint8_t format = 3)
Get timestamp.
Parameters | |
---|---|
header out | Column header(s) of timestamp element |
timestamp out | String to fill with timestamp element(s) |
delimiter in | Delimiter to use |
format in | How to format timestamp (0: no timestamp added, 1: only date added, 2: only time added, 3: both date and time added (two fields), 4: both date and time added (combined field) ), |
void LoomRTC:: set_alarm(DateTime time) pure virtual
Set an alarm to go off at the specified time.
Parameters | |
---|---|
time in | DateTime of time alarm should go off |
void LoomRTC:: set_alarm(const TimeSpan duration)
Set an alarm for a duration.
Parameters | |
---|---|
duration in | TimeSpan of duration before alarm goes off |
void LoomRTC:: print_time(const bool verbose = false)
Print the current time.
Parameters | |
---|---|
verbose in | True for multile lines, false for short display |
static void LoomRTC:: print_DateTime(DateTime time)
Print an arbitrary DateTime object.
Parameters | |
---|---|
time in | Time to print |
const char* LoomRTC:: get_datestring()
Get the pin the RTC interrupt is assumed to be connected to.
Returns | Interrupt pin Get string of date |
---|
void LoomRTC:: link_device_manager(LoomManager* LM) override
Add pointer back to device manager.
Parameters | |
---|---|
LM in | LoomManager to point to |
Generally only called when device manager links module to provide pointer both directions. Derived modules may override this for increased function, such as linking a submanager or RTC module.
static char* LoomRTC:: enum_timezone_string(const TimeZone t)
Get string of name associated with time zone enum.
Parameters | |
---|---|
t in | TimeZone value to get string of |
Returns | C-string of time zone |
bool LoomRTC:: _begin() pure virtual protected
Begin auxiliary function that subclasses need to implement.
Returns | True if begin worked without issue, false otherwise |
---|
bool LoomRTC:: _initialized() pure virtual protected
Initialization auxiliary function that subclasses need to implement.
Returns | True if RTC is initialized / did not lose power |
---|
void LoomRTC:: convert_local_to_utc(const bool to_utc = true) protected
Convert time between local and UTC.
Parameters | |
---|---|
to_utc in | True to switch to UTC, false to go to local from UTC |
Uses current timezone setting
bool LoomRTC:: rtc_validity_check() protected
Check if current RTC time is valid (not necessarily correct)
Returns | True if valid |
---|
DateTime LoomRTC:: convert_daylight_to_standard(DateTime local_time) protected
Convert time between daylight saving time and standard time.
Parameters | |
---|---|
local_time in | The updated version of local time after convertion of daylight saving / summer time or standard time |
DateTime LoomRTC:: us_daylight_to_standard(DateTime local_time) protected
Convert the time in the US daylight saving and standard.
Parameters | |
---|---|
local_time in | The updated local_time based on us daylight saving |
DateTime LoomRTC:: eu_daylight_to_standard(DateTime local_time) protected
Convert the time in the EU summer time and standard.
Parameters | |
---|---|
local_time in | The updated local_time based on eu summmer time |