Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (2.99 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
        
74
        hardware_init ();
75
        comm_server_init ();
76
        comm_robot_init ();
77

    
78
        orb1_set (255, 0, 0); usb_puts("# Initializing wireless" NL);
79
        xbee_init ();
80
        wl_init();
81
        orb2_set (255, 0, 0); usb_puts("# Done" NL);
82

    
83

    
84
        // If button 1 is pressed after initialization of the wireless (which takes about 1s), run all tests.
85
        if (button1_read ())
86
                        test_all ();
87

    
88
        // If button 2 is pressed, go to interactive mode (green/green). If not, go to server mode (green/yellow).
89
        if (button2_read ())
90
                interactive_main ();
91
        else
92
        {
93
                // Set the orbs to green/yellow
94
                orbs_set (0,255,0, 255,127,0);
95

    
96
                server_main ();
97
        }
98

    
99
        while (1);
100
        return 0;
101
}
102

    
103
int main_default (void)
104
{
105
    dragonfly_init(0);
106

    
107
        // Initialize before using USB
108
        comm_server_init ();
109

    
110
        usb_puts(NL NL NL);
111
        usb_puts("# Diagnostic station version " version_string " starting" NL);
112

    
113
    orb_init_pwm ();
114
        hardware_init ();
115

    
116
        orb1_set (255, 0, 0); usb_puts("# Initializing wireless" NL);
117
        xbee_init ();
118
        wl_init();
119
        orb2_set (255, 0, 0); usb_puts("# Done" NL);
120

    
121
        // If button 1 is pressed after initialization of the wireless (which takes about 1s), run all tests.
122
        if (button1_read ())
123
                        test_all ();
124

    
125
        // If button 2 is pressed, go to interactive mode (green/green). If not, go to server mode (green/yellow).
126
        if (button2_read ())
127
                interactive_main ();
128
        else
129
        {
130
                // Set the orbs to green/yellow
131
                orbs_set (0,255,0, 255,127,0);
132

    
133
                server_main ();
134
        }
135

    
136
        while (1);
137
}