Add mgos_barometer API

This commit is contained in:
Pim van Pelt
2018-04-21 15:17:24 +02:00
parent acec109ae8
commit 89ec34dc1d
7 changed files with 324 additions and 1 deletions

54
include/mgos_barometer.h Normal file
View File

@ -0,0 +1,54 @@
/*
* Copyright 2018 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "mgos.h"
#include "mgos_i2c.h"
#ifdef __cplusplus
extern "C" {
#endif
enum mgos_barometer_type {
BARO_NONE = 0,
BARO_MPL115
};
struct mgos_barometer;
struct mgos_barometer *mgos_barometer_create_i2c(struct mgos_i2c *i2c, uint8_t i2caddr, enum mgos_barometer_type type);
void mgos_barometer_destroy(struct mgos_barometer **sensor);
bool mgos_barometer_has_thermometer(struct mgos_barometer *sensor);
bool mgos_barometer_has_barometer(struct mgos_barometer *sensor);
/* Read all available sensor data from the IMU */
bool mgos_barometer_read(struct mgos_barometer *sensor);
/* Return barometer data in units of Pascals */
bool mgos_barometer_get_pressure(struct mgos_barometer *sensor, float *p);
/* Return temperature data in units of Celcius */
bool mgos_barometer_get_temperature(struct mgos_barometer *sensor, float *t);
/*
* Initialization function for MGOS -- currently a noop.
*/
bool mgos_barometer_init(void);
#ifdef __cplusplus
}
#endif