mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-26 17:55:30 +03:00
fix barometer timing code
Delays between baro calls are modified to always take at least specified amount of time
This commit is contained in:
parent
988ae2d503
commit
a189d8e7fb
1 changed files with 3 additions and 2 deletions
|
@ -24,6 +24,7 @@
|
||||||
#include "common/maths.h"
|
#include "common/maths.h"
|
||||||
|
|
||||||
#include "drivers/barometer.h"
|
#include "drivers/barometer.h"
|
||||||
|
#include "drivers/system.h"
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
|
|
||||||
#include "sensors/barometer.h"
|
#include "sensors/barometer.h"
|
||||||
|
@ -104,8 +105,7 @@ void baroUpdate(uint32_t currentTime)
|
||||||
if ((int32_t)(currentTime - baroDeadline) < 0)
|
if ((int32_t)(currentTime - baroDeadline) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
baroDeadline = currentTime;
|
baroDeadline = 0;
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case BAROMETER_NEEDS_SAMPLES:
|
case BAROMETER_NEEDS_SAMPLES:
|
||||||
baro.get_ut();
|
baro.get_ut();
|
||||||
|
@ -127,6 +127,7 @@ void baroUpdate(uint32_t currentTime)
|
||||||
baroPressureSum = recalculateBarometerTotal(barometerConfig->baro_sample_count, baroPressureSum, baroPressure);
|
baroPressureSum = recalculateBarometerTotal(barometerConfig->baro_sample_count, baroPressureSum, baroPressure);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
baroDeadline += micros(); // make sure deadline is set after calling baro callbacks
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t baroCalculateAltitude(void)
|
int32_t baroCalculateAltitude(void)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue