altos: Use ao_data_accel_invert when changing orientation value
authorKeith Packard <keithp@keithp.com>
Thu, 18 Apr 2019 21:42:15 +0000 (14:42 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 18 Apr 2019 21:42:15 +0000 (14:42 -0700)
Instead of using AO_ACCEL_INVERT, use the macro which flips the values
around. This fixes a bug with ADXL375 flight computers (EasyMega v2.0) where the
accel cal values would be scrambled when changing orientation.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/kernel/ao_config.c
src/kernel/ao_data.h
src/telefireone-v1.0/Makefile

index fb7d333b42b4aaef6ea1837c1fa46087a5d04ec1..4de72c5cd751dbd1994f1277f873b8c7a71c82c2 100644 (file)
@@ -665,10 +665,6 @@ ao_config_pad_orientation_show(void)
        printf("Pad orientation: %d\n", ao_config.pad_orientation);
 }
 
-#ifndef AO_ACCEL_INVERT
-#define AO_ACCEL_INVERT        0x7fff
-#endif
-
 static void
 ao_config_pad_orientation_set(void) 
 {
@@ -677,10 +673,10 @@ ao_config_pad_orientation_set(void)
                return;
        _ao_config_edit_start();
        if (ao_config.pad_orientation != r) {
-               int16_t t;
+               accel_t t;
                t = ao_config.accel_plus_g;
-               ao_config.accel_plus_g = AO_ACCEL_INVERT - ao_config.accel_minus_g;
-               ao_config.accel_minus_g = AO_ACCEL_INVERT - t;
+               ao_config.accel_plus_g = ao_data_accel_invert(ao_config.accel_minus_g);
+               ao_config.accel_minus_g = ao_data_accel_invert(t);
        }
        ao_config.pad_orientation = r;
        _ao_config_edit_finish();
index dda5de4c6638bc62161619c677f4a877c345c5b9..abbace8e88981463326d8fbb83593009028ab9d3 100644 (file)
@@ -328,8 +328,6 @@ typedef int16_t     accel_t;
 
 #define HAS_ACCEL      1
 
-#define AO_ACCEL_INVERT                0
-
 typedef int16_t accel_t;
 
 /* MPU6000 is hooked up so that positive y is positive acceleration */
index b2e7eec48af6895e2dc074c90abbba558e698f33..afcdcd67e6932e3654cd28a05f47a75b13b2b2dc 100644 (file)
@@ -89,3 +89,5 @@ install:
 
 uninstall:
 
+echo:
+       echo $(PROG) $(VERSION)