Create empty BME280 driver
This commit is contained in:
25
src/main.c
25
src/main.c
@ -161,12 +161,11 @@ bool do_baro(struct mgos_barometer *sensor) {
|
||||
if (!sensor)
|
||||
return false;
|
||||
|
||||
if (mgos_barometer_get_pressure(sensor, &pressure)) {
|
||||
if (mgos_barometer_get_pressure(sensor, &pressure))
|
||||
LOG(LL_INFO, ("Pressure %.2fPa", pressure));
|
||||
}
|
||||
if (mgos_barometer_get_temperature(sensor, &temperature)) {
|
||||
|
||||
if (mgos_barometer_get_temperature(sensor, &temperature))
|
||||
LOG(LL_INFO, ("Temperature %.2fC", temperature));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -179,7 +178,7 @@ int main() {
|
||||
struct mgos_mcp9808 *mcp9808;
|
||||
struct mgos_ccs811 * ccs811;
|
||||
struct mgos_mpu9250 *mpu9250;
|
||||
struct mgos_barometer *baro;
|
||||
struct mgos_barometer *baro1, *baro2;
|
||||
|
||||
if (!mgos_i2c_open(I2CBUSNR)) {
|
||||
LOG(LL_ERROR, ("Cannot open I2C bus %u", I2CBUSNR));
|
||||
@ -215,10 +214,16 @@ int main() {
|
||||
mgos_mpu9250_set_magnetometer_speed(mpu9250, MAG_100_HZ);
|
||||
}
|
||||
*/
|
||||
if (!(baro=mgos_barometer_create_i2c(i2c, 0x60, BARO_MPL3115))) {
|
||||
if (!(baro1=mgos_barometer_create_i2c(i2c, 0x60, BARO_MPL3115))) {
|
||||
LOG(LL_ERROR, ("Cannot create barometer"));
|
||||
} else {
|
||||
mgos_barometer_set_cache_ttl(baro, 1000);
|
||||
mgos_barometer_set_cache_ttl(baro1, 1000);
|
||||
}
|
||||
|
||||
if (!(baro2=mgos_barometer_create_i2c(i2c, 0x76, BARO_BME280))) {
|
||||
LOG(LL_ERROR, ("Cannot create barometer"));
|
||||
} else {
|
||||
mgos_barometer_set_cache_ttl(baro2, 1000);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
@ -230,7 +235,8 @@ int main() {
|
||||
* do_ccs811(ccs811);
|
||||
* do_mpu9250(mpu9250);
|
||||
*/
|
||||
do_baro(baro);
|
||||
do_baro(baro1);
|
||||
do_baro(baro2);
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
@ -240,7 +246,8 @@ int main() {
|
||||
mgos_mcp9808_destroy(&mcp9808);
|
||||
mgos_ccs811_destroy(&ccs811);
|
||||
mgos_mpu9250_destroy(&mpu9250);
|
||||
mgos_barometer_destroy(&baro);
|
||||
mgos_barometer_destroy(&baro1);
|
||||
mgos_barometer_destroy(&baro2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user