From: Keith Packard Date: Sun, 2 Aug 2020 19:51:16 +0000 (-0700) Subject: altos/drivers: Add ao_adxl375_accel_to_sample macro X-Git-Tag: 1.9.6~1^2~39 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=8ddade934e965e19b760cdde4eb8ecadf6abf70c 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 --- 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);