[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

@@ -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;

View File

@@ -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();
}