From 8ddade934e965e19b760cdde4eb8ecadf6abf70c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 2 Aug 2020 12:51:16 -0700 Subject: [PATCH] altos/drivers: Add ao_adxl375_accel_to_sample macro This converts from acceleration levels to sample counts for use in detecting stability of airframe after landing when no other IMU is present. Signed-off-by: Keith Packard --- src/drivers/ao_adxl375.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/drivers/ao_adxl375.h b/src/drivers/ao_adxl375.h index a1ed216d..fe448fd0 100644 --- a/src/drivers/ao_adxl375.h +++ b/src/drivers/ao_adxl375.h @@ -93,6 +93,8 @@ #define AO_ADXL375_FIFO_STATUS 0x39 +#define ADXL375_ACCEL_FULLSCALE 200 + struct ao_adxl375_sample { int16_t x; int16_t y; @@ -101,6 +103,8 @@ struct ao_adxl375_sample { extern struct ao_adxl375_sample ao_adxl375_current; +#define ao_adxl375_accel_to_sample(accel) ((accel_t) (accel) * (4095.0f / (ADXL375_ACCEL_FULLSCALE * GRAVITY))) + void ao_adxl375_init(void); -- 2.30.2