Redid formula for calculating subticks

changed subticks calculation to give a range from 0 to 32767.
This commit is contained in:
DavePutz 2020-06-09 10:08:49 -05:00 committed by GitHub
parent d8bb2d7c6d
commit ec7a3feeba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -119,11 +119,11 @@ uint64_t port_get_raw_ticks(uint8_t* subticks) {
struct timeval tv_now;
gettimeofday(&tv_now, NULL);
// convert usec back to ticks
uint64_t all_subticks = (uint64_t)tv_now.tv_usec / 1024;
uint64_t all_subticks = (uint64_t)(tv_now.tv_usec * 2) / 71;
if (subticks != NULL) {
*subticks = all_subticks % 32;
}
return (uint64_t)tv_now.tv_sec * 1024L + all_subticks;
return (uint64_t)tv_now.tv_sec * 1024L + all_subticks / 32;
}
// Enable 1/1024 second tick.