Class AnalogInputJNI

java.lang.Object
org.wpilib.hardware.hal.JNIWrapper
org.wpilib.hardware.hal.AnalogInputJNI

public class AnalogInputJNI extends JNIWrapper
Analog Input / Output / Trigger JNI Functions.
See Also:
  • "wpi/hal/AnalogInput.h"
  • Method Details

    • initializeAnalogInputPort

      public static int initializeAnalogInputPort(int channel)
      Initializes the analog input port using the given port object.
      Parameters:
      channel - The smartio channel.
      Returns:
      the created analog input handle
      See Also:
      • "HAL_InitializeAnalogInputPort"
    • freeAnalogInputPort

      public static void freeAnalogInputPort(int analogPortHandle)
      Frees an analog input port.
      Parameters:
      analogPortHandle - Handle to the analog port.
      See Also:
      • "HAL_FreeAnalogInputPort"
    • checkAnalogModule

      public static boolean checkAnalogModule(byte module)
      Checks that the analog module number is valid.
      Parameters:
      module - The analog module number.
      Returns:
      Analog module is valid and present
      See Also:
      • "HAL_CheckAnalogModule"
    • checkAnalogInputChannel

      public static boolean checkAnalogInputChannel(int channel)
      Checks that the analog output channel number is valid. Verifies that the analog channel number is one of the legal channel numbers. Channel numbers are 0-based.
      Parameters:
      channel - The analog output channel number.
      Returns:
      Analog channel is valid
      See Also:
      • "HAL_CheckAnalogInputChannel"
    • setAnalogInputSimDevice

      public static void setAnalogInputSimDevice(int handle, int device)
      Indicates the analog input is used by a simulated device.
      Parameters:
      handle - the analog input handle
      device - simulated device handle
      See Also:
      • "HAL_SetAnalogInputSimDevice"
    • getAnalogValue

      public static short getAnalogValue(int analogPortHandle)
      Gets a sample straight from the channel on this module.

      The sample is a 12-bit value representing the 0V to 3.3V range of the A/D converter in the module. The units are in A/D converter codes. Use GetVoltage() to get the analog value in calibrated units.

      Parameters:
      analogPortHandle - Handle to the analog port to use.
      Returns:
      A sample straight from the channel on this module.
      See Also:
      • "HAL_GetAnalogValue"
    • getAnalogVoltsToValue

      public static int getAnalogVoltsToValue(int analogPortHandle, double voltage)
      Converts a voltage to a raw value for a specified channel.

      This process depends on the calibration of each channel, so the channel must be specified.

      todo This assumes raw values. Oversampling not supported as is.

      Parameters:
      analogPortHandle - Handle to the analog port to use.
      voltage - The voltage to convert.
      Returns:
      The raw value for the channel.
      See Also:
      • "HAL_GetAnalogVoltsToValue"
    • getAnalogValueToVolts

      public static double getAnalogValueToVolts(int analogPortHandle, int value)
      Get the analog voltage from a raw value.
      Parameters:
      analogPortHandle - Handle to the analog port the values were read from.
      value - The raw analog value
      Returns:
      The voltage relating to the value
      See Also:
      • "HAL_GetAnalogValueToVolts"
    • getAnalogVoltage

      public static double getAnalogVoltage(int analogPortHandle)
      Gets a scaled sample straight from the channel on this module.

      The value is scaled to units of Volts.

      Parameters:
      analogPortHandle - Handle to the analog port to use.
      Returns:
      A scaled sample straight from the channel on this module.
      See Also:
      • "HAL_GetAnalogVoltage"