Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / statusbot / main.c @ 1964

History | View | Annotate | Download (1.05 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
    }
23
    for(byte = 0; byte < length; byte++){
24
      usb_puti(packet[byte]);
25
      usb_putc(' ');
26
    }
27
    orb1_set_color(ORB_OFF);
28
    length = 0;
29

    
30
  }
31

    
32
        return 0;
33
}
34

    
35
/* Copy this function into your program whever you want to report the status of the robot
36
 * Edit the parameters to contain all the variables you want to send from your program
37
 */
38
void send_status(char var1, char var2){
39
  int length = 3;//Set this to the number of bytes you want to report
40
  char buffer[length];
41

    
42
  //Copy all variables into the buffer
43
  buffer[0] = get_robotid();
44
  buffer[1] = var1;
45
  buffer[2] = var2;
46

    
47
  wl_basic_send_global_packet(42, buffer, length);
48

    
49
}