Smartcar Shield
Public Member Functions | List of all members
InfraredAnalogSensor Class Reference

#include <InfraredAnalogSensor.hpp>

Inheritance diagram for InfraredAnalogSensor:
Inheritance graph
Collaboration diagram for InfraredAnalogSensor:
Collaboration graph

Public Member Functions

 InfraredAnalogSensor (Runtime &runtime)
 
unsigned int getMedianDistance (uint8_t iterations=smartcarlib::constants::analogInfraredSensor::kDefaultIterations) override
 Gets the median distance from the specified number of measurements. More...
 
- Public Member Functions inherited from DistanceSensor
virtual ~DistanceSensor ()=default
 
virtual unsigned int getDistance ()=0
 Gets the distance measured by the sensor in centimeters. More...
 

Detailed Description

An abstract class to represent the various infrared analog sensors. These sensors are able to conduct measurements by emiting an analog signal that can be read by a microcontroller through the ADC.

Definition at line 25 of file InfraredAnalogSensor.hpp.

Constructor & Destructor Documentation

◆ InfraredAnalogSensor()

InfraredAnalogSensor::InfraredAnalogSensor ( Runtime runtime)

Definition at line 12 of file InfraredAnalogSensor.cpp.

Member Function Documentation

◆ getMedianDistance()

unsigned int InfraredAnalogSensor::getMedianDistance ( uint8_t  iterations = smartcarlib::constants::analogInfraredSensor::kDefaultIterations)
overridevirtual

Gets the median distance from the specified number of measurements.

Parameters
iterationsNumber of measurements to conduct (at most kMaxMedianMeasurements)
Returns
The median of the conducted measurements or an error value if the number of iterations is 0 or larger than kMaxMedianMeasurements

Example:

// Get the median of `10` measurements
unsigned int distance = sensor.getMedianDistance(10);

Implements DistanceSensor.

Definition at line 17 of file InfraredAnalogSensor.cpp.

Here is the call graph for this function:

The documentation for this class was generated from the following files: