77 static const uint8_t RTC_ADDRESS = 0x68;
80 static uint8_t bcd2bin(uint8_t binaryRepresentation);
81 static uint8_t bin2bcd(uint8_t bcdRepresentation);
82 static uint8_t rtc_i2c_seek(
const uint8_t Address);
83 static uint8_t rtc_i2c_write_byte(
const uint8_t Address,
const uint8_t Byte);
84 static uint8_t rtc_i2c_read_byte(
const uint8_t Address, uint8_t &Byte);
85 static void print_zero_padded(Stream &Printer, uint8_t x);
108 static const uint8_t ALARM_EVERY_SECOND = 0B11110001;
109 static const uint8_t ALARM_MATCH_SECOND = 0B01110001;
110 static const uint8_t ALARM_MATCH_SECOND_MINUTE = 0B00110001;
111 static const uint8_t ALARM_MATCH_SECOND_MINUTE_HOUR = 0B00010001;
112 static const uint8_t ALARM_MATCH_SECOND_MINUTE_HOUR_DATE = 0B00000001;
113 static const uint8_t ALARM_MATCH_SECOND_MINUTE_HOUR_DOW = 0B00001001;
115 static const uint8_t ALARM_EVERY_MINUTE = 0B01110010;
116 static const uint8_t ALARM_MATCH_MINUTE = 0B00110010;
117 static const uint8_t ALARM_MATCH_MINUTE_HOUR = 0B00010010;
118 static const uint8_t ALARM_MATCH_MINUTE_HOUR_DATE = 0B00000010;
119 static const uint8_t ALARM_MATCH_MINUTE_HOUR_DOW = 0B00001010;
121 static const uint8_t ALARM_HOURLY = 0B00110011;
122 static const uint8_t ALARM_DAILY = 0B00010011;
123 static const uint8_t ALARM_WEEKLY = 0B00001011;
124 static const uint8_t ALARM_MONTHLY = 0B00000011;
145 void promptForTimeAndDate(Stream &Serial);
199 uint8_t
setAlarm(uint8_t AlarmMode);
292 void printTimeTo_HMS(Stream &Printer,
const DateTime &Timestamp,
const char hoursToMinutesSeparator =
':',
const char minutesToSecondsSeparator =
':');
302 void printTimeTo_HM (Stream &Printer,
const DateTime &Timestamp,
const char hoursToMinutesSeparator =
':');
312 void print12HourTimeTo_HMS(Stream &Printer,
const DateTime &Timestamp,
const char hoursToMinutesSeparator =
':',
const char minutesToSecondsSeparator =
':');
337 static const uint8_t EEPROM_ADDRESS = 0x57;
350 static const uint16_t EEPROM_SIZE_KBIT = 32768;
351 static const uint8_t EEPROM_PAGE_SIZE = 32;
352 static const uint16_t EEPROM_BYTES = EEPROM_SIZE_KBIT/8;
353 static const uint8_t EEPROM_PAGES = EEPROM_BYTES/EEPROM_PAGE_SIZE;
372 uint16_t eepromWriteAddress = EEPROM_BYTES;
378 uint16_t eepromReadAddress = EEPROM_BYTES;
415 uint16_t
readLogFrom(uint16_t Address,
DateTime ×tamp, uint8_t *data, uint8_t size = 0);
504 template <
typename datatype>
506 return writeLog(
read(), (uint8_t *) &data, (uint8_t)
sizeof(datatype));
516 template <
typename datatype>
518 return writeLog(timestamp, (uint8_t *) &data, (uint8_t)
sizeof(datatype));
528 uint8_t
writeLog(
const DateTime ×tamp,
const uint8_t *data, uint8_t size = 1 );
543 template <
typename datatype>
545 return readLog(timestamp, (uint8_t *) &data, (uint8_t)
sizeof(datatype));
558 uint8_t
readLog(
DateTime ×tamp, uint8_t *data, uint8_t size = 1 );
uint8_t getTemperature()
Get the temperature accurate to within 1 degree (C)
Definition: DS3231_Simple.cpp:582
int8_t compareTimestamps(const DateTime &A, const DateTime &B)
Compare two DateTime objects to determine which one is older.
Definition: DS3231_Simple.cpp:69
void printDateTo_YMD(Stream &Printer)
Print the date portion of the current DateTime structure in YYYY-MM-DD format.
Definition: DS3231_Simple.h:287
uint8_t formatEEPROM()
Erase the EEPROM ready for storing log entries.
Definition: DS3231_Simple.cpp:93
uint16_t readLogFrom(uint16_t Address, DateTime ×tamp, uint8_t *data, uint8_t size=0)
Read log timestamp and data from a given EEPROM address.
Definition: DS3231_Simple.cpp:311
void print12HourTimeTo_HM(Stream &Printer)
Print the time portion of the current DateTime structure in HH:MM:SS [AM/PM] format (12 Hour Clock) ...
Definition: DS3231_Simple.h:327
void printDateTo_YMD(Stream &Printer, const DateTime &Timestamp, const char separator= '-')
Print the date portion of the given DateTime structure in YYYY-MM-DD format.
Definition: DS3231_Simple.cpp:669
uint8_t writeLog(const datatype &data)
Write a log entry to the EEPROM, having current timestamp, with an attached data of arbitrary datatyp...
Definition: DS3231_Simple.h:505
uint8_t writeLog(const DateTime ×tamp, const datatype &data)
Write a log entry to the EEPROM, having supplied timestamp, with an attached data of arbitrary dataty...
Definition: DS3231_Simple.h:517
uint8_t writeBytePagewize(const uint8_t data)
Write a byte during a pagewize operation.
Definition: DS3231_Simple.cpp:244
void print12HourTimeTo_HMS(Stream &Printer, const DateTime &Timestamp, const char hoursToMinutesSeparator= ':', const char minutesToSecondsSeparator= ':')
Print the time portion of the given DateTime structure in HH:MM:SS [AM/PM] format (12 Hour Clock) ...
Definition: DS3231_Simple.cpp:706
uint8_t disableAlarms()
Disable any existing alarm settings.
Definition: DS3231_Simple.cpp:561
uint8_t setAlarm(const DateTime &AlarmTime, uint8_t AlarmMode)
Sets an alarm, the alarm will pull the SQW pin low (you can monitor with an interrupt).
Definition: DS3231_Simple.cpp:457
uint8_t writeBytePagewizeStart()
Start a "pagewize" write at the eepromWriteAddress.
Definition: DS3231_Simple.cpp:236
void begin()
Initialize.
Definition: DS3231_Simple.cpp:3
void printDateTo_MDY(Stream &Printer, const DateTime &Timestamp, const char separator= '/')
Print the date portion of the given DateTime structure in MM/DD/YYYY format.
Definition: DS3231_Simple.cpp:652
uint8_t readEEPROMByte(const uint16_t Address)
Read a byte from the EEPROM.
Definition: DS3231_Simple.cpp:108
uint8_t writeBytePagewizeEnd()
End a pagewize write operation.
Definition: DS3231_Simple.cpp:264
uint8_t readLog(DateTime ×tamp, datatype &data)
Read the oldest log entry and clear it from EEPROM.
Definition: DS3231_Simple.h:544
uint8_t makeEEPROMSpace(uint16_t Address, int8_t BytesRequired)
Delete enough complete blocks to have enough free space for the given required number of bytes...
Definition: DS3231_Simple.cpp:202
void printDateTo_DMY(Stream &Printer, const DateTime &Timestamp, const char separator= '/')
Print the date portion of the given DateTime structure in DD/MM/YYYY format.
Definition: DS3231_Simple.cpp:635
Simple DS3231 RTC and AT24C32 EEPROM Library.
Definition: DS3231_Simple.h:40
DateTime read()
Read the current date and time, returning a structure containing that information.
Definition: DS3231_Simple.cpp:398
Definition: DS3231_Simple.h:61
void print12HourTimeTo_HM(Stream &Printer, const DateTime &Timestamp, const char hoursToMinutesSeparator= ':')
Print the time portion of the given DateTime structure in HH:MM:SS [AM/PM] format (12 Hour Clock) ...
Definition: DS3231_Simple.cpp:736
void printTimeTo_HM(Stream &Printer)
Print the time portion of the current DateTime structure in HH:MM format (24 Hour Clock) ...
Definition: DS3231_Simple.h:307
void printTo(Stream &Printer)
Print the current DateTime structure in ISO8601 Format.
Definition: DS3231_Simple.cpp:623
void printDateTo_DMY(Stream &Printer)
Print the date portion of the current DateTime structure in DD/MM/YYYY format.
Definition: DS3231_Simple.h:267
uint8_t checkAlarms(uint8_t PauseClock=false)
Determine if an alarm has triggered, also clears the alarm if so.
Definition: DS3231_Simple.cpp:530
void printTimeTo_HM(Stream &Printer, const DateTime &Timestamp, const char hoursToMinutesSeparator= ':')
Print the time portion of the given DateTime structure in HH:MM format (24 Hour Clock) ...
Definition: DS3231_Simple.cpp:700
void print12HourTimeTo_HMS(Stream &Printer)
Print the time portion of the current DateTime structure in HH:MM:SS [AM/PM] format (12 Hour Clock) ...
Definition: DS3231_Simple.h:317
float getTemperatureFloat()
Get the temprature accurate to within 0.25 degrees (C)
Definition: DS3231_Simple.cpp:605
uint16_t findEEPROMWriteAddress()
Searches the EEPROM for the next place to store a block, sets eepromWriteAddress. ...
Definition: DS3231_Simple.cpp:131
void printTimeTo_HMS(Stream &Printer)
Print the time portion of the current DateTime structure in HH:MM:SS format (24 Hour Clock) ...
Definition: DS3231_Simple.h:297
void printTimeTo_HMS(Stream &Printer, const DateTime &Timestamp, const char hoursToMinutesSeparator= ':', const char minutesToSecondsSeparator= ':')
Print the time portion of the given DateTime structure in HH:MM:SS format (24 Hour Clock) ...
Definition: DS3231_Simple.cpp:686
uint16_t findEEPROMReadAddress()
Find the oldest block to read (based on timestamp date), set eepromReadAddress.
Definition: DS3231_Simple.cpp:162
void printDateTo_MDY(Stream &Printer)
Print the date portion of the current DateTime structure in MM/DD/YYYY format.
Definition: DS3231_Simple.h:277
uint8_t write(const DateTime &)
Set the date and time from the settings in the given structure.
Definition: DS3231_Simple.cpp:443