#include <ao_quadrature.h>
#include <ao_lco_func.h>
#include <ao_radio_cmac.h>
+#include <ao_adc_single.h>
#define DEBUG 1
{
uint8_t tens, ones, tenths;
+ PRINTD("voltage %d\n", decivolts);
tenths = decivolts % 10;
ones = (decivolts / 10) % 10;
tens = (decivolts / 100) % 10;
for (c = 0; c < AO_LED_CONTINUITY_NUM; c++) {
uint8_t status;
- if (ao_lco_drag_race) {
- if (ao_lco_selected[ao_lco_box] & (1 << c) && t)
+ if (ao_pad_query.channels & (1 << c))
+ status = ao_pad_query.igniter_status[c];
+ else
+ status = AO_PAD_IGNITER_STATUS_NO_IGNITER_RELAY_OPEN;
+
+ if (ao_lco_drag_race && (ao_lco_selected[ao_lco_box] & (1 << c))) {
+ uint8_t on = 0;
+ if (status == AO_PAD_IGNITER_STATUS_GOOD_IGNITER_RELAY_OPEN) {
+ if (t)
+ on = 1;
+ } else {
+ if (t == 1)
+ on = 1;
+ }
+ if (on)
ao_led_on(continuity_led[c]);
else
ao_led_off(continuity_led[c]);
} else {
- if (ao_pad_query.channels & (1 << c))
- status = ao_pad_query.igniter_status[c];
- else
- status = AO_PAD_IGNITER_STATUS_NO_IGNITER_RELAY_OPEN;
if (status == AO_PAD_IGNITER_STATUS_GOOD_IGNITER_RELAY_OPEN)
ao_led_on(continuity_led[c]);
else
ao_led_off(continuity_led[c]);
}
}
- t = 1-t;
+ t = (t + 1) & 3;
}
}
}
}
+/*
+ * Light up everything for a second at power on to let the user
+ * visually inspect the system for correct operation
+ */
+static void
+ao_lco_display_test()
+{
+ ao_mutex_get(&ao_lco_display_mutex);
+ ao_seven_segment_set(AO_LCO_PAD_DIGIT, 8 | 0x10);
+ ao_seven_segment_set(AO_LCO_BOX_DIGIT_1, 8 | 0x10);
+ ao_seven_segment_set(AO_LCO_BOX_DIGIT_10, 8 | 0x10);
+ ao_mutex_put(&ao_lco_display_mutex);
+ ao_led_on(LEDS_AVAILABLE);
+ ao_delay(AO_MS_TO_TICKS(1000));
+ ao_led_off(LEDS_AVAILABLE);
+}
+
+static void
+ao_lco_batt_voltage(void)
+{
+ struct ao_adc packet;
+ int16_t decivolt;
+
+ ao_adc_single_get(&packet);
+ decivolt = ao_battery_decivolt(packet.v_batt);
+ ao_lco_set_voltage(decivolt);
+ ao_delay(AO_MS_TO_TICKS(1000));
+}
+
static struct ao_task ao_lco_input_task;
static struct ao_task ao_lco_monitor_task;
static struct ao_task ao_lco_arm_warn_task;
uint16_t delay;
uint8_t box;
+ ao_lco_display_test();
+ ao_lco_batt_voltage();
ao_lco_search();
ao_add_task(&ao_lco_input_task, ao_lco_input, "lco input");
ao_add_task(&ao_lco_arm_warn_task, ao_lco_arm_warn, "lco arm warn");