-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathepuckBTseteventfilter.c
92 lines (79 loc) · 2.12 KB
/
epuckBTseteventfilter.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
Small tool to change the event filter of the e-puck's bluetooth module.
Copyright (C) 2008 -- 2009:
Michael Bonani <michael dot bonani at epfl dot ch>
Stephane Magnenat <stephane at magnenat dot net>
Mobots group, Laboratory of Robotics Systems, EPFL, Lausanne
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Usage: on e-puck reset:
- if selector == 0, then fully transparent mode (no event), all leds on
- if selector != 0, then normal mode (connection and disconnection events), led 1 on
The bluetooth module retains this settings across power off/on.
*/
#include <motor_led/e_epuck_ports.h>
#include <stdio.h>
#include <uart/e_uart_char.h>
#include <bluetooth/e_bluetooth.h>
#include <motor_led/e_init_port.h>
#include <motor_led/e_led.h>
#include <string.h>
int getselector()
{
return SELECTOR0 + 2*SELECTOR1 + 4*SELECTOR2 + 8*SELECTOR3;
}
void delay()
{
int wait;
for (wait=0;wait<30000;wait++);
}
int main(void)
{
int i;
char event;
e_init_port(); //Configure port pins
e_init_uart1(); //Initialize UART to 115200Kbaud
if(RCONbits.POR) //Reset if Power on (some problem for few robots)
{
RCONbits.POR=0;
__asm__ volatile ("reset");
}
if(getselector()==0)
{
e_bt_set_event_filter(3);
for (i=0;i<8;i++)
{
e_set_led(i,1);
delay();
e_set_led(i-1,0);
delay();
}
e_set_led(7,0);
delay();
e_set_led(8,1);
}
else
{
e_bt_set_event_filter(1);
for (i=0;i<8;i++)
{
e_set_led(i,1);
delay();
e_set_led(i-1,0);
delay();
}
e_set_led(7,0);
delay();
event = e_bt_get_event_filter();
e_set_led(event,1);
}
while(1)
;
}