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