Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.wpi.first.wpilibj
Class DriverStationEnhancedIO

    java.lang.Object
      edu.wpi.first.wpilibj.DriverStationEnhancedIO

All Implemented Interfaces:
  IDevice, IInputOutput

    public class DriverStationEnhancedIO

extends Object
implements IInputOutput

Author:
  dtjones

Nested Class Summary
`static class` | `DriverStationEnhancedIO.EnhancedIOException`
`static class` | `DriverStationEnhancedIO.tAccelChannel` Accelerometer channel for enhanced IO
`static class` | `DriverStationEnhancedIO.tDigitalConfig` Digital configuration for enhanced IO
`static class` | `DriverStationEnhancedIO.tPWMPeriodChannels` PWM period channels for enhanced IO

Field Summary
`static double` | `kAccelOffset`
`static double` | `kAccelScale`
`static double` | `kAnalogInputReference`
`static double` | `kAnalogInputResolution`
`static double` | `kAnalogOutputReference`
`static double` | `kAnalogOutputResolution`
`static int` | `kSupportedAPIVersion`

Method Summary
`double` | `getAcceleration(DriverStationEnhancedIO.tAccelChannel channel)` Query an accelerometer channel on the DS IO.
`double` | `getAnalogIn(int channel)` Query an analog input channel on the DS IO.
`double` | `getAnalogInRatio(int channel)` Query an analog input channel on the DS IO in ratiometric form.
`double` | `getAnalogOut(int channel)` Query the voltage currently being output.
`boolean` | `getButton(int channel)` Get the state of a button on the IO board.
`byte` | `getButtons()` Get the state of all the button channels.
`boolean` | `getDigital(int channel)` Get the current state of a DIO channel regardless of mode.
`DriverStationEnhancedIO.tDigitalConfig` | `getDigitalConfig(int channel)` Get the current configuration for a DIO line.
`short` | `getDigitals()` Get the state of all 16 DIO lines regardless of mode.
`short` | `getEncoder(int encoderNumber)` Get the position of a quadrature encoder.
`boolean` | `getEncoderIndexEnable(int encoderNumber)` Get the current configuration of a quadrature encoder index channel.
`byte` | `getFirmwareVersion()` Get the firmware version running on the IO board.
`boolean` | `getFixedDigitalOutput(int channel)` Get the state being output on a fixed digital output.
`double` | `getPWMOutput(int channel)` Get the percent duty-cycle that the PWM generator channel is configured to output.
`double` | `getPWMPeriod(DriverStationEnhancedIO.tPWMPeriodChannels channels)` Get the period of a PWM generator.
`double` | `getTouchSlider()` Get the value of the Capacitive Sense touch slider.
`void` | `resetEncoder(int encoderNumber)` Reset the position of an encoder to 0.
`void` | `setAnalogOut(int channel, double value)` Set the analog output voltage.
`void` | `setDigitalConfig(int channel, DriverStationEnhancedIO.tDigitalConfig config)` Override the DS's configuration of a DIO line.
`void` | `setDigitalOutput(int channel, boolean value)` Set the state of a DIO line that is configured for digital output.
`void` | `setEncoderIndexEnable(int encoderNumber, boolean enable)` Enable or disable the index channel of a quadrature encoder.
`void` | `setFixedDigitalOutput(int channel, boolean value)` Set the state to output on a Fixed High Current Digital Output line.
`void` | `setLED(int channel, boolean value)` Set the state of an LED on the IO board.
`void` | `setLEDs(byte value)` Set the state of all 8 LEDs on the IO board.
`void` | `setPWMOutput(int channel, double value)` Set the percent duty-cycle to output on a PWM enabled DIO line.
`void` | `setPWMPeriod(DriverStationEnhancedIO.tPWMPeriodChannels channels, double period)` Set the period of a PWM generator.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### kAnalogInputResolution

    public static final double kAnalogInputResolution

See Also:
  Constant Field Values

### kAnalogInputReference

    public static final double kAnalogInputReference

See Also:
  Constant Field Values

### kAnalogOutputResolution

    public static final double kAnalogOutputResolution

See Also:
  Constant Field Values

### kAnalogOutputReference

    public static final double kAnalogOutputReference

