Class AnalogInput
java.lang.Object
org.wpilib.hardware.discrete.AnalogInput
- All Implemented Interfaces:
AutoCloseable, TelemetryLoggable
Analog channel class.
Each analog channel is read from hardware as a 12-bit number representing 0V to 3.3V.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()intGet the channel number.Gets the telemetry table type.intgetValue()Get a sample straight from this channel.doubleGet a scaled sample straight from this channel.voidlogTo(TelemetryTable table) Logs the object to aTelemetryTable.voidsetSimDevice(SimDevice device) Indicates this input is used by a simulated device.
-
Constructor Details
-
AnalogInput
public AnalogInput(int channel) Construct an analog channel.- Parameters:
channel- The SmartIO channel for the analog input.
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
getValue
public int getValue()Get a sample straight from this channel. The sample is a 12-bit value representing the 0V to 3.3V range of the A/D converter. The units are in A/D converter codes. Use GetVoltage() to get the analog value in calibrated units.- Returns:
- A sample straight from this channel.
-
getVoltage
public double getVoltage()Get a scaled sample straight from this channel. The value is scaled to units of Volts.- Returns:
- A scaled sample straight from this channel.
-
getChannel
public int getChannel()Get the channel number.- Returns:
- The channel number.
-
setSimDevice
Indicates this input is used by a simulated device.- Parameters:
device- simulated device handle
-
logTo
Description copied from interface:TelemetryLoggableLogs the object to aTelemetryTable.- Specified by:
logToin interfaceTelemetryLoggable- Parameters:
table- telemetry table
-
getTelemetryType
Description copied from interface:TelemetryLoggableGets the telemetry table type. Default is no specified table type (null). A mismatch in type during logging results in a reported warning, so this should always return the same value.- Specified by:
getTelemetryTypein interfaceTelemetryLoggable- Returns:
- Table type
-