root / branches / analog / code / projects / diagnostic_station / station / main.c @ 1390
History | View | Annotate | Download (3.53 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 |
#include "comm_interactive.h" |
14 |
|
15 |
int main_default (void) |
16 |
{ |
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
|
40 |
server_main (); |
41 |
|
42 |
while (1); |
43 |
return 0; |
44 |
} |
45 |
|
46 |
int main_martin (void) |
47 |
{ |
48 |
dragonfly_init (0);
|
49 |
orb_init (); |
50 |
|
51 |
if (!button2_read ())
|
52 |
{ |
53 |
// Initialize before using USB
|
54 |
// Do something else
|
55 |
} |
56 |
else
|
57 |
{ |
58 |
delay_ms (1000);
|
59 |
main_default (); |
60 |
} |
61 |
|
62 |
while (1); |
63 |
return 0; |
64 |
} |
65 |
|
66 |
int main_john (void) |
67 |
{ |
68 |
dragonfly_init(0);
|
69 |
|
70 |
// Initialize before using USB
|
71 |
comm_server_init (); |
72 |
|
73 |
usb_puts(NL NL NL); |
74 |
usb_puts("# Diagnostic station version " version_string " starting" NL); |
75 |
|
76 |
orb_init_pwm (); |
77 |
hardware_init (); |
78 |
|
79 |
orb1_set (255, 0, 0); usb_puts("# Initializing wireless" NL); |
80 |
comm_robot_init (); |
81 |
orb2_set (255, 0, 0); usb_puts("# Done" NL); |
82 |
|
83 |
while (1) { |
84 |
|
85 |
ibom_set(true);
|
86 |
delay_ms(500);
|
87 |
ibom_set(false);
|
88 |
delay_ms(500);
|
89 |
} |
90 |
return 0; |
91 |
} |
92 |
|
93 |
|
94 |
int main_evan (void) |
95 |
{ |
96 |
dragonfly_init(0);
|
97 |
|
98 |
usb_init (); |
99 |
|
100 |
usb_puts(NL NL NL); |
101 |
usb_puts("# Diagnostic station version " version_string " starting" NL); |
102 |
|
103 |
orb_init_pwm (); |
104 |
|
105 |
hardware_init (); |
106 |
comm_server_init (); |
107 |
comm_robot_init (); |
108 |
|
109 |
orb1_set (255, 0, 0); usb_puts("# Initializing wireless" NL); |
110 |
xbee_init (); |
111 |
wl_init(); |
112 |
orb2_set (255, 0, 0); usb_puts("# Done" NL); |
113 |
|
114 |
|
115 |
// If button 1 is pressed after initialization of the wireless (which takes about 1s), run all tests.
|
116 |
if (button1_read ())
|
117 |
test_all (); |
118 |
|
119 |
// If button 2 is pressed, go to interactive mode (green/green). If not, go to server mode (green/yellow).
|
120 |
if (button2_read ())
|
121 |
interactive_main (); |
122 |
else
|
123 |
{ |
124 |
// Set the orbs to green/yellow
|
125 |
orbs_set (0,255,0, 255,127,0); |
126 |
|
127 |
server_main (); |
128 |
} |
129 |
|
130 |
while (1); |
131 |
return 0; |
132 |
} |
133 |
|
134 |
int main_kwoo (void) |
135 |
{ |
136 |
dragonfly_init(0);
|
137 |
orb_init_pwm(); |
138 |
|
139 |
usb_init (); |
140 |
|
141 |
usb_puts(NL NL NL); |
142 |
usb_puts("# Diagnostic station version " version_string " starting" NL); |
143 |
|
144 |
wall_init(); |
145 |
|
146 |
wall_set_position(1);
|
147 |
wall_set_position(2);
|
148 |
wall_set_position(3);
|
149 |
wall_set_position(4);
|
150 |
wall_set_position(5);
|
151 |
|
152 |
while (1) { |
153 |
//usb_puti(wall_get_position());
|
154 |
//usb_puts("\r\n");
|
155 |
if (PINF & _BV(PINF0)) {
|
156 |
orbs_set(0,0,255,0,0,0); |
157 |
} |
158 |
|
159 |
} |
160 |
|
161 |
return 0; |
162 |
} |
163 |
|
164 |
int main_brad(void) |
165 |
{ |
166 |
dragonfly_init (ALL_ON); |
167 |
|
168 |
if (!button2_read ()) {
|
169 |
|
170 |
usb_puts("running Brad's tests" NL);
|
171 |
|
172 |
turntable_init(); |
173 |
turntable_rotate_to_position(0);
|
174 |
delay_ms(1000);
|
175 |
usb_puts("actually got to:");
|
176 |
usb_puti(turntable_get_position()); |
177 |
usb_puts(NL); |
178 |
turntable_rotate_to_position(512);
|
179 |
delay_ms(1000);
|
180 |
usb_puts("actually got to:");
|
181 |
usb_puti(turntable_get_position()); |
182 |
usb_puts(NL); |
183 |
|
184 |
|
185 |
} |
186 |
else {
|
187 |
|
188 |
//could put a call to default_main here
|
189 |
turntable_init(); |
190 |
interactive_main(); |
191 |
|
192 |
|
193 |
} |
194 |
|
195 |
while (1); |
196 |
return 0; |
197 |
} |