Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / diagnostic_station / station / main.c @ 1169

History | View | Annotate | Download (1.7 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 "station_hardware.h"
9
#include "tests.h"
10

    
11
void interactive_main (void)
12
{
13
        while (1)
14
        {
15
                // Set the orbs to green/green
16
                orbs_set (0,255,0, 0,255,0);
17

    
18
                usb_puts (NL);
19
                usb_puts ("# Diagnostic station interactive mode" NL);
20
                usb_puts ("# Test (s)elf, (a)ll, (c)omm, (b)om, (r)angefinders, (m)otors, (e)ncoders" NL);
21

    
22
                char choice = usb_getc ();
23
                switch (choice) {
24
                        case 'c': case 'C': test_comm ();                               break;
25
                        case 'a': case 'A': test_all ();                                break; // test_all will test comm itself
26
                        case 'b': case 'B': if (require_comm ()) test_bom (true, true); break;
27
                        case 'r': case 'R': if (require_comm ()) test_rangefinders ();  break;
28
                        case 'm': case 'M': if (require_comm ()) test_motors ();        break;
29
                        case 'e': case 'E': if (require_comm ()) test_encoders ();      break;
30
                        case 's': case 'S': self_test ();                               break;
31
                        default: break; // ignore it
32
                }
33
        }
34
}
35

    
36
void server_main (void)
37
{
38
        // Set the orbs to green/yellow
39
        orbs_set (0,255,0, 255,127,0);
40

    
41
        while (1);
42
}
43

    
44
int main (void)
45
{
46
#include <dragonfly_lib.h>
47
#include <wireless.h>
48

    
49
    dragonfly_init(0);
50

    
51
    usb_init ();
52

    
53
        usb_puts(NL NL NL);
54
        usb_puts("# Diagnostic station version " version_string " starting" NL);
55

    
56
    orb_init_pwm ();
57
        hardware_init ();
58
        server_comm_init ();
59

    
60
        orb1_set (255, 0, 0); usb_puts("# Initializing wireless" NL);
61
        xbee_init ();
62
        wl_init();
63
        orb2_set (255, 0, 0); usb_puts("# Done" NL);
64

    
65
        if (button1_read ())
66
                        test_all ();
67

    
68
        if (button2_read ())
69
                server_main ();
70
        else
71
                interactive_main ();
72

    
73
        while (1);
74
}