From b430bf86cb9757c99f80f7ef12512840bfa336bd Mon Sep 17 00:00:00 2001 From: lilian Date: Thu, 15 Sep 2016 10:42:58 +0200 Subject: [PATCH] bmp280 more options add option to user for temp oversampling and possibility to skipp a specific measure --- extras/bmp280/bmp280.c | 8 +++----- extras/bmp280/bmp280.h | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/extras/bmp280/bmp280.c b/extras/bmp280/bmp280.c index ab81dae..83fdfe0 100644 --- a/extras/bmp280/bmp280.c +++ b/extras/bmp280/bmp280.c @@ -60,7 +60,8 @@ void bmp280_init_default_params(bmp280_params_t *params) { params->mode = BMP280_MODE_NORMAL; params->filter = BMP280_FILTER_OFF; - params->oversampling = BMP280_STANDARD; + params->oversampling_pressure = BMP280_STANDARD; + params->oversampling_temperature = BMP280_STANDARD ; params->oversampling_humidity = BMP280_STANDARD; params->standby = BMP280_STANDBY_250; } @@ -194,14 +195,11 @@ bool bmp280_init(bmp280_t *dev, bmp280_params_t *params) return false; } - uint8_t oversampling_temp = - (params->oversampling == BMP280_ULTRA_HIGH_RES) ? 2 : 1; - if (params->mode == BMP280_MODE_FORCED) { params->mode = BMP280_MODE_SLEEP; // initial mode for forced is sleep } - uint8_t ctrl = (oversampling_temp << 5) | (params->oversampling << 2) + uint8_t ctrl = (params->oversampling_temperature << 5) | (params->oversampling_pressure << 2) | (params->mode); diff --git a/extras/bmp280/bmp280.h b/extras/bmp280/bmp280.h index 8a43ad0..84dc869 100644 --- a/extras/bmp280/bmp280.h +++ b/extras/bmp280/bmp280.h @@ -65,6 +65,7 @@ typedef enum { * Pressure oversampling settings */ typedef enum { + BMP280_SKIPPED = 0, /* no measurement */ BMP280_ULTRA_LOW_POWER = 1, /* oversampling x1 */ BMP280_LOW_POWER = 2, /* oversampling x2 */ BMP280_STANDARD = 3, /* oversampling x4 */ @@ -94,6 +95,7 @@ typedef struct { BMP280_Mode mode; BMP280_Filter filter; BMP280_Oversampling oversampling; // pressure oversampling + BMP280_Oversampling oversampling_temperature; // temperature oversampling BMP280_Oversampling oversampling_humidity; BMP280_StandbyTime standby; } bmp280_params_t;