/* * 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; }
/* * Class: edu_wpi_first_wpilibj_hal_EncoderJNI * Method: setEncoderIndexSource * Signature: (JIZZZ)V */ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderIndexSource (JNIEnv * env, jclass, jlong id, jint pin, jboolean analogTrigger, jboolean activeHigh, jboolean edgeSensitive) { ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI setEncoderIndexSource"; ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id; 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"); int32_t status = 0; setEncoderIndexSource((void*)id, pin, analogTrigger, activeHigh, edgeSensitive, &status); ENCODERJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); }
/* * Class: edu_wpi_first_wpilibj_hal_EncoderJNI * Method: initializeEncoder * Signature: (BIBBIBBLjava/nio/IntBuffer;Ljava/nio/IntBuffer;)Ljava/nio/ByteBuffer; */ JNIEXPORT jobject JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_initializeEncoder (JNIEnv * env, jclass, jbyte port_a_module, jint port_a_pin, jbyte port_a_analog_trigger, jbyte port_b_module, jint port_b_pin, jbyte port_b_analog_trigger, jbyte reverseDirection, jobject index, jobject status) { ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI initializeEncoder"; ENCODERJNI_LOG(logDEBUG) << "Module A = " << (jint)port_a_module; ENCODERJNI_LOG(logDEBUG) << "Pin A = " << port_a_pin; ENCODERJNI_LOG(logDEBUG) << "Analog Trigger A = " << (jint)port_a_analog_trigger; ENCODERJNI_LOG(logDEBUG) << "Module B = " << (jint)port_b_module; ENCODERJNI_LOG(logDEBUG) << "Pin B = " << port_b_pin; ENCODERJNI_LOG(logDEBUG) << "Analog Trigger B = " << (jint)port_b_analog_trigger; ENCODERJNI_LOG(logDEBUG) << "Reverse direction = " << (jint)reverseDirection; jint * indexPtr = (jint*)env->GetDirectBufferAddress(index); ENCODERJNI_LOG(logDEBUG) << "Index Ptr = " << indexPtr; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; void** encoderPtr = (void**)new unsigned char[4]; *encoderPtr = initializeEncoder(port_a_module, port_a_pin, port_a_analog_trigger, port_b_module, port_b_pin, port_b_analog_trigger, reverseDirection, indexPtr, statusPtr); ENCODERJNI_LOG(logDEBUG) << "Index = " << *indexPtr; ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; ENCODERJNI_LOG(logDEBUG) << "ENCODER Ptr = " << *encoderPtr; return env->NewDirectByteBuffer( encoderPtr, 4); }
/* * Class: edu_wpi_first_wpilibj_hal_EncoderJNI * Method: initializeEncoder * Signature: (BIZBIZZLjava/nio/IntBuffer;)J */ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_initializeEncoder (JNIEnv * env, jclass, jbyte port_a_module, jint port_a_pin, jboolean port_a_analog_trigger, jbyte port_b_module, jint port_b_pin, jboolean port_b_analog_trigger, jboolean reverseDirection, jobject index) { ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI initializeEncoder"; ENCODERJNI_LOG(logDEBUG) << "Module A = " << (jint)port_a_module; ENCODERJNI_LOG(logDEBUG) << "Pin A = " << port_a_pin; ENCODERJNI_LOG(logDEBUG) << "Analog Trigger A = " << (jint)port_a_analog_trigger; ENCODERJNI_LOG(logDEBUG) << "Module B = " << (jint)port_b_module; ENCODERJNI_LOG(logDEBUG) << "Pin B = " << port_b_pin; ENCODERJNI_LOG(logDEBUG) << "Analog Trigger B = " << (jint)port_b_analog_trigger; ENCODERJNI_LOG(logDEBUG) << "Reverse direction = " << (jint)reverseDirection; jint * indexPtr = (jint*)env->GetDirectBufferAddress(index); ENCODERJNI_LOG(logDEBUG) << "Index Ptr = " << indexPtr; int32_t status = 0; void* encoder = initializeEncoder(port_a_module, port_a_pin, port_a_analog_trigger, port_b_module, port_b_pin, port_b_analog_trigger, reverseDirection, indexPtr, &status); ENCODERJNI_LOG(logDEBUG) << "Index = " << *indexPtr; ENCODERJNI_LOG(logDEBUG) << "Status = " << status; ENCODERJNI_LOG(logDEBUG) << "ENCODER Ptr = " << encoder; CheckStatus(env, status); return (jlong)encoder; }