ao-tools/ao-eeprom: Add altitude data for baro values
authorKeith Packard <keithp@keithp.com>
Tue, 16 Jul 2019 16:57:24 +0000 (09:57 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 16 Jul 2019 16:57:24 +0000 (09:57 -0700)
Displays altitude along with pressure and temp for baro sensor data.

Signed-off-by: Keith Packard <keithp@keithp.com>
ao-tools/ao-eeprom/Makefile.am
ao-tools/ao-eeprom/ao-eeprom.c

index d4aca00..1e38eba 100644 (file)
@@ -5,7 +5,7 @@ AO_EEPROM_LIBS=$(top_builddir)/ao-tools/lib/libao-tools.a
 
 ao_eeprom_DEPENDENCIES = $(AO_EEPROM_LIBS)
 
-ao_eeprom_LDADD=$(AO_EEPROM_LIBS) -ljson-c
+ao_eeprom_LDADD=$(AO_EEPROM_LIBS) -ljson-c -lm
 
 ao_eeprom_SOURCES = ao-eeprom.c
 
index 0c0500f..0a4db82 100644 (file)
@@ -22,6 +22,7 @@
 #include <unistd.h>
 #include <getopt.h>
 #include <ao-eeprom-read.h>
+#include <ao-atmosphere.h>
 
 static const struct option options[] = {
        { .name = "raw", .has_arg = 0, .val = 'r' },
@@ -55,11 +56,12 @@ ao_ms5607(uint32_t pres, uint32_t temp, struct ao_eeprom *eeprom, bool is_ms5611
 
        ao_ms5607_convert(&ms5607_sample, &ms5607_value,
                          &eeprom->ms5607_prom, is_ms5611);
-       printf(" pres %9u temp %9u (%7.3f kPa %6.2f°C)",
+       printf(" pres %9u temp %9u (%7.3f kPa %6.2f°C %7.1f m)",
               pres,
               temp,
               ms5607_value.pres / 1000.0,
-              ms5607_value.temp / 100.0);
+              ms5607_value.temp / 100.0,
+              ao_pressure_to_altitude(ms5607_value.pres));
 }
 
 #define GRAVITY 9.80665