mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Add braces to C++ single-line loops and conditionals (NFC) (#2973)
This makes code easier to read and more consistent between C++ and Java. Also update clang-format settings to always add a line break (even if no braces are used).
This commit is contained in:
@@ -59,14 +59,18 @@ PWM::~PWM() {
|
||||
wpi_setHALError(status);
|
||||
}
|
||||
|
||||
void PWM::StopMotor() { SetDisabled(); }
|
||||
void PWM::StopMotor() {
|
||||
SetDisabled();
|
||||
}
|
||||
|
||||
void PWM::GetDescription(wpi::raw_ostream& desc) const {
|
||||
desc << "PWM " << GetChannel();
|
||||
}
|
||||
|
||||
void PWM::SetRaw(uint16_t value) {
|
||||
if (StatusIsFatal()) return;
|
||||
if (StatusIsFatal()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t status = 0;
|
||||
HAL_SetPWMRaw(m_handle, value, &status);
|
||||
@@ -74,7 +78,9 @@ void PWM::SetRaw(uint16_t value) {
|
||||
}
|
||||
|
||||
uint16_t PWM::GetRaw() const {
|
||||
if (StatusIsFatal()) return 0;
|
||||
if (StatusIsFatal()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t status = 0;
|
||||
uint16_t value = HAL_GetPWMRaw(m_handle, &status);
|
||||
@@ -84,14 +90,18 @@ uint16_t PWM::GetRaw() const {
|
||||
}
|
||||
|
||||
void PWM::SetPosition(double pos) {
|
||||
if (StatusIsFatal()) return;
|
||||
if (StatusIsFatal()) {
|
||||
return;
|
||||
}
|
||||
int32_t status = 0;
|
||||
HAL_SetPWMPosition(m_handle, pos, &status);
|
||||
wpi_setHALError(status);
|
||||
}
|
||||
|
||||
double PWM::GetPosition() const {
|
||||
if (StatusIsFatal()) return 0.0;
|
||||
if (StatusIsFatal()) {
|
||||
return 0.0;
|
||||
}
|
||||
int32_t status = 0;
|
||||
double position = HAL_GetPWMPosition(m_handle, &status);
|
||||
wpi_setHALError(status);
|
||||
@@ -99,7 +109,9 @@ double PWM::GetPosition() const {
|
||||
}
|
||||
|
||||
void PWM::SetSpeed(double speed) {
|
||||
if (StatusIsFatal()) return;
|
||||
if (StatusIsFatal()) {
|
||||
return;
|
||||
}
|
||||
int32_t status = 0;
|
||||
HAL_SetPWMSpeed(m_handle, speed, &status);
|
||||
wpi_setHALError(status);
|
||||
@@ -108,7 +120,9 @@ void PWM::SetSpeed(double speed) {
|
||||
}
|
||||
|
||||
double PWM::GetSpeed() const {
|
||||
if (StatusIsFatal()) return 0.0;
|
||||
if (StatusIsFatal()) {
|
||||
return 0.0;
|
||||
}
|
||||
int32_t status = 0;
|
||||
double speed = HAL_GetPWMSpeed(m_handle, &status);
|
||||
wpi_setHALError(status);
|
||||
@@ -116,7 +130,9 @@ double PWM::GetSpeed() const {
|
||||
}
|
||||
|
||||
void PWM::SetDisabled() {
|
||||
if (StatusIsFatal()) return;
|
||||
if (StatusIsFatal()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t status = 0;
|
||||
|
||||
@@ -125,7 +141,9 @@ void PWM::SetDisabled() {
|
||||
}
|
||||
|
||||
void PWM::SetPeriodMultiplier(PeriodMultiplier mult) {
|
||||
if (StatusIsFatal()) return;
|
||||
if (StatusIsFatal()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t status = 0;
|
||||
|
||||
@@ -149,7 +167,9 @@ void PWM::SetPeriodMultiplier(PeriodMultiplier mult) {
|
||||
}
|
||||
|
||||
void PWM::SetZeroLatch() {
|
||||
if (StatusIsFatal()) return;
|
||||
if (StatusIsFatal()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t status = 0;
|
||||
|
||||
@@ -158,7 +178,9 @@ void PWM::SetZeroLatch() {
|
||||
}
|
||||
|
||||
void PWM::EnableDeadbandElimination(bool eliminateDeadband) {
|
||||
if (StatusIsFatal()) return;
|
||||
if (StatusIsFatal()) {
|
||||
return;
|
||||
}
|
||||
int32_t status = 0;
|
||||
HAL_SetPWMEliminateDeadband(m_handle, eliminateDeadband, &status);
|
||||
wpi_setHALError(status);
|
||||
@@ -166,7 +188,9 @@ void PWM::EnableDeadbandElimination(bool eliminateDeadband) {
|
||||
|
||||
void PWM::SetBounds(double max, double deadbandMax, double center,
|
||||
double deadbandMin, double min) {
|
||||
if (StatusIsFatal()) return;
|
||||
if (StatusIsFatal()) {
|
||||
return;
|
||||
}
|
||||
int32_t status = 0;
|
||||
HAL_SetPWMConfig(m_handle, max, deadbandMax, center, deadbandMin, min,
|
||||
&status);
|
||||
@@ -175,7 +199,9 @@ void PWM::SetBounds(double max, double deadbandMax, double center,
|
||||
|
||||
void PWM::SetRawBounds(int max, int deadbandMax, int center, int deadbandMin,
|
||||
int min) {
|
||||
if (StatusIsFatal()) return;
|
||||
if (StatusIsFatal()) {
|
||||
return;
|
||||
}
|
||||
int32_t status = 0;
|
||||
HAL_SetPWMConfigRaw(m_handle, max, deadbandMax, center, deadbandMin, min,
|
||||
&status);
|
||||
@@ -190,7 +216,9 @@ void PWM::GetRawBounds(int* max, int* deadbandMax, int* center,
|
||||
wpi_setHALError(status);
|
||||
}
|
||||
|
||||
int PWM::GetChannel() const { return m_channel; }
|
||||
int PWM::GetChannel() const {
|
||||
return m_channel;
|
||||
}
|
||||
|
||||
void PWM::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("PWM");
|
||||
|
||||
Reference in New Issue
Block a user