mirror of
https://github.com/eclipse/upm.git
synced 2025-07-02 01:41:12 +03:00
Added iGas interface
Signed-off-by: Serban Waltter <serban.waltter@rinftech.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:

committed by
Mihai Tudor Panu

parent
f28a6d2561
commit
e4f106a0c7
@ -2,4 +2,5 @@ set (libname "mg811")
|
||||
set (libdescription "CO2 Sensor")
|
||||
set (module_src ${libname}.cxx)
|
||||
set (module_hpp ${libname}.hpp)
|
||||
set (module_iface iGas.hpp)
|
||||
upm_module_init(mraa)
|
||||
|
@ -88,6 +88,20 @@ float MG811::ppm()
|
||||
(m_reactionValue / (log400-log1000))+log400);
|
||||
}
|
||||
|
||||
float MG811::getConcentration()
|
||||
{
|
||||
static const float log400 = log10f(400);
|
||||
static const float log1000 = log10f(1000);
|
||||
|
||||
float val = volts();
|
||||
|
||||
if ((val / dcGain) >= m_zeroPointValue)
|
||||
return 0.0;
|
||||
else
|
||||
return powf(10.0, ((val/dcGain)-m_zeroPointValue) /
|
||||
(m_reactionValue / (log400-log1000))+log400);
|
||||
}
|
||||
|
||||
bool MG811::thresholdReached()
|
||||
{
|
||||
return (m_gpio.read() ? true : false);
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include <mraa/aio.hpp>
|
||||
#include <mraa/gpio.hpp>
|
||||
|
||||
#include <interfaces/iGas.hpp>
|
||||
|
||||
namespace upm {
|
||||
/**
|
||||
* @brief MG811 CO2 Sensor
|
||||
@ -68,7 +70,7 @@ namespace upm {
|
||||
* @snippet mg811.cxx Interesting
|
||||
*/
|
||||
|
||||
class MG811 {
|
||||
class MG811: virtual public iGas {
|
||||
public:
|
||||
|
||||
/**
|
||||
@ -83,7 +85,7 @@ namespace upm {
|
||||
/**
|
||||
* MG811 destructor
|
||||
*/
|
||||
~MG811();
|
||||
virtual ~MG811();
|
||||
|
||||
/**
|
||||
* Return a cumputed reference voltage to be used in calibration.
|
||||
@ -118,6 +120,7 @@ namespace upm {
|
||||
* @return The computed CO2 concentration in ppm
|
||||
*/
|
||||
float ppm();
|
||||
float getConcentration();
|
||||
|
||||
/**
|
||||
* Read the digital pin and return true if the set threshold has
|
||||
|
Reference in New Issue
Block a user