001    /*----------------------------------------------------------------------------*/
002    /* Copyright (c) FIRST 2008-2012. All Rights Reserved.                        */
003    /* Open Source Software - may be modified and shared by FRC teams. The code   */
004    /* must be accompanied by the FIRST BSD license file in the root directory of */
005    /* the project.                                                               */
006    /*----------------------------------------------------------------------------*/
007    
008    package edu.wpi.first.wpilibj.buttons;
009    
010    import edu.wpi.first.wpilibj.DriverStation;
011    import edu.wpi.first.wpilibj.DriverStationEnhancedIO.EnhancedIOException;
012    
013    /**
014     *
015     * @author Greg
016     */
017    public class DigitalIOButton extends Button {
018        public final static boolean ACTIVE_STATE = false;
019    
020        int port;
021    
022        public DigitalIOButton(int port){
023            this.port = port;
024        }
025    
026        public boolean get(){
027            try {
028                return DriverStation.getInstance().getEnhancedIO().getDigital(port) == ACTIVE_STATE;
029            } catch (EnhancedIOException ex) {
030                return false;
031            }
032        }
033    }