altos/drivers: Add ao_adxl375_accel_to_sample macro
authorKeith Packard <keithp@keithp.com>
Sun, 2 Aug 2020 19:51:16 +0000 (12:51 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 22 Oct 2020 04:33:58 +0000 (21:33 -0700)
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 <keithp@keithp.com>
src/drivers/ao_adxl375.h

index a1ed216dc447abfefe8b139a60c64aac9e0c5f54..fe448fd0e27857d06592188d5aa38548ca5b6348 100644 (file)
@@ -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);