Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (2.68 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
        {
41
                // Set the orbs to green/yellow
42
                orbs_set (0,255,0, 255,127,0);
43

    
44
                server_main ();
45
        }
46

    
47
        while (1);
48
        return 0;
49
}
50

    
51
int main_martin (void)
52
{
53
        dragonfly_init (0);
54
        orb_init ();
55

    
56
        if (!button2_read ())
57
        {
58
                // Initialize before using USB
59
                comm_server_init ();
60

    
61
                orb1_set (0, 0, 255);
62
                comm_robot_init ();
63
                orb2_set (0, 0, 255);
64
                
65
                int16_t left=69, right=105;
66
                
67
                while (0)
68
                {
69
                        robot_set_motors (motor_direction_backward, 250, motor_direction_forward, 250);
70
                        delay_ms (200);
71
                }
72
                
73
                // Encoder test
74
                robot_reset_encoders ();
75
                while (1)
76
                {
77
                        bool result=robot_read_encoders (&left, &right);
78
                        usb_puti (result);
79
                        usb_puts (" ");
80
                        usb_puti (left);
81
                        usb_puts (" ");
82
                        usb_puti (right);
83
                        usb_puts (NL);
84
                        
85
                        delay_ms (200);
86
                }
87
        }
88
        else
89
        {
90
                delay_ms (1000);
91
                main_default ();
92
        }
93
        
94
        while (1);
95
        return 0;
96
}
97

    
98
int main_john (void)
99
{
100
        dragonfly_init(0);
101
        orb_init();
102
        usb_init();
103
        analog_init(ADC_START);
104

    
105
        orbs_set(255, 0,255,255,0,255);
106

    
107
        rbom_debug();
108

    
109
        return 0;
110
}
111

    
112

    
113
int main_evan (void)
114
{
115
    dragonfly_init(0);
116

    
117
    usb_init ();
118

    
119
        usb_puts(NL NL NL);
120
        usb_puts("# Diagnostic station version " version_string " starting" NL);
121

    
122
    orb_init_pwm ();
123
        
124
        hardware_init ();
125
        comm_server_init ();
126
        comm_robot_init ();
127

    
128
        orb1_set (255, 0, 0); usb_puts("# Initializing wireless" NL);
129
        xbee_init ();
130
        wl_init();
131
        orb2_set (255, 0, 0); usb_puts("# Done" NL);
132

    
133

    
134
        // If button 1 is pressed after initialization of the wireless (which takes about 1s), run all tests.
135
        if (button1_read ())
136
                        test_all ();
137

    
138
        // If button 2 is pressed, go to interactive mode (green/green). If not, go to server mode (green/yellow).
139
        if (button2_read ())
140
                interactive_main ();
141
        else
142
        {
143
                // Set the orbs to green/yellow
144
                orbs_set (0,255,0, 255,127,0);
145

    
146
                server_main ();
147
        }
148

    
149
        while (1);
150
        return 0;
151
}