mirror of
https://github.com/eclipse/upm.git
synced 2025-07-02 01:41:12 +03:00
Added interface iRotaryAngle
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:

committed by
Mihai Tudor Panu

parent
75c7bd8d12
commit
8693a72ed6
@ -77,3 +77,8 @@ float GroveRotary::rel_rad()
|
||||
{
|
||||
return GroveRotary::rel_deg() * M_PI / 180.0;
|
||||
}
|
||||
|
||||
float GroveRotary::getValue()
|
||||
{
|
||||
return GroveRotary::abs_value();
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <string>
|
||||
#include <mraa/aio.hpp>
|
||||
#include "grovebase.hpp"
|
||||
#include <interfaces/iRotaryAngle.hpp>
|
||||
|
||||
namespace upm {
|
||||
|
||||
@ -53,7 +54,7 @@ namespace upm {
|
||||
* @image html rotaryencoder.jpg
|
||||
* @snippet grove-groverotary.cxx Interesting
|
||||
*/
|
||||
class GroveRotary: public Grove {
|
||||
class GroveRotary: public Grove, virtual public iRotaryAngle {
|
||||
public:
|
||||
/**
|
||||
* Grove rotary angle sensor constructor
|
||||
@ -101,6 +102,14 @@ class GroveRotary: public Grove {
|
||||
* @return Signed radians from the ADC
|
||||
*/
|
||||
float rel_rad();
|
||||
|
||||
/**
|
||||
* Get rotation value as raw degrees from the AIO pin.
|
||||
*
|
||||
* @return rotation value.
|
||||
*/
|
||||
virtual float getValue();
|
||||
|
||||
private:
|
||||
mraa_aio_context m_aio;
|
||||
static const int m_max_angle = 300;
|
||||
|
@ -76,3 +76,8 @@ float Rotary::rel_rad()
|
||||
{
|
||||
return Rotary::rel_deg() * M_PI / 180.0;
|
||||
}
|
||||
|
||||
float Rotary::getValue()
|
||||
{
|
||||
return Rotary::abs_value();
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <mraa/aio.hpp>
|
||||
|
||||
#include "rotary.hpp"
|
||||
#include <interfaces/iRotaryAngle.hpp>
|
||||
|
||||
namespace upm {
|
||||
|
||||
@ -59,7 +60,7 @@ namespace upm {
|
||||
* @image html rotary.jpg
|
||||
* @snippet rotary.cxx Interesting
|
||||
*/
|
||||
class Rotary{
|
||||
class Rotary : virtual public iRotaryAngle {
|
||||
public:
|
||||
/**
|
||||
* Rotary angle sensor constructor
|
||||
@ -77,6 +78,7 @@ class Rotary{
|
||||
* @return Unsigned value from the ADC
|
||||
*/
|
||||
float abs_value();
|
||||
|
||||
/**
|
||||
* Gets absolute raw degrees from the AIO pin
|
||||
*
|
||||
@ -107,6 +109,14 @@ class Rotary{
|
||||
* @return Signed radians from the ADC
|
||||
*/
|
||||
float rel_rad();
|
||||
|
||||
/**
|
||||
* Get rotation value as raw degrees from the AIO pin.
|
||||
*
|
||||
* @return rotation value.
|
||||
*/
|
||||
virtual float getValue();
|
||||
|
||||
std::string name(){ return "Rotary Angle Sensor";}
|
||||
private:
|
||||
mraa_aio_context m_aio;
|
||||
|
@ -53,4 +53,6 @@ int RotaryEncoder::position()
|
||||
return rotaryencoder_get_position(m_rotaryencoder);
|
||||
}
|
||||
|
||||
|
||||
float RotaryEncoder::getValue() {
|
||||
return (float) RotaryEncoder::position();
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "rotaryencoder.h"
|
||||
#include <interfaces/iRotaryAngle.hpp>
|
||||
|
||||
namespace upm {
|
||||
|
||||
@ -60,7 +61,7 @@ namespace upm {
|
||||
* @snippet rotaryencoder.cxx Interesting
|
||||
*/
|
||||
|
||||
class RotaryEncoder {
|
||||
class RotaryEncoder : virtual public iRotaryAngle {
|
||||
public:
|
||||
/**
|
||||
* RotaryEncoder constructor
|
||||
@ -87,6 +88,13 @@ namespace upm {
|
||||
*/
|
||||
int position();
|
||||
|
||||
/**
|
||||
* Get rotation value from sensor data.
|
||||
*
|
||||
* @return rotation value.
|
||||
*/
|
||||
virtual float getValue();
|
||||
|
||||
private:
|
||||
/* Disable implicit copy and assignment operators */
|
||||
RotaryEncoder(const RotaryEncoder&) = delete;
|
||||
@ -95,5 +103,3 @@ namespace upm {
|
||||
rotaryencoder_context m_rotaryencoder;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user