mirror of
				https://github.com/eclipse/upm.git
				synced 2025-10-31 23:24:20 +03:00 
			
		
		
		
	Updated interfaces and sensors
Signed-off-by: Serban Waltter <serban.waltter@rinftech.com>
This commit is contained in:
		| @@ -29,16 +29,16 @@ namespace upm | ||||
| /**
 | ||||
|  * @brief Interface for Rotary Angle sensors | ||||
| */ | ||||
|   class iRotaryAngle | ||||
|   class iAngle | ||||
|   { | ||||
|   public: | ||||
|     virtual ~iRotaryAngle() {} | ||||
|     virtual ~iAngle() {} | ||||
| 
 | ||||
|     /**
 | ||||
|      * Get rotation value from sensor data. | ||||
|      * | ||||
|      * @return rotation value. | ||||
|      * @return rotation value in degrees. | ||||
|      */ | ||||
|     virtual float getValue() = 0; | ||||
|     virtual float getAngle() = 0; | ||||
|   }; | ||||
| } | ||||
| @@ -35,18 +35,10 @@ namespace upm | ||||
|     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; | ||||
|  | ||||
|     /** | ||||
|      * Sets the time. You should call loadTime() beforehand to | ||||
|      * maintain consistency | ||||
|      * | ||||
|      * @return True if time is set successfully | ||||
|      */ | ||||
|     virtual bool setTime() = 0; | ||||
|     virtual unsigned long getTime() = 0; | ||||
|   }; | ||||
| } | ||||
|   | ||||
| @@ -34,18 +34,6 @@ namespace upm | ||||
|   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; | ||||
|  | ||||
|     /** | ||||
|      * Read scaled/offset voltage from the sensor | ||||
|      *  | ||||
|   | ||||
| @@ -40,13 +40,5 @@ namespace upm | ||||
|      * @param enable true to enable the device, false otherwise. | ||||
|      */ | ||||
|     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; | ||||
|  | ||||
|   }; | ||||
| } | ||||
|   | ||||
| @@ -35,13 +35,11 @@ namespace upm | ||||
|     virtual ~iPH() {} | ||||
|  | ||||
|     /** | ||||
|      * Take a number of samples and return the detected pH value.  The | ||||
|      * default number of samples is 15. | ||||
|      * Returns the detected pH value. | ||||
|      * | ||||
|      * @param samples The number of samples to average over, default 15 | ||||
|      * @return The pH value detected | ||||
|      */ | ||||
|     virtual float pH(unsigned int samples = 15) = 0; | ||||
|     virtual float getPH() = 0; | ||||
|  | ||||
|   }; | ||||
| } | ||||
|   | ||||
| @@ -40,7 +40,7 @@ namespace upm | ||||
|     /** | ||||
|      * Measures applied pressure | ||||
|      *  | ||||
|      * @return gets pressure value | ||||
|      * @return gets pressure value in Pa | ||||
|      */ | ||||
|     virtual float getPressure() = 0; | ||||
|  | ||||
|   | ||||
| @@ -37,7 +37,7 @@ namespace upm | ||||
|     /** | ||||
|      * Gets the conversion value from the sensor | ||||
|      * | ||||
|      * @return ADC conversion value | ||||
|      * @return ADC conversion value in volts | ||||
|      */ | ||||
|     virtual unsigned int getValue() = 0; | ||||
|  | ||||
|   | ||||
| @@ -74,3 +74,8 @@ float DFRPH::pH(unsigned int samples) | ||||
|  | ||||
|     return ph_avg/samples; | ||||
| } | ||||
|  | ||||
| float DFRPH::getPH() | ||||
| { | ||||
|     return pH(10); | ||||
| } | ||||
|   | ||||
| @@ -132,6 +132,13 @@ namespace upm { | ||||
|      */ | ||||
|     virtual float pH(unsigned int samples = 15); | ||||
|  | ||||
|     /** | ||||
|      * Returns the detected pH value. | ||||
|      * | ||||
|      * @return The pH value detected | ||||
|      */ | ||||
|     virtual float getPH(); | ||||
|  | ||||
|   private: | ||||
|     /** | ||||
|      * Don't allow copies of this class | ||||
|   | ||||
| @@ -28,7 +28,6 @@ | ||||
|  | ||||
| #include <string> | ||||
| #include <mraa/i2c.hpp> | ||||
| #include <interfaces/iClock.hpp> | ||||
|  | ||||
| #define DS1307_I2C_BUS     0 | ||||
| #define DS1307_I2C_ADDR    0x68 | ||||
| @@ -70,7 +69,7 @@ namespace upm { | ||||
|    * @image html ds1307.jpg | ||||
|    * @snippet ds1307.cxx Interesting | ||||
|    */ | ||||
|   class DS1307 : virtual public iClock { | ||||
|   class DS1307 { | ||||
|   public: | ||||
|     /** | ||||
|      * DS1307 constructor | ||||
| @@ -84,7 +83,7 @@ namespace upm { | ||||
|      * | ||||
|      * @return True if time data loaded successfully | ||||
|      */ | ||||
|     virtual bool loadTime(); | ||||
|     bool loadTime(); | ||||
|  | ||||
|     /** | ||||
|      * Sets the time. You should call loadTime() beforehand to | ||||
| @@ -92,7 +91,7 @@ namespace upm { | ||||
|      * | ||||
|      * @return True if time is set successfully | ||||
|      */ | ||||
|     virtual bool setTime(); | ||||
|     bool setTime(); | ||||
|  | ||||
|     /** | ||||
|      * Enables an oscillator on the clock. | ||||
|   | ||||
| @@ -78,7 +78,7 @@ float GroveRotary::rel_rad() | ||||
|     return GroveRotary::rel_deg() * M_PI / 180.0; | ||||
| } | ||||
|  | ||||
| float GroveRotary::getValue() | ||||
| float GroveRotary::getAngle() | ||||
| { | ||||
|     return GroveRotary::abs_value(); | ||||
|     return GroveRotary::abs_deg(); | ||||
| } | ||||
|   | ||||
| @@ -29,7 +29,7 @@ | ||||
| #include <string> | ||||
| #include <mraa/aio.hpp> | ||||
| #include "grovebase.hpp" | ||||
| #include <interfaces/iRotaryAngle.hpp> | ||||
| #include <interfaces/iAngle.hpp> | ||||
|  | ||||
| namespace upm { | ||||
|  | ||||
| @@ -54,7 +54,7 @@ namespace upm { | ||||
|  * @image html rotaryencoder.jpg | ||||
|  * @snippet grove-groverotary.cxx Interesting | ||||
|  */ | ||||
| class GroveRotary: public Grove, virtual public iRotaryAngle { | ||||
| class GroveRotary: public Grove, virtual public iAngle { | ||||
|     public: | ||||
|         /** | ||||
|          * Grove rotary angle sensor constructor | ||||
| @@ -108,7 +108,7 @@ class GroveRotary: public Grove, virtual public iRotaryAngle { | ||||
|          * | ||||
|          * @return rotation value. | ||||
|          */ | ||||
|         virtual float getValue(); | ||||
|         virtual float getAngle(); | ||||
|  | ||||
|     private: | ||||
|         mraa_aio_context m_aio; | ||||
|   | ||||
| @@ -275,7 +275,7 @@ namespace upm { | ||||
|     virtual float getTemperature(); | ||||
|  | ||||
|     /** | ||||
|      * Returns the pressure in millibars | ||||
|      * Returns the pressure in pascal | ||||
|      * | ||||
|      * @return Pressure | ||||
|      */ | ||||
|   | ||||
| @@ -137,9 +137,9 @@ namespace upm { | ||||
|         /** | ||||
|          * Return the latest measured pressure.  update() must have | ||||
|          * 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(); | ||||
|  | ||||
|   | ||||
| @@ -77,7 +77,7 @@ float Rotary::rel_rad() | ||||
|     return Rotary::rel_deg() * M_PI / 180.0; | ||||
| } | ||||
|  | ||||
|  float Rotary::getValue() | ||||
|  float Rotary::getAngle() | ||||
|  { | ||||
|      return Rotary::abs_value(); | ||||
|      return Rotary::abs_deg(); | ||||
|  } | ||||
|   | ||||
| @@ -30,7 +30,7 @@ | ||||
| #include <mraa/aio.hpp> | ||||
|  | ||||
| #include "rotary.hpp" | ||||
| #include <interfaces/iRotaryAngle.hpp> | ||||
| #include <interfaces/iAngle.hpp> | ||||
|  | ||||
| namespace upm { | ||||
|  | ||||
| @@ -60,7 +60,7 @@ namespace upm { | ||||
|  * @image html rotary.jpg | ||||
|  * @snippet rotary.cxx Interesting | ||||
|  */ | ||||
| class Rotary : virtual public iRotaryAngle { | ||||
| class Rotary : virtual public iAngle { | ||||
|     public: | ||||
|         /** | ||||
|          * Rotary angle sensor constructor | ||||
| @@ -115,7 +115,7 @@ class Rotary : virtual public iRotaryAngle { | ||||
|          * | ||||
|          * @return rotation value. | ||||
|          */ | ||||
|         virtual float getValue(); | ||||
|         virtual float getAngle(); | ||||
|  | ||||
|         std::string name(){ return "Rotary Angle Sensor";} | ||||
|     private: | ||||
|   | ||||
| @@ -53,6 +53,6 @@ int RotaryEncoder::position() | ||||
|     return rotaryencoder_get_position(m_rotaryencoder); | ||||
| } | ||||
|  | ||||
| float RotaryEncoder::getValue() { | ||||
|     return (float) RotaryEncoder::position(); | ||||
| float RotaryEncoder::getAngle() { | ||||
|     return (float) RotaryEncoder::position() / 20.0 * 360; | ||||
| } | ||||
|   | ||||
| @@ -24,7 +24,7 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "rotaryencoder.h" | ||||
| #include <interfaces/iRotaryAngle.hpp> | ||||
| #include <interfaces/iAngle.hpp> | ||||
|  | ||||
| namespace upm { | ||||
|  | ||||
| @@ -61,7 +61,7 @@ namespace upm { | ||||
|      * @snippet rotaryencoder.cxx Interesting | ||||
|      */ | ||||
|  | ||||
|     class RotaryEncoder : virtual public iRotaryAngle { | ||||
|     class RotaryEncoder : virtual public iAngle { | ||||
|     public: | ||||
|         /** | ||||
|          * RotaryEncoder constructor | ||||
| @@ -93,7 +93,7 @@ namespace upm { | ||||
|          * | ||||
|          * @return rotation value. | ||||
|          */ | ||||
|         virtual float getValue(); | ||||
|         virtual float getAngle(); | ||||
|  | ||||
|     private: | ||||
|         /* Disable implicit copy and assignment operators */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Serban Waltter
					Serban Waltter