Add Read Cache and Stats
- baro.cache_ttl_ms avoids multiple reads - by default, cache is off (cache_ttl_ms=0) - stats are updated (similar to how prometheus-sensors does this)
This commit is contained in:
@ -32,6 +32,7 @@ typedef bool (*mgos_barometer_mag_read_fn)(struct mgos_barometer *dev);
|
||||
struct mgos_barometer {
|
||||
struct mgos_i2c * i2c;
|
||||
uint8_t i2caddr;
|
||||
uint16_t cache_ttl_ms;
|
||||
enum mgos_barometer_type type;
|
||||
bool has_thermometer;
|
||||
bool has_barometer;
|
||||
@ -45,6 +46,8 @@ struct mgos_barometer {
|
||||
|
||||
float pressure; // in Pascals
|
||||
float temperature; // in Celcius
|
||||
|
||||
struct mgos_barometer_stats stats;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
Reference in New Issue
Block a user