[wpilib] PH: Revert to 5V rail being fixed 5V (#5122)

This commit is contained in:
Noah Andrews
2023-02-24 21:55:50 -06:00
committed by GitHub
parent 4c46b6aff9
commit edf4ded412
2 changed files with 26 additions and 12 deletions

View File

@@ -161,11 +161,14 @@ void PneumaticHub::EnableCompressorAnalog(
"maxPressure must be between 0 and 120 PSI, got {}",
maxPressure);
}
// Send the voltage as it would be if the 5V rail was at exactly 5V.
// The firmware will compensate for the real 5V rail voltage, which
// can fluctuate somewhat over time.
units::volt_t minAnalogVoltage = PSIToVolts(minPressure, 5_V);
units::volt_t maxAnalogVoltage = PSIToVolts(maxPressure, 5_V);
int32_t status = 0;
units::volt_t minAnalogVoltage =
PSIToVolts(minPressure, Get5VRegulatedVoltage());
units::volt_t maxAnalogVoltage =
PSIToVolts(maxPressure, Get5VRegulatedVoltage());
HAL_SetREVPHClosedLoopControlAnalog(m_handle, minAnalogVoltage.value(),
maxAnalogVoltage.value(), &status);
FRC_ReportError(status, "Module {}", m_module);
@@ -188,11 +191,14 @@ void PneumaticHub::EnableCompressorHybrid(
"maxPressure must be between 0 and 120 PSI, got {}",
maxPressure);
}
// Send the voltage as it would be if the 5V rail was at exactly 5V.
// The firmware will compensate for the real 5V rail voltage, which
// can fluctuate somewhat over time.
units::volt_t minAnalogVoltage = PSIToVolts(minPressure, 5_V);
units::volt_t maxAnalogVoltage = PSIToVolts(maxPressure, 5_V);
int32_t status = 0;
units::volt_t minAnalogVoltage =
PSIToVolts(minPressure, Get5VRegulatedVoltage());
units::volt_t maxAnalogVoltage =
PSIToVolts(maxPressure, Get5VRegulatedVoltage());
HAL_SetREVPHClosedLoopControlHybrid(m_handle, minAnalogVoltage.value(),
maxAnalogVoltage.value(), &status);
FRC_ReportError(status, "Module {}", m_module);