Beispiel #1
0
/**
 * Set the index source for the encoder.  When this source is activated, the encoder count automatically resets.
 *
 * @param channel A DIO channel to set as the encoder index
 * @param type The state that will cause the encoder to reset
 */
void Encoder::SetIndexSource(uint32_t channel, Encoder::IndexingType type) {
	int32_t status = 0;
	bool activeHigh = (type == kResetWhileHigh) || (type == kResetOnRisingEdge);
	bool edgeSensitive = (type == kResetOnFallingEdge) || (type == kResetOnRisingEdge);

  setEncoderIndexSource(m_encoder, channel, false, activeHigh, edgeSensitive, &status);
  wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
}
Beispiel #2
0
/**
 * Set the index source for the encoder.  When this source is activated, the encoder count automatically resets.
 *
 * @param channel A digital source to set as the encoder index
 * @param type The state that will cause the encoder to reset
 */
void Encoder::SetIndexSource(DigitalSource *source, Encoder::IndexingType type) {
	int32_t status = 0;
	bool activeHigh = (type == kResetWhileHigh) || (type == kResetOnRisingEdge);
	bool edgeSensitive = (type == kResetOnFallingEdge) || (type == kResetOnRisingEdge);

  setEncoderIndexSource(m_encoder, source->GetChannelForRouting(), source->GetAnalogTriggerForRouting(), activeHigh,
  		edgeSensitive, &status);
  wpi_setGlobalErrorWithContext(status, getHALErrorMessage(status));
}
Beispiel #3
0
/*
 * 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);
}
Beispiel #4
0
/*
 * 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;
}