public class AnalogInput extends AnalogIO implements LiveWindowSendable, NumberSource
| Modifier and Type | Class and Description |
|---|---|
class |
AnalogInput.AccumulatorResult
Accumulator class
|
static class |
AnalogInput.AnalogTriggerType
Analog Trigger Type Enum
|
AnalogIO.AnalogChannel, AnalogIO.DirectionInterface.InterfaceType| Modifier and Type | Field and Description |
|---|---|
private static int[] |
ACCUMULATOR_CHANNELS |
private static int |
ACCUMULATOR_SLOT |
private long |
m_accumulatorOffset |
protected ITable |
m_table |
private int |
m_triggerIndex |
private java.nio.ByteBuffer |
m_triggerPort |
m_channel, m_port, m_portPointerm_ifaceType, MAX_ANALOG_IN_CHANNELS, MAX_ANALOG_OUT_CHANNELS, MAX_DIGITAL_CHANNELS, MAX_PWM_CHANNELS, MAX_RELAY_CHANNELS| Constructor and Description |
|---|
AnalogInput(AnalogIO.AnalogChannel channel)
Construct an analog channel.
|
| Modifier and Type | Method and Description |
|---|---|
AnalogTriggerOutput |
createTriggerOutput(AnalogInput.AnalogTriggerType type)
Creates an AnalogTriggerOutput object.
|
void |
free()
Release the resources used by this object
|
double |
get()
Get the value of this double source
|
long |
getAccumulatorCount()
Read the number of accumulated values.
|
void |
getAccumulatorOutput(AnalogInput.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.
|
static double |
getGlobalSampleRate()
Get the current sample rate.
|
boolean |
getInWindow()
Return the InWindow output of the analog trigger.
|
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.
|
java.lang.String |
getSmartDashboardType()
Live Window code, only does anything if live window is activated.
|
ITable |
getTable() |
int |
getTriggerIndex()
Return the index of the analog trigger.
|
boolean |
getTriggerState()
Return the TriggerState output of the analog trigger.
|
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(ITable subtable) |
void |
initTrigger() |
boolean |
isAccumulatorChannel()
Is the channel attached to an accumulator.
|
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.
|
void |
setAveraged(boolean useAveraged)
Configure the analog trigger to use the averaged vs.
|
void |
setFiltered(boolean useFiltered)
Configure the analog trigger to use a filtered value.
|
static void |
setGlobalSampleRate(double samples)
Set the sample rate per channel.
|
void |
setLimitsRaw(int lower,
int upper)
Set the upper and lower limits of the analog trigger.
|
void |
setLimitsVoltage(double lower,
double upper)
Set the upper and lower limits of the analog trigger.
|
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() |
private void |
validateTrigger()
validate that the trigger pointer is not null
|
getChannel, getChannelNumberallocateMXPPin, checkAnalogInputChannel, checkAnalogOutputChannel, checkDigitalChannel, checkPWMChannel, checkRelayChannel, freeMXPPin, getInterfaceTypeprivate static final int ACCUMULATOR_SLOT
private static final int[] ACCUMULATOR_CHANNELS
protected ITable m_table
private long m_accumulatorOffset
private java.nio.ByteBuffer m_triggerPort
private int m_triggerIndex
public AnalogInput(AnalogIO.AnalogChannel channel)
channel - The AnalogChannel to represent. 0-3 are on-board 4-7 are on the MXP port.public final void free()
public int getValue()
public int getAverageValue()
public double getVoltage()
public double getAverageVoltage()
public double get()
get in interface NumberSourcepublic long getLSBWeight()
public int getOffset()
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)
center - the center of the accumulatorpublic void setAccumulatorDeadband(int deadband)
deadband - The deadband size in ADC codes (12-bit value)public long getAccumulatorValue()
public long getAccumulatorCount()
public void getAccumulatorOutput(AnalogInput.AccumulatorResult result)
result - AccumulatorResult object to store the results in.public boolean isAccumulatorChannel()
public static void setGlobalSampleRate(double samples)
samples - The number of samples per second.public static double getGlobalSampleRate()
public void initTrigger()
public void setLimitsRaw(int lower,
int upper)
lower - the lower raw limitupper - the upper raw limitpublic void setLimitsVoltage(double lower,
double upper)
lower - the lower voltage limitupper - the upper voltage limitpublic void setAveraged(boolean useAveraged)
useAveraged - true to use an averaged value, false otherwisepublic void setFiltered(boolean useFiltered)
useFiltered - true to use a filterd value, false otherwisepublic int getTriggerIndex()
public boolean getInWindow()
public boolean getTriggerState()
public AnalogTriggerOutput createTriggerOutput(AnalogInput.AnalogTriggerType type)
type - An enum of the type of output object to create.private void validateTrigger()
public java.lang.String getSmartDashboardType()
getSmartDashboardType in interface Sendablepublic void updateTable()
updateTable in interface UpdatingSendablepublic void startLiveWindowMode()
startLiveWindowMode in interface LiveWindowSendablepublic void stopLiveWindowMode()
stopLiveWindowMode in interface LiveWindowSendable