AceTimeClock  1.3.0
Clock classes for Arduino that can synchronize from an NTP server or an RTC chip
Public Member Functions | List of all members
ace_time::clock::DS3231Clock< T_WIREI > Class Template Reference

An implementation of Clock that uses a DS3231 RTC chip. More...

#include <DS3231Clock.h>

Inheritance diagram for ace_time::clock::DS3231Clock< T_WIREI >:
Inheritance graph
[legend]
Collaboration diagram for ace_time::clock::DS3231Clock< T_WIREI >:
Collaboration graph
[legend]

Public Member Functions

 DS3231Clock (const T_WIREI &wireInterface)
 Constructor.
 
void setup ()
 Setup that currently does nothing.
 
acetime_t getNow () const override
 Return the number of seconds since the AceTime epoch (2000-01-01T00:00:00Z). More...
 
void setNow (acetime_t epochSeconds) override
 Set the time to the indicated seconds. More...
 
- Public Member Functions inherited from ace_time::clock::Clock
 Clock ()=default
 Default constructor.
 
 ~Clock ()=default
 We deliberately avoid using a virtual destructor. More...
 
virtual void sendRequest () const
 Send a time request asynchronously.
 
virtual bool isResponseReady () const
 Return true if a response is ready.
 
virtual acetime_t readResponse () const
 Returns number of seconds since AceTime epoch (2000-01-01). More...
 

Additional Inherited Members

- Static Public Attributes inherited from ace_time::clock::Clock
static const acetime_t kInvalidSeconds = LocalTime::kInvalidSeconds
 Error value returned by getNow() and other methods when this object is not yet initialized.
 

Detailed Description

template<typename T_WIREI>
class ace_time::clock::DS3231Clock< T_WIREI >

An implementation of Clock that uses a DS3231 RTC chip.

Template Parameters
T_WIREItype of the AceWire implementation to communicate over I2C

Definition at line 24 of file DS3231Clock.h.

Member Function Documentation

◆ getNow()

template<typename T_WIREI >
acetime_t ace_time::clock::DS3231Clock< T_WIREI >::getNow ( ) const
inlineoverridevirtual

Return the number of seconds since the AceTime epoch (2000-01-01T00:00:00Z).

Returns kInvalidSeconds if an error has occured.

This is a blocking call. Some clocks (e.g. NTP client) this may take many seconds. On those clocks, use the asynchronous methods (sendRequest(), isResponseReady(), and readResponse()) instead.

Implements ace_time::clock::Clock.

Definition at line 34 of file DS3231Clock.h.

◆ setNow()

template<typename T_WIREI >
void ace_time::clock::DS3231Clock< T_WIREI >::setNow ( acetime_t  )
inlineoverridevirtual

Set the time to the indicated seconds.

Calling with a value of kInvalidSeconds indicates an error condition, so the method should do nothing. Some clocks do not support this feature, for example, NTP or GPS clocks and this method will be a no-op.

Reimplemented from ace_time::clock::Clock.

Definition at line 40 of file DS3231Clock.h.


The documentation for this class was generated from the following file: