root / trunk / code / projects / diagnostic_station / station / main.c @ 1152
History | View | Annotate | Download (1.83 KB)
1 |
#include <dragonfly_lib.h> |
---|---|
2 |
|
3 |
#include "global.h" |
4 |
#include "station_hardware.h" |
5 |
|
6 |
#include "test_comm.h" |
7 |
#include "test_bom.h" |
8 |
#include "test_rangefinders.h" |
9 |
#include "test_encoders.h" |
10 |
#include "test_motors.h" |
11 |
|
12 |
bool communication_ok=false; |
13 |
|
14 |
bool require_comm (void) |
15 |
{ |
16 |
if (!communication_ok)
|
17 |
communication_ok=test_comm (); |
18 |
|
19 |
if (!communication_ok)
|
20 |
usb_puts ("Communications required. Stop." NL);
|
21 |
|
22 |
return communication_ok;
|
23 |
} |
24 |
|
25 |
void test_all (void) |
26 |
{ |
27 |
test_bom (true, true); |
28 |
test_rangefinders (); |
29 |
test_encoders (); |
30 |
test_motors (); |
31 |
} |
32 |
|
33 |
void interactive_main (void) |
34 |
{ |
35 |
while (1) |
36 |
{ |
37 |
// Set the orbs to green/green
|
38 |
orbs_set (0,255,0, 0,255,0); |
39 |
|
40 |
usb_puts (NL); |
41 |
usb_puts ("Diagnostic station interactive mode" NL);
|
42 |
usb_puts ("Test (s)elf, (a)ll, (c)omm, (b)om, (r)angefinders, (e)ncoders, (m)otors" NL);
|
43 |
|
44 |
char choice = usb_getc ();
|
45 |
switch (choice) {
|
46 |
case 'c': case 'C': test_comm (); break; |
47 |
case 'a': case 'A': if (require_comm ()) test_all (); break; |
48 |
case 'b': case 'B': if (require_comm ()) test_bom (true, true); break; |
49 |
case 'r': case 'R': if (require_comm ()) test_rangefinders (); break; |
50 |
case 'e': case 'E': if (require_comm ()) test_encoders (); break; |
51 |
case 'm': case 'M': if (require_comm ()) test_motors (); break; |
52 |
case 's': case 'S': self_test (); break; |
53 |
default: break; // ignore it |
54 |
// usb_puts("Received invalid input ");
|
55 |
// usb_putc(choice);
|
56 |
// usb_puts(NL);
|
57 |
} |
58 |
} |
59 |
} |
60 |
|
61 |
void server_main (void) |
62 |
{ |
63 |
// Set the orbs to green/yellow
|
64 |
orbs_set (0,255,0, 255,127,0); |
65 |
|
66 |
while (1); |
67 |
} |
68 |
|
69 |
int main (void) |
70 |
{ |
71 |
dragonfly_init(0);
|
72 |
usb_init (); |
73 |
orb_init (); |
74 |
|
75 |
usb_puts(NL NL NL); |
76 |
usb_puts("Diagnostic station version " version_string " starting" NL); |
77 |
hardware_init (); |
78 |
|
79 |
if (button2_read ())
|
80 |
server_main (); |
81 |
else
|
82 |
interactive_main (); |
83 |
|
84 |
while (1); |
85 |
} |