diff options
author | Keith Packard <keithp@keithp.com> | 2011-08-02 19:07:56 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2011-08-02 19:07:56 -0700 |
commit | 6492218fc316f8cf6214a577807a8dd0a80a9b6a (patch) | |
tree | 27c0c590dd237c481dbf576b709010c141ecab3b /src | |
parent | 11a2bb8e28df7ed87542f2ee726f877971f5d52a (diff) |
altos/altosui: Add pad orientation configure option
Allow TeleMetrum to be operated with the antenna pointing downwards on
the pad. This provides some additional flexibility when designing an
ebay.
The accelerometer calibration levels are flipped around to match, so
no re-calibration should be required.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/ao.h | 6 | ||||
-rw-r--r-- | src/ao_config.c | 39 | ||||
-rw-r--r-- | src/ao_flight_test.c | 4 | ||||
-rw-r--r-- | src/ao_sample.c | 2 |
4 files changed, 49 insertions, 2 deletions
@@ -1358,7 +1358,7 @@ ao_igniter_init(void); */ #define AO_CONFIG_MAJOR 1 -#define AO_CONFIG_MINOR 5 +#define AO_CONFIG_MINOR 6 struct ao_config { uint8_t major; @@ -1372,12 +1372,16 @@ struct ao_config { uint32_t radio_cal; /* minor version 3 */ uint32_t flight_log_max; /* minor version 4 */ uint8_t ignite_mode; /* minor version 5 */ + uint8_t pad_orientation; /* minor version 6 */ }; #define AO_IGNITE_MODE_DUAL 0 #define AO_IGNITE_MODE_APOGEE 1 #define AO_IGNITE_MODE_MAIN 2 +#define AO_PAD_ORIENTATION_ANTENNA_UP 0 +#define AO_PAD_ORIENTATION_ANTENNA_DOWN 1 + extern __xdata struct ao_config ao_config; #define AO_CONFIG_MAX_SIZE 128 diff --git a/src/ao_config.c b/src/ao_config.c index 48349886..215dda92 100644 --- a/src/ao_config.c +++ b/src/ao_config.c @@ -28,6 +28,7 @@ __xdata uint8_t ao_config_mutex; #define AO_CONFIG_DEFAULT_ACCEL_ZERO_G 16000 #define AO_CONFIG_DEFAULT_APOGEE_DELAY 0 #define AO_CONFIG_DEFAULT_IGNITE_MODE AO_IGNITE_MODE_DUAL +#define AO_CONFIG_DEFAULT_PAD_ORIENTATION AO_PAD_ORIENTATION_ANTENNA_UP #if USE_INTERNAL_EEPROM #define AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX ao_storage_config #else @@ -77,6 +78,7 @@ _ao_config_get(void) ao_config.radio_cal = ao_radio_cal; ao_config.flight_log_max = AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX; ao_config.ignite_mode = AO_CONFIG_DEFAULT_IGNITE_MODE; + ao_config.pad_orientation = AO_CONFIG_DEFAULT_PAD_ORIENTATION; ao_config_dirty = 1; } if (ao_config.minor < AO_CONFIG_MINOR) { @@ -97,6 +99,8 @@ _ao_config_get(void) /* Fixupes for minor version 5 */ if (ao_config.minor < 5) ao_config.ignite_mode = AO_CONFIG_DEFAULT_IGNITE_MODE; + if (ao_config.minor < 6) + ao_config.pad_orientation = AO_CONFIG_DEFAULT_PAD_ORIENTATION; ao_config.minor = AO_CONFIG_MINOR; ao_config_dirty = 1; } @@ -357,7 +361,36 @@ ao_config_ignite_mode_set(void) __reentrant ao_config.ignite_mode = ao_cmd_lex_i; ao_config_dirty = 1; ao_mutex_put(&ao_config_mutex); - ao_config_log_show(); + ao_config_ignite_mode_show(); +} +#endif + +#if HAS_IGNITE +void +ao_config_pad_orientation_show(void) __reentrant +{ + printf("Pad orientation: %d\n", ao_config.pad_orientation); +} + +void +ao_config_pad_orientation_set(void) __reentrant +{ + ao_cmd_decimal(); + if (ao_cmd_status != ao_cmd_success) + return; + ao_mutex_get(&ao_config_mutex); + _ao_config_get(); + ao_cmd_lex_i &= 1; + if (ao_config.pad_orientation != ao_cmd_lex_i) { + uint16_t t; + t = ao_config.accel_plus_g; + ao_config.accel_plus_g = 0x7fff - ao_config.accel_minus_g; + ao_config.accel_minus_g = 0x7fff - t; + } + ao_config.pad_orientation = ao_cmd_lex_i; + ao_config_dirty = 1; + ao_mutex_put(&ao_config_mutex); + ao_config_pad_orientation_show(); } #endif @@ -401,6 +434,10 @@ __code struct ao_config_var ao_config_vars[] = { { "i <0 dual, 1 apogee, 2 main>\0Set igniter mode", ao_config_ignite_mode_set, ao_config_ignite_mode_show }, #endif +#if HAS_ACCEL + { "o <0 antenna up, 1 antenna down>\0Set pad orientation", + ao_config_pad_orientation_set,ao_config_pad_orientation_show }, +#endif { "s\0Show", ao_config_show, ao_config_show }, #if HAS_EEPROM diff --git a/src/ao_flight_test.c b/src/ao_flight_test.c index e55d5ade..56733c89 100644 --- a/src/ao_flight_test.c +++ b/src/ao_flight_test.c @@ -179,8 +179,12 @@ struct ao_config { uint16_t main_deploy; int16_t accel_plus_g; int16_t accel_minus_g; + uint8_t pad_orientation; }; +#define AO_PAD_ORIENTATION_ANTENNA_UP 0 +#define AO_PAD_ORIENTATION_ANTENNA_DOWN 1 + #define ao_config_get() struct ao_config ao_config; diff --git a/src/ao_sample.c b/src/ao_sample.c index ac156646..88ba58c5 100644 --- a/src/ao_sample.c +++ b/src/ao_sample.c @@ -179,6 +179,8 @@ ao_sample(void) * just dropped a bit of noise off the low end. */ ao_sample_accel = (uint16_t) ((((uint32_t) ao_sample_accel << 16) / (ao_accel_ref[ao_sample_adc] << 1))) >> 1; + if (ao_config.pad_orientation != AO_PAD_ORIENTATION_ANTENNA_UP) + ao_sample_accel = 0x7fff - ao_sample_accel; ao_adc->accel = ao_sample_accel; #endif #endif |