Ejemplo n.º 1
0
/**
 * Set the direction sensing for this encoder.
 *
 * This sets the direction sensing on the encoder so that it could count in the
 * correct software direction regardless of the mounting.
 *
 * @param reverseDirection true if the encoder direction should be reversed
 */
void Encoder::SetReverseDirection(bool reverseDirection) {
  if (StatusIsFatal()) return;
  if (m_counter) {
    m_counter->SetReverseDirection(reverseDirection);
  } else {
    int32_t status = 0;
    setEncoderReverseDirection(m_encoder, reverseDirection, &status);
    wpi_setErrorWithContext(status, getHALErrorMessage(status));
  }
}
Ejemplo n.º 2
0
/*
 * Class:     edu_wpi_first_wpilibj_hal_EncoderJNI
 * Method:    setEncoderReverseDirection
 * Signature: (JZ)V
 */
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderReverseDirection
  (JNIEnv * env, jclass, jlong id, jboolean value)
{
	ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI setEncoderReverseDirection";
	ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
	int32_t status = 0;
	setEncoderReverseDirection((void*)id, value, &status);
	ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
	CheckStatus(env, status);
}
Ejemplo n.º 3
0
/*
 * Class:     edu_wpi_first_wpilibj_hal_EncoderJNI
 * Method:    setEncoderReverseDirection
 * Signature: (Ljava/nio/ByteBuffer;BLjava/nio/IntBuffer;)V
 */
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_setEncoderReverseDirection
(JNIEnv * env, jclass, jobject id, jbyte value, jobject status)
{
    ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI setEncoderReverseDirection";
    void ** javaId = (void**)env->GetDirectBufferAddress(id);
    ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId;
    jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
    ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
    setEncoderReverseDirection(*javaId, value, statusPtr);
    ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
}