root / trunk / code / projects / diagnostic_station / station / robot_comm.c @ 1159
History | View | Annotate | Download (1.1 KB)
1 |
#include <dragonfly_lib.h> |
---|---|
2 |
#include <wireless.h> |
3 |
|
4 |
#include "robot_comm.h" |
5 |
#include "../common/comm_station_robot.h" |
6 |
|
7 |
static void send_packet (char type, char *data, int len) |
8 |
{ |
9 |
wl_send_global_packet (station_robot_group, type, data, len, 0);
|
10 |
|
11 |
// TODO: is it guaranteed that the package will be sent on the next call to wl_do, or
|
12 |
// do we have to call wl_do in a loop?
|
13 |
wl_do (); |
14 |
} |
15 |
|
16 |
void robot_set_orbs (uint8_t red1, uint8_t green1, uint8_t blue1, uint8_t red2, uint8_t green2, uint8_t blue2)
|
17 |
{ |
18 |
char data[6]; |
19 |
|
20 |
data[0]=red1;
|
21 |
data[1]=green1;
|
22 |
data[2]=blue1;
|
23 |
|
24 |
data[3]=red2;
|
25 |
data[4]=green2;
|
26 |
data[5]=blue2;
|
27 |
|
28 |
send_packet (station_robot_set_orbs, data, 6);
|
29 |
} |
30 |
|
31 |
void robot_set_motors (uint8_t direction1, uint8_t speed1, uint8_t direction2, uint8_t speed2)
|
32 |
{ |
33 |
char data[4]; |
34 |
|
35 |
data[0]=direction1;
|
36 |
data[1]=speed1;
|
37 |
data[2]=direction2;
|
38 |
data[3]=speed2;
|
39 |
|
40 |
send_packet (station_robot_set_motors, data, 4);
|
41 |
} |
42 |
|
43 |
void robot_set_bom (uint16_t bitmask)
|
44 |
{ |
45 |
char data[2]; |
46 |
|
47 |
data[0]=WORD_BYTE_0(bitmask);
|
48 |
data[1]=WORD_BYTE_1(bitmask);
|
49 |
|
50 |
send_packet (station_robot_set_bom, data, 2);
|
51 |
} |