mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 16:25:31 +03:00
Rename 'altimeter' related files to 'barometer' since GPS and other
sensors handle altitude too - requested by @treymarc
This commit is contained in:
parent
c658e31b62
commit
d4ebd8a748
9 changed files with 8 additions and 8 deletions
47
src/sensors_barometer.c
Normal file
47
src/sensors_barometer.c
Normal file
|
@ -0,0 +1,47 @@
|
|||
#include "board.h"
|
||||
#include "mw.h"
|
||||
|
||||
#ifdef BARO
|
||||
void Baro_Common(void)
|
||||
{
|
||||
static int32_t baroHistTab[BARO_TAB_SIZE_MAX];
|
||||
static int baroHistIdx;
|
||||
int indexplus1;
|
||||
|
||||
indexplus1 = (baroHistIdx + 1);
|
||||
if (indexplus1 == cfg.baro_tab_size)
|
||||
indexplus1 = 0;
|
||||
baroHistTab[baroHistIdx] = baroPressure;
|
||||
baroPressureSum += baroHistTab[baroHistIdx];
|
||||
baroPressureSum -= baroHistTab[indexplus1];
|
||||
baroHistIdx = indexplus1;
|
||||
}
|
||||
|
||||
|
||||
int Baro_update(void)
|
||||
{
|
||||
static uint32_t baroDeadline = 0;
|
||||
static int state = 0;
|
||||
|
||||
if ((int32_t)(currentTime - baroDeadline) < 0)
|
||||
return 0;
|
||||
|
||||
baroDeadline = currentTime;
|
||||
|
||||
if (state) {
|
||||
baro.get_up();
|
||||
baro.start_ut();
|
||||
baroDeadline += baro.ut_delay;
|
||||
baro.calculate(&baroPressure, &baroTemperature);
|
||||
state = 0;
|
||||
return 2;
|
||||
} else {
|
||||
baro.get_ut();
|
||||
baro.start_up();
|
||||
Baro_Common();
|
||||
state = 1;
|
||||
baroDeadline += baro.up_delay;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif /* BARO */
|
Loading…
Add table
Add a link
Reference in a new issue