RTClib
Public Member Functions | Protected Attributes | List of all members
RTC_Millis Class Reference

RTC using the internal millis() clock, has to be initialized before use. NOTE: this is immune to millis() rollover events. More...

#include <RTClib.h>

Public Member Functions

void begin (const DateTime &dt)
 Start the RTC. More...
 
void adjust (const DateTime &dt)
 Set the current date/time of the RTC_Millis clock. More...
 
DateTime now ()
 Return a DateTime object containing the current date/time. Note that computing (millis() - lastMillis) is rollover-safe as long as this method is called at least once every 49.7 days. More...
 

Protected Attributes

uint32_t lastUnix
 
uint32_t lastMillis
 

Detailed Description

RTC using the internal millis() clock, has to be initialized before use. NOTE: this is immune to millis() rollover events.

Member Function Documentation

◆ begin()

void RTC_Millis::begin ( const DateTime dt)
inline

Start the RTC.

Parameters
dtDateTime object with the date/time to set

◆ adjust()

void RTC_Millis::adjust ( const DateTime dt)

Set the current date/time of the RTC_Millis clock.

Parameters
dtDateTime object with the desired date and time

◆ now()

DateTime RTC_Millis::now ( )

Return a DateTime object containing the current date/time. Note that computing (millis() - lastMillis) is rollover-safe as long as this method is called at least once every 49.7 days.

Returns
DateTime object containing current time

Member Data Documentation

◆ lastUnix

uint32_t RTC_Millis::lastUnix
protected

Unix time from the previous call to now().

This, together with lastMillis, defines the alignment between the millis() timescale and the Unix timescale. Both variables are updated on each call to now(), which prevents rollover issues.

◆ lastMillis

uint32_t RTC_Millis::lastMillis
protected

millis() value corresponding lastUnix.

Note that this is not the millis() value of the last call to now(): it's the millis() value corresponding to the last full second of Unix time preceding the last call to now().


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