}
minor = ao_config.minor;
if (minor != AO_CONFIG_MINOR) {
+#if AO_PYRO_NUM
+ ao_pyro_update_version();
+#endif
/* Fixups for minor version 1 */
if (minor < 1)
ao_config.apogee_delay = AO_CONFIG_DEFAULT_APOGEE_DELAY;
if (minor < 14)
ao_config.radio_amp = AO_CONFIG_DEFAULT_RADIO_AMP;
#endif
-#if HAS_GYRO
+#if HAS_IMU
if (minor < 15) {
ao_config.accel_zero_along = 0;
ao_config.accel_zero_across = 0;
ao_config.accel_minus_g = 0;
}
#endif
-#if HAS_BEEP_CONFIG
+#if HAS_BEEP
if (minor < 16)
ao_config.mid_beep = AO_BEEP_MID_DEFAULT;
#endif
#if HAS_FLIGHT
+#if HAS_BARO
+
static void
ao_config_main_deploy_show(void)
{
_ao_config_edit_finish();
}
+#endif
+
#if HAS_ACCEL
static void
ao_config_accel_calibrate_show(void)
{
printf("Accel cal +1g: %d -1g: %d\n",
ao_config.accel_plus_g, ao_config.accel_minus_g);
-#if HAS_GYRO
+#if HAS_IMU
printf ("IMU cal along %d across %d through %d\n",
ao_config.accel_zero_along,
ao_config.accel_zero_across,
#define ACCEL_CALIBRATE_SAMPLES 1024
#define ACCEL_CALIBRATE_SHIFT 10
-#if HAS_GYRO
+#if HAS_IMU
static int16_t accel_cal_along;
static int16_t accel_cal_across;
static int16_t accel_cal_through;
uint16_t i;
int32_t accel_total;
uint8_t cal_data_ring;
-#if HAS_GYRO
+#if HAS_IMU
int32_t accel_along_total = 0;
int32_t accel_across_total = 0;
int32_t accel_through_total = 0;
ao_sleep(&ao_sample_data);
while (i && cal_data_ring != ao_sample_data) {
accel_total += (int32_t) ao_data_accel(&ao_data_ring[cal_data_ring]);
-#if HAS_GYRO
+#if HAS_IMU
accel_along_total += (int32_t) ao_data_along(&ao_data_ring[cal_data_ring]);
accel_across_total += (int32_t) ao_data_across(&ao_data_ring[cal_data_ring]);
accel_through_total += (int32_t) ao_data_through(&ao_data_ring[cal_data_ring]);
i--;
}
}
-#if HAS_GYRO
+#if HAS_IMU
accel_cal_along = accel_along_total >> ACCEL_CALIBRATE_SHIFT;
accel_cal_across = accel_across_total >> ACCEL_CALIBRATE_SHIFT;
accel_cal_through = accel_through_total >> ACCEL_CALIBRATE_SHIFT;
ao_config_accel_calibrate_set(void)
{
int16_t up, down;
- uint16_t r;
-#if HAS_GYRO
+ bool auto_cal;
+#if HAS_IMU
int16_t accel_along_up = 0, accel_along_down = 0;
int16_t accel_across_up = 0, accel_across_down = 0;
int16_t accel_through_up = 0, accel_through_down = 0;
#endif
- r = ao_cmd_decimal();
+ up = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
- if (r == 0) {
+ down = ao_cmd_decimal();
+ auto_cal = (up == 0 && ao_cmd_status != ao_cmd_success);
+ if (auto_cal) {
up = ao_config_accel_calibrate_auto("up");
-#if HAS_GYRO
+#if HAS_IMU
accel_along_up = accel_cal_along;
accel_across_up = accel_cal_across;
accel_through_up = accel_cal_through;
#endif
down = ao_config_accel_calibrate_auto("down");
-#if HAS_GYRO
+#if HAS_IMU
accel_along_down = accel_cal_along;
accel_across_down = accel_cal_across;
accel_through_down = accel_cal_through;
#endif
- } else {
- up = r;
- r = ao_cmd_decimal();
- if (ao_cmd_status != ao_cmd_success)
- return;
- down = r;
}
if (up >= down) {
printf("Invalid accel: up (%d) down (%d)\n",
_ao_config_edit_start();
ao_config.accel_plus_g = up;
ao_config.accel_minus_g = down;
-#if HAS_GYRO
- if (r == 0) {
+#if HAS_IMU
+ if (auto_cal) {
ao_config.accel_zero_along = (accel_along_up + accel_along_down) / 2;
ao_config.accel_zero_across = (accel_across_up + accel_across_down) / 2;
ao_config.accel_zero_through = (accel_through_up + accel_through_down) / 2;
+ } else {
+ int16_t v;
+
+ v = ao_cmd_decimal();
+ if (ao_cmd_status == ao_cmd_success) {
+ ao_config.accel_zero_along = v;
+ v = ao_cmd_decimal();
+ if (ao_cmd_status == ao_cmd_success) {
+ ao_config.accel_zero_across = v;
+ v = ao_cmd_decimal();
+ if (ao_cmd_status == ao_cmd_success)
+ ao_config.accel_zero_through = v;
+ }
+ }
}
#endif
_ao_config_edit_finish();
}
#endif /* HAS_ACCEL */
+#if HAS_BARO
static void
ao_config_apogee_delay_show(void)
{
ao_config.apogee_lockout = r;
_ao_config_edit_finish();
}
+#endif
#endif /* HAS_FLIGHT */
ao_config_log_set(void)
{
#if FLIGHT_LOG_APPEND
- printf("Flight log fixed size %d kB\n", ao_storage_log_max >> 10);
+ printf("Flight log fixed size %u kB\n", (unsigned) (ao_storage_log_max >> 10));
#else
- uint16_t block = (uint16_t) (ao_storage_block >> 10);
- uint16_t log_max = (uint16_t) (ao_storage_log_max >> 10);
uint32_t r;
r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
- if (ao_log_present())
- printf("Storage must be empty before changing log size\n");
- else if (block > 1024 && (r & (block - 1)))
- printf("Flight log size must be multiple of %d kB\n", block);
- else if (r > log_max)
- printf("Flight log max %d kB\n", log_max);
- else {
- _ao_config_edit_start();
- ao_config.flight_log_max = r << 10;
- _ao_config_edit_finish();
+ r = r << 10;
+ if (ao_log_present()) {
+ if (r != ao_config.flight_log_max)
+ printf("Storage must be empty before changing log size\n");
+ return;
+ }
+ if (r > ao_storage_log_max) {
+ printf("Flight log max %u kB\n", (unsigned) (ao_storage_log_max >> 10));
+ return;
}
+ _ao_config_edit_start();
+ ao_config.flight_log_max = r & ~(ao_storage_block - 1);
+ _ao_config_edit_finish();
#endif
}
#endif /* HAS_LOG */
#endif
-#if HAS_BEEP_CONFIG
+#if HAS_BEEP
static void
ao_config_beep_show(void)
{
#endif
const struct ao_config_var ao_config_vars[] = {
-#if HAS_FLIGHT
+#if HAS_FLIGHT && HAS_BARO
{ "m <meters>\0Main deploy (m)",
ao_config_main_deploy_set, ao_config_main_deploy_show, },
{ "d <delay>\0Apogee delay (s)",
ao_config_log_set, ao_config_log_show },
#endif
#if HAS_IGNITE
- { "i <0 dual, 1 apogee, 2 main>\0Igniter mode",
+ { "i <0 dual, 1 apogee, 2 main, 3 booster>\0Igniter mode",
ao_config_ignite_mode_set, ao_config_ignite_mode_show },
#endif
#if HAS_AES
{ "A <secs>\0APRS packet interval (0 disable)",
ao_config_aprs_set, ao_config_aprs_show },
#endif
-#if HAS_BEEP_CONFIG
+#if HAS_BEEP
{ "b <val>\0Beeper tone (freq = 1/2 (24e6/32) / beep",
ao_config_beep_set, ao_config_beep_show },
#endif