Exemplo n.º 1
0
RakNet::Time RakNet::GetTime( void )
{
	return (RakNet::Time)(GetTimeUS()/1000);
}
Exemplo n.º 2
0
RakNet::TimeMS RakNet::GetTimeMS( void )
{
	return (RakNet::TimeMS)(GetTimeUS()/1000);
}
Exemplo n.º 3
0
SLNet::TimeMS SLNet::GetTimeMS( void )
{
	return (SLNet::TimeMS)(GetTimeUS()/1000);
}
Exemplo n.º 4
0
SLNet::Time SLNet::GetTime( void )
{
	return (SLNet::Time)(GetTimeUS()/1000);
}
Exemplo n.º 5
0
VENet::TimeMS VENet::GetTimeMS( void )
{
    return (VENet::TimeMS)(GetTimeUS()/1000);
}
Exemplo n.º 6
0
VENet::Time VENet::GetTime( void )
{
    return (VENet::Time)(GetTimeUS()/1000);
}
Exemplo n.º 7
0
Arquivo: Main.c Projeto: dteal/rasware
// main function
int main(void){
    // initialize io
    initialize_pins();

    // set up sensors
    ADCReadContinuously(side_ir_sensor, 0.01);
    ADCReadContinuously(front_ir_sensor, 0.01);
    ADCReadContinuously(goal_ir_sensor, 0.01);

    // turn on status led
    SetPin(green_led_pin, 1);

    #ifdef WAIT_FOR_BUTTON_TO_START
        // wait for button press
        CallOnPinRising(react_to_button, 0, PIN_F0);
        while(!running){}
    #else
        running=1;
    #endif

    // main loop
    while(1){
        if(running){
            // poll sensors
            float side_value = ADCRead(side_ir_sensor);
            float front_value = ADCRead(front_ir_sensor);
            float goal_value = ADCRead(goal_ir_sensor);

            // sanitize values
            side_value = coerce(side_value, 0, 1, side_avg[avg_idx]);
            front_value = coerce(front_value, 0, 1, front_avg[avg_idx]);
            goal_value = coerce(goal_value, 0, 1, goal_avg[avg_idx]);

            float side_dist = 0;
            float front_dist = 0;
            float goal_dist = 0;
            if(reset_ir_flag){
                // initialize averaging arrays to values
                fill_array(side_avg, AVG_LEN, side_value);
                fill_array(front_avg, AVG_LEN, front_value);
                fill_array(goal_avg, AVG_LEN, goal_value);
                reset_ir_flag = 0;
                side_dist = side_value;
                front_dist = front_value;
                goal_dist = goal_value;
            }else{
                // average values
                avg_idx++;
                if(avg_idx>=AVG_LEN){
                    avg_idx=0;
                }
                side_avg[avg_idx] = side_value;
                front_avg[avg_idx] = front_value;
                goal_avg[avg_idx] = goal_value;
                side_dist = average(side_avg, AVG_LEN);
                front_dist = average(front_avg, AVG_LEN);
                goal_dist = average(goal_avg, AVG_LEN);
            }

            SetMotor(right_motor, 1);
            if(GetTimeUS()/1000){
                left_motor_power += 0.1;
            }
            SetMotor(left_motor, left_motor_power);

            if(side_dist > side_to_can){
                SetMotor(right_motor, 0.5);
                SetMotor(left_motor, 1);
            }

            // follow wall
            if(side_value > side_max || front_value > front_max){
                SetMotor(left_motor, -1);
            }else{
                SetMotor(left_motor, 1);
            }
            SetMotor(right_motor, 1);
        }
    }
}