示例#1
0
/**
 * Sets the maximum period for stopped detection.
 *
 * Sets the value that represents the maximum period of the Encoder before it
 * will assume that the attached device is stopped. This timeout allows users
 * to determine if the wheels or other shaft has stopped rotating.
 * This method compensates for the decoding type.
 *
 * @deprecated Use SetMinRate() in favor of this method.  This takes unscaled
 *             periods and SetMinRate() scales using value from
 *             SetDistancePerPulse().
 *
 * @param maxPeriod The maximum time between rising and falling edges before
 *                  the FPGA will report the device stopped. This is expressed
 *                  in seconds.
 */
void Encoder::SetMaxPeriod(double maxPeriod) {
  if (StatusIsFatal()) return;
  if (m_counter) {
    m_counter->SetMaxPeriod(maxPeriod * DecodingScaleFactor());
  } else {
    int32_t status = 0;
    setEncoderMaxPeriod(m_encoder, maxPeriod, &status);
    wpi_setErrorWithContext(status, getHALErrorMessage(status));
  }
}
示例#2
0
/*
 * Class:     edu_wpi_first_wpilibj_hal_EncoderJNI
 * Method:    setEncoderMaxPeriod
 * Signature: (JD)V
 */
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderMaxPeriod
  (JNIEnv * env, jclass, jlong id, jdouble value)
{
	ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI setEncoderMaxPeriod";
	ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
	int32_t status = 0;
	setEncoderMaxPeriod((void*)id, value, &status);
	ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
	CheckStatus(env, status);
}
示例#3
0
/*
 * Class:     edu_wpi_first_wpilibj_hal_EncoderJNI
 * Method:    setEncoderMaxPeriod
 * Signature: (Ljava/nio/ByteBuffer;DLjava/nio/IntBuffer;)V
 */
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderMaxPeriod
(JNIEnv * env, jclass, jobject id, jdouble value, jobject status)
{
    ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI setEncoderMaxPeriod";
    void ** javaId = (void**)env->GetDirectBufferAddress(id);
    ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId;
    jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
    ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
    setEncoderMaxPeriod(*javaId, value, statusPtr);
    ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
}