mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
[hal, wpilib] Add brownout voltage configuration (#3632)
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user