8 #include "simpletools.h" 11 static volatile int dt_sec;
12 static volatile int dt_ticks;
13 static volatile int dt_cog = 0;
14 static volatile int dt_ets_sys;
16 static int stack[174+20];
18 void secondctr(
void *par)
20 dt_ets_sys = (int) par;
45 dt_cog = 1 + cogstart(secondctr, (
int*) et, stack,
sizeof(stack));
60 int t = dt_ticks - CLKFREQ;
61 return (cnt - t) / (CLKFREQ / 1000);
void dt_end()
Stop a date/time second counting process and recover the cog and lock.
datetime dt_get()
Get the current system time. To find the current system time (as a datetime type), call this function. Note: This assumes that a call to dt_run has been made. This is common near the beginning of a program that uses the system timekeeping.
void dt_run(datetime dt)
Run a date/time second counting process in another cog. Example: datetime dts = {2015, 9, 25, 8, 11, 04}; dt_run(dts);.
int dt_getms()
Get the number of ms into the current second from the system time second. Notes: This assumes that a ...
int dt_toEt(datetime dt)
Get the Unix epoch time (number of seconds from Midnight, 1/1/1970) from a datetime type...
< datetime_st Structure containing y, mo, h, m, and s elements.
This library provides convenient functions for a variety of timekeeping operations. This library makes use of a manual Spin to C translation of functions from Bob Belleville's date_time_epoch.spin for converting to/from between epoch time (seconds from midnight, 1/1/1970) and a datetime format.
datetime dt_fromEt(int et)
Get the datetime representation of an a Unix epoch time (number of seconds from Midnight, 1/1/1970).
void dt_set(datetime dt)
Set the system date and time. This can be used to change the system's current date/time. Example datetime mydt={2015, 9, 25, 8, 13, 51}; dt_set(mydt); You can also use this to change the datetime type that was used in dt_start to "set" the second counter that auto-increments.