Esempio n. 1
0
void Process_LED_Control(void*arg){
    char c;
    
    while(1){

        // wait until something is received
        do{
            /*
             * In a process, "el_process_cooperate" need to be called in any
             * polling loops. See the documentation of the Process module to
             * learn more details.
             */
            el_process_cooperate();

        }while(el_uart_get_char_counter(EL_UART_1)==0);
        
        c = el_uart_get_char(EL_UART_1);
        if(c=='f'){
            el_led_set(EL_LED_FRONT,EL_TOGGLE);
        }
        
    }
    
}
Esempio n. 2
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;

        }
    }
}
Esempio n. 3
0
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();

}