summaryrefslogtreecommitdiff
path: root/peripheral/libupm/src/grove/grove.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'peripheral/libupm/src/grove/grove.cxx')
-rw-r--r--peripheral/libupm/src/grove/grove.cxx11
1 files changed, 3 insertions, 8 deletions
diff --git a/peripheral/libupm/src/grove/grove.cxx b/peripheral/libupm/src/grove/grove.cxx
index b0be12d..4be1f3e 100644
--- a/peripheral/libupm/src/grove/grove.cxx
+++ b/peripheral/libupm/src/grove/grove.cxx
@@ -28,7 +28,7 @@
#include <string>
#include <stdexcept>
-#include "grove.hpp"
+#include "grove.h"
#include "math.h"
using namespace upm;
@@ -109,7 +109,7 @@ bool GroveRelay::isOff()
//// GroveTemp ////
-GroveTemp::GroveTemp(unsigned int pin, float scale)
+GroveTemp::GroveTemp(unsigned int pin)
{
if ( !(m_aio = mraa_aio_init(pin)) ) {
throw std::invalid_argument(std::string(__FUNCTION__) +
@@ -117,7 +117,6 @@ GroveTemp::GroveTemp(unsigned int pin, float scale)
return;
}
m_name = "Temperature Sensor";
- m_scale = scale;
}
GroveTemp::~GroveTemp()
@@ -127,10 +126,7 @@ GroveTemp::~GroveTemp()
int GroveTemp::value ()
{
- float a = (float) mraa_aio_read(m_aio);
- if (a == -1.0) return -1;
- // Apply scale factor after error check
- a *= m_scale;
+ int a = mraa_aio_read(m_aio);
float r = (float)(1023.0-a)*10000.0/a;
float t = 1.0/(log(r/10000.0)/3975.0 + 1.0/298.15)-273.15;
return (int) round(t);
@@ -162,7 +158,6 @@ int GroveLight::value()
{
// rough conversion to lux, using formula from Grove Starter Kit booklet
float a = (float) mraa_aio_read(m_aio);
- if (a == -1.0) return -1;
a = 10000.0/pow(((1023.0-a)*10.0/a)*15.0,4.0/3.0);
return (int) round(a);
}