Browse Source

tfmini: reduce sampling rate from 10kHz to 143Hz

10kHz sampling seems excessive, given that the sensor is expected to output
at 100Hz.

Also don't reschedule immediately in case we have not received any data.
sbg
Beat Küng 5 years ago committed by Daniel Agar
parent
commit
336745f9f7
  1. 8
      src/drivers/distance_sensor/tfmini/TFMINI.cpp

8
src/drivers/distance_sensor/tfmini/TFMINI.cpp

@ -168,7 +168,7 @@ TFMINI::collect() @@ -168,7 +168,7 @@ TFMINI::collect()
if (!bytes_available) {
perf_end(_sample_perf);
return -EAGAIN;
return 0;
}
// parse entire buffer
@ -223,8 +223,8 @@ TFMINI::collect() @@ -223,8 +223,8 @@ TFMINI::collect()
void
TFMINI::start()
{
// schedule a cycle to start things
ScheduleOnInterval(100_us);
// schedule a cycle to start things (the sensor sends at 100Hz, but we run a bit faster to avoid missing data)
ScheduleOnInterval(7_ms);
}
void
@ -246,7 +246,7 @@ TFMINI::Run() @@ -246,7 +246,7 @@ TFMINI::Run()
if (collect() == -EAGAIN) {
// reschedule to grab the missing bits, time to transmit 9 bytes @ 115200 bps
ScheduleClear();
ScheduleOnInterval(100_us, 87 * 9);
ScheduleOnInterval(7_ms, 87 * 9);
return;
}
}

Loading…
Cancel
Save