mirror of
				https://github.com/eclipse/upm.git
				synced 2025-10-30 22:54:44 +03:00 
			
		
		
		
	Added interfaces iEC,iEmg,iClock,iHeartRate,iLineFinder
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
					Stefan Andritoiu
				
			
				
					committed by
					
						 Mihai Tudor Panu
						Mihai Tudor Panu
					
				
			
			
				
	
			
			
			 Mihai Tudor Panu
						Mihai Tudor Panu
					
				
			
						parent
						
							f035470822
						
					
				
				
					commit
					a589f92cec
				
			
							
								
								
									
										52
									
								
								include/interfaces/iClock.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								include/interfaces/iClock.hpp
									
									
									
									
									
										Normal 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; | ||||
|   }; | ||||
| } | ||||
							
								
								
									
										45
									
								
								include/interfaces/iEC.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								include/interfaces/iEC.hpp
									
									
									
									
									
										Normal 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; | ||||
|  | ||||
|   }; | ||||
| } | ||||
							
								
								
									
										49
									
								
								include/interfaces/iEmg.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								include/interfaces/iEmg.hpp
									
									
									
									
									
										Normal 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; | ||||
|   }; | ||||
| } | ||||
							
								
								
									
										44
									
								
								include/interfaces/iHeartRate.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								include/interfaces/iHeartRate.hpp
									
									
									
									
									
										Normal 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; | ||||
|   }; | ||||
| } | ||||
							
								
								
									
										51
									
								
								include/interfaces/iLineFinder.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								include/interfaces/iLineFinder.hpp
									
									
									
									
									
										Normal 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; | ||||
