Support for the "USER" button on the RoboRIO

You can get the state of the USER button with GetUserButton() in
C++ or Utility.getUserButton() in java.

Change-Id: I923e62cab5e621ef43fed503acab5c0d751264fb
This commit is contained in:
Thomas Clark
2014-07-29 14:34:52 -04:00
parent 8b612f713b
commit 6deb196e90
7 changed files with 59 additions and 13 deletions

View File

@@ -25,7 +25,7 @@ public class Utility implements IUtility {
/**
* Return the FPGA Version number. For now, expect this to be 2009.
*
*
* @return FPGA Version number.
*/
int getFPGAVersion() {
@@ -41,7 +41,7 @@ public class Utility implements IUtility {
* Return the FPGA Revision number. The format of the revision is 3 numbers.
* The 12 most significant bits are the Major Revision. the next 8 bits are
* the Minor Revision. The 12 least significant bits are the Build Number.
*
*
* @return FPGA Revision number.
*/
long getFPGARevision() {
@@ -55,23 +55,37 @@ public class Utility implements IUtility {
/**
* Read the microsecond timer from the FPGA.
*
*
* @return The current time in microseconds according to the FPGA.
*/
public static long getFPGATime() {
ByteBuffer status = ByteBuffer.allocateDirect(4);
// set the byte order
status.order(ByteOrder.LITTLE_ENDIAN);
long value = HALUtil.getFPGATime(status.asIntBuffer());
HALUtil.checkStatus(status.asIntBuffer());
return value;
}
/**
* Get the state of the "USER" button on the RoboRIO
* @return true if the button is currently pressed down
*/
public static boolean getUserButton() {
ByteBuffer status = ByteBuffer.allocateDirect(4);
// set the byte order
status.order(ByteOrder.LITTLE_ENDIAN);
boolean value = HALUtil.getFPGAButton(status.asIntBuffer());
HALUtil.checkStatus(status.asIntBuffer());
return value;
}
/**
* Control whether to send System.err output to the driver station's error
* pane.
*
*
* @param enabled
* if true, send error stream to driver station, otherwise
* disable sending error stream

View File

@@ -25,7 +25,8 @@ public class HALUtil extends JNIWrapper {
public static native short getFPGAVersion(IntBuffer status);
public static native int getFPGARevision(IntBuffer status);
public static native long getFPGATime(IntBuffer status);
public static native boolean getFPGAButton(IntBuffer status);
public static native String getHALErrorMessage(int code);
public static void checkStatus(IntBuffer status)