int main(){ el_initialization(); /* * This is to let the robot automaticaly reset when TinyBootloader * attemps to write a new HEX, so you dont need to touch the reset * button. * To achieve this, TinyBootloader also needs to be configured: * in "Options" tab, set "Codes to send first" to 6. */ el_uart_use_reset_code(true,6); /* * Put the robot in silence when the selector is in 0~3. */ BootingProcedure01_SelectorBarrier(); // see documentation for details about "elu_printf" and the UART module elu_printf("Hello World! This is e-puck!\n"); // setup some process, which will be concurrenly executed in "el_main_loop()" el_launch_process(Process_LED_PatternA,NULL); el_launch_process(Process_LED_PatternB,NULL); el_launch_process(Process_LED_Control,NULL); el_led_set(EL_LED_BODY,EL_ON); elu_printf("setup finished\n"); // this it the loop to run everything, including Timer, Process and Trigger. el_main_loop(); return 0; }
EL_PROCESS Process_UART(void*data){ el_camera_image *frame; char c; int i; int ir0,ir7; el_ir_proximity_data prox[8]; el_int16 xyz[3]; /* elu_printf("ENTER YOUR PIN >>"); elu_scanf("%d",&i); if(i==9527){ elu_printf("PIN OK.\n"); }else{ elu_printf("PIN ERROR.\n"); } */ while(1){ WAIT_FOR_UART1_CHAR; c = el_uart_get_char(EL_UART_1); switch(c){ case 'f': el_led_set(EL_LED_FRONT,EL_TOGGLE); break; case 'y': elu_println("[CAM]\nFPS:\t%d\tNUM:\t%lu",CameraFPS,el_camera_get_frame_counter()); break; case 't': el_camera_lock_frame(); frame = el_camera_frame(); elu_print_camera_image(frame,el_camera_get_frame_counter()); el_camera_unlock_frame(); elu_putchar('\n'); break; case 'g': elu_println("[ACC]"); el_accelerometer_get(EL_ACCELEROMETER_ONE,EL_ACCELERATION_ALL_3V,xyz); elu_println("%d\t%d\t%d",xyz[0],xyz[1],xyz[2]); elu_putchar('\n'); break; case 'r': elu_println("[IR,%d]",(int)el_ir_proximity_get_counter()); el_ir_proximity_get(EL_IR_PROXIMITY_SENSOR_ALL,EL_IR_ALL_3V,(el_int16*)prox); elu_printf("AMB:"); for(i=0;i<8;i++){ elu_printf("\t%d",prox[i].Ambient); } elu_putchar('\n'); elu_printf("REF:"); for(i=0;i<8;i++){ elu_printf("\t%d",prox[i].Reflection); } elu_putchar('\n'); break; case 'e': el_ir_proximity_get(EL_IR_PROXIMITY_SENSOR_0,EL_IR_REFLECTION,&ir0); el_ir_proximity_get(EL_IR_PROXIMITY_SENSOR_7,EL_IR_REFLECTION,&ir7); elu_println("%d,%d",ir0,ir7); break; case 'c': elu_println("[IRNR]"); for(i=0;i<8;i++){ elu_printf("%d\t",el_irps_samples_NeutralReflection[i]); } elu_putchar('\n'); break; case 'w': el_set_wheel_speed(1000,1000); break; case 'a': el_set_wheel_speed(-250,250); break; case 's': el_set_wheel_speed(-500,-500); break; case 'd': el_set_wheel_speed(250,-250); break; case ' ': el_set_wheel_speed(0,0); break; } } }
void Process_ConsoleLoop(void*arg){ char c; int i; elu_printf("EL_EXAMPLE_04\n"); // setup the task Task_ObjectFollowing_Setup(); el_process_wait(500);// wait for 500 ms el_uart_flush_char(EL_UART_1); while(1){ do{ el_process_cooperate(); }while(el_uart_get_char_counter(EL_UART_1)==0); c = el_uart_get_char(EL_UART_1); switch(c){ case 'f': el_led_set(EL_LED_FRONT,EL_TOGGLE); break; case 'r':// report ir proximity sensor outputs elu_println("<IR>"); el_ir_proximity_get(EL_IR_PROXIMITY_SENSOR_ALL,EL_IR_ALL_3V,(el_int16*)ProximitySensor); elu_printf("AMB:"); for(i=0;i<8;i++){ elu_printf("\t%d",ProximitySensor[i].Ambient); } elu_putchar('\n'); elu_printf("REF:"); for(i=0;i<8;i++){ elu_printf("\t%d",ProximitySensor[i].Reflection); } elu_putchar('\n'); break; case 'p':// report image processing result elu_println("<IMG>"); elu_println("MASS:\t%d\t%d\t%d",vision_mass_red,vision_mass_green,vision_mass_blue); elu_println("BIAS:\t%d\t%d\t%d",vision_bias_red,vision_bias_green,vision_bias_blue); elu_putchar('\n'); break; case '1': Task_ObjectColor = TASK_OBJECT_RED; elu_println("FOLLOW RED"); break; case '2': Task_ObjectColor = TASK_OBJECT_GREEN; elu_println("FOLLOW GREEN"); break; case '3': Task_ObjectColor = TASK_OBJECT_BLUE; elu_println("FOLLOW BLUE"); break; } } Task_ObjectFollowing_Clear(); }