mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
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:
parent
ea669ddfc6
commit
42c59e98ab
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user