Article # 44, added by Geoworks, historical record
| first | previous | index | next | last |

Real-time timers




Question:
How do I set real-time timers using TimerStart?

Answer:
TIMER_EVENT_REAL_TIME starts a real-time clock on the device that will
send a message at some particular date and time. You pass the date that
the event should happen in the "ticks" parameter and the time of day in
the "interval" parameter of TimerStart. 
 
The date is stored in a compressed format that is word-sized. The year
(since 1980) is in the high 7 bits, the month is in the next 4 bits, and
the day is in the low 5-bits. 

The hour is stored in the high byte of "interval" and the minute is stored
in the low byte of "interval. 

For example, if I wanted to have a wakeup notification sent on March 5,
1996 at 8:05am, I would set up the "ticks" and "interval" parameter as
follows: 

    ticks = 0x2065;
     (year  = 1996-1980 = 16 = 0x10,  0x10 << 9 = 0x2000
      month = 3,                      0x03 << 5 = 0x0060
      day   = 5,                      0x05 << 0 = 0x0005)

    interval = 0x0805;

By the way, another option is to use the Real-Time Clock Manager library
of GEOS. Search on RTCM to find the documentation on the RTCM functions.
Also, check out the OmniGo Alarm Clock program, available from
http://members.aol.com/nfiedler/software.html, which uses RTCM and comes
with the source code.