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 Details

    • m_port

      protected int m_port
      Where the analog trigger is attached.
  • Constructor Details

    • AnalogTrigger

      public AnalogTrigger​(int channel)
      Constructor for an analog trigger given a channel number.
      Parameters:
      channel - the port to use for the analog trigger
    • AnalogTrigger

      public AnalogTrigger​(AnalogInput channel)
      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

      public AnalogTrigger​(DutyCycle input)
      Construct an analog trigger given a duty cycle input.
      Parameters:
      input - the DutyCycle to use for the analog trigger
  • Method Details

    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • setLimitsRaw

      public void setLimitsRaw​(int lower, int upper)
      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 limit
      upper - the upper raw limit
    • setLimitsDutyCycle

      public void setLimitsDutyCycle​(double lower, double upper)
      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 limit
      upper - the upper duty cycle limit
    • setLimitsVoltage

      public void setLimitsVoltage​(double lower, double upper)
      Set the upper and lower limits of the analog trigger. The limits are given as floating point voltage values.
      Parameters:
      lower - the lower voltage limit
      upper - the upper voltage limit
    • setAveraged

      public void setAveraged​(boolean useAveragedValue)
      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

      public void setFiltered​(boolean useFilteredValue)
      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

      public final int 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

      public boolean 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

      public boolean 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

      public void initSendable​(SendableBuilder builder)
      Description copied from interface: Sendable
      Initializes this Sendable object.
      Specified by:
      initSendable in interface Sendable
      Parameters:
      builder - sendable builder