Added interfaces:

iEC
iEmg
iClock
iHeartRate
iLineFinder
iOrp

Signed-off-by: Stefan Andritoiu <stefan.andritoiu@gmail.com>
This commit is contained in:
Stefan Andritoiu 2018-06-07 17:50:55 +03:00
parent 75ffc8452c
commit a4b84824f8
22 changed files with 368 additions and 59 deletions

View File

@ -0,0 +1,52 @@
/*
* Author: Mihai Stefanescu <mihai.stefanescu@rinftech.com>
* Copyright (c) 2018 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
namespace upm
{
/**
* @brief Interface for Real Time Clock (RTC) Modules
*/
class iClock
{
public:
virtual ~iClock() {}
/**
* Loads all the time values
*
* @return True if time data loaded successfully
*/
virtual bool loadTime() = 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

@ -0,0 +1,45 @@
/*
* Author: Mihai Stefanescu <mihai.stefanescu@rinftech.com>
* Copyright (c) 2018 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
namespace upm
{
/**
* @brief Interface for Electrical Conductivity (EC) Sensors
*/
class iEC
{
public:
virtual ~iEC() {}
/**
* Get computed EC (ms/cm) value from the sensor.
*
* @return EC value in ms/cm.
*/
virtual float getECValue() = 0;
};
}

View File

@ -0,0 +1,49 @@
/*
* Author: Mihai Stefanescu <mihai.stefanescu@rinftech.com>
* Copyright (c) 2018 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
namespace upm
{
/**
* @brief Interface for Electromyography (EMG) Sensors
*/
class iEmg
{
public:
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;
};
}

View File

@ -0,0 +1,44 @@
/*
* Author: Mihai Stefanescu <mihai.stefanescu@rinftech.com>
* Copyright (c) 2018 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
namespace upm
{
/**
* @brief Interface for Heart Rate sensors
*/
class iHeartRate
{
public:
virtual ~iHeartRate() {}
/**
* Retrieve the computed heart rate
*
* @return Computed heart rate
*/
virtual int getHeartRate() = 0;
};
}

View File

@ -0,0 +1,51 @@
/*
* Author: Mihai Stefanescu <mihai.stefanescu@rinftech.com>
* Copyright (c) 2018 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
namespace upm
{
/**
* @brief Interface for Line Finder Modules
*/
class iLineFinder
{
public:
virtual ~iLineFinder() {}
/**
* Determines whether white has been detected
*
* @return True if white is detected
*/
virtual bool whiteDetected() = 0;
/**
* Determines whether black has been detected
*
* @return True if black is detected
*/
virtual bool blackDetected() = 0;
};
}

View File

