[hal] Fix unfinished/incorrect GetCPUTemp functions (#5598)

This commit is contained in:
Ryan Blue
2023-08-31 14:51:57 -04:00
committed by GitHub
parent 99f66b1e24
commit b2dd59450b
11 changed files with 171 additions and 6 deletions

View File

@@ -525,6 +525,38 @@ public final class RoboRioSim {
RoboRioDataJNI.setBrownoutVoltage(vInVoltage);
}
/**
* Register a callback to be run whenever the cpu temp 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 registerCPUTempCallback(
NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerCPUTempCallback(callback, initialNotify);
return new CallbackStore(uid, RoboRioDataJNI::cancelCPUTempCallback);
}
/**
* Get the cpu temp.
*
* @return the cpu temp.
*/
public static double getCPUTemp() {
return RoboRioDataJNI.getCPUTemp();
}
/**
* Set the cpu temp.
*
* @param cpuTemp the new cpu temp.
*/
public static void setCPUTemp(double cpuTemp) {
RoboRioDataJNI.setCPUTemp(cpuTemp);
}
/**
* Get the serial number.
*