[wpilibc] Errors: Use fmtlib

This commit is contained in:
Peter Johnson
2021-05-23 19:33:33 -07:00
parent 87603e400d
commit 831c10bdfc
55 changed files with 551 additions and 533 deletions

View File

@@ -22,8 +22,7 @@ using namespace frc;
AnalogOutput::AnalogOutput(int channel) {
if (!SensorUtil::CheckAnalogOutputChannel(channel)) {
throw FRC_MakeError(err::ChannelIndexOutOfRange,
"analog output " + wpi::Twine(channel));
throw FRC_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
}
m_channel = channel;
@@ -32,7 +31,7 @@ AnalogOutput::AnalogOutput(int channel) {
int32_t status = 0;
std::string stackTrace = wpi::GetStackTrace(1);
m_port = HAL_InitializeAnalogOutputPort(port, stackTrace.c_str(), &status);
FRC_CheckErrorStatus(status, "analog output " + wpi::Twine(channel));
FRC_CheckErrorStatus(status, "Channel {}", channel);
HAL_Report(HALUsageReporting::kResourceType_AnalogOutput, m_channel + 1);
SendableRegistry::GetInstance().AddLW(this, "AnalogOutput", m_channel);
@@ -45,13 +44,13 @@ AnalogOutput::~AnalogOutput() {
void AnalogOutput::SetVoltage(double voltage) {
int32_t status = 0;
HAL_SetAnalogOutput(m_port, voltage, &status);
FRC_CheckErrorStatus(status, "SetVoltage");
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
}
double AnalogOutput::GetVoltage() const {
int32_t status = 0;
double voltage = HAL_GetAnalogOutput(m_port, &status);
FRC_CheckErrorStatus(status, "GetVoltage");
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
return voltage;
}