Package edu.wpi.first.wpilibj
Class AnalogTrigger
java.lang.Object
edu.wpi.first.wpilibj.AnalogTrigger
- All Implemented Interfaces:
Sendable
,AutoCloseable
public class AnalogTrigger extends Object implements Sendable, AutoCloseable
Class for creating and configuring Analog Triggers.
-
Field Summary
Fields Modifier and Type Field Description protected int
m_port
Where the analog trigger is attached. -
Constructor Summary
Constructors Constructor Description AnalogTrigger(int channel)
Constructor for an analog trigger given a channel number.AnalogTrigger(AnalogInput channel)
Construct an analog trigger given an analog channel.AnalogTrigger(DutyCycle input)
Construct an analog trigger given a duty cycle input. -
Method Summary
Modifier and Type Method Description void
close()
AnalogTriggerOutput
createOutput(AnalogTriggerOutput.AnalogTriggerType type)
Creates an AnalogTriggerOutput object.int
getIndex()
Return the index of the analog trigger.boolean
getInWindow()
Return the InWindow output of the analog trigger.boolean
getTriggerState()
Return the TriggerState output of the analog trigger.void
initSendable(SendableBuilder builder)
Initializes thisSendable
object.void
setAveraged(boolean useAveragedValue)
Configure the analog trigger to use the averaged vs.void
setFiltered(boolean useFilteredValue)
Configure the analog trigger to use a filtered value.void
setLimitsDutyCycle(double lower, double upper)
Set the upper and lower limits of the analog trigger.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.
-
Field Details
-
m_port
Where the analog trigger is attached.
-
-
Constructor Details
-
AnalogTrigger
Constructor for an analog trigger given a channel number.- Parameters:
channel
- the port to use for the analog trigger
-
AnalogTrigger
Construct an analog trigger given an analog channel. This should be used in the case of sharing an analog channel between the trigger and an analog input object.- Parameters:
channel
- the AnalogInput to use for the analog trigger
-
AnalogTrigger
Construct an analog trigger given a duty cycle input.- Parameters:
input
- the DutyCycle to use for the analog trigger
-
-
Method Details
-
close
- Specified by:
close
in interfaceAutoCloseable
-
setLimitsRaw
Set the upper and lower limits of the analog trigger. The limits are given in ADC codes. If oversampling is used, the units must be scaled appropriately.- Parameters:
lower
- the lower raw limitupper
- the upper raw limit
-
setLimitsDutyCycle
Set the upper and lower limits of the analog trigger. The limits are given as floating point values between 0 and 1.- Parameters:
lower
- the lower duty cycle limitupper
- the upper duty cycle limit
-
setLimitsVoltage
Set the upper and lower limits of the analog trigger. The limits are given as floating point voltage values.- Parameters:
lower
- the lower voltage limitupper
- the upper voltage limit
-
setAveraged
Configure the analog trigger to use the averaged vs. raw values. If the value is true, then the averaged value is selected for the analog trigger, otherwise the immediate value is used.- Parameters:
useAveragedValue
- true to use an averaged value, false otherwise
-
setFiltered
Configure the analog trigger to use a filtered value. The analog trigger will operate with a 3 point average rejection filter. This is designed to help with 360 degree pot applications for the period where the pot crosses through zero.- Parameters:
useFilteredValue
- true to use a filtered value, false otherwise
-
getIndex
Return the index of the analog trigger. This is the FPGA index of this analog trigger instance.- Returns:
- The index of the analog trigger.
-
getInWindow
Return the InWindow output of the analog trigger. True if the analog input is between the upper and lower limits.- Returns:
- The InWindow output of the analog trigger.
-
getTriggerState
Return the TriggerState output of the analog trigger. True if above upper limit. False if below lower limit. If in Hysteresis, maintain previous state.- Returns:
- The TriggerState output of the analog trigger.
-
createOutput
Creates an AnalogTriggerOutput object. Gets an output object that can be used for routing. Caller is responsible for deleting the AnalogTriggerOutput object.- Parameters:
type
- An enum of the type of output object to create.- Returns:
- A pointer to a new AnalogTriggerOutput object.
-
initSendable
Description copied from interface:Sendable
Initializes thisSendable
object.- Specified by:
initSendable
in interfaceSendable
- Parameters:
builder
- sendable builder
-