View Single Post
  #1   Spotlight this post!  
Unread 24-11-2012, 17:09
Skyehawk's Avatar
Skyehawk Skyehawk is offline
Nuts N' Bolts
AKA: Skye Leake
FRC #0876 (Thunder Robotics)
Team Role: Mentor
 
Join Date: Nov 2012
Rookie Year: 2011
Location: Northwood, ND
Posts: 204
Skyehawk is a name known to allSkyehawk is a name known to allSkyehawk is a name known to allSkyehawk is a name known to allSkyehawk is a name known to allSkyehawk is a name known to all
Enhanced I/O through Cypress

Our team is new to the Enhanced I/O through Cypress. I have done everything to spec in setting it up except one thing; when I tried to load the 2012.hex onto the module it said fail in the lower right hand corner (where it says connected) so I used the 2009.hex and it loaded fine. The DS reconized it and I have full suport on the DS of all the functions that are native.

When I loaded my code onto the robot I am using Cypress to get a button value. Here's where I need help:
Initilized:
Code:
    public class RobotClass extends IterativeRobot {
        Relay Feed = new Relay(2);
        DriverStationEnhancedIO Cypress = DriverStation.getInstance().getEnhancedIO();
Teleop:
Code:
if (Cypress.getButton(2) ) {
                Feed.setDirection(Relay.Direction.kForward);
            } else if (Cypress.getButton(3)) {
                Feed.setDirection(Relay.Direction.kReverse);
            } else {
                Feed.set(Relay.Value.kOff);
Netbeans wants me to sorround the teleop portion of code with a try - catch statement:
Code:
        try {
            if(Cypress.getButton(2) ) {
                    Feed.setDirection(Relay.Direction.kForward);
                } else if (Cypress.getButton(3)) {
                    Feed.setDirection(Relay.Direction.kReverse);
                } else {
                    Feed.set(Relay.Value.kOff);
            }
        } catch (EnhancedIOException ex) {
            ex.printStackTrace();
        }
Is the try - catch the correct way to do this? It doesnt seem right. If it isn't, what is the correct way to do this?
Thanks,
Skyehawk
Reply With Quote