mirror of
https://github.com/eclipse/upm.git
synced 2025-03-24 01:10:22 +03:00
java: fix Java return types in MMA7660
Signed-off-by: Petre <petre.p.eftime@intel.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
parent
a21db7ca78
commit
58846ba68a
@ -15,4 +15,34 @@
|
|||||||
#include "mma7660.h"
|
#include "mma7660.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
%typemap(jni) float* "jfloatArray"
|
||||||
|
%typemap(jstype) float* "float[]"
|
||||||
|
%typemap(jtype) float* "float[]"
|
||||||
|
|
||||||
|
%typemap(javaout) float* {
|
||||||
|
return $jnicall;
|
||||||
|
}
|
||||||
|
|
||||||
|
%typemap(out) float *getAcceleration {
|
||||||
|
$result = JCALL1(NewFloatArray, jenv, 3);
|
||||||
|
JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
%typemap(jni) int* "jintArray"
|
||||||
|
%typemap(jstype) int* "int[]"
|
||||||
|
%typemap(jtype) int* "int[]"
|
||||||
|
|
||||||
|
%typemap(javaout) int* {
|
||||||
|
return $jnicall;
|
||||||
|
}
|
||||||
|
|
||||||
|
%typemap(out) int *getRawValues {
|
||||||
|
$result = JCALL1(NewIntArray, jenv, 3);
|
||||||
|
JCALL4(SetIntArrayRegion, jenv, $result, 0, 3, (const signed int*)$1);
|
||||||
|
}
|
||||||
|
|
||||||
|
%ignore getRawValues(int *, int *, int *);
|
||||||
|
%ignore getAcceleration(float *, float *, float *);
|
||||||
|
|
||||||
%include "mma7660.h"
|
%include "mma7660.h"
|
||||||
|
@ -88,6 +88,15 @@ void MMA7660::getRawValues(int *x, int *y, int *z)
|
|||||||
*z = getVerifiedAxis(REG_ZOUT);
|
*z = getVerifiedAxis(REG_ZOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SWIGJAVA
|
||||||
|
int *MMA7660::getRawValues()
|
||||||
|
{
|
||||||
|
int *values = new int[3];
|
||||||
|
getRawValues(&values[0], &values[1], &values[2]);
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void MMA7660::setModeActive()
|
void MMA7660::setModeActive()
|
||||||
{
|
{
|
||||||
uint8_t modeReg = readByte(REG_MODE);
|
uint8_t modeReg = readByte(REG_MODE);
|
||||||
@ -254,3 +263,12 @@ void MMA7660::getAcceleration(float *ax, float *ay, float *az)
|
|||||||
*az = z/21.33;
|
*az = z/21.33;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SWIGJAVA
|
||||||
|
float *MMA7660::getAcceleration()
|
||||||
|
{
|
||||||
|
float *values = new float[3];
|
||||||
|
getAcceleration(&values[0], &values[1], &values[2]);
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@ -169,6 +169,15 @@ namespace upm {
|
|||||||
*/
|
*/
|
||||||
void getRawValues(int *x, int *y, int *z);
|
void getRawValues(int *x, int *y, int *z);
|
||||||
|
|
||||||
|
#ifdef SWIGJAVA
|
||||||
|
/**
|
||||||
|
* Reads the current value of conversion
|
||||||
|
*
|
||||||
|
* @return Array containing x, y, z. Free using delete.
|
||||||
|
*/
|
||||||
|
int *getRawValues();
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the computed acceleration
|
* Gets the computed acceleration
|
||||||
*
|
*
|
||||||
@ -178,6 +187,15 @@ namespace upm {
|
|||||||
*/
|
*/
|
||||||
void getAcceleration(float *ax, float *ay, float *az);
|
void getAcceleration(float *ax, float *ay, float *az);
|
||||||
|
|
||||||
|
#ifdef SWIGJAVA
|
||||||
|
/**
|
||||||
|
* Gets the computed acceleration
|
||||||
|
*
|
||||||
|
* @return Array containing x, y, z. Free using delete.
|
||||||
|
*/
|
||||||
|
float *getAcceleration();
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads an axis, verifying its validity. The value passed must
|
* Reads an axis, verifying its validity. The value passed must
|
||||||
* be one of REG_XOUT, REG_YOUT, or REG_ZOUT.
|
* be one of REG_XOUT, REG_YOUT, or REG_ZOUT.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user