See Also:
  Constant Field Values

### kAccelOffset

    public static final double kAccelOffset

See Also:
  Constant Field Values

### kAccelScale

    public static final double kAccelScale

See Also:
  Constant Field Values

### kSupportedAPIVersion

    public static final int kSupportedAPIVersion

See Also:
  Constant Field Values

Method Detail

### getAcceleration

    public double getAcceleration(DriverStationEnhancedIO.tAccelChannel channel)
                           throws DriverStationEnhancedIO.EnhancedIOException

  Query an accelerometer channel on the DS IO.

  Parameters:
    `channel` - The channel number to read.
  Returns:
    The current acceleration on the channel in Gs.
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### getAnalogIn

    public double getAnalogIn(int channel)
                       throws DriverStationEnhancedIO.EnhancedIOException

  Query an analog input channel on the DS IO.

  Parameters:
    `channel` - The channel number to read. [1,8]
  Returns:
    The analog input voltage for the channel.
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### getAnalogInRatio

    public double getAnalogInRatio(int channel)
                            throws DriverStationEnhancedIO.EnhancedIOException

  Query an analog input channel on the DS IO in ratiometric form.

  Parameters:
    `channel` - The channel number to read. [1,8]
  Returns:
    The analog input percentage for the channel.
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### getAnalogOut

    public double getAnalogOut(int channel)
                        throws DriverStationEnhancedIO.EnhancedIOException

  Query the voltage currently being output. AO1 is pin 11 on the top connector (P2). AO2 is pin 12 on the top connector (P2).

  Parameters:
    `channel` - The analog output channel on the DS IO. [1,2]
  Returns:
    The voltage being output on the channel.
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### setAnalogOut

    public void setAnalogOut(int channel,
                             double value)
                      throws DriverStationEnhancedIO.EnhancedIOException

  Set the analog output voltage. AO1 is pin 11 on the top connector (P2). AO2 is pin 12 on the top connector (P2). AO1 is the reference voltage for the 2 analog comparators on DIO15 and DIO16. The output range is 0V to 4V, however due to the supply voltage don't expect more than about 3V. Current supply capability is only 100uA.

  Parameters:
    `channel` - The analog output channel on the DS IO. [1,2]
    `value` - The voltage to output on the channel.
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### getButton

    public boolean getButton(int channel)
                      throws DriverStationEnhancedIO.EnhancedIOException

  Get the state of a button on the IO board. Button1 is the physical button "S1". Button2 is pin 4 on the top connector (P2). Button3 is pin 6 on the top connector (P2). Button4 is pin 8 on the top connector (P2). Button5 is pin 10 on the top connector (P2). Button6 is pin 7 on the top connector (P2). Button2 through Button6 are Capacitive Sense buttons.

  Parameters:
    `channel` - The button channel to read. [1,6]
  Returns:
    The state of the selected button.
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### getButtons

    public byte getButtons()
                    throws DriverStationEnhancedIO.EnhancedIOException

  Get the state of all the button channels.

  Returns:
    The state of the 6 button channels in the 6 lsb of the returned byte.
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### setLED

    public void setLED(int channel,
                       boolean value)
                throws DriverStationEnhancedIO.EnhancedIOException

  Set the state of an LED on the IO board.

  Parameters:
    `channel` - The LED channel to set. [1,8]
    `value` - True to turn the LED on.
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### setLEDs

    public void setLEDs(byte value)
                 throws DriverStationEnhancedIO.EnhancedIOException

  Set the state of all 8 LEDs on the IO board.

  Parameters:
    `value` - The state of each LED. LED1 is lsb and LED8 is msb.
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### getDigital

    public boolean getDigital(int channel)
                       throws DriverStationEnhancedIO.EnhancedIOException

  Get the current state of a DIO channel regardless of mode.

  Parameters:
    `channel` - The DIO channel to read. [1,16]
  Returns:
    The state of the selected digital line.
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### getDigitals

    public short getDigitals()
                      throws DriverStationEnhancedIO.EnhancedIOException

  Get the state of all 16 DIO lines regardless of mode.

  Returns:
    The state of all DIO lines. DIO1 is lsb and DIO16 is msb.
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### setDigitalOutput

    public void setDigitalOutput(int channel,
                                 boolean value)
                          throws DriverStationEnhancedIO.EnhancedIOException

  Set the state of a DIO line that is configured for digital output.

  Parameters:
    `channel` - The DIO channel to set. [1,16]
    `value` - The state to set the selected channel to.
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### getDigitalConfig

    public DriverStationEnhancedIO.tDigitalConfig getDigitalConfig(int channel)
                                                            throws DriverStationEnhancedIO.EnhancedIOException

  Get the current configuration for a DIO line. This has the side effect of forcing the Driver Station to switch to Enhanced mode if it's not when called. If Enhanced mode is not enabled when this is called, it will return kUnknown.

  Parameters:
    `channel` - The DIO channel config to get. [1,16]
  Returns:
    The configured mode for the DIO line.
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### setDigitalConfig

    public void setDigitalConfig(int channel,
                                 DriverStationEnhancedIO.tDigitalConfig config)
                          throws DriverStationEnhancedIO.EnhancedIOException

  Override the DS's configuration of a DIO line. If configured to kInputFloating, the selected DIO line will be tri-stated with no internal pull resistor. If configured to kInputPullUp, the selected DIO line will be tri-stated with a 5k-Ohm internal pull-up resistor enabled. If configured to kInputPullDown, the selected DIO line will be tri-stated with a 5k-Ohm internal pull-down resistor enabled. If configured to kOutput, the selected DIO line will actively drive to 0V or Vddio (specified by J1 and J4). DIO1 through DIO12, DIO15, and DIO16 can source 4mA and can sink 8mA. DIO12 and DIO13 can source 4mA and can sink 25mA. In addition to the common configurations, DIO1 through DIO4 can be configured to kPWM to enable PWM output. In addition to the common configurations, DIO15 and DIO16 can be configured to kAnalogComparator to enable analog comparators on those 2 DIO lines. When enabled, the lines are tri-stated and will accept analog voltages between 0V and 3.3V. If the input voltage is greater than the voltage output by AO1, the DIO will read as true, if less then false.

  Parameters:
    `channel` - The DIO line to configure. [1,16]
    `config` - The mode to put the DIO line in.
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### getPWMPeriod

    public double getPWMPeriod(DriverStationEnhancedIO.tPWMPeriodChannels channels)
                        throws DriverStationEnhancedIO.EnhancedIOException

  Get the period of a PWM generator. This has the side effect of forcing the Driver Station to switch to Enhanced mode if it's not when called. If Enhanced mode is not enabled when this is called, it will return 0.

  Parameters:
    `channels` - Select the generator by specifying the two channels to which it is connected.
  Returns:
    The period of the PWM generator in seconds.
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### setPWMPeriod

    public void setPWMPeriod(DriverStationEnhancedIO.tPWMPeriodChannels channels,
                             double period)
                      throws DriverStationEnhancedIO.EnhancedIOException

  Set the period of a PWM generator. There are 2 PWM generators on the IO board. One can generate PWM signals on DIO1 and DIO2, the other on DIO3 and DIO4. Each generator has one counter and two compare registers. As such, each pair of PWM outputs share the output period but have independent duty cycles.

  Parameters:
    `channels` - Select the generator by specifying the two channels to which it is connected.
    `period` - The period of the PWM generator in seconds. [0.0,0.002731]
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### getFixedDigitalOutput

    public boolean getFixedDigitalOutput(int channel)
                                  throws DriverStationEnhancedIO.EnhancedIOException

  Get the state being output on a fixed digital output.

  Parameters:
    `channel` - The FixedDO line to get. [1,2]
  Returns:
    The state of the FixedDO line.
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### setFixedDigitalOutput

    public void setFixedDigitalOutput(int channel,
                                      boolean value)
                               throws DriverStationEnhancedIO.EnhancedIOException

  Set the state to output on a Fixed High Current Digital Output line. FixedDO1 is pin 5 on the top connector (P2). FixedDO2 is pin 3 on the top connector (P2). The FixedDO lines always output 0V and 3.3V regardless of J1 and J4. They can source 4mA and can sink 25mA. Because of this, they are expected to be used in an active low configuration, such as connecting to the cathode of a bright LED. Because they are expected to be active low, they default to true.

  Parameters:
    `channel` - The FixedDO channel to set.
    `value` - The state to set the FixedDO.
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### getEncoder

    public short getEncoder(int encoderNumber)
                     throws DriverStationEnhancedIO.EnhancedIOException

  Get the position of a quadrature encoder. There are two signed 16-bit 4X quadrature decoders on the IO board. These decoders are always monitoring the state of the lines assigned to them, but these lines do not have to be used for encoders. Encoder1 uses DIO4 for "A", DIO6 for "B", and DIO8 for "Index". Encoder2 uses DIO5 for "A", DIO7 for "B", and DIO9 for "Index". The index functionality can be enabled or disabled using SetEncoderIndexEnable().

  Parameters:
    `encoderNumber` - The quadrature encoder to access. [1,2]
  Returns:
    The current position of the quadrature encoder.
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### resetEncoder

    public void resetEncoder(int encoderNumber)
                      throws DriverStationEnhancedIO.EnhancedIOException

  Reset the position of an encoder to 0. This simply stores an offset locally. It does not reset the hardware counter on the IO board. If you use this method with Index enabled, you may get unexpected results.

  Parameters:
    `encoderNumber` - The quadrature encoder to reset. [1,2]
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### getEncoderIndexEnable

    public boolean getEncoderIndexEnable(int encoderNumber)
                                  throws DriverStationEnhancedIO.EnhancedIOException

  Get the current configuration of a quadrature encoder index channel. This has the side effect of forcing the Driver Station to switch to Enhanced mode if it's not when called. If Enhanced mode is not enabled when this is called, it will return false.

  Parameters:
    `encoderNumber` - The quadrature encoder. [1,2]
  Returns:
    Is the index channel of the encoder enabled.
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### setEncoderIndexEnable

    public void setEncoderIndexEnable(int encoderNumber,
                                      boolean enable)

  Enable or disable the index channel of a quadrature encoder. The quadrature decoders on the IO board support an active-low index input. Encoder1 uses DIO8 for "Index". Encoder2 uses DIO9 for "Index". When enabled, the decoder's counter will be reset to 0 when A, B, and Index are all low.

  Parameters:
    `encoderNumber` - The quadrature encoder. [1,2]
    `enable` - If true, reset the encoder in an index condition.

