public class AnalogInput extends SensorBase implements PIDSource, LiveWindowSendable
PIDSource.PIDSourceParameter
kAnalogInputChannels, kAnalogOutputChannels, kDigitalChannels, kPDPChannels, kPwmChannels, kRelayChannels, kSolenoidChannels, kSolenoidModules, kSystemClockTicksPerMicrosecond
Constructor and Description |
---|
AnalogInput(int channel)
Construct an analog channel.
|
Modifier and Type | Method and Description |
---|---|
void |
free()
Channel destructor.
|
long |
getAccumulatorCount()
Read the number of accumulated values.
|
void |
getAccumulatorOutput(AccumulatorResult result)
Read the accumulated value and the number of accumulated values
atomically.
|
long |
getAccumulatorValue()
Read the accumulated value.
|
int |
getAverageBits()
Get the number of averaging bits.
|
int |
getAverageValue()
Get a sample from the output of the oversample and average engine for
this channel.
|
double |
getAverageVoltage()
Get a scaled sample from the output of the oversample and average engine
for this channel.
|
int |
getChannel()
Get the channel number.
|
static double |
getGlobalSampleRate()
Get the current sample rate.
|
long |
getLSBWeight()
Get the factory scaling least significant bit weight constant.
|
int |
getOffset()
Get the factory scaling offset constant.
|
int |
getOversampleBits()
Get the number of oversample bits.
|
String |
getSmartDashboardType()
Live Window code, only does anything if live window is activated.
|
edu.wpi.first.wpilibj.tables.ITable |
getTable() |
int |
getValue()
Get a sample straight from this channel.
|
double |
getVoltage()
Get a scaled sample straight from this channel.
|
void |
initAccumulator()
Initialize the accumulator.
|
void |
initTable(edu.wpi.first.wpilibj.tables.ITable subtable)
Initializes a table for this sendable object.
|
boolean |
isAccumulatorChannel()
Is the channel attached to an accumulator.
|
double |
pidGet()
Get the average voltage for use with PIDController
|
void |
resetAccumulator()
Resets the accumulator to the initial value.
|
void |
setAccumulatorCenter(int center)
Set the center value of the accumulator.
|
void |
setAccumulatorDeadband(int deadband)
Set the accumulator's deadband.
|
void |
setAccumulatorInitialValue(long initialValue)
Set an initial value for the accumulator.
|
void |
setAverageBits(int bits)
Set the number of averaging bits.
|
static void |
setGlobalSampleRate(double samplesPerSecond)
Set the sample rate per channel.
|
void |
setOversampleBits(int bits)
Set the number of oversample bits.
|
void |
startLiveWindowMode()
Analog Channels don't have to do anything special when entering the
LiveWindow.
|
void |
stopLiveWindowMode()
Analog Channels don't have to do anything special when exiting the
LiveWindow.
|
void |
updateTable()
Update the table for this sendable object with the latest
values.
|
checkAnalogInputChannel, checkAnalogOutputChannel, checkDigitalChannel, checkPDPChannel, checkPWMChannel, checkRelayChannel, checkSolenoidChannel, checkSolenoidModule, getDefaultSolenoidModule, setDefaultSolenoidModule
public AnalogInput(int channel)
channel
- The channel number to represent. 0-3 are on-board 4-7 are on the MXP port.public void free()
free
in class SensorBase
public int getValue()
public int getAverageValue()
public double getVoltage()
public double getAverageVoltage()
public long getLSBWeight()
public int getOffset()
public int getChannel()
public void setAverageBits(int bits)
bits
- The number of averaging bits.public int getAverageBits()
public void setOversampleBits(int bits)
bits
- The number of oversample bits.public int getOversampleBits()
public void initAccumulator()
public void setAccumulatorInitialValue(long initialValue)
initialValue
- The value that the accumulator should start from when reset.public void resetAccumulator()
public void setAccumulatorCenter(int center)
public void setAccumulatorDeadband(int deadband)
deadband
- The deadband size in ADC codes (12-bit value)public long getAccumulatorValue()
public long getAccumulatorCount()
public void getAccumulatorOutput(AccumulatorResult result)
result
- AccumulatorResult object to store the results in.public boolean isAccumulatorChannel()
public static void setGlobalSampleRate(double samplesPerSecond)
samplesPerSecond
- The number of samples per second.public static double getGlobalSampleRate()
public double pidGet()
public String getSmartDashboardType()
getSmartDashboardType
in interface Sendable
public void initTable(edu.wpi.first.wpilibj.tables.ITable subtable)
public void updateTable()
updateTable
in interface LiveWindowSendable
public edu.wpi.first.wpilibj.tables.ITable getTable()
public void startLiveWindowMode()
startLiveWindowMode
in interface LiveWindowSendable
public void stopLiveWindowMode()
stopLiveWindowMode
in interface LiveWindowSendable
Copyright © 2015. All rights reserved.