int SonarAlert::detectBarrier()

in str/apps/src/SonarAlert.cpp [30:50]


int SonarAlert::detectBarrier()
{
    timeCounter++;
    int alert = 0;

    if( timeCounter == 40/secPerCycle )
    {
        if( sonarSensor->getDistance() <= SONAR_ALERT_DISTANCE
                && 0 <= sonarSensor->getDistance() )
        {
            alert = 1;
        }
        else
        {
            alert = 0;
        }
        timeCounter = 0;
    }

    return alert;
}