|  | ||||
|   }; | ||||
| } | ||||
| @@ -73,6 +73,12 @@ float DFREC::getEC() | ||||
|   return dfrec_get_ec(m_dfrec); | ||||
| } | ||||
|  | ||||
| float DFREC::getECValue() | ||||
| { | ||||
|   DFREC::update(); | ||||
|   return DFREC::getEC(); | ||||
| } | ||||
|  | ||||
| float DFREC::getVolts() | ||||
| { | ||||
|   return dfrec_get_volts(m_dfrec); | ||||
|   | ||||
| @@ -31,6 +31,7 @@ | ||||
| #include <string.h> | ||||
|  | ||||
| #include "dfrec.h" | ||||
| #include <interfaces/iEC.hpp> | ||||
|  | ||||
| namespace upm { | ||||
|   /** | ||||
| @@ -65,7 +66,7 @@ namespace upm { | ||||
|    * @snippet dfrec.cxx Interesting | ||||
|    */ | ||||
|  | ||||
|   class DFREC { | ||||
|   class DFREC : virtual public iEC { | ||||
|   public: | ||||
|  | ||||
|     /** | ||||
| @@ -120,6 +121,13 @@ namespace upm { | ||||
|      */ | ||||
|     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 | ||||
|      * called prior to calling this function. | ||||
|   | ||||
| @@ -28,6 +28,7 @@ | ||||
|  | ||||
| #include <string> | ||||
| #include <mraa/i2c.hpp> | ||||
| #include <interfaces/iClock.hpp> | ||||
|  | ||||
| #define DS1307_I2C_BUS     0 | ||||
| #define DS1307_I2C_ADDR    0x68 | ||||
| @@ -69,7 +70,7 @@ namespace upm { | ||||
|    * @image html ds1307.jpg | ||||
|    * @snippet ds1307.cxx Interesting | ||||
|    */ | ||||
|   class DS1307 { | ||||
|   class DS1307 : virtual public iClock { | ||||
|   public: | ||||
|     /** | ||||
|      * DS1307 constructor | ||||
| @@ -83,7 +84,7 @@ namespace upm { | ||||
|      * | ||||
|      * @return True if time data loaded successfully | ||||
|      */ | ||||
|     bool loadTime(); | ||||
|     virtual bool loadTime(); | ||||
|  | ||||
|     /** | ||||
|      * Sets the time. You should call loadTime() beforehand to | ||||
| @@ -91,7 +92,7 @@ namespace upm { | ||||
|      * | ||||
|      * @return True if time is set successfully | ||||
|      */ | ||||
|     bool setTime(); | ||||
|     virtual bool setTime(); | ||||
|  | ||||
|     /** | ||||
|      * Enables an oscillator on the clock. | ||||
| @@ -190,5 +191,3 @@ namespace upm { | ||||
|     mraa::I2c m_i2c; | ||||
|   }; | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -81,6 +81,12 @@ float ECEZO::getEC() | ||||
|     return ecezo_get_ec(m_ecezo); | ||||
| } | ||||
|  | ||||
| float ECEZO::getECValue() | ||||
| { | ||||
|     ECEZO::update(); | ||||
|     return ECEZO::getEC(); | ||||
| } | ||||
|  | ||||
| float ECEZO::getTDS() | ||||
| { | ||||
|     return ecezo_get_tds(m_ecezo); | ||||
|   | ||||
| @@ -30,6 +30,7 @@ | ||||
| #include <unistd.h> | ||||
|  | ||||
| #include "ecezo.h" | ||||
| #include <interfaces/iEC.hpp> | ||||
|  | ||||
| namespace upm { | ||||
|     /** | ||||
| @@ -57,7 +58,7 @@ namespace upm { | ||||
|      * @snippet ecezo.cxx Interesting | ||||
|      */ | ||||
|  | ||||
|     class ECEZO { | ||||
|     class ECEZO : virtual public iEC { | ||||
|     public: | ||||
|  | ||||
|         /** | ||||
| @@ -127,6 +128,14 @@ namespace upm { | ||||
|          */ | ||||
|         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. | ||||
|          * update() must have been called before calling this | ||||
|   | ||||
| @@ -128,3 +128,8 @@ int EHR::heartRate() | ||||
|  | ||||
|   return int(heartRate); | ||||
| } | ||||
|  | ||||
| int EHR::getHeartRate() | ||||
| { | ||||
|     return EHR::heartRate(); | ||||
| } | ||||
|   | ||||
| @@ -27,6 +27,7 @@ | ||||
| #include <stdint.h> | ||||
| #include <sys/time.h> | ||||
| #include <mraa/gpio.h> | ||||
| #include <interfaces/iHeartRate.hpp> | ||||
|  | ||||
| namespace upm { | ||||
|   /** | ||||
| @@ -51,7 +52,7 @@ namespace upm { | ||||
|    * @image html ehr.jpg | ||||
|    * @snippet ehr.cxx Interesting | ||||
|    */ | ||||
|   class EHR { | ||||
|   class EHR : virtual public iHeartRate { | ||||
|   public: | ||||
|     /** | ||||
|      * EHR constructor | ||||
| @@ -110,6 +111,13 @@ namespace upm { | ||||
|      */ | ||||
|     int heartRate(); | ||||
|  | ||||
|     /** | ||||
|      * Retrieve the computed heart rate | ||||
|      * | ||||
|      * @return Computed heart rate | ||||
|      */ | ||||
|     virtual int getHeartRate(); | ||||
|  | ||||
|   private: | ||||
|     /** | ||||
|      * Beat interrupt service routine (ISR) | ||||
| @@ -122,5 +130,3 @@ namespace upm { | ||||
|     mraa_gpio_context m_gpio; | ||||
|   }; | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -25,6 +25,7 @@ | ||||
|  | ||||
| #include <string> | ||||
| #include <mraa/aio.h> | ||||
| #include "interfaces/iEmg.hpp" | ||||
|  | ||||
| namespace upm { | ||||
|   /** | ||||
| @@ -50,7 +51,7 @@ namespace upm { | ||||
|    * @image html emg.jpg | ||||
|    * @snippet emg.cxx Interesting | ||||
|    */ | ||||
|   class EMG { | ||||
|   class EMG : virtual public iEmg { | ||||
|   public: | ||||
|     /** | ||||
|      * Grove EMG reader constructor | ||||
| @@ -66,18 +67,16 @@ namespace upm { | ||||
|     /** | ||||
|      * Calibrates the Grove EMG reader | ||||
|      */ | ||||
|     void calibrate(); | ||||
|     virtual void calibrate(); | ||||
|  | ||||
|     /** | ||||
|      * Measures muscle signals from the reader | ||||
|      * | ||||
|      * @return Muscle output as analog voltage | ||||
|      */ | ||||
|     int value(); | ||||
|     virtual int value(); | ||||
|  | ||||
|   private: | ||||
|     mraa_aio_context m_aio; | ||||
|   }; | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -128,3 +128,8 @@ int GroveEHR::heartRate() | ||||
|  | ||||
|   return int(heartRate); | ||||
| } | ||||
|  | ||||
| int GroveEHR::getHeartRate() | ||||
| { | ||||
|     return GroveEHR::heartRate(); | ||||
| } | ||||
|   | ||||
| @@ -27,6 +27,7 @@ | ||||
| #include <stdint.h> | ||||
| #include <sys/time.h> | ||||
| #include <mraa/gpio.h> | ||||
| #include <interfaces/iHeartRate.hpp> | ||||
|  | ||||
| namespace upm { | ||||
|   /** | ||||
| @@ -53,7 +54,7 @@ namespace upm { | ||||
|    * @image html groveehr.jpg | ||||
|    * @snippet groveehr.cxx Interesting | ||||
|    */ | ||||
|   class GroveEHR { | ||||
|   class GroveEHR : virtual public iHeartRate { | ||||
|   public: | ||||
|     /** | ||||
|      * GroveEHR constructor | ||||
| @@ -112,6 +113,13 @@ namespace upm { | ||||
|      */ | ||||
|     int heartRate(); | ||||
|  | ||||
|     /** | ||||
|      * Retrieve the computed heart rate | ||||
|      * | ||||
|      * @return Computed heart rate | ||||
|      */ | ||||
|     virtual int getHeartRate(); | ||||
|  | ||||
|   private: | ||||
|     /** | ||||
|      * Beat interrupt service routine (ISR) | ||||
| @@ -124,5 +132,3 @@ namespace upm { | ||||
|     mraa_gpio_context m_gpio; | ||||
|   }; | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -25,6 +25,7 @@ | ||||
|  | ||||
| #include <string> | ||||
| #include <mraa/aio.h> | ||||
| #include "interfaces/iEmg.hpp" | ||||
|  | ||||
| namespace upm { | ||||
|   /** | ||||
| @@ -51,7 +52,7 @@ namespace upm { | ||||
|    * @image html emg.jpg | ||||
|    * @snippet groveemg.cxx Interesting | ||||
|    */ | ||||
|   class GroveEMG { | ||||
|   class GroveEMG : virtual public iEmg { | ||||
|   public: | ||||
|     /** | ||||
|      * Grove EMG reader constructor | ||||
| @@ -67,18 +68,16 @@ namespace upm { | ||||
|     /** | ||||
|      * Calibrates the Grove EMG reader | ||||
|      */ | ||||
|     void calibrate(); | ||||
|     virtual void calibrate(); | ||||
|  | ||||
|     /** | ||||
|      * Measures muscle signals from the reader | ||||
|      * | ||||
|      * @return Muscle output as analog voltage | ||||
|      */ | ||||
|     int value(); | ||||
|     virtual int value(); | ||||
|  | ||||
|   private: | ||||
|     mraa_aio_context m_aio; | ||||
|   }; | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -68,3 +68,8 @@ int GroveGSR::value() | ||||
| 	int val = mraa_aio_read(m_aio); | ||||
| 	return val; | ||||
| } | ||||
|  | ||||
| float GroveGSR::getECValue() | ||||
| { | ||||
| 	return (float) GroveGSR::value(); | ||||
| } | ||||
|   | ||||
| @@ -25,6 +25,7 @@ | ||||
|  | ||||
| #include <string> | ||||
| #include <mraa/aio.h> | ||||
| #include <interfaces/iEC.hpp> | ||||
|  | ||||
| namespace upm { | ||||
|   /** | ||||
| @@ -53,7 +54,7 @@ namespace upm { | ||||
|    * @image html gsr.jpg | ||||
|    * @snippet grovegsr.cxx Interesting | ||||
|    */ | ||||
|   class GroveGSR { | ||||
|   class GroveGSR : virtual public iEC { | ||||
|   public: | ||||
|     /** | ||||
|      * Grove GSR sensor constructor | ||||
| @@ -78,9 +79,14 @@ namespace upm { | ||||
|      */ | ||||
|     int value(); | ||||
|  | ||||
|     /** | ||||
|      * Gets the electrical conductance of the skin from the sensor | ||||
|      * | ||||
|      * @return Electrical conductance of the skin | ||||
|      */ | ||||
|     virtual float getECValue(); | ||||
|  | ||||
|   private: | ||||
|     mraa_aio_context m_aio; | ||||
|   }; | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -25,6 +25,7 @@ | ||||
|  | ||||
| #include <string> | ||||
| #include <mraa/gpio.h> | ||||
| #include <interfaces/iLineFinder.hpp> | ||||
|  | ||||
| namespace upm { | ||||
|   /** | ||||
| @@ -53,7 +54,7 @@ namespace upm { | ||||
|    * @image html grovelinefinder.jpg | ||||
|    * @snippet grovelinefinder.cxx Interesting | ||||
|    */ | ||||
|   class GroveLineFinder { | ||||
|   class GroveLineFinder : virtual public iLineFinder { | ||||
|   public: | ||||
|     /** | ||||
|      * Grove Line Finder digital sensor constructor | ||||
| @@ -70,17 +71,15 @@ namespace upm { | ||||
|      * | ||||
|      * @return True if white is detected | ||||
|      */ | ||||
|     bool whiteDetected(); | ||||
|     virtual bool whiteDetected(); | ||||
|     /** | ||||
|      * Determines whether black has been detected | ||||
|      * | ||||
|      * @return True if black is detected | ||||
|      */ | ||||
|     bool blackDetected(); | ||||
|     virtual bool blackDetected(); | ||||
|  | ||||
|   private: | ||||
|     mraa_gpio_context m_gpio; | ||||
|   }; | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -65,3 +65,8 @@ int GSR::value() | ||||
|     int val = mraa_aio_read(m_aio); | ||||
|     return val; | ||||
| } | ||||
|  | ||||
| float GSR::getECValue() | ||||
| { | ||||
| 	return (float) GSR::value(); | ||||
| } | ||||
|   | ||||
| @@ -25,6 +25,7 @@ | ||||
|  | ||||
| #include <string> | ||||
| #include <mraa/aio.h> | ||||
| #include <interfaces/iEC.hpp> | ||||
|  | ||||
| namespace upm { | ||||
|   /** | ||||
| @@ -51,7 +52,7 @@ namespace upm { | ||||
|    * @image html gsr.jpg | ||||
|    * @snippet gsr.cxx Interesting | ||||
|    */ | ||||
|   class GSR { | ||||
|   class GSR : virtual public iEC { | ||||
|   public: | ||||
|     /** | ||||
|      * Grove GSR sensor constructor | ||||
| @@ -76,9 +77,14 @@ namespace upm { | ||||
|      */ | ||||
|     int value(); | ||||
|  | ||||
|     /** | ||||
|      * Gets the electrical conductance of the skin from the sensor | ||||
|      * | ||||
|      * @return Electrical conductance of the skin | ||||
|      */ | ||||
|     virtual float getECValue(); | ||||
|  | ||||
|   private: | ||||
|     mraa_aio_context m_aio; | ||||
|   }; | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -24,6 +24,7 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include <linefinder.h> | ||||
| #include <interfaces/iLineFinder.hpp> | ||||
|  | ||||
| namespace upm { | ||||
|     /** | ||||
| @@ -51,7 +52,7 @@ namespace upm { | ||||
|      * @image html linefinder.jpg | ||||
|      * @snippet linefinder.cxx Interesting | ||||
|      */ | ||||
|     class LineFinder { | ||||
|     class LineFinder : virtual public iLineFinder { | ||||
|     public: | ||||
|         /** | ||||
|          *  Line Finder digital sensor constructor | ||||
| @@ -70,14 +71,14 @@ namespace upm { | ||||
|          * | ||||
|          * @return True if white is detected | ||||
|          */ | ||||
|         bool whiteDetected(); | ||||
|         virtual bool whiteDetected(); | ||||
|  | ||||
|         /** | ||||
|          * Determines whether black has been detected | ||||
|          * | ||||
|          * @return True if black is detected | ||||
|          */ | ||||
|         bool blackDetected(); | ||||
|         virtual bool blackDetected(); | ||||
|  | ||||
|     private: | ||||
|         /* Disable implicit copy and assignment operators */ | ||||
| @@ -87,5 +88,3 @@ namespace upm { | ||||
|         linefinder_context m_linefinder; | ||||
|     }; | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user