Revision 1272
Added "interactive" command in server mode
Moved hardware_init out of interactive_main
Made calling interactive_main/server_main more consistent
trunk/code/projects/diagnostic_station/station/comm_interactive.c | ||
---|---|---|
88 | 88 |
|
89 | 89 |
void interactive_main (void) |
90 | 90 |
{ |
91 |
hardware_init(); |
|
92 |
|
|
93 | 91 |
while (1) |
94 | 92 |
{ |
95 | 93 |
// Set the orbs to green/green |
trunk/code/projects/diagnostic_station/station/comm_server.c | ||
---|---|---|
6 | 6 |
#include "global.h" |
7 | 7 |
#include "tests.h" |
8 | 8 |
|
9 |
#include "comm_interactive.h" |
|
10 |
|
|
9 | 11 |
// ############## |
10 | 12 |
// ## Settings ## |
11 | 13 |
// ############## |
... | ... | |
33 | 35 |
const char command_emitter [] PROGMEM = "emitter" ; |
34 | 36 |
const char command_detector [] PROGMEM = "detector" ; |
35 | 37 |
const char command_help [] PROGMEM = "help" ; |
38 |
const char command_interactive [] PROGMEM = "interactive"; |
|
39 |
const char command_i [] PROGMEM = "i" ; |
|
36 | 40 |
|
37 | 41 |
// Help |
38 | 42 |
const char help_text [] PROGMEM = |
... | ... | |
287 | 291 |
#endif |
288 | 292 |
|
289 | 293 |
bool handled=false; |
290 |
if (serial_match (command_ping , message)) { handle_message_ping (message); handled=true; } |
|
291 |
if (serial_match (command_start_test, message)) { handle_message_start_test (message); handled=true; } |
|
292 |
if (serial_match (command_help , message)) { handle_message_help (message); handled=true; } |
|
294 |
if (serial_match (command_ping , message)) { handle_message_ping (message); handled=true; } |
|
295 |
if (serial_match (command_start_test , message)) { handle_message_start_test (message); handled=true; } |
|
296 |
if (serial_match (command_help , message)) { handle_message_help (message); handled=true; } |
|
297 |
if (serial_match (command_interactive, message)) { interactive_main () ; handled=true; } |
|
298 |
if (serial_match (command_i , message)) { interactive_main () ; handled=true; } |
|
293 | 299 |
// More messages go here |
294 | 300 |
|
295 | 301 |
if (!handled) |
... | ... | |
334 | 340 |
uint8_t c; |
335 | 341 |
uint8_t buffer_fill=0; |
336 | 342 |
|
343 |
// Set the orbs to green/yellow |
|
344 |
orbs_set (0,255,0, 255,127,0); |
|
345 |
|
|
337 | 346 |
//byte_transmission_test (); // Does not return |
338 | 347 |
|
339 | 348 |
usb_puts (NL); |
trunk/code/projects/diagnostic_station/station/main.c | ||
---|---|---|
31 | 31 |
|
32 | 32 |
// If button 1 is pressed after initialization of the wireless (which takes about 1s), run all tests. |
33 | 33 |
if (button1_read ()) |
34 |
test_all ();
|
|
34 |
test_all (); |
|
35 | 35 |
|
36 | 36 |
// If button 2 is pressed, go to interactive mode (green/green). If not, go to server mode (green/yellow). |
37 | 37 |
if (button2_read ()) |
38 | 38 |
interactive_main (); |
39 | 39 |
else |
40 |
{ |
|
41 |
// Set the orbs to green/yellow |
|
42 |
orbs_set (0,255,0, 255,127,0); |
|
43 |
|
|
44 | 40 |
server_main (); |
45 |
} |
|
46 | 41 |
|
47 | 42 |
while (1); |
48 | 43 |
return 0; |
... | ... | |
56 | 51 |
if (!button2_read ()) |
57 | 52 |
{ |
58 | 53 |
// 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 |
} |
|
54 |
// Do something else |
|
87 | 55 |
} |
88 | 56 |
else |
89 | 57 |
{ |
Also available in: Unified diff