Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / template / main.c @ 1394

History | View | Annotate | Download (876 Bytes)

1
#include <dragonfly_lib.h>
2
#include <wireless.h>
3
#include <wl_basic.h>
4

    
5
#define CHAN 0xE               /* channel to use for wireless communication */
6

    
7
unsigned char* packet;
8

    
9
int main(void)
10
{
11
        /* initialize components, set wireless channel */
12
        dragonfly_init(ALL_ON);
13
        wl_basic_init_default();
14
        wl_set_channel(CHAN);
15

    
16
        while (1) {
17
                packet = wl_basic_do();
18
        if (packet != 0) {
19
            if (current_packet.length > 0) {
20
                if (packet[0] == 'r')
21
                    orb_set_color(RED);
22
                else if (packet[0] == 'b')
23
                    orb_set_color(BLUE);
24
            }
25
        }
26

    
27
                /* send a packet with no useful info for testing */
28
        if (button1_click() ) {
29
                    wl_basic_send_global_packet(1, "r", 2);
30
        }
31
        if (button2_click() ) {
32
                    wl_basic_send_global_packet(1, "b", 2);
33
        }
34
        }
35

    
36
        wl_terminate();
37

    
38
        return 0;
39
}
40