|
Re: PSoc Java code.
A simple snippet to read a digital input:
Code:
DriverStationEnhancedIO m_io = DriverStation.getInstance().getEnhancedIO();
/**
* Get the state of a digital input
* @param which The channel
* @return The state of the digital input
*/
public boolean getDigital(int which) {
try { //You need to catch an exception
return m_io.getDigital(which); //Return the state of the digital input
} catch(Exception e) { //An exception will be thrown if the board is not plugged in
e.printStackTrace(); //If an exception is thrown, print exception data
return false; //and return false
}
}
of course, you need your imports and all that other fun stuff.
Hope it helps
If you need help with anything else PSoC related, ask away. We've worked with all features of it in some form or another.
__________________
Drive Coach Team 5012 Gryffingear / Antelope Valley FIRST teams / EWCP - (2013 - Current)
Student / Driver / Programmer / CAD - FRC Team 399: Eagle Robotics / FTC Team 72: GarageBots - (2009 - 2013)
Los Angeles Region FTC FTA/CSA/Head Ref
[FF] FIRST Pick
2014 FTC Los Angeles Regional Compass Award Winner.
2017 - San Diego Regional / Sacramento Regional / Las Vegas Regional
2016 - Los Angeles Regional Creativity + Winners (1197, 987, 5012) / Las Vegas Regional Team Spirit + SF (5012, 5851, 5049) / Galileo Subdivision
2015 - Inland Empire QF (597, 5012, 4413) / Las Vegas Imagery + Winners (148, 987, 5012) / Newton Subdivision and World Champions (118, 1678, 1671, 5012)
2014 - Inland Empire Rookie All Star + Highest Rookie Seed + SF (2339, 1967, 5012) / Las Vegas Rookie All Star / Galileo Division Imagery
Last edited by Jeremy Germita : 24-06-2011 at 22:25.
|