ArduinoLibs
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | List of all members
DS1307RTC Class Reference

Communicates with a DS1307 realtime clock chip via I2C. More...

#include <DS1307RTC.h>

Inheritance diagram for DS1307RTC:
RTC

Public Member Functions

 DS1307RTC (I2CMaster &bus, uint8_t oneHzPin=255)
 Attaches to a realtime clock slave device on bus. More...
 
bool isRealTime () const
 Returns true if the realtime clock is on the I2C bus; false if the time and date are simulated.
 
bool hasUpdates ()
 Returns true if the realtime clock has updated since the last call to this function. More...
 
void readTime (RTCTime *value)
 Reads the current time from the realtime clock into value. More...
 
void readDate (RTCDate *value)
 Reads the current date from the realtime clock into value. More...
 
void writeTime (const RTCTime *value)
 Updates the time in the realtime clock to match value. More...
 
void writeDate (const RTCDate *value)
 Updates the date in the realtime clock to match value. More...
 
void readAlarm (uint8_t alarmNum, RTCAlarm *value)
 Reads the details of the alarm with index alarmNum into value. More...
 
void writeAlarm (uint8_t alarmNum, const RTCAlarm *value)
 Updates the details of the alarm with index alarmNum from value. More...
 
int byteCount () const
 Returns the number of bytes of non-volatile memory that can be used for storage of arbitrary settings, excluding storage used by alarms. More...
 
uint8_t readByte (uint8_t offset)
 Reads the byte at offset within the realtime clock's non-volatile memory. More...
 
void writeByte (uint8_t offset, uint8_t value)
 Writes value to offset within the realtime clock's non-volatile memory. More...
 
- Public Member Functions inherited from RTC
 RTC ()
 Constructs a new realtime clock handler. More...
 
virtual int readTemperature ()
 Reads the value of the temperature sensor and returns the temperature in quarters of a degree celcius. More...
 

Additional Inherited Members

- Public Types inherited from RTC
enum  DayOfWeek {
  Monday = 1, Tuesday, Wednesday, Thursday,
  Friday, Saturday, Sunday
}
 Day of the week corresponding to a date. More...
 
- Static Public Member Functions inherited from RTC
static void adjustDays (RTCDate *date, uint8_t flags)
 Adjusts date up or down one day according to flags. More...
 
static void adjustMonths (RTCDate *date, uint8_t flags)
 Adjusts date up or down one month according to flags. More...
 
static void adjustYears (RTCDate *date, uint8_t flags)
 Adjusts date up or down one year according to flags. More...
 
static DayOfWeek dayOfWeek (const RTCDate *date)
 Returns the day of the week corresponding to date. More...
 
- Static Public Attributes inherited from RTC
static const uint8_t ALARM_COUNT = 4
 Number of alarms that are supported by RTC::readAlarm() and RTC::writeAlarm().
 
static const int NO_TEMPERATURE = 32767
 Value that is returned from readTemperature() if the realtime clock chip cannot determine the temperature.
 
static const uint8_t INCREMENT = 0x0000
 Increment the day, month, or year in a call to adjustDays(), adjustMonths(), or adjustYears().
 
static const uint8_t DECREMENT = 0x0001
 Decrement the day, month, or year in a call to adjustDays(), adjustMonths(), or adjustYears().
 
static const uint8_t WRAP = 0x0002
 Wrap around to the beginning of the current month/year rather than advance to the next one.
 

Detailed Description

Communicates with a DS1307 realtime clock chip via I2C.

This class simplifies the process of reading and writing the time and date information in a DS1307 realtime clock chip. The class also provides support for reading and writing information about alarms and other clock settings.

If there is no DS1307 chip on the I2C bus, this class will fall back to the RTC class to simulate the current time and date based on the value of millis().

The DS1307 uses a 2-digit year so this class is limited to dates between 2000 and 2099 inclusive.

