Hi all,
Have modified the orbit demo to be a clock for those working with time as I couldn't see a code sample on the forum.
The key bit of code is here:
// calculate the new time, assume we get round in 32767 millisecs or 32.767 seconds!!!
n := ot; ot:=sys_Get(TIMER) & 0x7FFF;
if (n > ot) n := n - 32768;
millisecs := millisecs + ot - n;
// Have we got to a second?
while (millisecs > 999)
millisecs := millisecs - 1000;
if (!(seconds := (++seconds % 60)))
if (!(minutes := (++minutes % 60)))
(!(hours := (++hours % 12)))
endif
endif
wend
Cheers,
Tim
Attached files clock.4dg (5.3 KB)
Have modified the orbit demo to be a clock for those working with time as I couldn't see a code sample on the forum.
The key bit of code is here:
// calculate the new time, assume we get round in 32767 millisecs or 32.767 seconds!!!
n := ot; ot:=sys_Get(TIMER) & 0x7FFF;
if (n > ot) n := n - 32768;
millisecs := millisecs + ot - n;
// Have we got to a second?
while (millisecs > 999)
millisecs := millisecs - 1000;
if (!(seconds := (++seconds % 60)))
if (!(minutes := (++minutes % 60)))
(!(hours := (++hours % 12)))
endif
endif
wend
Cheers,
Tim
Attached files clock.4dg (5.3 KB)
Comment