#define AO_CONFIG_DEFAULT_RADIO_CHANNEL 0
#define AO_CONFIG_DEFAULT_CALLSIGN "KD7SQG"
#define AO_CONFIG_DEFAULT_ACCEL_ZERO_G 16000
+#define AO_CONFIG_DEFAULT_APOGEE_DELAY 0
static void
_ao_config_put(void)
memset(&ao_config.callsign, '\0', sizeof (ao_config.callsign));
memcpy(&ao_config.callsign, AO_CONFIG_DEFAULT_CALLSIGN,
sizeof(AO_CONFIG_DEFAULT_CALLSIGN) - 1);
+ ao_config.apogee_delay = AO_CONFIG_DEFAULT_APOGEE_DELAY;
+ ao_config_dirty = 1;
+ }
+ if (ao_config.minor < AO_CONFIG_MINOR) {
+ /* Fixups for major version 1 */
+ if (ao_config.minor < 1)
+ ao_config.apogee_delay = AO_CONFIG_DEFAULT_APOGEE_DELAY;
+ ao_config.minor = AO_CONFIG_MINOR;
ao_config_dirty = 1;
}
- /* deal with minor version issues here, at 0 we haven't any */
ao_config_loaded = 1;
}
void
ao_config_main_deploy_show(void) __reentrant
{
- printf("Main deploy set to %d meters (%d feet)\n",
+ printf("Main deploy: %d meters (%d feet)\n",
ao_config.main_deploy,
(int16_t) ((int32_t) ao_config.main_deploy * 328 / 100));
}
void
ao_config_accel_zero_g_show(void) __reentrant
{
- printf("Accel zero g point set to %d\n",
+ printf("Accel zero g point: %d\n",
ao_config.accel_zero_g);
}
ao_config_accel_zero_g_show();
}
+void
+ao_config_apogee_delay_show(void) __reentrant
+{
+ printf("Apogee delay: %d seconds\n",
+ ao_config.apogee_delay);
+}
+
+void
+ao_config_apogee_delay_set(void) __reentrant
+{
+ ao_cmd_decimal();
+ if (ao_cmd_status != ao_cmd_success)
+ return;
+ ao_mutex_get(&ao_config_mutex);
+ _ao_config_get();
+ ao_config.apogee_delay = ao_cmd_lex_i;
+ ao_config_dirty = 1;
+ ao_mutex_put(&ao_config_mutex);
+ ao_config_apogee_delay_show();
+}
+
struct ao_config_var {
char cmd;
void (*set)(void) __reentrant;
"r <channel> Set radio channel (freq = 434.550 + channel * .1)" },
{ 'c', ao_config_callsign_set, ao_config_callsign_show,
"c <call> Set callsign broadcast in each packet (8 char max)" },
+ { 'd', ao_config_apogee_delay_set, ao_config_apogee_delay_show,
+ "d <delay> Set apogee igniter delay (in seconds)" },
{ 's', ao_config_show, ao_config_show,
"s Show current config values" },
{ 'w', ao_config_write, ao_config_write,
ao_config_show(void) __reentrant
{
uint8_t cmd;
+ printf("Config version: %d.%d\n",
+ ao_config.major, ao_config.minor);
for (cmd = 0; ao_config_vars[cmd].cmd != '\0'; cmd++)
if (ao_config_vars[cmd].show != ao_config_vars[cmd].set)
(*ao_config_vars[cmd].show)();
}
}
+static uint8_t
+ao_report_igniter_ready(enum ao_igniter igniter)
+{
+ return ao_igniter_status(igniter) == ao_igniter_ready ? 1 : 0;
+}
+
+static void
+ao_report_continuity(void) __reentrant
+{
+ uint8_t c = (ao_report_igniter_ready(ao_igniter_drogue) |
+ (ao_report_igniter_ready(ao_igniter_main) << 1));
+ if (c) {
+ while (c--) {
+ ao_beep_for(AO_BEEP_HIGH, AO_MS_TO_TICKS(25));
+ pause(AO_MS_TO_TICKS(100));
+ }
+ } else {
+ c = 10;
+ while (c--) {
+ ao_beep_for(AO_BEEP_HIGH, AO_MS_TO_TICKS(20));
+ ao_beep_for(AO_BEEP_LOW, AO_MS_TO_TICKS(20));
+ }
+ }
+ c = 50;
+ while (c-- && ao_flight_state == ao_flight_pad)
+ pause(AO_MS_TO_TICKS(100));
+}
+
void
ao_report(void)
{
if (ao_flight_state == ao_flight_landed)
ao_report_altitude();
ao_report_beep();
+ if (ao_flight_state == ao_flight_idle)
+ ao_report_continuity();
+ while (ao_flight_state == ao_flight_pad)
+ ao_report_continuity();
__critical {
while (ao_report_state == ao_flight_state)
ao_sleep(DATA_TO_XDATA(&ao_flight_state));