root / trunk / code / projects / statusbot / main.c @ 1955
History | View | Annotate | Download (1.1 KB)
1 |
#include <dragonfly_lib.h> |
---|---|
2 |
#include <wl_basic.h> |
3 |
|
4 |
int main(void) |
5 |
{ |
6 |
|
7 |
char *packet;
|
8 |
int length, byte;
|
9 |
|
10 |
|
11 |
/* initialize components, set wireless channel */
|
12 |
dragonfly_init(ALL_ON); |
13 |
wl_basic_init_default(); |
14 |
//REMEMBER to change this to whatever channel your program uses
|
15 |
wl_set_channel(15);
|
16 |
|
17 |
while(1){ |
18 |
packet = wl_basic_do_default(&length); |
19 |
if(length > 0){ |
20 |
usb_puts("\r\n");
|
21 |
orb1_set_color(BLUE); |
22 |
usb_puti(length); |
23 |
usb_puts(" bytes: ");
|
24 |
} |
25 |
for(byte = 0; byte < length; byte++){ |
26 |
usb_puti(packet[byte]); |
27 |
usb_putc(' ');
|
28 |
} |
29 |
orb1_set_color(ORB_OFF); |
30 |
length = 0;
|
31 |
|
32 |
} |
33 |
|
34 |
return 0; |
35 |
} |
36 |
|
37 |
/* Copy this function into your program whever you want to report the status of the robot
|
38 |
* Edit the parameters to contain all the variables you want to send from your program
|
39 |
*/
|
40 |
void send_status(char var1, char var2){ |
41 |
int length = 3;//Set this to the number of bytes you want to report |
42 |
char buffer[length];
|
43 |
|
44 |
//Copy all variables into the buffer
|
45 |
buffer[0] = get_robotid();
|
46 |
buffer[1] = var1;
|
47 |
buffer[2] = var2;
|
48 |
|
49 |
wl_basic_send_global_packet(42, buffer, length);
|
50 |
|
51 |
} |