MHVLib  20111227
An efficiency oriented runtime library for AVR microcontrollers
MHV_RTC Class Reference

#include <MHV_RTC.h>

List of all members.

Public Member Functions

 MHV_RTC (MHV_ALARM eventBuffer[], uint8_t eventCount, int16_t timezone)
 MHV_RTC (MHV_ALARM eventBuffer[], uint8_t eventCount)
void synchronise (MHV_Timer8 &_timer)
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)
void removeAlarm (MHV_AlarmListener *listener)

Protected Attributes

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

Detailed Description

Definition at line 122 of file MHV_RTC.h.


Constructor & Destructor Documentation

MHV_RTC::MHV_RTC ( MHV_ALARM  eventBuffer[],
uint8_t  eventCount,
int16_t  timezone 
)

Create a new RTC

Parameters:
eventBufferA buffer to store events until they are executed
eventCountThe number of events that can be stored in the buffer
timezoneminutes offset from UTC

Definition at line 166 of file MHV_RTC.cpp.

MHV_RTC::MHV_RTC ( MHV_ALARM  eventBuffer[],
uint8_t  eventCount 
)

Create a new RTC

Parameters:
eventBufferA buffer to store events until they are executed
eventCountThe number of events that can be stored in the buffer

Definition at line 182 of file MHV_RTC.cpp.


Member Function Documentation

bool MHV_RTC::addAlarm ( MHV_ALARM *  alarm)

Insert an alarm, to be triggered at a later date

Parameters:
alarmthe 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
Returns:
true if the event could not be added

Definition at line 450 of file MHV_RTC.cpp.

uint8_t MHV_RTC::alarmsPending ( )

How many events are left in the queue

Returns:
the number of events

Definition at line 515 of file MHV_RTC.cpp.

void MHV_RTC::current ( MHV_TIMESTAMP *  timestamp)

Get the current timestamp

Definition at line 283 of file MHV_RTC.cpp.

void MHV_RTC::elapsed ( MHV_TIMESTAMP *  since,
MHV_TIMESTAMP *  elapsed 
)

Determine how long has elapsed since the supplied timestamp

Parameters:
sincethe timestamp to measure against
elapsedreturns how much time has elapsed

Definition at line 296 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 481 of file MHV_RTC.cpp.

void MHV_RTC::removeAlarm ( MHV_AlarmListener &  listener)

Remove all matching events from the list of pending events

Parameters:
listenerthe listener for the event to remove

Definition at line 523 of file MHV_RTC.cpp.

void MHV_RTC::removeAlarm ( MHV_AlarmListener *  listener)

Remove all matching events from the list of pending events

Parameters:
listenerthe listener for the event to remove

Definition at line 540 of file MHV_RTC.cpp.

void MHV_RTC::setTime ( uint32_t  timestamp,
uint16_t  milliseconds 
)

Set the current time

Parameters:
timestampthe current Unix timestamp
millisecondsthe current milliseconds offset

Definition at line 207 of file MHV_RTC.cpp.

void MHV_RTC::setTime ( MHV_TIMESTAMP *  timestamp)

Set the current time

Parameters:
timestampthe current Unix timestamp

Definition at line 218 of file MHV_RTC.cpp.

void MHV_RTC::synchronise ( MHV_Timer8 &  timer)

Synchronise the ticksPerMillisecond with the timer (useful if you change the timer values)

Parameters:
timerthe timer to sync with

Definition at line 197 of file MHV_RTC.cpp.

void MHV_RTC::tick ( void  )

Tick from the timer module

Definition at line 240 of file MHV_RTC.cpp.

void MHV_RTC::tick1ms ( void  )

Tick from the timer module that is exactly 1ms

Definition at line 253 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 275 of file MHV_RTC.cpp.

void MHV_RTC::tickAndRunEvents ( void  )

Tick from the timer module, and run any pending events

Definition at line 260 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

Parameters:
tothe MHV_TIME to store the results
fromthe MHV_TIMESTAMP struct to convert from

Definition at line 334 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

Parameters:
tothe MHV_TIMESTAMP to store the results
fromthe MHV_TIME struct to convert from

Definition at line 403 of file MHV_RTC.cpp.


Member Data Documentation

volatile uint8_t MHV_RTC::_alarmCount [protected]

Definition at line 128 of file MHV_RTC.h.

uint8_t MHV_RTC::_alarmMax [protected]

Definition at line 129 of file MHV_RTC.h.

Definition at line 127 of file MHV_RTC.h.

uint16_t MHV_RTC::_milliseconds [protected]

Definition at line 131 of file MHV_RTC.h.

uint8_t MHV_RTC::_ticks [protected]

Definition at line 132 of file MHV_RTC.h.

uint8_t MHV_RTC::_ticksPerMillisecond [protected]

Definition at line 133 of file MHV_RTC.h.

uint32_t MHV_RTC::_timestamp [protected]

Definition at line 130 of file MHV_RTC.h.

int16_t MHV_RTC::_tzOffset [protected]

Definition at line 134 of file MHV_RTC.h.


The documentation for this class was generated from the following files: