PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
#include <libpropeller/libpropeller/pcf8523/pcf8523.h>
Public Member Functions | |
PCF8523 () | |
bool | Init (libpropeller::I2C *newbus) |
bool | GetStatus () |
bool | SetClock (const int year, const int month, const int day, const int hour, const int minute, const int second, const int weekday=0) |
bool | GetClock (int &year, int &month, int &day, int &hour, int &minute, int &second, int &weekday) |
bool | GetClock (int &year, int &month, int &day, int &hour, int &minute, int &second) |
Friends | |
class | ::UnityTests |
Interface to the PCF8523 Real Time Clock (RTC).
Hardware connections: The PCF8523 should be connected to an I2C bus. If you want the clock to keep ticking after power is removed, make sure to attach a battery to the batt pin. The SQW pin can optionally be connected. At this time, this class does not use that pin for any purpose.
Possible improvements:
libpropeller::PCF8523::PCF8523 | ( | ) |
bool libpropeller::PCF8523::GetClock | ( | int & | year, |
int & | month, | ||
int & | day, | ||
int & | hour, | ||
int & | minute, | ||
int & | second | ||
) |
Get the current time from the RTC chip. Note that the parameters are passed by reference.
year | The current year, in the range 0 to 99. |
month | The current month, in the range 1 to 12. |
day | The current day, in the range 1 to 31. |
hour | The current hour, in the range 0 to 23. |
minute | The current second, in the range 0 to 59. |
second | The current second, in the range 0 to 59. |
Definition at line 179 of file pcf8523.h.
bool libpropeller::PCF8523::GetClock | ( | int & | year, |
int & | month, | ||
int & | day, | ||
int & | hour, | ||
int & | minute, | ||
int & | second, | ||
int & | weekday | ||
) |
Get the current time from the RTC chip. Note that the parameters are passed by reference.
year | The current year, in the range 0 to 99. |
month | The current month, in the range 1 to 12. |
day | The current day, in the range 1 to 31. |
hour | The current hour, in the range 0 to 23. |
minute | The current second, in the range 0 to 59. |
second | The current second, in the range 0 to 59. |
weekday | The current weekday, in the range 0 to 6. |
Definition at line 148 of file pcf8523.h.
bool libpropeller::PCF8523::GetStatus | ( | ) |
bool libpropeller::PCF8523::Init | ( | libpropeller::I2C * | newbus | ) |
Initialize a PCF8523 instance.
Set the control registers of the device:
newbus | The i2c bus to use. |
Definition at line 69 of file pcf8523.h.
bool libpropeller::PCF8523::SetClock | ( | const int | year, |
const int | month, | ||
const int | day, | ||
const int | hour, | ||
const int | minute, | ||
const int | second, | ||
const int | weekday = 0 |
||
) |
Sets the time on the RTC. The various limits (ie, month less than 12) are not checked.
If the RTC chip has a battery backup, then the time will persist across power cycles.
year | The year to set, in the range 0 to 99. |
month | The month to set, in the range 1 to 12. |
day | The day to set, in the range 1 to 31. |
hour | The hour to set, in the range 0 to 23. |
minute | The minute to set, in the range 0 to 59. |
second | The second to set, in the range 0 to 59. |
weekday | The weekday to set, in the range of 0 to 6. You can set and interpret this anyway that you want: it's simply incremented when the day changes. |
Definition at line 113 of file pcf8523.h.