sensor data timestamp
This commit is contained in:
parent
088e0225ca
commit
9f740d8435
1 changed files with 8 additions and 0 deletions
|
@ -76,25 +76,33 @@ async fn init_sensors(mut hardware: SensorHardware) {
|
||||||
};
|
};
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
let mut updated = false;
|
||||||
POLL_STATE.store(PollState::Tof1 as u8, Ordering::SeqCst);
|
POLL_STATE.store(PollState::Tof1 as u8, Ordering::SeqCst);
|
||||||
if let Ok(dist) = tof.read_range_single_millimeters_blocking() {
|
if let Ok(dist) = tof.read_range_single_millimeters_blocking() {
|
||||||
info!("dist1: {dist}mm");
|
info!("dist1: {dist}mm");
|
||||||
data.tof1 = Some(dist);
|
data.tof1 = Some(dist);
|
||||||
|
updated = true;
|
||||||
}
|
}
|
||||||
Timer::after_millis(3).await;
|
Timer::after_millis(3).await;
|
||||||
POLL_STATE.store(PollState::Tof2 as u8, Ordering::SeqCst);
|
POLL_STATE.store(PollState::Tof2 as u8, Ordering::SeqCst);
|
||||||
if let Ok(dist) = tof2.read_range_single_millimeters_blocking() {
|
if let Ok(dist) = tof2.read_range_single_millimeters_blocking() {
|
||||||
info!("dist2: {dist}mm");
|
info!("dist2: {dist}mm");
|
||||||
data.tof2 = Some(dist);
|
data.tof2 = Some(dist);
|
||||||
|
updated = true;
|
||||||
}
|
}
|
||||||
Timer::after_millis(3).await;
|
Timer::after_millis(3).await;
|
||||||
POLL_STATE.store(PollState::Gyro as u8, Ordering::SeqCst);
|
POLL_STATE.store(PollState::Gyro as u8, Ordering::SeqCst);
|
||||||
if let Ok(gyro) = gyro.get_gyro() {
|
if let Ok(gyro) = gyro.get_gyro() {
|
||||||
info!("rotation: {gyro}");
|
info!("rotation: {gyro}");
|
||||||
data.gyro = Some(gyro);
|
data.gyro = Some(gyro);
|
||||||
|
updated = true;
|
||||||
}
|
}
|
||||||
if let Ok(accel) = gyro.get_acc() {
|
if let Ok(accel) = gyro.get_acc() {
|
||||||
data.accel = Some(accel);
|
data.accel = Some(accel);
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
if updated {
|
||||||
|
data.updated = Instant::now();
|
||||||
}
|
}
|
||||||
POLL_STATE.store(PollState::None as u8, Ordering::SeqCst);
|
POLL_STATE.store(PollState::None as u8, Ordering::SeqCst);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue