Example #1
0
/*
 * Class:     edu_wpi_first_wpilibj_hal_AnalogJNI
 * Method:    setAnalogOversampleBits
 * Signature: (Ljava/nio/ByteBuffer;ILjava/nio/IntBuffer;)V
 */
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAnalogOversampleBits
  (JNIEnv * env, jclass, jobject id, jint value, jobject status)
{
	ANALOGJNI_LOG(logDEBUG) << "OversampleBits = " << value;
	void ** javaId = (void**)env->GetDirectBufferAddress(id);
	ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId;
	jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
	setAnalogOversampleBits( *javaId, value, statusPtr );
	ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
}
Example #2
0
/**
 * Initialize the analog input port using the given port object.
 */
void* initializeAnalogInputPort(void* port_pointer, int32_t *status) {
  initializeAnalog(status);
  Port* port = (Port*) port_pointer;

  // Initialize port structure
  AnalogPort* analog_port = new AnalogPort();
  analog_port->port = *port;
  if (isAccumulatorChannel(analog_port, status)) {
    analog_port->accumulator = tAccumulator::create(port->pin, status);
  } else analog_port->accumulator = NULL;

  // Set default configuration
  analogInputSystem->writeScanList(port->pin, port->pin, status);
  setAnalogAverageBits(analog_port, kDefaultAverageBits, status);
  setAnalogOversampleBits(analog_port, kDefaultOversampleBits, status);
  return analog_port;
}
Example #3
0
/**
 * Set the number of oversample bits.
 * This sets the number of oversample bits. The actual number of oversampled
 * values is 2^bits.
 * Use oversampling to improve the resolution of your measurements at the
 * expense of sampling rate.
 * The oversampling is done automatically in the FPGA.
 *
 * @param bits Number of bits of oversampling.
 */
void AnalogInput::SetOversampleBits(uint32_t bits) {
    if (StatusIsFatal()) return;
    int32_t status = 0;
    setAnalogOversampleBits(m_port, bits, &status);
    wpi_setErrorWithContext(status, getHALErrorMessage(status));
}