edu.wpi.first.wpilibj

## Class AnalogTrigger

- java.lang.Object
- - edu.wpi.first.wpilibj.AnalogTrigger

-     public class AnalogTrigger
      extends java.lang.Object

  Class for creating and configuring Analog Triggers.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `AnalogTrigger.AnalogTriggerException` Exceptions dealing with improper operation of the Analog trigger.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected AnalogInput` | `m_analogInput`
    `protected int` | `m_index`
    `protected boolean` | `m_ownsAnalog`
    `protected int` | `m_port` Where the analog trigger is attached.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AnalogTrigger(AnalogInput channel)` Construct an analog trigger given an analog channel.
    `AnalogTrigger(int channel)` Constructor for an analog trigger given a channel number.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `AnalogTriggerOutput` | `createOutput(AnalogTriggerOutput.AnalogTriggerType type)` Creates an AnalogTriggerOutput object.
    `void` | `free()` Release the resources used by this 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` | `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` | `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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### m_port

          protected int m_port

      Where the analog trigger is attached.

    - #### m_index

          protected int m_index

    - #### m_analogInput

          protected AnalogInput m_analogInput

    - #### m_ownsAnalog

          protected boolean m_ownsAnalog

  - ### Constructor Detail

    - #### 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

  - ### Method Detail

    - #### free

          public void free()

      Release the resources used by this object.

    - #### 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

    - #### 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 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

          public AnalogTriggerOutput createOutput(AnalogTriggerOutput.AnalogTriggerType type)

      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.