### getTouchSlider

    public double getTouchSlider()
                          throws DriverStationEnhancedIO.EnhancedIOException

  Get the value of the Capacitive Sense touch slider.

  Returns:
    Value between 0.0 (toward center of board) and 1.0 (toward edge of board). -1.0 means no touch detected.
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### getPWMOutput

    public double getPWMOutput(int channel)
                        throws DriverStationEnhancedIO.EnhancedIOException

  Get the percent duty-cycle that the PWM generator channel is configured to output.

  Parameters:
    `channel` - The DIO line's PWM generator to get the duty-cycle from. [1,4]
  Returns:
    The percent duty-cycle being output (if the DIO line is configured for PWM). [0.0,1.0]
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### setPWMOutput

    public void setPWMOutput(int channel,
                             double value)
                      throws DriverStationEnhancedIO.EnhancedIOException

  Set the percent duty-cycle to output on a PWM enabled DIO line. DIO1 through DIO4 have the ability to output a PWM signal. The period of the signal can be configured in pairs using SetPWMPeriod().

  Parameters:
    `channel` - The DIO line's PWM generator to set. [1,4]
    `value` - The percent duty-cycle to output from the PWM generator. [0.0,1.0]
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

### getFirmwareVersion

    public byte getFirmwareVersion()
                            throws DriverStationEnhancedIO.EnhancedIOException

  Get the firmware version running on the IO board. This also has the side effect of forcing the driver station to switch to Enhanced mode if it is not. If you plan to switch between Driver Stations with unknown IO configurations, you can call this until it returns a non-0 version to ensure that this API is accessible before proceeding.

  Returns:
    The version of the firmware running on the IO board. 0 if the board is not attached or not in Enhanced mode.
  Throws:
    `DriverStationEnhancedIO.EnhancedIOException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

"
For updated information see the Java FRC site
"