Updated interfaces and sensors

Signed-off-by: Serban Waltter <serban.waltter@rinftech.com>
This commit is contained in:
Serban Waltter 2018-07-26 18:04:31 +03:00
parent d3ff8cfbc7
commit d431d1458e
18 changed files with 44 additions and 63 deletions

View File

@ -29,16 +29,16 @@ namespace upm
/** /**
* @brief Interface for Rotary Angle sensors * @brief Interface for Rotary Angle sensors
*/ */
class iRotaryAngle class iAngle
{ {
public: public:
virtual ~iRotaryAngle() {} virtual ~iAngle() {}
/** /**
* Get rotation value from sensor data. * Get rotation value from sensor data.
* *
* @return rotation value. * @return rotation value in degrees.
*/ */
virtual float getValue() = 0; virtual float getAngle() = 0;
}; };
} }

View File

@ -35,18 +35,10 @@ namespace upm
virtual ~iClock() {} virtual ~iClock() {}
/** /**
* Loads all the time values * Returns the time since epoch in seconds
* *
* @return True if time data loaded successfully * @return time since epoch in seconds
*/ */
virtual bool loadTime() = 0; virtual unsigned long getTime() = 0;
/**
* Sets the time. You should call loadTime() beforehand to
* maintain consistency
*
* @return True if time is set successfully
*/
virtual bool setTime() = 0;
}; };
} }

View File

@ -34,18 +34,6 @@ namespace upm
public: public:
virtual ~iEmg() {} virtual ~iEmg() {}
/**
* Calibrates the EMG reader
*/
virtual void calibrate() = 0;
/**
* Measures muscle signals from the reader
*
* @return Muscle output as analog voltage
*/
virtual int value() = 0;
/** /**
* Read scaled/offset voltage from the sensor * Read scaled/offset voltage from the sensor
* *

View File

@ -40,13 +40,5 @@ namespace upm
* @param enable true to enable the device, false otherwise. * @param enable true to enable the device, false otherwise.
*/ */
virtual void enable(bool enable) = 0; virtual void enable(bool enable) = 0;
/**
* Set the baudrate of the device.
*
* @param baudrate The baud rate to set for the device.
*/
virtual void setBaudrate(unsigned int baudrate) = 0;
}; };
} }

View File

@ -35,13 +35,11 @@ namespace upm
virtual ~iPH() {} virtual ~iPH() {}
/** /**
* Take a number of samples and return the detected pH value. The * Returns the detected pH value.
* default number of samples is 15.
* *
* @param samples The number of samples to average over, default 15
* @return The pH value detected * @return The pH value detected
*/ */
virtual float pH(unsigned int samples = 15) = 0; virtual float getPH() = 0;
}; };
} }

View File

@ -40,7 +40,7 @@ namespace upm
/** /**
* Measures applied pressure * Measures applied pressure
* *
* @return gets pressure value * @return gets pressure value in Pa
*/ */
virtual float getPressure() = 0; virtual float getPressure() = 0;

View File

@ -37,7 +37,7 @@ namespace upm
/** /**
* Gets the conversion value from the sensor * Gets the conversion value from the sensor
* *
* @return ADC conversion value * @return ADC conversion value in volts
*/ */
virtual unsigned int getValue() = 0; virtual unsigned int getValue() = 0;

View File

@ -74,3 +74,8 @@ float DFRPH::pH(unsigned int samples)
return ph_avg/samples; return ph_avg/samples;
} }
float DFRPH::getPH()
{
return pH(10);
}

View File