@ -73,6 +73,12 @@ float DFREC::getEC()
return dfrec_get_ec(m_dfrec); return dfrec_get_ec(m_dfrec);
} }
float DFREC::getECValue()
{
DFREC::update();
return DFREC::getEC();
}
float DFREC::getVolts() float DFREC::getVolts()
{ {
return dfrec_get_volts(m_dfrec); return dfrec_get_volts(m_dfrec);

View File

@ -31,6 +31,7 @@
#include <string.h> #include <string.h>
#include "dfrec.h" #include "dfrec.h"
#include <interfaces/iEC.hpp>
namespace upm { namespace upm {
/** /**
@ -65,7 +66,7 @@ namespace upm {
* @snippet dfrec.cxx Interesting * @snippet dfrec.cxx Interesting
*/ */
class DFREC { class DFREC : virtual public iEC {
public: public:
/** /**
@ -120,6 +121,13 @@ namespace upm {
*/ */
float getEC(); float getEC();
/**
* Get computed EC (ms/cm) value from the sensor. update() is called
* in this function.
* @return EC value in ms/cm.
*/
virtual float getECValue();
/** /**
* Get the measured volts from the sensor. update() must have been * Get the measured volts from the sensor. update() must have been
* called prior to calling this function. * called prior to calling this function.

View File

@ -28,6 +28,7 @@
#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
@ -69,7 +70,7 @@ namespace upm {
* @image html ds1307.jpg * @image html ds1307.jpg
* @snippet ds1307.cxx Interesting * @snippet ds1307.cxx Interesting
*/ */
class DS1307 { class DS1307 : virtual public iClock {
public: public:
/** /**
* DS1307 constructor * DS1307 constructor
@ -83,7 +84,7 @@ namespace upm {
* *
* @return True if time data loaded successfully * @return True if time data loaded successfully
*/ */
bool loadTime(); virtual bool loadTime();
/** /**
* Sets the time. You should call loadTime() beforehand to * Sets the time. You should call loadTime() beforehand to
@ -91,7 +92,7 @@ namespace upm {
* *
* @return True if time is set successfully * @return True if time is set successfully
*/ */
bool setTime(); virtual bool setTime();
/** /**
* Enables an oscillator on the clock. * Enables an oscillator on the clock.
@ -132,7 +133,7 @@ namespace upm {
* Converts a BCD value into decimal * Converts a BCD value into decimal
* *
* @param val BCD value to convert * @param val BCD value to convert
* @return Converted decimal value * @return Converted decimal value
*/ */
unsigned int bcdToDec(uint8_t val); unsigned int bcdToDec(uint8_t val);
@ -190,5 +191,3 @@ namespace upm {
mraa::I2c m_i2c; mraa::I2c m_i2c;
}; };
} }

View File

@ -81,6 +81,12 @@ float ECEZO::getEC()
return ecezo_get_ec(m_ecezo); return ecezo_get_ec(m_ecezo);
} }
float ECEZO::getECValue()
{
ECEZO::update();
return ECEZO::getEC();
}
float ECEZO::getTDS() float ECEZO::getTDS()
{ {
return ecezo_get_tds(m_ecezo); return ecezo_get_tds(m_ecezo);

View File

@ -30,6 +30,7 @@
#include <unistd.h> #include <unistd.h>
#include "ecezo.h" #include "ecezo.h"
#include <interfaces/iEC.hpp>
namespace upm { namespace upm {
/** /**
@ -57,7 +58,7 @@ namespace upm {
* @snippet ecezo.cxx Interesting * @snippet ecezo.cxx Interesting
*/ */
class ECEZO { class ECEZO : virtual public iEC {
public: public:
/** /**
@ -127,6 +128,14 @@ namespace upm {
*/ */
float getEC(); float getEC();
/**
* Measures and retrieves the Electrical Conductivity (EC)
* value in microsiemens. update() is called during this function.
*
* @return EC value in microsiemens
*/
virtual float getECValue();
/** /**
* Retrieve the last measured Total Dissolved solids (TDS) value. * Retrieve the last measured Total Dissolved solids (TDS) value.
* update() must have been called before calling this * update() must have been called before calling this

View File

@ -65,12 +65,12 @@ uint32_t EHR::getMillis()
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
// compute the delta since m_startTime // compute the delta since m_startTime
if( (elapsed.tv_usec = now.tv_usec - m_startTime.tv_usec) < 0 ) if( (elapsed.tv_usec = now.tv_usec - m_startTime.tv_usec) < 0 )
{ {
elapsed.tv_usec += 1000000; elapsed.tv_usec += 1000000;
elapsed.tv_sec = now.tv_sec - m_startTime.tv_sec - 1; elapsed.tv_sec = now.tv_sec - m_startTime.tv_sec - 1;
} }
else else
{ {
elapsed.tv_sec = now.tv_sec - m_startTime.tv_sec; elapsed.tv_sec = now.tv_sec - m_startTime.tv_sec;
} }
@ -92,7 +92,7 @@ void EHR::clearBeatCounter()
void EHR::startBeatCounter() void EHR::startBeatCounter()
{ {
// install our interrupt handler // install our interrupt handler
mraa_gpio_isr(m_gpio, MRAA_GPIO_EDGE_RISING, mraa_gpio_isr(m_gpio, MRAA_GPIO_EDGE_RISING,
&beatISR, this); &beatISR, this);
} }
@ -117,7 +117,7 @@ int EHR::heartRate()
{ {
uint32_t millis = getMillis(); uint32_t millis = getMillis();
uint32_t beats = beatCounter(); uint32_t beats = beatCounter();
float heartRate = 0; float heartRate = 0;
// wait at least 5 seconds before attempting to compute the // wait at least 5 seconds before attempting to compute the
// heart rate // heart rate
@ -128,3 +128,8 @@ int EHR::heartRate()
return int(heartRate); return int(heartRate);
} }
int EHR::getHeartRate()
{
return EHR::heartRate();
}

View File

@ -27,6 +27,7 @@
#include <stdint.h> #include <stdint.h>
#include <sys/time.h> #include <sys/time.h>
#include <mraa/gpio.h> #include <mraa/gpio.h>
#include <interfaces/iHeartRate.hpp>
namespace upm { namespace upm {
/** /**
@ -46,12 +47,12 @@ namespace upm {
* @brief API for the Ear-clip Heart Rate Sensor * @brief API for the Ear-clip Heart Rate Sensor
* *
* UPM module for the ear-clip heart rate sensor. It is used to measure your * UPM module for the ear-clip heart rate sensor. It is used to measure your
* heart rate. * heart rate.
* *
* @image html ehr.jpg * @image html ehr.jpg
* @snippet ehr.cxx Interesting * @snippet ehr.cxx Interesting
*/ */
class EHR { class EHR : virtual public iHeartRate {
public: public:
/** /**
* EHR constructor * EHR constructor
@ -110,17 +111,22 @@ namespace upm {
*/ */
int heartRate(); int heartRate();
/**
* Retrieve the computed heart rate
*
* @return Computed heart rate
*/
virtual int getHeartRate();
private: private:
/** /**
* Beat interrupt service routine (ISR) * Beat interrupt service routine (ISR)
* *
*/ */
static void beatISR(void *ctx); static void beatISR(void *ctx);
volatile uint32_t m_beatCounter; volatile uint32_t m_beatCounter;
struct timeval m_startTime; struct timeval m_startTime;
mraa_gpio_context m_gpio; mraa_gpio_context m_gpio;
}; };
} }

View File

@ -25,6 +25,7 @@
#include <string> #include <string>
#include <mraa/aio.h> #include <mraa/aio.h>
#include "interfaces/iEmg.hpp"
namespace upm { namespace upm {
/** /**
@ -43,14 +44,14 @@ namespace upm {
* @con analog * @con analog
* *
* @brief API for the Grove EMG Muscle Signal Reader * @brief API for the Grove EMG Muscle Signal Reader
* *
* Grove EMG muscle signal reader gathers small muscle signals, * Grove EMG muscle signal reader gathers small muscle signals,
* then processes them, and returns the result * then processes them, and returns the result
* *
* @image html emg.jpg * @image html emg.jpg
* @snippet emg.cxx Interesting * @snippet emg.cxx Interesting
*/ */
class EMG { class EMG : virtual public iEmg {
public: public:
/** /**
* Grove EMG reader constructor * Grove EMG reader constructor
@ -66,18 +67,16 @@ namespace upm {
/** /**
* Calibrates the Grove EMG reader * Calibrates the Grove EMG reader
*/ */
void calibrate(); virtual void calibrate();
/** /**
* Measures muscle signals from the reader * Measures muscle signals from the reader
* *
* @return Muscle output as analog voltage * @return Muscle output as analog voltage
*/ */
int value(); virtual int value();
private: private:
mraa_aio_context m_aio; mraa_aio_context m_aio;
}; };
} }

View File

@ -65,12 +65,12 @@ uint32_t GroveEHR::getMillis()
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
// compute the delta since m_startTime // compute the delta since m_startTime
if( (elapsed.tv_usec = now.tv_usec - m_startTime.tv_usec) < 0 ) if( (elapsed.tv_usec = now.tv_usec - m_startTime.tv_usec) < 0 )
{ {
elapsed.tv_usec += 1000000; elapsed.tv_usec += 1000000;
elapsed.tv_sec = now.tv_sec - m_startTime.tv_sec - 1; elapsed.tv_sec = now.tv_sec - m_startTime.tv_sec - 1;
} }
else else
{ {
elapsed.tv_sec = now.tv_sec - m_startTime.tv_sec; elapsed.tv_sec = now.tv_sec - m_startTime.tv_sec;
} }
@ -92,7 +92,7 @@ void GroveEHR::clearBeatCounter()
void GroveEHR::startBeatCounter() void GroveEHR::startBeatCounter()
{ {
// install our interrupt handler // install our interrupt handler
mraa_gpio_isr(m_gpio, MRAA_GPIO_EDGE_RISING, mraa_gpio_isr(m_gpio, MRAA_GPIO_EDGE_RISING,
&beatISR, this); &beatISR, this);
} }
@ -117,7 +117,7 @@ int GroveEHR::heartRate()
{ {
uint32_t millis = getMillis(); uint32_t millis = getMillis();
uint32_t beats = beatCounter(); uint32_t beats = beatCounter();
float heartRate = 0; float heartRate = 0;
// wait at least 5 seconds before attempting to compute the // wait at least 5 seconds before attempting to compute the
// heart rate // heart rate
@ -128,3 +128,8 @@ int GroveEHR::heartRate()
return int(heartRate); return int(heartRate);
} }
int GroveEHR::getHeartRate()
{
return GroveEHR::heartRate();
}

View File

@ -27,6 +27,7 @@
#include <stdint.h> #include <stdint.h>
#include <sys/time.h> #include <sys/time.h>
#include <mraa/gpio.h> #include <mraa/gpio.h>
#include <interfaces/iHeartRate.hpp>
namespace upm { namespace upm {
/** /**
@ -48,12 +49,12 @@ namespace upm {
* @brief API for the Grove Ear-clip Heart Rate Sensor * @brief API for the Grove Ear-clip Heart Rate Sensor
* *
* UPM module for the Grove ear-clip heart rate sensor. It is used to measure your * UPM module for the Grove ear-clip heart rate sensor. It is used to measure your
* heart rate. * heart rate.
* *
* @image html groveehr.jpg * @image html groveehr.jpg
* @snippet groveehr.cxx Interesting * @snippet groveehr.cxx Interesting
*/ */
class GroveEHR { class GroveEHR : virtual public iHeartRate {
public: public:
/** /**
* GroveEHR constructor * GroveEHR constructor
@ -112,17 +113,22 @@ namespace upm {
*/ */
int heartRate(); int heartRate();
/**
* Retrieve the computed heart rate
*
* @return Computed heart rate
*/
virtual int getHeartRate();
private: private:
/** /**
* Beat interrupt service routine (ISR) * Beat interrupt service routine (ISR)
* *
*/ */
static void beatISR(void *ctx); static void beatISR(void *ctx);
volatile uint32_t m_beatCounter; volatile uint32_t m_beatCounter;
struct timeval m_startTime; struct timeval m_startTime;
mraa_gpio_context m_gpio; mraa_gpio_context m_gpio;
}; };
} }

View File

@ -25,6 +25,7 @@
#include <string> #include <string>
#include <mraa/aio.h> #include <mraa/aio.h>
#include "interfaces/iEmg.hpp"
namespace upm { namespace upm {
/** /**
@ -51,7 +52,7 @@ namespace upm {
* @image html emg.jpg * @image html emg.jpg
* @snippet groveemg.cxx Interesting * @snippet groveemg.cxx Interesting
*/ */
class GroveEMG { class GroveEMG : virtual public iEmg {
public: public:
/** /**
* Grove EMG reader constructor * Grove EMG reader constructor
@ -67,18 +68,16 @@ namespace upm {
/** /**
* Calibrates the Grove EMG reader * Calibrates the Grove EMG reader
*/ */
void calibrate(); virtual void calibrate();
/** /**
* Measures muscle signals from the reader * Measures muscle signals from the reader
* *
* @return Muscle output as analog voltage * @return Muscle output as analog voltage
*/ */
int value(); virtual int value();
private: private:
mraa_aio_context m_aio; mraa_aio_context m_aio;
}; };
} }

View File

@ -68,3 +68,8 @@ int GroveGSR::value()
int val = mraa_aio_read(m_aio); int val = mraa_aio_read(m_aio);
return val; return val;
} }
float GroveGSR::getECValue()
{
return (float) GroveGSR::value();
}

View File

@ -25,6 +25,7 @@
#include <string> #include <string>
#include <mraa/aio.h> #include <mraa/aio.h>
#include <interfaces/iEC.hpp>
namespace upm { namespace upm {
/** /**
@ -44,7 +45,7 @@ namespace upm {
* @con analog * @con analog
* *
* @brief API for the Grove GSR Galvanic Skin Response Sensor * @brief API for the Grove GSR Galvanic Skin Response Sensor
* *
* Measures the electrical conductance of skin * Measures the electrical conductance of skin
* to measure strong emotional reactions. * to measure strong emotional reactions.
* In other words, it measures sweat on your fingers * In other words, it measures sweat on your fingers
@ -53,7 +54,7 @@ namespace upm {
* @image html gsr.jpg * @image html gsr.jpg
* @snippet grovegsr.cxx Interesting * @snippet grovegsr.cxx Interesting
*/ */
class GroveGSR { class GroveGSR : virtual public iEC {
public: public:
/** /**
* Grove GSR sensor constructor * Grove GSR sensor constructor
@ -78,9 +79,14 @@ namespace upm {
*/ */
int value(); int value();
/**
* Gets the electrical conductance of the skin from the sensor
*
* @return Electrical conductance of the skin
*/
virtual float getECValue();
private: private:
mraa_aio_context m_aio; mraa_aio_context m_aio;
}; };
} }

View File

@ -25,6 +25,7 @@
#include <string> #include <string>
#include <mraa/gpio.h> #include <mraa/gpio.h>
#include <interfaces/iLineFinder.hpp>
namespace upm { namespace upm {
/** /**
@ -53,7 +54,7 @@ namespace upm {
* @image html grovelinefinder.jpg * @image html grovelinefinder.jpg
* @snippet grovelinefinder.cxx Interesting * @snippet grovelinefinder.cxx Interesting
*/ */
class GroveLineFinder { class GroveLineFinder : virtual public iLineFinder {
public: public:
/** /**
* Grove Line Finder digital sensor constructor * Grove Line Finder digital sensor constructor
@ -70,17 +71,15 @@ namespace upm {
* *
* @return True if white is detected * @return True if white is detected
*/ */
bool whiteDetected(); virtual bool whiteDetected();
/** /**
* Determines whether black has been detected * Determines whether black has been detected
* *
* @return True if black is detected * @return True if black is detected
*/ */
bool blackDetected(); virtual bool blackDetected();
private: private:
mraa_gpio_context m_gpio; mraa_gpio_context m_gpio;
}; };
} }

View File

@ -65,3 +65,8 @@ int GSR::value()
int val = mraa_aio_read(m_aio); int val = mraa_aio_read(m_aio);
return val; return val;
} }
float GSR::getECValue()
{
return (float) GSR::value();
}

View File

@ -25,6 +25,7 @@
#include <string> #include <string>
#include <mraa/aio.h> #include <mraa/aio.h>
#include <interfaces/iEC.hpp>
namespace upm { namespace upm {
/** /**
@ -42,7 +43,7 @@ namespace upm {
* @con analog * @con analog
* *
* @brief API for the Grove GSR Galvanic Skin Response Sensor * @brief API for the Grove GSR Galvanic Skin Response Sensor
* *
* Measures the electrical conductance of skin * Measures the electrical conductance of skin
* to measure strong emotional reactions. * to measure strong emotional reactions.
* In other words, it measures sweat on your fingers * In other words, it measures sweat on your fingers
@ -51,7 +52,7 @@ namespace upm {
* @image html gsr.jpg * @image html gsr.jpg
* @snippet gsr.cxx Interesting * @snippet gsr.cxx Interesting
*/ */
class GSR { class GSR : virtual public iEC {
public: public:
/** /**
* Grove GSR sensor constructor * Grove GSR sensor constructor
@ -76,9 +77,14 @@ namespace upm {
*/ */
int value(); int value();
/**
* Gets the electrical conductance of the skin from the sensor
*
* @return Electrical conductance of the skin
*/
virtual float getECValue();
private: private:
mraa_aio_context m_aio; mraa_aio_context m_aio;
}; };
} }

View File

@ -24,6 +24,7 @@
#pragma once #pragma once
#include <linefinder.h> #include <linefinder.h>
#include <interfaces/iLineFinder.hpp>
namespace upm { namespace upm {
/** /**
@ -51,7 +52,7 @@ namespace upm {
* @image html linefinder.jpg * @image html linefinder.jpg
* @snippet linefinder.cxx Interesting * @snippet linefinder.cxx Interesting
*/ */
class LineFinder { class LineFinder : virtual public iLineFinder {
public: public:
/** /**
* Line Finder digital sensor constructor * Line Finder digital sensor constructor
@ -70,14 +71,14 @@ namespace upm {
* *
* @return True if white is detected * @return True if white is detected
*/ */
bool whiteDetected(); virtual bool whiteDetected();
/** /**
* Determines whether black has been detected * Determines whether black has been detected
* *
* @return True if black is detected * @return True if black is detected
*/ */
bool blackDetected(); virtual bool blackDetected();
private: private:
/* Disable implicit copy and assignment operators */ /* Disable implicit copy and assignment operators */
@ -87,5 +88,3 @@ namespace upm {
linefinder_context m_linefinder; linefinder_context m_linefinder;
}; };
} }