$search
00001 /* 00002 Small tool to change the event filter of the e-puck's bluetooth module. 00003 Copyright (C) 2008 -- 2009: 00004 Michael Bonani <michael dot bonani at epfl dot ch> 00005 Stephane Magnenat <stephane at magnenat dot net> 00006 Mobots group, Laboratory of Robotics Systems, EPFL, Lausanne 00007 00008 This program is free software: you can redistribute it and/or modify 00009 it under the terms of the GNU Lesser General Public License as published 00010 by the Free Software Foundation, version 3 of the License. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. 00019 00020 Usage: on e-puck reset: 00021 - if selector == 0, then fully transparent mode (no event), all leds on 00022 - if selector != 0, then normal mode (connection and disconnection events), led 1 on 00023 The bluetooth module retains this settings across power off/on. 00024 */ 00025 00026 00027 #include <motor_led/e_epuck_ports.h> 00028 #include <stdio.h> 00029 #include <uart/e_uart_char.h> 00030 #include <bluetooth/e_bluetooth.h> 00031 #include <motor_led/e_init_port.h> 00032 #include <motor_led/e_led.h> 00033 #include <string.h> 00034 00035 int getselector() 00036 { 00037 return SELECTOR0 + 2*SELECTOR1 + 4*SELECTOR2 + 8*SELECTOR3; 00038 } 00039 00040 void delay() 00041 { 00042 int wait; 00043 for (wait=0;wait<30000;wait++); 00044 } 00045 00046 int main(void) 00047 { 00048 int i; 00049 char event; 00050 00051 e_init_port(); //Configure port pins 00052 e_init_uart1(); //Initialize UART to 115200Kbaud 00053 00054 if(RCONbits.POR) //Reset if Power on (some problem for few robots) 00055 { 00056 RCONbits.POR=0; 00057 __asm__ volatile ("reset"); 00058 } 00059 00060 if(getselector()==0) 00061 { 00062 e_bt_set_event_filter(3); 00063 for (i=0;i<8;i++) 00064 { 00065 e_set_led(i,1); 00066 delay(); 00067 e_set_led(i-1,0); 00068 delay(); 00069 } 00070 e_set_led(7,0); 00071 delay(); 00072 e_set_led(8,1); 00073 } 00074 else 00075 { 00076 e_bt_set_event_filter(1); 00077 for (i=0;i<8;i++) 00078 { 00079 e_set_led(i,1); 00080 delay(); 00081 e_set_led(i-1,0); 00082 delay(); 00083 } 00084 e_set_led(7,0); 00085 delay(); 00086 event = e_bt_get_event_filter(); 00087 e_set_led(event,1); 00088 } 00089 00090 while(1) 00091 ; 00092 }