Revision 1242
Moved interactive_main to comm_interactive.c
Added multiple menus in interactive mode
main.c | ||
---|---|---|
10 | 10 |
#include "self_test.h" |
11 | 11 |
#include "comm_server.h" |
12 | 12 |
#include "comm_robot.h" |
13 |
#include "comm_interactive.h" |
|
13 | 14 |
|
14 |
void interactive_main (void)
|
|
15 |
int main_default (void)
|
|
15 | 16 |
{ |
16 |
while (1) |
|
17 |
dragonfly_init(0); |
|
18 |
|
|
19 |
// Initialize before using USB |
|
20 |
comm_server_init (); |
|
21 |
|
|
22 |
usb_puts(NL NL NL); |
|
23 |
usb_puts("# Diagnostic station version " version_string " starting" NL); |
|
24 |
|
|
25 |
orb_init_pwm (); |
|
26 |
hardware_init (); |
|
27 |
|
|
28 |
orb1_set (255, 0, 0); usb_puts("# Initializing wireless" NL); |
|
29 |
comm_robot_init (); |
|
30 |
orb2_set (255, 0, 0); usb_puts("# Done" NL); |
|
31 |
|
|
32 |
// If button 1 is pressed after initialization of the wireless (which takes about 1s), run all tests. |
|
33 |
if (button1_read ()) |
|
34 |
test_all (); |
|
35 |
|
|
36 |
// If button 2 is pressed, go to interactive mode (green/green). If not, go to server mode (green/yellow). |
|
37 |
if (button2_read ()) |
|
38 |
interactive_main (); |
|
39 |
else |
|
17 | 40 |
{ |
18 |
// Set the orbs to green/green
|
|
19 |
orbs_set (0,255,0, 0,255,0);
|
|
41 |
// Set the orbs to green/yellow
|
|
42 |
orbs_set (0,255,0, 255,127,0);
|
|
20 | 43 |
|
21 |
usb_puts (NL); |
|
22 |
usb_puts ("# Diagnostic station interactive mode" NL); |
|
23 |
usb_puts ("# Test (s)elf, (a)ll, (c)omm, (b)om, (r)angefinders, (m)otors, (e)ncoders" NL); |
|
44 |
server_main (); |
|
45 |
} |
|
24 | 46 |
|
25 |
char choice = usb_getc (); |
|
26 |
switch (choice) { |
|
27 |
case 'c': case 'C': test_comm (); break; |
|
28 |
case 'a': case 'A': test_all (); break; // test_all will test comm itself |
|
29 |
case 'b': case 'B': if (require_comm ()) test_bom_all (true, true); break; |
|
30 |
case 'r': case 'R': if (require_comm ()) test_rangefinder_all (); break; |
|
31 |
case 'm': case 'M': if (require_comm ()) test_motor_all (); break; |
|
32 |
case 'e': case 'E': if (require_comm ()) test_encoder_all (); break; |
|
33 |
case 's': case 'S': self_test (); break; |
|
34 |
default: break; // ignore it |
|
35 |
} |
|
36 |
} |
|
47 |
while (1); |
|
48 |
return 0; |
|
37 | 49 |
} |
38 | 50 |
|
39 | 51 |
int main_martin (void) |
... | ... | |
137 | 149 |
while (1); |
138 | 150 |
return 0; |
139 | 151 |
} |
140 |
|
|
141 |
int main_default (void) |
|
142 |
{ |
|
143 |
dragonfly_init(0); |
|
144 |
|
|
145 |
// Initialize before using USB |
|
146 |
comm_server_init (); |
|
147 |
|
|
148 |
usb_puts(NL NL NL); |
|
149 |
usb_puts("# Diagnostic station version " version_string " starting" NL); |
|
150 |
|
|
151 |
orb_init_pwm (); |
|
152 |
hardware_init (); |
|
153 |
|
|
154 |
orb1_set (255, 0, 0); usb_puts("# Initializing wireless" NL); |
|
155 |
comm_robot_init (); |
|
156 |
orb2_set (255, 0, 0); usb_puts("# Done" NL); |
|
157 |
|
|
158 |
// If button 1 is pressed after initialization of the wireless (which takes about 1s), run all tests. |
|
159 |
if (button1_read ()) |
|
160 |
test_all (); |
|
161 |
|
|
162 |
// If button 2 is pressed, go to interactive mode (green/green). If not, go to server mode (green/yellow). |
|
163 |
if (button2_read ()) |
|
164 |
interactive_main (); |
|
165 |
else |
|
166 |
{ |
|
167 |
// Set the orbs to green/yellow |
|
168 |
orbs_set (0,255,0, 255,127,0); |
|
169 |
|
|
170 |
server_main (); |
|
171 |
} |
|
172 |
|
|
173 |
while (1); |
|
174 |
return 0; |
|
175 |
} |
Also available in: Unified diff