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:
Pim van Pelt
2018-04-21 15:39:57 +02:00
parent 89ec34dc1d
commit 9d9cd1d00a
5 changed files with 57 additions and 1 deletions

View File

@ -217,6 +217,8 @@ int main() {
*/
if (!(baro=mgos_barometer_create_i2c(i2c, 0x60, BARO_MPL115))) {
LOG(LL_ERROR, ("Cannot create MPL115 barometer"));
} else {
mgos_barometer_set_cache_ttl(baro, 5000);
}
for (;;) {