/* * Class: edu_wpi_first_wpilibj_hal_AnalogJNI * Method: setAccumulatorCenter * Signature: (Ljava/nio/ByteBuffer;ILjava/nio/IntBuffer;)V */ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_setAccumulatorCenter (JNIEnv * env, jclass, jobject id, jint center, jobject status) { void ** javaId = (void**)env->GetDirectBufferAddress(id); ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); setAccumulatorCenter(*javaId, center, statusPtr); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; }
/** * Initialize the accumulator. */ void initAccumulator(void* analog_port_pointer, int32_t *status) { setAccumulatorCenter(analog_port_pointer, 0, status); resetAccumulator(analog_port_pointer, status); }
/** * Set the center value of the accumulator. * * The center value is subtracted from each A/D value before it is added to the * accumulator. This * is used for the center value of devices like gyros and accelerometers to * take the device offset into account when integrating. * * This center value is based on the output of the oversampled and averaged * source from the accumulator * channel. Because of this, any non-zero oversample bits will affect the size * of the value for this field. */ void AnalogInput::SetAccumulatorCenter(int32_t center) { if (StatusIsFatal()) return; int32_t status = 0; setAccumulatorCenter(m_port, center, &status); wpi_setErrorWithContext(status, getHALErrorMessage(status)); }