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:
@@ -33,7 +33,7 @@ AnalogGyro::AnalogGyro(AnalogInput* channel)
|
||||
AnalogGyro::AnalogGyro(std::shared_ptr<AnalogInput> channel)
|
||||
: m_analog(channel) {
|
||||
if (!channel) {
|
||||
throw FRC_MakeError(err::NullParameter, "channel");
|
||||
throw FRC_MakeError(err::NullParameter, "{}", "channel");
|
||||
}
|
||||
InitGyro();
|
||||
Calibrate();
|
||||
@@ -48,13 +48,13 @@ AnalogGyro::AnalogGyro(std::shared_ptr<AnalogInput> channel, int center,
|
||||
double offset)
|
||||
: m_analog(channel) {
|
||||
if (!channel) {
|
||||
throw FRC_MakeError(err::NullParameter, "channel");
|
||||
throw FRC_MakeError(err::NullParameter, "{}", "channel");
|
||||
}
|
||||
InitGyro();
|
||||
int32_t status = 0;
|
||||
HAL_SetAnalogGyroParameters(m_gyroHandle, kDefaultVoltsPerDegreePerSecond,
|
||||
offset, center, &status);
|
||||
FRC_CheckErrorStatus(status, "SetAnalogGyroParameters");
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_analog->GetChannel());
|
||||
Reset();
|
||||
}
|
||||
|
||||
@@ -65,28 +65,28 @@ AnalogGyro::~AnalogGyro() {
|
||||
double AnalogGyro::GetAngle() const {
|
||||
int32_t status = 0;
|
||||
double value = HAL_GetAnalogGyroAngle(m_gyroHandle, &status);
|
||||
FRC_CheckErrorStatus(status, "GetAngle");
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_analog->GetChannel());
|
||||
return value;
|
||||
}
|
||||
|
||||
double AnalogGyro::GetRate() const {
|
||||
int32_t status = 0;
|
||||
double value = HAL_GetAnalogGyroRate(m_gyroHandle, &status);
|
||||
FRC_CheckErrorStatus(status, "GetRate");
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_analog->GetChannel());
|
||||
return value;
|
||||
}
|
||||
|
||||
int AnalogGyro::GetCenter() const {
|
||||
int32_t status = 0;
|
||||
int value = HAL_GetAnalogGyroCenter(m_gyroHandle, &status);
|
||||
FRC_CheckErrorStatus(status, "GetCenter");
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_analog->GetChannel());
|
||||
return value;
|
||||
}
|
||||
|
||||
double AnalogGyro::GetOffset() const {
|
||||
int32_t status = 0;
|
||||
double value = HAL_GetAnalogGyroOffset(m_gyroHandle, &status);
|
||||
FRC_CheckErrorStatus(status, "GetOffset");
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_analog->GetChannel());
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -94,19 +94,19 @@ void AnalogGyro::SetSensitivity(double voltsPerDegreePerSecond) {
|
||||
int32_t status = 0;
|
||||
HAL_SetAnalogGyroVoltsPerDegreePerSecond(m_gyroHandle,
|
||||
voltsPerDegreePerSecond, &status);
|
||||
FRC_CheckErrorStatus(status, "SetSensitivity");
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_analog->GetChannel());
|
||||
}
|
||||
|
||||
void AnalogGyro::SetDeadband(double volts) {
|
||||
int32_t status = 0;
|
||||
HAL_SetAnalogGyroDeadband(m_gyroHandle, volts, &status);
|
||||
FRC_CheckErrorStatus(status, "SetDeadband");
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_analog->GetChannel());
|
||||
}
|
||||
|
||||
void AnalogGyro::Reset() {
|
||||
int32_t status = 0;
|
||||
HAL_ResetAnalogGyro(m_gyroHandle, &status);
|
||||
FRC_CheckErrorStatus(status, "Reset");
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_analog->GetChannel());
|
||||
}
|
||||
|
||||
void AnalogGyro::InitGyro() {
|
||||
@@ -115,12 +115,12 @@ void AnalogGyro::InitGyro() {
|
||||
std::string stackTrace = wpi::GetStackTrace(1);
|
||||
m_gyroHandle =
|
||||
HAL_InitializeAnalogGyro(m_analog->m_port, stackTrace.c_str(), &status);
|
||||
FRC_CheckErrorStatus(status, "InitializeAnalogGyro");
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_analog->GetChannel());
|
||||
}
|
||||
|
||||
int32_t status = 0;
|
||||
HAL_SetupAnalogGyro(m_gyroHandle, &status);
|
||||
FRC_CheckErrorStatus(status, "SetupAnalogGyro");
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_analog->GetChannel());
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_Gyro, m_analog->GetChannel() + 1);
|
||||
|
||||
@@ -131,7 +131,7 @@ void AnalogGyro::InitGyro() {
|
||||
void AnalogGyro::Calibrate() {
|
||||
int32_t status = 0;
|
||||
HAL_CalibrateAnalogGyro(m_gyroHandle, &status);
|
||||
FRC_CheckErrorStatus(status, "Calibrate");
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_analog->GetChannel());
|
||||
}
|
||||
|
||||
std::shared_ptr<AnalogInput> AnalogGyro::GetAnalogInput() const {
|
||||
|
||||
Reference in New Issue
Block a user