Added iProximity interface

Signed-off-by: Stefan Andritoiu <stefan.andritoiu@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Stefan Andritoiu
2018-06-20 18:27:11 +03:00
committed by Mihai Tudor Panu
parent 6d8e6d8a9f
commit 75c7bd8d12
5 changed files with 72 additions and 7 deletions

View File

@@ -67,3 +67,8 @@ float GP2Y0A::value(float aref, uint8_t samples)
return volts;
}
float GP2Y0A::getValue()
{
return GP2Y0A::value(5.0, (uint8_t) 1);
}

View File

@@ -26,6 +26,7 @@
#include <iostream>
#include <string>
#include <mraa/aio.h>
#include <interfaces/iProximity.hpp>
namespace upm {
/**
@@ -46,15 +47,15 @@ namespace upm {
*
* @brief API for the GP2Y0A family of IR Proximity Sensors
*
* Sensors of this family return an analog voltage corresponding to the distance
* Sensors of this family return an analog voltage corresponding to the distance
* of an object from the sensor. The voltage is lower when objects
* are far away; the voltage increases as objects get closer
* to the sensor.
* to the sensor.
*
* @image html gp2y0a.jpg
* @snippet gp2y0a.cxx Interesting
*/
class GP2Y0A {
class GP2Y0A : virtual public iProximity {
public:
/**
@@ -78,11 +79,19 @@ namespace upm {
*/
float value(float aref, uint8_t samples);
/**
* Gets the voltage value from the sensor from a single sample
* A refernce voltage of 5.0V is used for the reading.
*
* @return Voltage reading from a single sample
*/
virtual float getValue();
private:
mraa_aio_context m_aio;
// ADC resolution
int m_aRes;
};
}