Browse Source

AP_InertialSensor: don't skip delay if we are a bit early

this produces a bit more even timing
mission-4.1.18
Andrew Tridgell 10 years ago
parent
commit
04bef5ccf3
  1. 4
      libraries/AP_InertialSensor/AP_InertialSensor.cpp

4
libraries/AP_InertialSensor/AP_InertialSensor.cpp

@ -1072,9 +1072,7 @@ void AP_InertialSensor::wait_for_sample(void) @@ -1072,9 +1072,7 @@ void AP_InertialSensor::wait_for_sample(void)
if (_next_sample_usec - now <=_sample_period_usec) {
// we're ahead on time, schedule next sample at expected period
uint32_t wait_usec = _next_sample_usec - now;
if (wait_usec > 200) {
hal.scheduler->delay_microseconds(wait_usec);
}
hal.scheduler->delay_microseconds(wait_usec);
_next_sample_usec += _sample_period_usec;
} else if (now - _next_sample_usec < _sample_period_usec/8) {
// we've overshot, but only by a small amount, keep on

Loading…
Cancel
Save