Added iGyroscope interface
Signed-off-by: Serban Waltter <serban.waltter@rinftech.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
committed by
Mihai Tudor Panu
parent
34bb12933d
commit
aa966946d5
@@ -3,5 +3,6 @@ if (MRAA_IIO_FOUND)
|
||||
set (libdescription "Tri-axis Digital Gyroscope")
|
||||
set (module_src ${libname}.cxx)
|
||||
set (module_hpp ${libname}.hpp)
|
||||
set (module_iface iGyroscope.hpp)
|
||||
upm_module_init(mraa)
|
||||
endif (MRAA_IIO_FOUND)
|
||||
|
||||
@@ -273,6 +273,16 @@ void L3GD20::getGyroscope(float *x, float *y, float *z)
|
||||
*z = m_gyrZ;
|
||||
}
|
||||
|
||||
std::vector<float> L3GD20::getGyroscope()
|
||||
{
|
||||
update();
|
||||
std::vector<float> values(3);
|
||||
values[0] = m_gyrX;
|
||||
values[1] = m_gyrY;
|
||||
values[2] = m_gyrZ;
|
||||
return values;
|
||||
}
|
||||
|
||||
void L3GD20::update()
|
||||
{
|
||||
int bufLen = 6;
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#include <mraa/iio.h>
|
||||
#include <mraa/i2c.hpp>
|
||||
|
||||
#include <interfaces/iGyroscope.hpp>
|
||||
|
||||
#define L3GD20_DEFAULT_I2C_BUS 0
|
||||
// if SDO tied to GND
|
||||
#define L3GD20_DEFAULT_I2C_ADDR 0x6a
|
||||
@@ -74,7 +76,7 @@ namespace upm
|
||||
* @snippet l3gd20-i2c.cxx Interesting
|
||||
*/
|
||||
|
||||
class L3GD20
|
||||
class L3GD20: virtual public iGyroscope
|
||||
{
|
||||
public:
|
||||
typedef struct {
|
||||
@@ -479,6 +481,16 @@ class L3GD20
|
||||
*/
|
||||
void getGyroscope(float *x, float *y, float *z);
|
||||
|
||||
/**
|
||||
* Return gyroscope data in degrees per second in the form of
|
||||
* a floating point vector. update() must have been called
|
||||
* prior to calling this method.
|
||||
*
|
||||
* @return A floating point vector containing x, y, and z in
|
||||
* that order.
|
||||
*/
|
||||
std::vector<float> getGyroscope();
|
||||
|
||||
/**
|
||||
* Set the power mode of the device. I2C only.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user