mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpilibc] Errors: Use fmtlib
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user