Changed the BMP280 default startup configuration and added a function allowing to change its working profile. This is used to get the best accuracy possible when using the altimeter app.

This commit is contained in:
anschrammh 2024-01-16 12:51:13 +01:00
parent fe41f1e5be
commit 97c6c4376e
2 changed files with 21 additions and 1 deletions

View File

@ -565,7 +565,7 @@ bool watch_peripherals_pressure_sensor_init(void)
else
APP_LOG_INFO("Inited BMP280");
if(!BMP280_configure(BMP280_Forced, BMP280_Oversampling_x2, BMP280_Oversampling_x16, BMP280_Filter_x4, BMP280_Standby_4000MS))
if(!BMP280_configure(BMP280_Forced, BMP280_Oversampling_x4, BMP280_Oversampling_x16, BMP280_Filter_OFF, BMP280_Standby_4000MS))
{
APP_LOG_ERROR("Failed to configure BMP280");
return false;
@ -576,6 +576,18 @@ bool watch_peripherals_pressure_sensor_init(void)
return true;
}
bool watch_peripherals_pressure_sensor_select_profile(watch_peripherals_pressure_sensor_profile_e profile)
{
switch(profile)
{
case WATCH_PERIPHERALS_PRESSURE_SENSOR_PROFILE_HIGH_PRECISION:
return BMP280_configure(BMP280_Forced, BMP280_Oversampling_x4, BMP280_Oversampling_x16, BMP280_Filter_x16, BMP280_Standby_4000MS);
case WATCH_PERIPHERALS_PRESSURE_SENSOR_PROFILE_LOW_POWER:
default:
return BMP280_configure(BMP280_Forced, BMP280_Oversampling_x4, BMP280_Oversampling_x16, BMP280_Filter_OFF, BMP280_Standby_4000MS);
}
}
float watch_peripherals_pressure_sensor_get_pressure(float * const temperature)
{
BMP280_trigger_measurement();

View File

@ -174,6 +174,14 @@ bool watch_peripherals_magnetometer_power_mode_set(QMC5883L_Mode_Control_e mode_
bool watch_peripherals_pressure_sensor_init(void);
typedef enum watch_peripherals_pressure_sensor_profile
{
WATCH_PERIPHERALS_PRESSURE_SENSOR_PROFILE_LOW_POWER = 0,
WATCH_PERIPHERALS_PRESSURE_SENSOR_PROFILE_HIGH_PRECISION,
} watch_peripherals_pressure_sensor_profile_e;
bool watch_peripherals_pressure_sensor_select_profile(watch_peripherals_pressure_sensor_profile_e profile);
float watch_peripherals_pressure_sensor_get_pressure(float * const temperature);
bool watch_peripherals_accelerometer_init(void);