mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
[hal, wpilib] Add brownout voltage configuration (#3632)
This commit is contained in:
@@ -159,6 +159,19 @@ int RobotController::GetFaultCount6V() {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
units::volt_t RobotController::GetBrownoutVoltage() {
|
||||
int32_t status = 0;
|
||||
double retVal = HAL_GetBrownoutVoltage(&status);
|
||||
FRC_CheckErrorStatus(status, "{}", "GetBrownoutVoltage");
|
||||
return units::volt_t(retVal);
|
||||
}
|
||||
|
||||
void RobotController::SetBrownoutVoltage(units::volt_t brownoutVoltage) {
|
||||
int32_t status = 0;
|
||||
HAL_SetBrownoutVoltage(brownoutVoltage.to<double>(), &status);
|
||||
FRC_CheckErrorStatus(status, "{}", "SetBrownoutVoltage");
|
||||
}
|
||||
|
||||
CANStatus RobotController::GetCANStatus() {
|
||||
int32_t status = 0;
|
||||
float percentBusUtilization = 0;
|
||||
|
||||
@@ -267,6 +267,23 @@ void RoboRioSim::SetUserFaults3V3(int userFaults3V3) {
|
||||
HALSIM_SetRoboRioUserFaults3V3(userFaults3V3);
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RoboRioSim::RegisterBrownoutVoltageCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
-1, callback, &HALSIM_CancelRoboRioBrownoutVoltageCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioBrownoutVoltageCallback(
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
units::volt_t RoboRioSim::GetBrownoutVoltage() {
|
||||
return units::volt_t(HALSIM_GetRoboRioBrownoutVoltage());
|
||||
}
|
||||
|
||||
void RoboRioSim::SetBrownoutVoltage(units::volt_t vInVoltage) {
|
||||
HALSIM_SetRoboRioBrownoutVoltage(vInVoltage.to<double>());
|
||||
}
|
||||
|
||||
void RoboRioSim::ResetData() {
|
||||
HALSIM_ResetRoboRioData();
|
||||
}
|
||||
|
||||
@@ -188,6 +188,28 @@ class RobotController {
|
||||
*/
|
||||
static int GetFaultCount6V();
|
||||
|
||||
/**
|
||||
* Get the current brownout voltage seting.
|
||||
*
|
||||
* @return The brownout voltage
|
||||
*/
|
||||
static units::volt_t GetBrownoutVoltage();
|
||||
|
||||
/**
|
||||
* Set the voltage the roborio will brownout and disable all outputs.
|
||||
*
|
||||
* Note that this only does anything on the roboRIO 2.
|
||||
* On the roboRIO it is a no-op.
|
||||
*
|
||||
* @param brownoutVoltage The brownout voltage
|
||||
*/
|
||||
static void SetBrownoutVoltage(units::volt_t brownoutVoltage);
|
||||
|
||||
/**
|
||||
* Get the current status of the CAN bus.
|
||||
*
|
||||
* @return The status of the CAN bus
|
||||
*/
|
||||
static CANStatus GetCANStatus();
|
||||
};
|
||||
|
||||
|
||||
@@ -394,6 +394,30 @@ class RoboRioSim {
|
||||
*/
|
||||
static void SetUserFaults3V3(int 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 CallbackStore object associated with this callback
|
||||
*/
|
||||
[[nodiscard]] static std::unique_ptr<CallbackStore>
|
||||
RegisterBrownoutVoltageCallback(NotifyCallback callback, bool initialNotify);
|
||||
|
||||
/**
|
||||
* Measure the brownout voltage.
|
||||
*
|
||||
* @return the brownout voltage
|
||||
*/
|
||||
static units::volt_t GetBrownoutVoltage();
|
||||
|
||||
/**
|
||||
* Define the brownout voltage.
|
||||
*
|
||||
* @param vInVoltage the new voltage
|
||||
*/
|
||||
static void SetBrownoutVoltage(units::volt_t brownoutVoltage);
|
||||
|
||||
/**
|
||||
* Reset all simulation data.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user