-
-
Notifications
You must be signed in to change notification settings - Fork 127
RtcPCF8563 object
RtcPCF8563 object provides access to all the functions of the PCF8563 module. Along with date and time, this also includes setting alarms/timers, and defining the square wave pin function.
Construct a Rtc object using the provided WIRE method.
T_WIRE_METHOD - the typename of the class to use for the wire method. TwoWire
is the normal hardware method class.
wire - the instance of the T_WIRE_METHOD to use. Wire
is the normal hardware instance to use.
Below is an example of how to create an instance of the object using the normal Arduino hardware Wire support.
#include <Wire.h>
#include <RtcPCF8563.h>
RtcPCF8563<TwoWire> Rtc(Wire);
If you want to use SoftwareWire library, you can replace the above with this and it will work.
#include <SoftwareWire.h>
#include <RtcPCF8563.h>
SoftwareWire myWire(SDA, SCL); // replace with the pins you use
RtcPCF8563<SoftwareWire> Rtc(myWire);
The normal begin method that should be called within Setup()
<return>, the error code from the last Wire transaction. After each method call below, you may check if this return value for an error. See https://www.arduino.cc/en/Reference/WireEndTransmission for values of this error.
<return>, the RTC has confidence in the date and time it returns. If this returns false it usually means the battery is dead or the date and time has never been set.
<return>, the actual clock is running on the RTC.
isRunning - set if the clock is running. If false then the time value will not progress.
dt - the date and time to set the RTC to.
<return>, the current date and time in the RTC.
piMode - the frequency to have the SquareWave pin pulse as. One of the following values:
- PCF8563SquareWavePinMode_None - disable the pin
- PCF8563SquareWavePinMode_32kHz - 32768 times per second
- PCF8563SquareWavePinMode_1kHz - 1024 times per second
- PCF8563SquareWavePinMode_32Hz - 32 times a second
- PCF8563SquareWavePinMode_1Hz - one per second
void SetAlarm(const PCF8563Alarm& alarm)
Set an alarm that is accurate to the minute with various modes. Repeats at the matching time elements. Will pulse the INT pin when alarm triggers.
alarm - a structure that defines all the properties to set the alarm.
Stops the alarm function.
Sets a timer that triggers on the given time elements. Repeats using the given time. Will pulse the INT pin when timer triggers.
mode - a enum that defines the time magnitude that the time arguments represents.
- PCF8563TimerMode_4096thOfASecond - 1/4096th of a second
- PCF8563TimerMode_64thOfASecond - 1/64th of a second
- PCF8563TimerMode_Seconds - seconds
- PCF8563TimerMode_Minutes - minutes, triggers at the top of the minute
time - (0-255) the number of time elements defined by mode to count down with
Example of setting a timer for every 60 seconds starting when you make this call:
rtc.SetTimer(PCF8563TimerMode_Seconds, 60);
Example of setting a timer for the top of every minute:
rtc.SetTimer(PCF8563TimerMode_Minutes, 1);
Stops the timer function.
This method must be called after an alarm is triggered otherwise it will not trigger again. It is used as a means to confirm you handled the alarm.
<return>, true if the alarm was active when this method is called.
This method must be called after a timer is triggered otherwise it will not trigger again. It is used as a means to confirm you handled the timer.
<return>, true if the timer was active when this method is called.
Tests the status of the alarm.
<return>, true if the alarm was active when this method is called.
Tests the status of the timer.
<return>, true if the timer was active when this method is called.