Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (2.09 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

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

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

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

    
38
int main_martin (void)
39
{
40
        dragonfly_init (0);
41
        orb_init ();
42
        orbs_set (255, 0,0,0,0,0);
43
}
44

    
45
int main_john (void)
46
{
47
        dragonfly_init (0);
48
        orb_init ();
49
        orbs_set (0, 255,0,0,0,0);
50
}
51

    
52
int main_default (void)
53
{
54
#include <dragonfly_lib.h>
55
#include <wireless.h>
56

    
57
    dragonfly_init(0);
58

    
59
    usb_init ();
60

    
61
        usb_puts(NL NL NL);
62
        usb_puts("# Diagnostic station version " version_string " starting" NL);
63

    
64
    orb_init_pwm ();
65
        hardware_init ();
66
        comm_server_init ();
67

    
68
        orb1_set (255, 0, 0); usb_puts("# Initializing wireless" NL);
69
        xbee_init ();
70
        wl_init();
71
        orb2_set (255, 0, 0); usb_puts("# Done" NL);
72

    
73
        // If button 1 is pressed after initialization of the wireless (which takes about 1s), run all tests.
74
        if (button1_read ())
75
                        test_all ();
76

    
77
        // If button 2 is pressed, go to interactive mode (green/green). If not, go to server mode (green/yellow).
78
        if (button2_read ())
79
                interactive_main ();
80
        else
81
        {
82
                // Set the orbs to green/yellow
83
                orbs_set (0,255,0, 255,127,0);
84

    
85
                server_main ();
86
        }
87

    
88
        while (1);
89
}