[hal, wpilib] Add brownout voltage configuration (#3632)

This commit is contained in:
Thad House
2021-10-13 19:14:27 -07:00
committed by GitHub
parent 9cd4bc407a
commit 689e9ccfb5
21 changed files with 319 additions and 0 deletions

View File

@@ -213,6 +213,26 @@ public final class RobotController {
return PowerJNI.getUserCurrentFaults6V();
}
/**
* Get the current brownout voltage seting.
*
* @return The brownout voltage
*/
public static double getBrownoutVoltage() {
return PowerJNI.getBrownoutVoltage();
}
/**
* Set the voltage the roborio will brownout and disable all outputs.
*
* <p>Note that this only does anything on the roboRIO 2. On the roboRIO it is a no-op.
*
* @param brownoutVoltage The brownout voltage
*/
public static void setBrownoutVoltage(double brownoutVoltage) {
PowerJNI.setBrownoutVoltage(brownoutVoltage);
}
/**
* Get the current status of the CAN bus.
*

View File

@@ -498,6 +498,39 @@ public final class RoboRioSim {
RoboRioDataJNI.setUserFaults3V3(userFaults3V3);
}
/**
* Register a callback to be run whenever the Brownout voltage 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 registerBrownoutVoltageCallback(
NotifyCallback callback, boolean initialNotify) {
int uid = RoboRioDataJNI.registerBrownoutVoltageCallback(callback, initialNotify);
return new CallbackStore(uid, RoboRioDataJNI::cancelBrownoutVoltageCallback);
}
/**
* Measure the Brownout voltage.
*
* @return the Brownout voltage
*/
public static double getBrownoutVoltage() {
return RoboRioDataJNI.getBrownoutVoltage();
}
/**
* Define the Brownout voltage.
*
* @param vInVoltage the new voltage
*/
@SuppressWarnings("ParameterName")
public static void setBrownoutVoltage(double vInVoltage) {
RoboRioDataJNI.setBrownoutVoltage(vInVoltage);
}
/** Reset all simulation data. */
public static void resetData() {
RoboRioDataJNI.resetData();