/** * The last direction the encoder value changed. * * @return The last direction the encoder value changed. */ bool Encoder::GetDirection() const { if (StatusIsFatal()) return false; if (m_counter) { return m_counter->GetDirection(); } else { int32_t status = 0; bool value = getEncoderDirection(m_encoder, &status); wpi_setErrorWithContext(status, getHALErrorMessage(status)); return value; } }
/* * Class: edu_wpi_first_wpilibj_hal_EncoderJNI * Method: getEncoderDirection * Signature: (J)Z */ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderDirection (JNIEnv * env, jclass, jlong id) { ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI getEncoderDirection"; ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id; int32_t status = 0; jboolean returnValue = getEncoderDirection((void*)id, &status); ENCODERJNI_LOG(logDEBUG) << "Status = " << status; ENCODERJNI_LOG(logDEBUG) << "getEncoderDirectionResult = " << returnValue; CheckStatus(env, status); return returnValue; }
/* * Class: edu_wpi_first_wpilibj_hal_EncoderJNI * Method: getEncoderDirection * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B */ JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderDirection (JNIEnv * env, jclass, jobject id, jobject status) { ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI getEncoderDirection"; void ** javaId = (void**)env->GetDirectBufferAddress(id); ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; jbyte returnValue = getEncoderDirection(*javaId, statusPtr); ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr; ENCODERJNI_LOG(logDEBUG) << "getEncoderDirectionResult = " << returnValue; return returnValue; }