Class AnalogInputDevice

java.lang.Object
com.cdarobotics.cdalib.devices.Device
com.cdarobotics.cdalib.devices.sensors.AnalogInputDevice

public class AnalogInputDevice extends Device
A Device wrapping an AnalogInput (e.g. a potentiometer or analog distance sensor). The voltage is read once per update() and cached.

Getters reflect the value from the most recent update().

  • Constructor Details

    • AnalogInputDevice

      public AnalogInputDevice(com.qualcomm.robotcore.hardware.AnalogInput input)
      Wraps an already-resolved analog input.
    • AnalogInputDevice

      public AnalogInputDevice(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String name)
      Resolves the analog input from the hardware map by configured name.
  • Method Details

    • getVoltage

      public double getVoltage()
      Returns:
      the input voltage as of the last update().
    • getMaxVoltage

      public double getMaxVoltage()
      Returns:
      the maximum voltage this input can report (a fixed hardware constant).
    • getInput

      public com.qualcomm.robotcore.hardware.AnalogInput getInput()
      Returns:
      the wrapped SDK input, for operations not exposed here.
    • update

      public void update()
      Description copied from class: Device
      Flush pending writes to, or refresh cached reads from, the underlying hardware.
      Specified by:
      update in class Device