2 * Copyright © 2012 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 #include <ao_button.h>
23 #include <ao_lco_func.h>
24 #include <ao_radio_cmac.h>
26 static uint8_t ao_lco_suspended;
31 if (!ao_lco_suspended) {
35 ao_wakeup(&ao_pad_query);
42 if (ao_lco_suspended) {
44 ao_wakeup(&ao_lco_suspended);
49 ao_lco_show_pad(uint8_t pad)
55 ao_lco_show_box(uint16_t box)
68 static struct ao_event event;
72 if (ao_config.pad_idle && !ao_lco_suspended) {
73 timeout = ao_event_get_for(&event, AO_SEC_TO_TICKS(ao_config.pad_idle));
82 PRINTD("event type %d unit %d value %ld\n",
83 event.type, event.unit, (long) event.value);
88 ao_lco_set_box((uint16_t) event.value);
92 ao_lco_set_armed((uint8_t) event.value);
96 ao_lco_set_firing((uint8_t) event.value);
104 static struct ao_task ao_lco_input_task;
105 static struct ao_task ao_lco_monitor_task;
106 static struct ao_task ao_lco_arm_warn_task;
107 static struct ao_task ao_lco_igniter_status_task;
113 ao_lco_set_box(ao_button_get(AO_BUTTON_BOX));
114 ao_add_task(&ao_lco_input_task, ao_lco_input, "lco input");
115 ao_add_task(&ao_lco_arm_warn_task, ao_lco_arm_warn, "lco arm warn");
116 ao_add_task(&ao_lco_igniter_status_task, ao_lco_igniter_status, "lco igniter status");
117 ao_led_on((uint16_t) ~0);
118 ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(200));
119 ao_led_off((uint16_t) ~0);
125 ao_lco_set_debug(void)
127 uint32_t r = ao_cmd_decimal();
128 if (ao_cmd_status == ao_cmd_success)
129 ao_lco_debug = r != 0;
132 const struct ao_cmds ao_lco_cmds[] = {
133 { ao_lco_set_debug, "D <0 off, 1 on>\0Debug" },
141 ao_add_task(&ao_lco_monitor_task, ao_lco_main, "lco monitor");
143 ao_cmd_register(&ao_lco_cmds[0]);