Example #1
0
/*
 * Class:     edu_wpi_first_wpilibj_hal_DIOJNI
 * Method:    getLoopTiming
 * Signature: (Ljava/nio/IntBuffer;)S
 */
JNIEXPORT jshort JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_getLoopTiming
(JNIEnv * env, jclass, jobject status)
{
    DIOJNI_LOG(logDEBUG) << "Calling DIOJNI getLoopTimeing";
    jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
    jshort returnValue = getLoopTiming( statusPtr );
    DIOJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
    DIOJNI_LOG(logDEBUG) << "LoopTiming = " << returnValue;
    return returnValue;

}
Example #2
0
/*
 * Class:     edu_wpi_first_wpilibj_hal_DIOJNI
 * Method:    getLoopTiming
 * Signature: ()S
 */
JNIEXPORT jshort JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_getLoopTiming
  (JNIEnv * env, jclass)
{
	DIOJNI_LOG(logDEBUG) << "Calling DIOJNI getLoopTimeing";
	int32_t status = 0;
	jshort returnValue = getLoopTiming( &status );
	DIOJNI_LOG(logDEBUG) << "Status = " << status;
	DIOJNI_LOG(logDEBUG) << "LoopTiming = " << returnValue;
	CheckStatus(env, status);
	return returnValue;

}
Example #3
0
/**
 * Set the bounds on the PWM pulse widths.
 * This sets the bounds on the PWM values for a particular type of controller.
 * The values
 * determine the upper and lower speeds as well as the deadband bracket.
 * @param max The max PWM pulse width in ms
 * @param deadbandMax The high end of the deadband range pulse width in ms
 * @param center The center (off) pulse width in ms
 * @param deadbandMin The low end of the deadband pulse width in ms
 * @param min The minimum pulse width in ms
 */
void PWM::SetBounds(double max, double deadbandMax, double center,
                    double deadbandMin, double min) {
  // calculate the loop time in milliseconds
  int32_t status = 0;
  double loopTime =
      getLoopTiming(&status) / (kSystemClockTicksPerMicrosecond * 1e3);
  wpi_setErrorWithContext(status, getHALErrorMessage(status));

  if (StatusIsFatal()) return;

  m_maxPwm = (int32_t)((max - kDefaultPwmCenter) / loopTime +
                       kDefaultPwmStepsDown - 1);
  m_deadbandMaxPwm = (int32_t)((deadbandMax - kDefaultPwmCenter) / loopTime +
                               kDefaultPwmStepsDown - 1);
  m_centerPwm = (int32_t)((center - kDefaultPwmCenter) / loopTime +
                          kDefaultPwmStepsDown - 1);
  m_deadbandMinPwm = (int32_t)((deadbandMin - kDefaultPwmCenter) / loopTime +
                               kDefaultPwmStepsDown - 1);
  m_minPwm = (int32_t)((min - kDefaultPwmCenter) / loopTime +
                       kDefaultPwmStepsDown - 1);
}