/** * Get a scaled sample from the output of the oversample and average engine for * this channel. * The value is scaled to units of Volts using the calibrated scaling data from * GetLSBWeight() and GetOffset(). * Using oversampling will cause this value to be higher resolution, but it will * update more slowly. * Using averaging will cause this value to be more stable, but it will update * more slowly. * @return A scaled sample from the output of the oversample and average engine * for this channel. */ float AnalogInput::GetAverageVoltage() const { if (StatusIsFatal()) return 0.0f; int32_t status = 0; float voltage = getAnalogAverageVoltage(m_port, &status); wpi_setErrorWithContext(status, getHALErrorMessage(status)); return voltage; }
/* * Class: edu_wpi_first_wpilibj_hal_AnalogJNI * Method: getAnalogAverageVoltage * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)D */ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogAverageVoltage (JNIEnv * env, jclass, jobject id, jobject status) { void ** javaId = (void**)env->GetDirectBufferAddress(id); ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); jdouble returnValue = getAnalogAverageVoltage( *javaId, statusPtr ); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; ANALOGJNI_LOG(logDEBUG) << "AverageVoltage = " << returnValue; return returnValue; }
int getAnalogAverageVoltageIntHack(void* analog_port_pointer, int32_t *status) { return floatToInt(getAnalogAverageVoltage(analog_port_pointer, status)); }