d/vive_controller: Fix imu timestamp calculation

Philipp Zabel looked into it and it turns out the timestamp from the
imu sample should be the third byte, not the fourth.
This commit is contained in:
Christoph Haag 2020-07-02 00:39:07 +02:00
parent acdda780b6
commit 08c6fe9744
2 changed files with 4 additions and 4 deletions

View file

@ -652,7 +652,7 @@ vive_controller_handle_imu_sample(struct vive_controller_device *d,
struct watchman_imu_sample *sample)
{
/* ouvrt: "Time in 48 MHz ticks, but we are missing the low byte" */
uint32_t time_raw = d->last_ticks | sample->timestamp_lo;
uint32_t time_raw = d->last_ticks | (sample->timestamp_hi << 8);
uint32_t dt_raw = calc_dt_raw_and_handle_overflow(d, time_raw);
uint64_t dt_ns = cald_dt_ns(dt_raw);

View file

@ -185,9 +185,9 @@ struct watchman_imu_sample
* The full timestamp is 4 bytes, formed by
* first byte : vive_controller_message.timestamp_hi
* second byte: vive_controller_message.timestamp_lo
* fourth byte: watchman_imu_sample.timestamp_lo */
//! @todo: confirm timestamp_lo shouldn't be third byte instead.
uint8_t timestamp_lo;
* third byte: watchman_imu_sample.timestamp_hi
* fourth byte: remains zero */
uint8_t timestamp_hi;
uint16_t acc[3];
uint16_t gyro[3];
} __attribute__((packed));