mirror of
https://github.com/eclipse/upm.git
synced 2025-07-26 21:51:16 +03:00
Added iMagnetometer 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
aa966946d5
commit
f28a6d2561
@ -2,5 +2,5 @@ set (libname "mpu9150")
|
||||
set (libdescription "IMU Sensor Library Based On the Mpu9150")
|
||||
set (module_src ${libname}.cxx ak8975.cxx mpu60x0.cxx mpu9250.cxx)
|
||||
set (module_hpp ${libname}.hpp ak8975.hpp mpu60x0.hpp mpu9250.hpp)
|
||||
set (module_iface iAcceleration.hpp iGyroscope.hpp)
|
||||
set (module_iface iAcceleration.hpp iGyroscope.hpp iMagnetometer.hpp iTemperature.hpp)
|
||||
upm_module_init(mraa)
|
||||
|
@ -237,3 +237,11 @@ void AK8975::getMagnetometer(float *x, float *y, float *z)
|
||||
*z = adjustValue(m_zData, m_zCoeff);
|
||||
}
|
||||
|
||||
std::vector<float> AK8975::getMagnetometer()
|
||||
{
|
||||
std::vector<float> v(3);
|
||||
v[0] = adjustValue(m_xData, m_xCoeff);
|
||||
v[0] = adjustValue(m_yData, m_yCoeff);
|
||||
v[0] = adjustValue(m_zData, m_zCoeff);
|
||||
return v;
|
||||
}
|
@ -27,6 +27,8 @@
|
||||
#include <mraa/common.hpp>
|
||||
#include <mraa/i2c.hpp>
|
||||
|
||||
#include <interfaces/iMagnetometer.hpp>
|
||||
|
||||
#define AK8975_I2C_BUS 0
|
||||
#define AK8975_DEFAULT_I2C_ADDR 0x0c
|
||||
|
||||
@ -50,7 +52,7 @@ namespace upm {
|
||||
*
|
||||
* @snippet mpu9150-ak8975.cxx Interesting
|
||||
*/
|
||||
class AK8975 {
|
||||
class AK8975: virtual public iMagnetometer {
|
||||
public:
|
||||
|
||||
/**
|
||||
@ -202,6 +204,16 @@ namespace upm {
|
||||
*/
|
||||
void getMagnetometer(float *x, float *y, float *z);
|
||||
|
||||
/**
|
||||
* Return magnetometer data in micro-Teslas (uT) 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> getMagnetometer();
|
||||
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
#include <interfaces/iAcceleration.hpp>
|
||||
#include <interfaces/iGyroscope.hpp>
|
||||
#include <interfaces/iTemperature.hpp>
|
||||
|
||||
#define MPU60X0_I2C_BUS 0
|
||||
#define MPU60X0_DEFAULT_I2C_ADDR 0x68
|
||||
|
@ -112,6 +112,6 @@ void MPU9150::getMagnetometer(float *x, float *y, float *z)
|
||||
std::vector<float> MPU9150::getMagnetometer()
|
||||
{
|
||||
std::vector<float> v(3);
|
||||
getMagnetometer(&v[0], &v[1], &v[2]);
|
||||
m_mag->getMagnetometer(&v[0], &v[1], &v[2]);
|
||||
return v;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ namespace upm {
|
||||
* @snippet mpu9150.cxx Interesting
|
||||
*/
|
||||
|
||||
class MPU9150: public MPU60X0
|
||||
class MPU9150: public MPU60X0, virtual public iMagnetometer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
Reference in New Issue
Block a user