change system time function to UNIX time
This commit is contained in:
@@ -51,17 +51,18 @@ static mcc_errcodes_t shortcmd(short_command_t *cmd);
|
||||
* @return time in seconds
|
||||
*/
|
||||
double nanotime(){
|
||||
static struct timespec *start = NULL;
|
||||
//static struct timespec *start = NULL;
|
||||
struct timespec now;
|
||||
if(!start){
|
||||
/*if(!start){
|
||||
start = malloc(sizeof(struct timespec));
|
||||
if(!start) return -1.;
|
||||
if(clock_gettime(CLOCK_MONOTONIC, start)) return -1.;
|
||||
}
|
||||
}*/
|
||||
if(clock_gettime(CLOCK_MONOTONIC, &now)) return -1.;
|
||||
double nd = ((double)now.tv_nsec - (double)start->tv_nsec) * 1e-9;
|
||||
/*double nd = ((double)now.tv_nsec - (double)start->tv_nsec) * 1e-9;
|
||||
double sd = (double)now.tv_sec - (double)start->tv_sec;
|
||||
return sd + nd;
|
||||
return sd + nd;*/
|
||||
return (double)now.tv_sec + (double)now.tv_nsec * 1e-9;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +76,7 @@ static void quit(){
|
||||
DBG("Exit");
|
||||
}
|
||||
|
||||
void getModData(coordval_pair_t *c){
|
||||
void getModData(coordval_pair_t *c, movestate_t *xst, movestate_t *yst){
|
||||
if(!c || !Xmodel || !Ymodel) return;
|
||||
double tnow = nanotime();
|
||||
moveparam_t Xp, Yp;
|
||||
@@ -87,6 +88,8 @@ void getModData(coordval_pair_t *c){
|
||||
c->X.t = c->Y.t = tnow;
|
||||
c->X.val = Xp.coord;
|
||||
c->Y.val = Yp.coord;
|
||||
if(xst) *xst = Xst;
|
||||
if(yst) *yst = Yst;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user