honey_the_codewitch
Active member
I'm not sure where to put this, so here goes. I hope it's useful to someone.
I just figured out how to resolve the linker error with _gettimeofday() and to implement that function such that it will actually make std::chrono be able to do its job properly as well as link properly.
After adding this code to your main cpp, your actual std::chrono calls will function now rather than causing linker errors and not working.
I just figured out how to resolve the linker error with _gettimeofday() and to implement that function such that it will actually make std::chrono be able to do its job properly as well as link properly.
Code:
volatile uint64_t chrono_tick_count;
void chrono_tick() {
++chrono_tick_count;
}
IntervalTimer chrono_timer;
...
void setup() {
chrono_timer.begin(chrono_tick,1);
...
}
...
extern "C" {
int _gettimeofday( struct timeval *tv, void *tzvp )
{
// uptime in microseconds
uint64_t t;
noInterrupts();
t=chrono_tick_count;
interrupts();
tv->tv_sec = t / 1000000; // convert to seconds
tv->tv_usec = ( t % 1000000 ) ; // get remaining microseconds
return 0; // return non-zero for error
} // end _gettimeofday()
}
After adding this code to your main cpp, your actual std::chrono calls will function now rather than causing linker errors and not working.