MHVLib  20111011
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_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

Detailed Description

Definition at line 102 of file MHV_RTC.h.


Constructor & Destructor Documentation

MHV_RTC::MHV_RTC ( MHV_Timer8 timer,
MHV_ALARM eventBuffer,
uint8_t  eventCount,
int16_t  timezone 
)

Create a new RTC

Parameters:
timerthe timer this RTC is associated with
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 167 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 443 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 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

Parameters:
sincethe timestamp to measure against
elapsedreturns 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

Parameters:
listenerthe 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

Parameters:
timestampthe current Unix timestamp
millisecondsthe current milliseconds offset

Definition at line 195 of file MHV_RTC.cpp.

void MHV_RTC::setTime ( MHV_TIMESTAMP timestamp)

Set the current time

Parameters:
timestampthe 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

Parameters:
tothe MHV_TIME to store the results
fromthe 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

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

Definition at line 396 of file MHV_RTC.cpp.


Member Data Documentation

volatile uint8_t MHV_RTC::_alarmCount [protected]

Definition at line 106 of file MHV_RTC.h.

uint8_t MHV_RTC::_alarmMax [protected]

Definition at line 107 of file MHV_RTC.h.

Definition at line 105 of file MHV_RTC.h.

uint16_t MHV_RTC::_milliseconds [protected]

Definition at line 109 of file MHV_RTC.h.

uint8_t MHV_RTC::_ticks [protected]

Definition at line 110 of file MHV_RTC.h.

uint8_t MHV_RTC::_ticksPerMillisecond [protected]

Definition at line 111 of file MHV_RTC.h.

Definition at line 104 of file MHV_RTC.h.

uint32_t MHV_RTC::_timestamp [protected]

Definition at line 108 of file MHV_RTC.h.

int16_t MHV_RTC::_tzOffset [protected]

Definition at line 112 of file MHV_RTC.h.


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