diff --git a/wpilibc/src/main/native/cpp/DigitalOutput.cpp b/wpilibc/src/main/native/cpp/DigitalOutput.cpp index 6cac8e8f06..bfcd2dc7dc 100644 --- a/wpilibc/src/main/native/cpp/DigitalOutput.cpp +++ b/wpilibc/src/main/native/cpp/DigitalOutput.cpp @@ -135,8 +135,8 @@ void DigitalOutput::DisablePWM() { int32_t status = 0; // Disable the output by routing to a dead bit. - HAL_SetDigitalPWMOutputChannel(m_pwmGenerator, SensorUtil::kDigitalChannels, - &status); + HAL_SetDigitalPWMOutputChannel(m_pwmGenerator, + SensorUtil::GetNumDigitalChannels(), &status); FRC_CheckErrorStatus(status, "Channel {}", m_channel); HAL_FreeDigitalPWM(m_pwmGenerator); diff --git a/wpilibc/src/main/native/cpp/LEDPattern.cpp b/wpilibc/src/main/native/cpp/LEDPattern.cpp index 537b459603..f2cc968adf 100644 --- a/wpilibc/src/main/native/cpp/LEDPattern.cpp +++ b/wpilibc/src/main/native/cpp/LEDPattern.cpp @@ -104,7 +104,7 @@ LEDPattern LEDPattern::Blink(units::second_t onTime, units::second_t offTime) { if (wpi::Now() % totalMicros < onMicros) { self.ApplyTo(data, writer); } else { - LEDPattern::kOff.ApplyTo(data, writer); + LEDPattern::Off().ApplyTo(data, writer); } }}; } @@ -118,7 +118,7 @@ LEDPattern LEDPattern::SynchronizedBlink(std::function signal) { if (signal()) { self.ApplyTo(data, writer); } else { - LEDPattern::kOff.ApplyTo(data, writer); + LEDPattern::Off().ApplyTo(data, writer); } }}; } @@ -198,7 +198,9 @@ LEDPattern LEDPattern::AtBrightness(double relativeBrightness) { // Static constants and functions -LEDPattern LEDPattern::kOff = LEDPattern::Solid(Color::kBlack); +LEDPattern LEDPattern::Off() { + return LEDPattern::Solid(Color::kBlack); +} LEDPattern LEDPattern::Solid(const Color color) { return LEDPattern{[=](auto data, auto writer) { @@ -228,7 +230,7 @@ LEDPattern LEDPattern::ProgressMaskLayer( LEDPattern LEDPattern::Steps(std::span> steps) { if (steps.size() == 0) { // no colors specified - return LEDPattern::kOff; + return LEDPattern::Off(); } if (steps.size() == 1 && steps[0].first == 0) { // only one color specified, just show a static color @@ -264,7 +266,7 @@ LEDPattern LEDPattern::Steps( LEDPattern LEDPattern::Gradient(std::span colors) { if (colors.size() == 0) { // no colors specified - return LEDPattern::kOff; + return LEDPattern::Off(); } if (colors.size() == 1) { // only one color specified, just show a static color diff --git a/wpilibc/src/main/native/cpp/SensorUtil.cpp b/wpilibc/src/main/native/cpp/SensorUtil.cpp index 55aacce0e0..08847fbdaf 100644 --- a/wpilibc/src/main/native/cpp/SensorUtil.cpp +++ b/wpilibc/src/main/native/cpp/SensorUtil.cpp @@ -13,12 +13,6 @@ using namespace frc; -const int SensorUtil::kDigitalChannels = HAL_GetNumDigitalChannels(); -const int SensorUtil::kAnalogInputs = HAL_GetNumAnalogInputs(); -const int SensorUtil::kAnalogOutputs = HAL_GetNumAnalogOutputs(); -const int SensorUtil::kPwmChannels = HAL_GetNumPWMChannels(); -const int SensorUtil::kRelayChannels = HAL_GetNumRelayHeaders(); - int SensorUtil::GetDefaultCTREPCMModule() { return 0; } @@ -46,3 +40,23 @@ bool SensorUtil::CheckAnalogInputChannel(int channel) { bool SensorUtil::CheckAnalogOutputChannel(int channel) { return HAL_CheckAnalogOutputChannel(channel); } + +int SensorUtil::GetNumDigitalChannels() { + return HAL_GetNumDigitalChannels(); +} + +int SensorUtil::GetNumAnalogInputs() { + return HAL_GetNumAnalogInputs(); +} + +int SensorUtil::GetNumAnalogOuputs() { + return HAL_GetNumAnalogOutputs(); +} + +int SensorUtil::GetNumPwmChannels() { + return HAL_GetNumPWMChannels(); +} + +int SensorUtil::GetNumRelayChannels() { + return HAL_GetNumRelayHeaders(); +} diff --git a/wpilibc/src/main/native/include/frc/LEDPattern.h b/wpilibc/src/main/native/include/frc/LEDPattern.h index 43b1614e2a..9a35032621 100644 --- a/wpilibc/src/main/native/include/frc/LEDPattern.h +++ b/wpilibc/src/main/native/include/frc/LEDPattern.h @@ -246,7 +246,7 @@ class LEDPattern { LEDPattern AtBrightness(double relativeBrightness); /** A pattern that turns off all LEDs. */ - static LEDPattern kOff; + static LEDPattern Off(); /** * Creates a pattern that displays a single static color along the entire diff --git a/wpilibc/src/main/native/include/frc/SensorUtil.h b/wpilibc/src/main/native/include/frc/SensorUtil.h index 60536b13ea..b1d8b61d5f 100644 --- a/wpilibc/src/main/native/include/frc/SensorUtil.h +++ b/wpilibc/src/main/native/include/frc/SensorUtil.h @@ -78,11 +78,11 @@ class SensorUtil final { */ static bool CheckAnalogOutputChannel(int channel); - static const int kDigitalChannels; - static const int kAnalogInputs; - static const int kAnalogOutputs; - static const int kPwmChannels; - static const int kRelayChannels; + static int GetNumDigitalChannels(); + static int GetNumAnalogInputs(); + static int GetNumAnalogOuputs(); + static int GetNumPwmChannels(); + static int GetNumRelayChannels(); }; } // namespace frc