- struct timeval t;
- gettimeofday(&t, NULL);
- // Record and save DataPoint
- DataPoint d = {TIMEVAL_DIFF(t, *Control_GetStartTime()), value};
- Data_Save(&(a->data_file), &d, 1);
+ struct timespec t;
+ clock_gettime(CLOCK_MONOTONIC, &t);
+ DataPoint d = {TIMEVAL_DIFF(t, *Control_GetStartTime()), a->last_setting.value};
+ // Record value change
+ if (record)
+ {
+ d.time_stamp -= 1e-6;
+ Data_Save(&(a->data_file), &d, 1);
+ d.value = value;
+ d.time_stamp += 1e-6;
+ Data_Save(&(a->data_file), &d, 1);
+ }
+ a->last_setting = d;