Bmp280 option (#220)

* bmp280 more options
add option to user for temp oversampling and possibility to skipp a specific measure

* Update bmp280.h

* quick fix oups

* less redundant terms
This commit is contained in:
Zaltora 2016-11-23 16:16:03 +01:00 committed by sheinz
parent 6bd2d15d23
commit 0d9094e443
2 changed files with 6 additions and 6 deletions

View file

@ -60,7 +60,8 @@ void bmp280_init_default_params(bmp280_params_t *params)
{ {
params->mode = BMP280_MODE_NORMAL; params->mode = BMP280_MODE_NORMAL;
params->filter = BMP280_FILTER_OFF; 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->oversampling_humidity = BMP280_STANDARD;
params->standby = BMP280_STANDBY_250; params->standby = BMP280_STANDBY_250;
} }
@ -194,14 +195,11 @@ bool bmp280_init(bmp280_t *dev, bmp280_params_t *params)
return false; return false;
} }
uint8_t oversampling_temp =
(params->oversampling == BMP280_ULTRA_HIGH_RES) ? 2 : 1;
if (params->mode == BMP280_MODE_FORCED) { if (params->mode == BMP280_MODE_FORCED) {
params->mode = BMP280_MODE_SLEEP; // initial mode for forced is sleep 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); | (params->mode);

View file

@ -69,6 +69,7 @@ typedef enum {
* Pressure oversampling settings * Pressure oversampling settings
*/ */
typedef enum { typedef enum {
BMP280_SKIPPED = 0, /* no measurement */
BMP280_ULTRA_LOW_POWER = 1, /* oversampling x1 */ BMP280_ULTRA_LOW_POWER = 1, /* oversampling x1 */
BMP280_LOW_POWER = 2, /* oversampling x2 */ BMP280_LOW_POWER = 2, /* oversampling x2 */
BMP280_STANDARD = 3, /* oversampling x4 */ BMP280_STANDARD = 3, /* oversampling x4 */
@ -97,7 +98,8 @@ typedef enum {
typedef struct { typedef struct {
BMP280_Mode mode; BMP280_Mode mode;
BMP280_Filter filter; BMP280_Filter filter;
BMP280_Oversampling oversampling; // pressure oversampling BMP280_Oversampling oversampling_pressure;
BMP280_Oversampling oversampling_temperature;
BMP280_Oversampling oversampling_humidity; BMP280_Oversampling oversampling_humidity;
BMP280_StandbyTime standby; BMP280_StandbyTime standby;
} bmp280_params_t; } bmp280_params_t;