The Date and Time Service

ravinrabbid edited this page Jan 19, 2012 · 1 revision
Clone this wiki locally

The Date and Time Service makes the current time of the day available on the Hexabus device.

Because the internal clock of the Atmega is rather imprecise, the time hast be updated every once in a while. By default this is every 5 minutes, but can be configured in the datetime_service.h. At the moment updating the time is done via hexaswitch: hexaswitch send 0 4 -1 to broadcast the current system time or hexaswitch send 0 4 x where x is an UNIX timestamp.

The use the current time on the Hexabus device, use getDatetime(). This function takes a pointer to a datetime struct, which contains separate fields for second,minute,hour,day,month,year and weekday, and fills it. It also returns 0 is the time has been updated regularly or -1 if not.