altos/telelco-v3.0: Fix up search UI
[fw/altos] / src / drivers / ao_lco.h
1 /*
2  * Copyright © 2012 Keith Packard <keithp@keithp.com>
3  *
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.
8  *
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.
13  *
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.
17  */
18
19 #ifndef _AO_LCO_H_
20 #define _AO_LCO_H_
21
22 #include <ao_lco_func.h>
23
24 #ifndef AO_LCO_DRAG
25 #define AO_LCO_DRAG     1
26 #endif
27
28 #define DEBUG   1
29
30 #if DEBUG
31 extern uint8_t  ao_lco_debug;
32 #define PRINTD(...) do { if (!ao_lco_debug) break; printf ("\r%5lu %s: ", (unsigned long) ao_tick_count, __func__); printf(__VA_ARGS__); flush(); } while(0)
33 #else
34 #define PRINTD(...) 
35 #endif
36
37 #if AO_LCO_DRAG
38 extern uint8_t  ao_lco_drag_race;       /* true when drag race mode enabled */
39 #endif
40
41 extern uint8_t  ao_lco_pad;             /* Currently selected pad */
42 extern uint16_t ao_lco_box;             /* Currently selected box */
43
44 extern uint8_t  ao_lco_armed;           /* armed mode active */
45 extern uint8_t  ao_lco_firing;          /* fire button pressed */
46
47 extern struct ao_pad_query      ao_pad_query;   /* Last received QUERY from pad */
48
49 #define AO_LCO_LCO_VOLTAGE      0               /* Box number to show LCO voltage */
50 #define AO_LCO_PAD_VOLTAGE      0               /* Pad number to show box voltage */
51
52 extern uint16_t ao_lco_min_box, ao_lco_max_box;
53
54 #define AO_LCO_MASK_SIZE(n)     (((n) + 7) >> 3)
55 #define AO_LCO_MASK_ID(n)       ((n) >> 3)
56 #define AO_LCO_MASK_SHIFT(n)    ((n) & 7)
57
58 extern uint8_t  ao_lco_box_mask[AO_LCO_MASK_SIZE(AO_PAD_MAX_BOXES)];
59
60 /*
61  * Shared functions
62  */
63
64 void
65 ao_lco_igniter_status(void);
66
67 void
68 ao_lco_update(void);
69
70 uint8_t
71 ao_lco_pad_present(uint16_t box, uint8_t pad);
72
73 uint8_t
74 ao_lco_pad_first(uint16_t box);
75
76 void
77 ao_lco_set_pad(uint8_t new_pad);
78
79 void
80 ao_lco_step_pad(int8_t dir);
81
82 void
83 ao_lco_set_box(uint16_t new_box);
84
85 void
86 ao_lco_step_box(int8_t dir);
87
88 void
89 ao_lco_set_armed(uint8_t armed);
90
91 void
92 ao_lco_set_firing(uint8_t firing);
93
94 void
95 ao_lco_pretend(void);
96
97 void
98 ao_lco_toggle_drag(void);
99
100 void
101 ao_lco_search(void);
102
103 void
104 ao_lco_monitor(void);
105
106 extern uint8_t                  ao_lco_drag_beep_count;
107
108 /* enable drag race mode */
109 void
110 ao_lco_drag_enable(void);
111
112 /* disable drag race mode */
113 void
114 ao_lco_drag_disable(void);
115
116 /* Handle drag beeps, return new delay */
117 AO_TICK_TYPE
118 ao_lco_drag_beep_check(AO_TICK_TYPE now, AO_TICK_TYPE delay);
119
120 /* Check if it's time to beep during drag race. Return new delay */
121 AO_TICK_TYPE
122 ao_lco_drag_warn_check(AO_TICK_TYPE now, AO_TICK_TYPE delay);
123
124 /* Request 'beeps' additional drag race beeps */
125 void
126 ao_lco_drag_add_beeps(uint8_t beeps);
127
128 /* task function for beeping while arm is active */
129 void
130 ao_lco_arm_warn(void);
131
132 /*
133  * Provided by the hw-specific driver code
134  */
135
136 void
137 ao_lco_show_pad(uint8_t pad);
138
139 void
140 ao_lco_show_box(uint16_t box);
141
142 void
143 ao_lco_show(void);
144
145 void
146 ao_lco_init(void);
147
148 uint8_t
149 ao_lco_box_present(uint16_t box);
150
151 #ifdef AO_LCO_SEARCH_API
152
153 void
154 ao_lco_search_start(void);
155
156 void
157 ao_lco_search_box_check(uint16_t box);
158
159 void
160 ao_lco_search_box_present(uint16_t box);
161
162 void
163 ao_lco_search_done(void);
164
165 #endif /* AO_LCO_SEARCH_API */
166
167 #endif /* _AO_LCO_H_ */