This allows alt_t to be overridden for systems using the MS5607/MS5611
sensors
Signed-off-by: Keith Packard <keithp@keithp.com>
* Convert between pressure in Pa and altitude in meters
*/
-int32_t
+#include <ao_data.h>
+
+alt_t
ao_pa_to_altitude(int32_t pa);
int32_t
-ao_altitude_to_pa(int32_t alt);
+ao_altitude_to_pa(alt_t alt);
#if HAS_DBG
#include <ao_dbg.h>
#define ALT_SCALE (1 << ALT_SHIFT)
#define ALT_MASK (ALT_SCALE - 1)
-int32_t
+alt_t
ao_pa_to_altitude(int32_t pa)
{
int16_t o;
o = pa >> ALT_SHIFT;
part = pa & ALT_MASK;
- low = (int32_t) altitude_table[o] * (ALT_SCALE - part);
- high = (int32_t) altitude_table[o+1] * part + (ALT_SCALE >> 1);
+ low = (alt_t) FETCH_ALT(o) * (ALT_SCALE - part);
+ high = (alt_t) FETCH_ALT(o+1) * part + (ALT_SCALE >> 1);
return (low + high) >> ALT_SHIFT;
}
#include <stdint.h>
#define AO_CONVERT_TEST
+typedef int32_t alt_t;
#include "ao_host.h"
#include "ao_convert_pa.c"
#define HAS_BARO 1
typedef int32_t pres_t;
-typedef int32_t alt_t;
+
+#ifndef AO_ALT_TYPE
+#define AO_ALT_TYPE int32_t
+#endif
+
+typedef AO_ALT_TYPE alt_t;
#define ao_data_pres_cook(packet) ao_ms5607_convert(&packet->ms5607_raw, &packet->ms5607_cooked)
#endif
+#if !HAS_BARO
+typedef int16_t alt_t;
+#endif
+
/*
* Need a few macros to pull data from the sensors:
*