root / trunk / code / projects / diagnostic_station / station / main.c @ 1202
History | View | Annotate | Download (2.97 KB)
1 |
#include <dragonfly_lib.h> |
---|---|
2 |
#include <wireless.h> |
3 |
#include <xbee.h> |
4 |
|
5 |
#include "../common/comm_station_robot.h" |
6 |
|
7 |
#include "global.h" |
8 |
#include "hardware.h" |
9 |
#include "tests.h" |
10 |
#include "self_test.h" |
11 |
#include "comm_server.h" |
12 |
#include "comm_robot.h" |
13 |
|
14 |
void interactive_main (void) |
15 |
{ |
16 |
while (1) |
17 |
{ |
18 |
// Set the orbs to green/green
|
19 |
orbs_set (0,255,0, 0,255,0); |
20 |
|
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);
|
24 |
|
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 |
} |
37 |
} |
38 |
|
39 |
int main_martin (void) |
40 |
{ |
41 |
dragonfly_init (0);
|
42 |
orb_init (); |
43 |
orbs_set (0, 0,255,0,0,0); |
44 |
while (1); |
45 |
return 0; |
46 |
} |
47 |
|
48 |
int main_john (void) |
49 |
{ |
50 |
dragonfly_init(0);
|
51 |
orb_init(); |
52 |
usb_init(); |
53 |
analog_init(ADC_START); |
54 |
|
55 |
orbs_set(255, 0,255,255,0,255); |
56 |
|
57 |
rbom_debug(); |
58 |
|
59 |
return 0; |
60 |
} |
61 |
|
62 |
|
63 |
int main_evan (void) |
64 |
{ |
65 |
dragonfly_init(0);
|
66 |
|
67 |
usb_init (); |
68 |
|
69 |
usb_puts(NL NL NL); |
70 |
usb_puts("# Diagnostic station version " version_string " starting" NL); |
71 |
|
72 |
orb_init_pwm (); |
73 |
hardware_init (); |
74 |
comm_server_init (); |
75 |
comm_robot_init (); |
76 |
|
77 |
orb1_set (255, 0, 0); usb_puts("# Initializing wireless" NL); |
78 |
xbee_init (); |
79 |
wl_init(); |
80 |
orb2_set (255, 0, 0); usb_puts("# Done" NL); |
81 |
|
82 |
|
83 |
// If button 1 is pressed after initialization of the wireless (which takes about 1s), run all tests.
|
84 |
if (button1_read ())
|
85 |
test_all (); |
86 |
|
87 |
// If button 2 is pressed, go to interactive mode (green/green). If not, go to server mode (green/yellow).
|
88 |
if (button2_read ())
|
89 |
interactive_main (); |
90 |
else
|
91 |
{ |
92 |
// Set the orbs to green/yellow
|
93 |
orbs_set (0,255,0, 255,127,0); |
94 |
|
95 |
server_main (); |
96 |
} |
97 |
|
98 |
while (1); |
99 |
return 0; |
100 |
} |
101 |
|
102 |
int main_default (void) |
103 |
{ |
104 |
dragonfly_init(0);
|
105 |
|
106 |
usb_init (); |
107 |
|
108 |
usb_puts(NL NL NL); |
109 |
usb_puts("# Diagnostic station version " version_string " starting" NL); |
110 |
|
111 |
orb_init_pwm (); |
112 |
hardware_init (); |
113 |
comm_server_init (); |
114 |
|
115 |
orb1_set (255, 0, 0); usb_puts("# Initializing wireless" NL); |
116 |
xbee_init (); |
117 |
wl_init(); |
118 |
orb2_set (255, 0, 0); usb_puts("# Done" NL); |
119 |
|
120 |
// If button 1 is pressed after initialization of the wireless (which takes about 1s), run all tests.
|
121 |
if (button1_read ())
|
122 |
test_all (); |
123 |
|
124 |
// If button 2 is pressed, go to interactive mode (green/green). If not, go to server mode (green/yellow).
|
125 |
if (button2_read ())
|
126 |
interactive_main (); |
127 |
else
|
128 |
{ |
129 |
// Set the orbs to green/yellow
|
130 |
orbs_set (0,255,0, 255,127,0); |
131 |
|
132 |
server_main (); |
133 |
} |
134 |
|
135 |
while (1); |
136 |
} |