Initial implementation of iAcceleration

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:
Serban Waltter
2018-07-26 18:06:33 +03:00
committed by Mihai Tudor Panu
parent 90524273ec
commit f992876461
48 changed files with 512 additions and 35 deletions

View File

@@ -190,3 +190,14 @@ void MMA7660::getAcceleration(float *ax, float *ay, float *az)
": mma7660_get_acceleration() failed");
}
std::vector<float> MMA7660::getAcceleration()
{
std::vector<float> v(3);
if (mma7660_get_acceleration(m_mma7660, &v[0], &v[1], &v[2]))
throw std::runtime_error(std::string(__FUNCTION__) +
": mma7660_get_acceleration() failed");
return v;
}

View File

@@ -26,6 +26,7 @@
#include <vector>
#include "mma7660.h"
#include <interfaces/iAcceleration.hpp>
namespace upm {
@@ -58,7 +59,7 @@ namespace upm {
* @image html mma7660.jpg
* @snippet mma7660.cxx Interesting
*/
class MMA7660 {
class MMA7660: virtual public iAcceleration {
public:
/**
@@ -109,6 +110,13 @@ namespace upm {
*/
void getAcceleration(float *ax, float *ay, float *az);
/**
* get acceleration values
*
* @return stl vector of size 3 representing the 3 axis
*/
virtual std::vector<float> getAcceleration();
/**
* Reads an axis, verifying its validity. The value passed must
* be one of REG_XOUT, REG_YOUT, or REG_ZOUT.
@@ -199,20 +207,6 @@ namespace upm {
*/
bool setSampleRate(MMA7660_AUTOSLEEP_T sr);
/**
* Reads the current acceleration values. The returned memory
* is statically allocated and will be overwritten on each
* call.
*
* @return std::vector containing x, y, z.
*/
std::vector<float> getAcceleration()
{
std::vector<float> values(3);
getAcceleration(&values[0], &values[1], &values[2]);
return values;
}
/**
* Reads the current value of conversion. The returned memory
* is statically allocated and will be overwritten on each