- ao_delay(AO_SEC_TO_TICKS(1));
-#if 0
- if (ao_igniter_status(ao_igniter_drogue) == ao_igniter_ready) {
- if (ao_igniter_status(ao_igniter_main) == ao_igniter_ready) {
- for (i = 0; i < 5; i++) {
- ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(50));
- ao_delay(AO_MS_TO_TICKS(100));
- }
- } else {
- ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(200));
+ __pdata int16_t pyro;
+ ao_arch_critical(
+ while (sample == ao_data_head)
+ ao_sleep((void *) DATA_TO_XDATA(&ao_data_head));
+ );
+
+ packet = &ao_data_ring[sample];
+ sample = ao_data_ring_next(sample);
+
+ pyro = packet->adc.pyro;
+
+#define VOLTS_TO_PYRO(x) ((int16_t) ((x) * 27.0 / 127.0 / 3.3 * 32767.0))
+
+ cur = 0;
+ if (pyro > VOLTS_TO_PYRO(10)) {
+ query.arm_status = AO_PAD_ARM_STATUS_ARMED;
+ cur |= AO_LED_ARMED;
+ } else if (pyro < VOLTS_TO_PYRO(5)) {
+ query.arm_status = AO_PAD_ARM_STATUS_DISARMED;
+ arm_beep_time = 0;
+ } else {
+ if ((ao_time() % 100) < 50)
+ cur |= AO_LED_ARMED;
+ query.arm_status = AO_PAD_ARM_STATUS_UNKNOWN;
+ arm_beep_time = 0;
+ }
+ if ((ao_time() - ao_pad_packet_time) > AO_SEC_TO_TICKS(2))
+ cur |= AO_LED_RED;
+ else if (ao_radio_cmac_rssi < -90)
+ cur |= AO_LED_AMBER;
+ else
+ cur |= AO_LED_GREEN;
+
+ for (c = 0; c < AO_PAD_NUM; c++) {
+ int16_t sense = packet->adc.sense[c];
+ uint8_t status = AO_PAD_IGNITER_STATUS_UNKNOWN;
+
+ /*
+ * pyro is run through a divider, so pyro = v_pyro * 27 / 127 ~= v_pyro / 20
+ * v_pyro = pyro * 127 / 27
+ *
+ * v_pyro \
+ * 100k igniter
+ * output /
+ * 100k \
+ * sense relay
+ * 27k /
+ * gnd ---
+ *
+ * If the relay is closed, then sense will be 0
+ * If no igniter is present, then sense will be v_pyro * 27k/227k = pyro * 127 / 227 ~= pyro/2
+ * If igniter is present, then sense will be v_pyro * 27k/127k ~= v_pyro / 20 = pyro
+ */
+
+ if (sense <= pyro / 8) {
+ status = AO_PAD_IGNITER_STATUS_NO_IGNITER_RELAY_CLOSED;
+ if ((ao_time() % 100) < 50)
+ cur |= AO_LED_CONTINUITY(c);