Include first driver: SHT31
Make I2C reads blocking w/ timeout Add SHT31 driver, roughly :) Fix mg_time() to return a double.
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
*/
|
||||
|
||||
#include "mgos_mock.h"
|
||||
#include <unistd.h>
|
||||
|
||||
int _mgos_timers = 0;
|
||||
|
||||
@ -31,14 +32,18 @@ int log_print_prefix(enum cs_log_level l, const char *func, const char *file) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
float mg_time() {
|
||||
struct timeval tod;
|
||||
float time;
|
||||
double mg_time() {
|
||||
struct timespec ts;
|
||||
double ret;
|
||||
|
||||
gettimeofday(&tod, NULL);
|
||||
clock_gettime(CLOCK_REALTIME_COARSE, &ts);
|
||||
|
||||
time = tod.tv_sec;
|
||||
time += tod.tv_usec/1000000;
|
||||
ret = (double) ts.tv_sec;
|
||||
ret += ((double)ts.tv_nsec)/1000000000;
|
||||
|
||||
return time;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void mgos_usleep(uint32_t usecs) {
|
||||
usleep(usecs);
|
||||
}
|
||||
|
Reference in New Issue
Block a user