Пример #1
0
/*
 * Class:     edu_wpi_first_wpilibj_hal_EncoderJNI
 * Method:    getEncoderSamplesToAverage
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderSamplesToAverage
  (JNIEnv * env, jclass, jlong id)
{
	ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI getEncoderSamplesToAverage";
	ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
	int32_t status = 0;
	jint returnValue = getEncoderSamplesToAverage((void*)id, &status);
	ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
	ENCODERJNI_LOG(logDEBUG) << "getEncoderSamplesToAverageResult = " <<  returnValue;
	CheckStatus(env, status);
	return returnValue;
}
Пример #2
0
/*
 * Class:     edu_wpi_first_wpilibj_hal_EncoderJNI
 * Method:    getEncoderSamplesToAverage
 * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)I
 */
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_getEncoderSamplesToAverage
(JNIEnv * env, jclass, jobject id, jobject status)
{
    ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI getEncoderSamplesToAverage";
    void ** javaId = (void**)env->GetDirectBufferAddress(id);
    ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId;
    jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
    ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
    jint returnValue = getEncoderSamplesToAverage(*javaId, statusPtr);
    ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
    ENCODERJNI_LOG(logDEBUG) << "getEncoderSamplesToAverageResult = " <<  returnValue;
    return returnValue;
}
Пример #3
0
/**
 * Get the Samples to Average which specifies the number of samples of the timer
 * to average when calculating the period.
 *
 * Perform averaging to account for mechanical imperfections or as oversampling
 * to increase resolution.
 *
 * @return The number of samples being averaged (from 1 to 127)
 */
int Encoder::GetSamplesToAverage() const {
  int result = 1;
  int32_t status = 0;
  switch (m_encodingType) {
    case k4X:
      result = getEncoderSamplesToAverage(m_encoder, &status);
      wpi_setErrorWithContext(status, getHALErrorMessage(status));
      break;
    case k1X:
    case k2X:
      result = m_counter->GetSamplesToAverage();
      break;
  }
  return result;
}