MHVLib
20111011
An efficiency oriented runtime library for AVR microcontrollers
|
#include <MHV_RTC.h>
Public Member Functions | |
MHV_RTC (MHV_Timer8 *timer, MHV_ALARM *eventBuffer, uint8_t eventCount, int16_t timezone) | |
void | synchronise () |
void | setTime (uint32_t timestamp, uint16_t milliseconds) |
void | setTime (MHV_TIMESTAMP *timestamp) |
void | tick () |
void | tick1ms () |
void | tickAndRunEvents () |
void | tick1msAndRunEvents () |
void | current (MHV_TIMESTAMP *timestamp) |
void | elapsed (MHV_TIMESTAMP *since, MHV_TIMESTAMP *elapsed) |
void | toTime (MHV_TIME *to, MHV_TIMESTAMP *from) |
void | toTimestamp (MHV_TIMESTAMP *to, MHV_TIME *from) |
bool | addAlarm (MHV_ALARM *alarm) |
void | handleEvents () |
uint8_t | alarmsPending () |
void | removeAlarm (MHV_AlarmListener *listener) |
Protected Attributes | |
MHV_Timer8 * | _timer |
MHV_ALARM * | _alarms |
volatile uint8_t | _alarmCount |
uint8_t | _alarmMax |
uint32_t | _timestamp |
uint16_t | _milliseconds |
uint8_t | _ticks |
uint8_t | _ticksPerMillisecond |
int16_t | _tzOffset |
MHV_RTC::MHV_RTC | ( | MHV_Timer8 * | timer, |
MHV_ALARM * | eventBuffer, | ||
uint8_t | eventCount, | ||
int16_t | timezone | ||
) |
Create a new RTC
timer | the timer this RTC is associated with |
eventBuffer | A buffer to store events until they are executed |
eventCount | The number of events that can be stored in the buffer |
timezone | minutes offset from UTC |
Definition at line 167 of file MHV_RTC.cpp.
bool MHV_RTC::addAlarm | ( | MHV_ALARM * | alarm | ) |
Insert an alarm, to be triggered at a later date
alarm | the alarm, consisting of: when it should be triggered what should be called (it will be passed a pointer to the event) a pointer to user-defined data |
Definition at line 443 of file MHV_RTC.cpp.
uint8_t MHV_RTC::alarmsPending | ( | ) |
How many events are left in the queue
Definition at line 508 of file MHV_RTC.cpp.
void MHV_RTC::current | ( | MHV_TIMESTAMP * | timestamp | ) |
Get the current timestamp
Definition at line 276 of file MHV_RTC.cpp.
void MHV_RTC::elapsed | ( | MHV_TIMESTAMP * | since, |
MHV_TIMESTAMP * | elapsed | ||
) |
Determine how long has elapsed since the supplied timestamp
since | the timestamp to measure against |
elapsed | returns how much time has elapsed |
Definition at line 289 of file MHV_RTC.cpp.
void MHV_RTC::handleEvents | ( | void | ) |
Check for events that are due, and run them Run this from your main loop if you have no blocking calls, otherwise, call tickAndRunEvents instead of tick from the timer (note that this will run your events in the interrupt handler, so keep them short!)
Definition at line 474 of file MHV_RTC.cpp.
void MHV_RTC::removeAlarm | ( | MHV_AlarmListener * | listener | ) |
Remove all matching events from the list of pending events
listener | the listener for the event to remove |
Definition at line 516 of file MHV_RTC.cpp.
void MHV_RTC::setTime | ( | uint32_t | timestamp, |
uint16_t | milliseconds | ||
) |
Set the current time
timestamp | the current Unix timestamp |
milliseconds | the current milliseconds offset |
Definition at line 195 of file MHV_RTC.cpp.
void MHV_RTC::setTime | ( | MHV_TIMESTAMP * | timestamp | ) |
Set the current time
timestamp | the current Unix timestamp |
Definition at line 206 of file MHV_RTC.cpp.
void MHV_RTC::synchronise | ( | void | ) |
Synchronise the ticksPerMillisecond with the timer (useful if you change the timer values)
Definition at line 185 of file MHV_RTC.cpp.
void MHV_RTC::tick | ( | void | ) |
Tick from the timer module
Definition at line 217 of file MHV_RTC.cpp.
void MHV_RTC::tick1ms | ( | void | ) |
Tick from the timer module that is exactly 1ms
Definition at line 234 of file MHV_RTC.cpp.
void MHV_RTC::tick1msAndRunEvents | ( | void | ) |
Tick from the timer module that is exactly 1ms, run any pending events
Definition at line 264 of file MHV_RTC.cpp.
void MHV_RTC::tickAndRunEvents | ( | void | ) |
Tick from the timer module, and run any pending events
Definition at line 245 of file MHV_RTC.cpp.
void MHV_RTC::toTime | ( | MHV_TIME * | to, |
MHV_TIMESTAMP * | from | ||
) |
Convert a timestamp into year,month,day,hours,minutes,seconds
to | the MHV_TIME to store the results |
from | the MHV_TIMESTAMP struct to convert from |
Definition at line 327 of file MHV_RTC.cpp.
void MHV_RTC::toTimestamp | ( | MHV_TIMESTAMP * | to, |
MHV_TIME * | from | ||
) |
Convert year,month,day,hours,minutes,seconds into a timestamp
to | the MHV_TIMESTAMP to store the results |
from | the MHV_TIME struct to convert from |
Definition at line 396 of file MHV_RTC.cpp.
volatile uint8_t MHV_RTC::_alarmCount [protected] |
uint8_t MHV_RTC::_alarmMax [protected] |
MHV_ALARM* MHV_RTC::_alarms [protected] |
uint16_t MHV_RTC::_milliseconds [protected] |
uint8_t MHV_RTC::_ticks [protected] |
uint8_t MHV_RTC::_ticksPerMillisecond [protected] |
MHV_Timer8* MHV_RTC::_timer [protected] |
uint32_t MHV_RTC::_timestamp [protected] |
int16_t MHV_RTC::_tzOffset [protected] |