libpropeller
Making PropellerGCC Easier
|
Interface to the PCF8523 Real Time Clock (RTC). More...
#include <pcf8523.h>
Public Member Functions | |
PCF8523 () | |
Create a PCF8523 instance. More... | |
bool | Init (I2C *newbus) |
Initialize a PCF8523 instance. More... | |
bool | GetStatus () |
Test to see if the device is present and readable. More... | |
bool | 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. More... | |
bool | GetClock (int &year, int &month, int &day, int &hour, int &minute, int &second, int &weekday) |
Get the current time from the RTC chip. More... | |
bool | GetClock (int &year, int &month, int &day, int &hour, int &minute, int &second) |
Get the current time from the RTC chip. More... | |
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:
|
inline |
Create a PCF8523 instance.
|
inline |
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. |
|
inline |
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. |
|
inline |
Test to see if the device is present and readable.
Sends a ping on the i2c bus.
|
inline |
Initialize a PCF8523 instance.
Set the control registers of the device:
newbus | The i2c bus to use. |
|
inline |
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. |