Note: if this class has not been used with the DS1307 chip before, then the contents of NVRAM will be cleared. Any previous contents will be lost.

See Also
RTC, DS3232RTC

Definition at line 30 of file DS1307RTC.h.

Constructor & Destructor Documentation

DS1307RTC::DS1307RTC ( I2CMaster bus,
uint8_t  oneHzPin = 255 
)

Attaches to a realtime clock slave device on bus.

If oneHzPin is not 255, then it indicates a digital input pin that is connected to the 1 Hz square wave output on the realtime clock. This input is used by hasUpdates() to determine if the time information has changed in a non-trivial manner.

See Also
hasUpdates()

Definition at line 83 of file DS1307RTC.cpp.

Member Function Documentation

int DS1307RTC::byteCount ( ) const
virtual

Returns the number of bytes of non-volatile memory that can be used for storage of arbitrary settings, excluding storage used by alarms.

See Also
readByte(), writeByte()

Reimplemented from RTC.

Definition at line 264 of file DS1307RTC.cpp.

bool DS1307RTC::hasUpdates ( )
virtual

Returns true if the realtime clock has updated since the last call to this function.

The default implementation returns true, indicating that an update is always available to be read.

Reimplemented from RTC.

Definition at line 118 of file DS1307RTC.cpp.

void DS1307RTC::readAlarm ( uint8_t  alarmNum,
RTCAlarm value 
)
virtual

Reads the details of the alarm with index alarmNum into value.

The alarmNum parameter must be between 0 and ALARM_COUNT - 1.

Alarm details are stored at the end of the realtime clock's non-volatile memory.

See Also
writeAlarm(), alarmCount()

Reimplemented from RTC.

Definition at line 230 of file DS1307RTC.cpp.

uint8_t DS1307RTC::readByte ( uint8_t  offset)
virtual

Reads the byte at offset within the realtime clock's non-volatile memory.

The offset parameter must be between 0 and byteCount() - 1.

See Also
writeByte(), byteCount()

Reimplemented from RTC.

Definition at line 269 of file DS1307RTC.cpp.

void DS1307RTC::readDate ( RTCDate value)
virtual

Reads the current date from the realtime clock into value.

The time should be read first with readTime() as the default implementation only advances the date when the time is read and it crosses midnight.

See Also
writeDate(), readTime()

Reimplemented from RTC.

Definition at line 177 of file DS1307RTC.cpp.

void DS1307RTC::readTime ( RTCTime value)
virtual

Reads the current time from the realtime clock into value.

See Also
writeTime(), readDate()

Reimplemented from RTC.

Definition at line 157 of file DS1307RTC.cpp.

void DS1307RTC::writeAlarm ( uint8_t  alarmNum,
const RTCAlarm value 
)
virtual

Updates the details of the alarm with index alarmNum from value.

The alarmNum parameter must be between 0 and ALARM_COUNT - 1.

Alarm details are stored at the end of the realtime clock's non-volatile memory.

See Also
readAlarm(), alarmCount()

Reimplemented from RTC.

Definition at line 250 of file DS1307RTC.cpp.

void DS1307RTC::writeByte ( uint8_t  offset,
uint8_t  value 
)
virtual

Writes value to offset within the realtime clock's non-volatile memory.

The offset parameter must be between 0 and byteCount() - 1.

See Also
readByte(), byteCount()

Reimplemented from RTC.

Definition at line 277 of file DS1307RTC.cpp.

void DS1307RTC::writeDate ( const RTCDate value)
virtual

Updates the date in the realtime clock to match value.

See Also
readDate(), writeTime()

Reimplemented from RTC.

Definition at line 216 of file DS1307RTC.cpp.

void DS1307RTC::writeTime ( const RTCTime value)
virtual

Updates the time in the realtime clock to match value.

See Also
readTime(), writeDate()

Reimplemented from RTC.

Definition at line 202 of file DS1307RTC.cpp.


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