@ -132,6 +132,13 @@ namespace upm {
*/ */
virtual float pH(unsigned int samples = 15); virtual float pH(unsigned int samples = 15);
/**
* Returns the detected pH value.
*
* @return The pH value detected
*/
virtual float getPH();
private: private:
/** /**
* Don't allow copies of this class * Don't allow copies of this class

View File

@ -28,7 +28,6 @@
#include <string> #include <string>
#include <mraa/i2c.hpp> #include <mraa/i2c.hpp>
#include <interfaces/iClock.hpp>
#define DS1307_I2C_BUS 0 #define DS1307_I2C_BUS 0
#define DS1307_I2C_ADDR 0x68 #define DS1307_I2C_ADDR 0x68
@ -70,7 +69,7 @@ namespace upm {
* @image html ds1307.jpg * @image html ds1307.jpg
* @snippet ds1307.cxx Interesting * @snippet ds1307.cxx Interesting
*/ */
class DS1307 : virtual public iClock { class DS1307 {
public: public:
/** /**
* DS1307 constructor * DS1307 constructor
@ -84,7 +83,7 @@ namespace upm {
* *
* @return True if time data loaded successfully * @return True if time data loaded successfully
*/ */
virtual bool loadTime(); bool loadTime();
/** /**
* Sets the time. You should call loadTime() beforehand to * Sets the time. You should call loadTime() beforehand to
@ -92,7 +91,7 @@ namespace upm {
* *
* @return True if time is set successfully * @return True if time is set successfully
*/ */
virtual bool setTime(); bool setTime();
/** /**
* Enables an oscillator on the clock. * Enables an oscillator on the clock.

View File

@ -78,7 +78,7 @@ float GroveRotary::rel_rad()
return GroveRotary::rel_deg() * M_PI / 180.0; return GroveRotary::rel_deg() * M_PI / 180.0;
} }
float GroveRotary::getValue() float GroveRotary::getAngle()
{ {
return GroveRotary::abs_value(); return GroveRotary::abs_deg();
} }

View File

@ -29,7 +29,7 @@
#include <string> #include <string>
#include <mraa/aio.hpp> #include <mraa/aio.hpp>
#include "grovebase.hpp" #include "grovebase.hpp"
#include <interfaces/iRotaryAngle.hpp> #include <interfaces/iAngle.hpp>
namespace upm { namespace upm {
@ -54,7 +54,7 @@ namespace upm {
* @image html rotaryencoder.jpg * @image html rotaryencoder.jpg
* @snippet grove-groverotary.cxx Interesting * @snippet grove-groverotary.cxx Interesting
*/ */
class GroveRotary: public Grove, virtual public iRotaryAngle { class GroveRotary: public Grove, virtual public iAngle {
public: public:
/** /**
* Grove rotary angle sensor constructor * Grove rotary angle sensor constructor
@ -108,7 +108,7 @@ class GroveRotary: public Grove, virtual public iRotaryAngle {
* *
* @return rotation value. * @return rotation value.
*/ */
virtual float getValue(); virtual float getAngle();
private: private:
mraa_aio_context m_aio; mraa_aio_context m_aio;

View File

@ -275,7 +275,7 @@ namespace upm {
virtual float getTemperature(); virtual float getTemperature();
/** /**
* Returns the pressure in millibars * Returns the pressure in pascal
* *
* @return Pressure * @return Pressure
*/ */

View File

@ -137,9 +137,9 @@ namespace upm {
/** /**
* Return the latest measured pressure. update() must have * Return the latest measured pressure. update() must have
* been called prior to calling this function. The returned * been called prior to calling this function. The returned
* value is in millibars. * value is in pascal.
* *
* @return Pressure in mbar * @return Pressure in Pa
*/ */
virtual float getPressure(); virtual float getPressure();

View File

@ -77,7 +77,7 @@ float Rotary::rel_rad()
return Rotary::rel_deg() * M_PI / 180.0; return Rotary::rel_deg() * M_PI / 180.0;
} }
float Rotary::getValue() float Rotary::getAngle()
{ {
return Rotary::abs_value(); return Rotary::abs_deg();
} }

View File

@ -30,7 +30,7 @@
#include <mraa/aio.hpp> #include <mraa/aio.hpp>
#include "rotary.hpp" #include "rotary.hpp"
#include <interfaces/iRotaryAngle.hpp> #include <interfaces/iAngle.hpp>
namespace upm { namespace upm {
@ -60,7 +60,7 @@ namespace upm {
* @image html rotary.jpg * @image html rotary.jpg
* @snippet rotary.cxx Interesting * @snippet rotary.cxx Interesting
*/ */
class Rotary : virtual public iRotaryAngle { class Rotary : virtual public iAngle {
public: public:
/** /**
* Rotary angle sensor constructor * Rotary angle sensor constructor
@ -115,7 +115,7 @@ class Rotary : virtual public iRotaryAngle {
* *
* @return rotation value. * @return rotation value.
*/ */
virtual float getValue(); virtual float getAngle();
std::string name(){ return "Rotary Angle Sensor";} std::string name(){ return "Rotary Angle Sensor";}
private: private:

View File

@ -53,6 +53,6 @@ int RotaryEncoder::position()
return rotaryencoder_get_position(m_rotaryencoder); return rotaryencoder_get_position(m_rotaryencoder);
} }
float RotaryEncoder::getValue() { float RotaryEncoder::getAngle() {
return (float) RotaryEncoder::position(); return (float) RotaryEncoder::position() / 20.0 * 360;
} }

View File

@ -24,7 +24,7 @@
#pragma once #pragma once
#include "rotaryencoder.h" #include "rotaryencoder.h"
#include <interfaces/iRotaryAngle.hpp> #include <interfaces/iAngle.hpp>
namespace upm { namespace upm {
@ -61,7 +61,7 @@ namespace upm {
* @snippet rotaryencoder.cxx Interesting * @snippet rotaryencoder.cxx Interesting
*/ */
class RotaryEncoder : virtual public iRotaryAngle { class RotaryEncoder : virtual public iAngle {
public: public:
/** /**
* RotaryEncoder constructor * RotaryEncoder constructor
@ -93,7 +93,7 @@ namespace upm {
* *
* @return rotation value. * @return rotation value.
*/ */
virtual float getValue(); virtual float getAngle();
private: private:
/* Disable implicit copy and assignment operators */ /* Disable implicit copy and assignment operators */