Project

General

Profile

Statistics
| Revision:

root / branches / analog / code / projects / diagnostic_station / station / main.c @ 1390

History | View | Annotate | Download (3.53 KB)

1 1151 deffi
#include <dragonfly_lib.h>
2 1159 deffi
#include <wireless.h>
3
#include <xbee.h>
4 1151 deffi
5 1159 deffi
#include "../common/comm_station_robot.h"
6
7 1151 deffi
#include "global.h"
8 1182 deffi
#include "hardware.h"
9 1169 deffi
#include "tests.h"
10 1182 deffi
#include "self_test.h"
11
#include "comm_server.h"
12 1198 deffi
#include "comm_robot.h"
13 1242 deffi
#include "comm_interactive.h"
14 1151 deffi
15 1242 deffi
int main_default (void)
16 1151 deffi
{
17 1242 deffi
    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 1272 deffi
                test_all ();
35 1242 deffi
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
                server_main ();
41 1151 deffi
42 1242 deffi
        while (1);
43
        return 0;
44 1151 deffi
}
45
46 1187 deffi
int main_martin (void)
47 1151 deffi
{
48 1187 deffi
        dragonfly_init (0);
49
        orb_init ();
50 1218 deffi
51 1226 deffi
        if (!button2_read ())
52
        {
53
                // Initialize before using USB
54 1272 deffi
                // Do something else
55 1218 deffi
        }
56 1226 deffi
        else
57 1218 deffi
        {
58 1226 deffi
                delay_ms (1000);
59
                main_default ();
60 1218 deffi
        }
61
62 1198 deffi
        while (1);
63
        return 0;
64 1187 deffi
}
65
66
int main_john (void)
67
{
68 1280 jsexton
    dragonfly_init(0);
69 1189 jsexton
70 1280 jsexton
        // Initialize before using USB
71
        comm_server_init ();
72 1189 jsexton
73 1280 jsexton
        usb_puts(NL NL NL);
74
        usb_puts("# Diagnostic station version " version_string " starting" NL);
75 1189 jsexton
76 1280 jsexton
    orb_init_pwm ();
77
        hardware_init ();
78
79
        orb1_set (255, 0, 0); usb_puts("# Initializing wireless" NL);
80
        comm_robot_init ();
81
        orb2_set (255, 0, 0); usb_puts("# Done" NL);
82
83 1286 jsexton
        while (1) {
84 1280 jsexton
85 1286 jsexton
                        ibom_set(true);
86
                        delay_ms(500);
87
                        ibom_set(false);
88
                        delay_ms(500);
89
        }
90 1198 deffi
        return 0;
91 1187 deffi
}
92
93 1192 emullini
94
int main_evan (void)
95
{
96
    dragonfly_init(0);
97
98
    usb_init ();
99
100
        usb_puts(NL NL NL);
101
        usb_puts("# Diagnostic station version " version_string " starting" NL);
102
103
    orb_init_pwm ();
104 1208 deffi
105 1192 emullini
        hardware_init ();
106
        comm_server_init ();
107 1198 deffi
        comm_robot_init ();
108 1192 emullini
109
        orb1_set (255, 0, 0); usb_puts("# Initializing wireless" NL);
110
        xbee_init ();
111
        wl_init();
112
        orb2_set (255, 0, 0); usb_puts("# Done" NL);
113
114
115
        // If button 1 is pressed after initialization of the wireless (which takes about 1s), run all tests.
116
        if (button1_read ())
117
                        test_all ();
118
119
        // If button 2 is pressed, go to interactive mode (green/green). If not, go to server mode (green/yellow).
120
        if (button2_read ())
121
                interactive_main ();
122
        else
123
        {
124
                // Set the orbs to green/yellow
125
                orbs_set (0,255,0, 255,127,0);
126
127
                server_main ();
128
        }
129
130
        while (1);
131 1198 deffi
        return 0;
132 1192 emullini
}
133 1281 kwoo
134
int main_kwoo (void)
135
{
136
    dragonfly_init(0);
137
    orb_init_pwm();
138
139
    usb_init ();
140
141
        usb_puts(NL NL NL);
142
        usb_puts("# Diagnostic station version " version_string " starting" NL);
143
144
    wall_init();
145 1285 kwoo
146
    wall_set_position(1);
147
    wall_set_position(2);
148
    wall_set_position(3);
149
    wall_set_position(4);
150
    wall_set_position(5);
151
152 1281 kwoo
        while (1) {
153 1285 kwoo
        //usb_puti(wall_get_position());
154
        //usb_puts("\r\n");
155 1281 kwoo
        if (PINF & _BV(PINF0)) {
156
            orbs_set(0,0,255,0,0,0);
157
        }
158
159
    }
160
161
        return 0;
162
}
163 1311 bneuman
164
int main_brad(void)
165
{
166
  dragonfly_init (ALL_ON);
167
168
  if (!button2_read ()) {
169
170
    usb_puts("running Brad's tests" NL);
171
172
    turntable_init();
173
    turntable_rotate_to_position(0);
174
    delay_ms(1000);
175
    usb_puts("actually got to:");
176
    usb_puti(turntable_get_position());
177
    usb_puts(NL);
178
    turntable_rotate_to_position(512);
179
    delay_ms(1000);
180
    usb_puts("actually got to:");
181
    usb_puti(turntable_get_position());
182
    usb_puts(NL);
183
184
185
  }
186
  else {
187
188
    //could put a call to default_main here
189
    turntable_init();
190
    interactive_main();
191
192
193
  }
194
195
  while (1);
196
  return 0;
197
}