RTClib
Static Public Member Functions | Static 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>

Static Public Member Functions

static void begin (const DateTime &dt)
 Start the RTC. More...
 
static void adjust (const DateTime &dt)
 Set the current date/time of the RTC_Millis clock. More...
 
static 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...
 

Static Protected Attributes

static uint32_t lastUnix
 
static 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()

static void RTC_Millis::begin ( const DateTime dt)
inlinestatic

Start the RTC.

Parameters
dtDateTime object with the date/time to set

◆ adjust()

void RTC_Millis::adjust ( const DateTime dt)
static

Set the current date/time of the RTC_Millis clock.

Parameters
dtDateTime object with the desired date and time

◆ now()

DateTime RTC_Millis::now ( )
static

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
staticprotected

Unix time from the previous call to now() - prevents rollover issues

◆ lastMillis

uint32_t RTC_Millis::lastMillis
staticprotected

the millis() value corresponding to the last full second of Unix time

Alignment between the milis() timescale and the Unix timescale. These two variables are updated on each call to now(), which prevents rollover issues. Note that lastMillis 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.


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