/** * Get the last distance measured by the sonar in centimeters. When the ground is too far away, SONAR_OUT_OF_RANGE is returned. */ int32_t sonarRead(void) { int32_t distance = hcsr04_get_distance(); if (distance > HCSR04_MAX_RANGE_CM) distance = SONAR_OUT_OF_RANGE; return distance; }
/** * Get the last distance measured by the sonar in centimeters. When the ground is too far away, SONAR_OUT_OF_RANGE is returned. */ int32_t sonarRead(void) { int32_t distance = hcsr04_get_distance(); if (distance > HCSR04_MAX_RANGE_CM) distance = SONAR_OUT_OF_RANGE; return applySonarMedianFilter(distance); }
void Sonar_update(void) { hcsr04_get_distance(&sonarAlt); }
/** * Get the last distance measured by the sonar in centimeters. When the ground is too far away, -1 is returned instead. */ int32_t sonarRead(void) { return hcsr04_get_distance(); }