[hal] Add GetTeamNumber (#5596)

This commit is contained in:
Ryan Blue
2023-09-02 02:34:18 -04:00
committed by GitHub
parent a750bee54d
commit ac23f92451
19 changed files with 259 additions and 0 deletions

View File

@@ -57,6 +57,15 @@ public final class RobotController {
return HALUtil.getComments();
}
/**
* Returns the team number configured for the robot controller.
*
* @return team number, or 0 if not found.
*/
public static int getTeamNumber() {
return HALUtil.getTeamNumber();
}
/**
* Read the microsecond timer from the FPGA.
*

View File

@@ -557,6 +557,38 @@ public final class RoboRioSim {
RoboRioDataJNI.setCPUTemp(cpuTemp);
}
/**
* Register a callback to be run whenever the team number changes.
*
* @param callback the callback
* @param initialNotify whether to call the callback with the initial state
* @return the {@link CallbackStore} object associated with this callback. Save a reference to
* this object so GC doesn't cancel the callback.
*/
public static CallbackStore registerTeamNumberCallback(
NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerTeamNumberCallback(callback, initialNotify);
return new CallbackStore(uid, RoboRioDataJNI::cancelTeamNumberCallback);
}
/**
* Get the team number.
*
* @return the team number.
*/
public static int getTeamNumber() {
return RoboRioDataJNI.getTeamNumber();
}
/**
* Set the team number.
*
* @param teamNumber the new team number.
*/
public static void setTeamNumber(int teamNumber) {
RoboRioDataJNI.setTeamNumber(teamNumber);
}
/**
* Get the serial number.
*