/** * Set the upper and lower limits of the analog trigger. * The limits are given as floating point voltage values. */ void setAnalogTriggerLimitsVoltage(void* analog_trigger_pointer, double lower, double upper, int32_t *status) { AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; if (lower > upper) { *status = ANALOG_TRIGGER_LIMIT_ORDER_ERROR; } // TODO: This depends on the averaged setting. Only raw values will work as is. trigger->trigger->writeLowerLimit(getAnalogVoltsToValue(trigger->port, lower, status), status); trigger->trigger->writeUpperLimit(getAnalogVoltsToValue(trigger->port, upper, status), status); }
/* * Class: edu_wpi_first_wpilibj_hal_AnalogJNI * Method: getAnalogVoltsToValue * Signature: (Ljava/nio/ByteBuffer;DLjava/nio/IntBuffer;)I */ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAnalogVoltsToValue (JNIEnv * env, jclass, jobject id, jdouble voltageValue, jobject status) { void ** javaId = (void**)env->GetDirectBufferAddress(id); ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId; ANALOGJNI_LOG(logDEBUG) << "VoltageValue = " << voltageValue; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); jint returnValue = getAnalogVoltsToValue( *javaId, voltageValue, statusPtr ); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; ANALOGJNI_LOG(logDEBUG) << "Value = " << returnValue; return returnValue; }
int32_t getAnalogVoltsToValueIntHack(void* analog_port_pointer, int voltage, int32_t *status) { return getAnalogVoltsToValue(analog_port_pointer, intToFloat(voltage), status); }