Add encoder indexing in Java

Change-Id: I7d6a7da4301703aafab9d63ce67b6c88c62647c9
This commit is contained in:
Thomas Clark
2015-01-08 00:23:32 -05:00
parent a2dfffeddc
commit e13720bb94
3 changed files with 79 additions and 1 deletions

View File

@@ -7,7 +7,7 @@
#include "HAL/Digital.hpp"
// set the logging level
TLogLevel encoderJNILogLevel = logWARNING;
TLogLevel encoderJNILogLevel = logDEBUG;
#define ENCODERJNI_LOG(level) \
if (level > encoderJNILogLevel) ; \
@@ -223,3 +223,24 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderSampl
ENCODERJNI_LOG(logDEBUG) << "getEncoderSamplesToAverageResult = " << returnValue;
return returnValue;
}
/*
* Class: edu_wpi_first_wpilibj_hal_EncoderJNI
* Method: setEncoderIndexSource
* Signature: (Ljava/nio/ByteBuffer;IZZZLjava/nio/IntBuffer;)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderIndexSource
(JNIEnv * env, jclass, jobject id, jint pin, jboolean analogTrigger, jboolean activeHigh, jboolean edgeSensitive, jobject status)
{
ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI setEncoderIndexSource";
void ** javaId = (void**)env->GetDirectBufferAddress(id);
ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId;
jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
ENCODERJNI_LOG(logDEBUG) << "Pin = " << pin;
ENCODERJNI_LOG(logDEBUG) << "Analog Trigger = " << (analogTrigger?"true":"false");
ENCODERJNI_LOG(logDEBUG) << "Active High = " << (activeHigh?"true":"false");
ENCODERJNI_LOG(logDEBUG) << "Edge Sensitive = " << (edgeSensitive?"true":"false");
ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
setEncoderIndexSource(*javaId, pin, analogTrigger, activeHigh, edgeSensitive, statusPtr);
ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
}