java: fix Java return types in lsm9ds0

Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Petre Eftime 2015-08-27 13:11:22 +03:00 committed by Mihai Tudor Panu
parent ea669ddfc6
commit 42c59e98ab
3 changed files with 74 additions and 0 deletions

View File

@ -16,4 +16,32 @@
%{
#include "lsm9ds0.h"
%}
%typemap(jni) float* "jfloatArray"
%typemap(jstype) float* "float[]"
%typemap(jtype) float* "float[]"
%typemap(javaout) float* {
return $jnicall;
}
%typemap(out) float *getAccelerometer {
$result = JCALL1(NewFloatArray, jenv, 3);
JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1);
}
%typemap(out) float *getGyroscope {
$result = JCALL1(NewFloatArray, jenv, 3);
JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1);
}
%typemap(out) float *getMagnetometer {
$result = JCALL1(NewFloatArray, jenv, 3);
JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1);
}
%ignore getAccelerometer(float *, float *, float *);
%ignore getGyroscope(float *, float *, float *);
%ignore getMagnetometer(float *, float *, float *);
%include "lsm9ds0.h"

View File

@ -602,6 +602,29 @@ void LSM9DS0::getMagnetometer(float *x, float *y, float *z)
*z = (m_magZ * m_magScale) / 1000.0;
}
#ifdef SWIGJAVA
float *LSM9DS0::getAccelerometer()
{
float *v = new float[3];
getAccelerometer(&v[0], &v[1], &v[2]);
return v;
}
float *LSM9DS0::getGyroscope()
{
float *v = new float[3];
getGyroscope(&v[0], &v[1], &v[2]);
return v;
}
float *LSM9DS0::getMagnetometer()
{
float *v = new float[3];
getMagnetometer(&v[0], &v[1], &v[2]);
return v;
}
#endif
float LSM9DS0::getTemperature()
{
// This might be wrong... The datasheet does not provide enough info

View File

@ -1267,6 +1267,29 @@ namespace upm {
*/
void getMagnetometer(float *x, float *y, float *z);
#ifdef SWIGJAVA
/**
* get the accelerometer values in gravities
*
* @return Array containing X, Y, Z acceleration values
*/
float *getAccelerometer();
/**
* get the gyroscope values in degrees per second
*
* @return Array containing X, Y, Z gyroscope values
*/
float *getGyroscope();
/**
* get the magnetometer values in gauss
*
* @return Array containing X, Y, Z magnetometer values
*/
float *getMagnetometer();
#endif
/**
* get the temperature value. Unfortunately the datasheet does
* not provide a mechanism to convert the temperature value into