Ejemplo n.º 1
0
EL_PROCESS Trigger_Accelerometer_Process(el_handle this_trigger){
    static int previous_xyz[3] = {0,0,0};
    const long threshold_s = 330L*330L;
    long magnitude_s;// _s means squared;
    int xyz[3];
    int dx,dy,dz;

    el_accelerometer_get(EL_ACCELEROMETER_ONE,EL_ACCELERATION_ALL_3V,xyz);
    if(previous_xyz[0]!=0){
        dx = xyz[0] - previous_xyz[0];
        dy = xyz[1] - previous_xyz[1];
        dz = xyz[2] - previous_xyz[2];
        magnitude_s = (long)dx*dx;
        magnitude_s += (long)dy*dy;
        magnitude_s += (long)dz*dz;
        if(magnitude_s > threshold_s){
            el_led_set(EL_LED_BODY,EL_ON);
            el_process_wait(200);
            el_led_set(EL_LED_BODY,EL_OFF);
            el_process_wait(200);
            // 400 ms past, need to refresh values
            el_accelerometer_get(EL_ACCELEROMETER_ONE,EL_ACCELERATION_ALL_3V,xyz);
        }
    }
    previous_xyz[0] = xyz[0];
    previous_xyz[1] = xyz[1];
    previous_xyz[2] = xyz[2];

    el_trigger_enable(this_trigger);

}
Ejemplo n.º 2
0
EL_PROCESS Process_LED(void*data){

    while(1){

        el_led_set(EL_LED_RING_2,1);
        el_led_set(EL_LED_RING_6,0);
        el_process_wait(500);

        el_led_set(EL_LED_RING_2,0);
        el_led_set(EL_LED_RING_6,1);
        el_process_wait(500);

    }

}
Ejemplo n.º 3
0
void Process_LED_PatternA(void*arg){
    
    while(1){

        el_led_set(EL_LED_BODY,EL_ON);
        
        el_process_wait(4800);// "el_process_wait" works only in a process

        el_led_set(EL_LED_BODY,EL_OFF);

        el_process_wait(200);

    }

}
Ejemplo n.º 4
0
void Process_LED_PatternB(void*arg){
    int i = 0;

    while(1){

        el_led_set(EL_LED_RING_0 + i,EL_ON);

        el_process_wait(125);

        el_led_set(EL_LED_RING_0 + i,EL_OFF);
        
        i++;
        i %= 8;
    }
    
}
Ejemplo n.º 5
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();

}