[hal,wpilib] Rename Encoder constants to all caps

This commit is contained in:
Peter Johnson
2026-03-14 11:12:57 -07:00
parent f6fdae3212
commit b68fbb1adc
14 changed files with 46 additions and 45 deletions

View File

@@ -144,7 +144,7 @@ void Encoder::InitSendable(wpi::util::SendableBuilder& builder) {
int32_t status = 0;
HAL_EncoderEncodingType type = HAL_GetEncoderEncodingType(m_encoder, &status);
WPILIB_CheckErrorStatus(status, "GetEncodingType");
if (type == HAL_EncoderEncodingType::HAL_Encoder_k4X) {
if (type == HAL_EncoderEncodingType::HAL_ENCODER_4X_ENCODING) {
builder.SetSmartDashboardType("Quadrature Encoder");
} else {
builder.SetSmartDashboardType("Encoder");
@@ -169,13 +169,13 @@ void Encoder::InitEncoder(int aChannel, int bChannel, bool reverseDirection,
const char* type = "Encoder";
switch (encodingType) {
case k1X:
case EncodingType::X1:
type = "Encoder:1x";
break;
case k2X:
case EncodingType::X2:
type = "Encoder:2x";
break;
case k4X:
case EncodingType::X4:
type = "Encoder:4x";
break;
}

View File

@@ -19,7 +19,8 @@ namespace wpi {
*/
class CounterBase {
public:
enum EncodingType { k1X, k2X, k4X };
/** The number of edges for the CounterBase to increment or decrement on. */
enum class EncodingType { X1, X2, X4 };
CounterBase() = default;
virtual ~CounterBase() = default;

View File

@@ -44,7 +44,7 @@ class Encoder : public CounterBase,
* @param reverseDirection represents the orientation of the encoder and
* inverts the output values if necessary so forward
* represents positive values.
* @param encodingType either k1X, k2X, or k4X to indicate 1X, 2X or 4X
* @param encodingType either X1, X2, or X4 to indicate 1X, 2X or 4X
* decoding. If 4X is selected, then an encoder FPGA
* object is used and the returned counts will be 4x
* the encoder spec'd value since all rising and
@@ -54,7 +54,7 @@ class Encoder : public CounterBase,
* be double (2x) the spec'd count.
*/
Encoder(int aChannel, int bChannel, bool reverseDirection = false,
EncodingType encodingType = k4X);
EncodingType encodingType = EncodingType::X4);
Encoder(Encoder&&) = default;
Encoder& operator=(Encoder&&) = default;
@@ -256,7 +256,7 @@ class Encoder : public CounterBase,
* @param bChannel The b channel.
* @param reverseDirection If true, counts down instead of up (this is all
* relative)
* @param encodingType either k1X, k2X, or k4X to indicate 1X, 2X or 4X
* @param encodingType either X1, X2, or X4 to indicate 1X, 2X or 4X
* decoding. If 4X is selected, then an encoder FPGA
* object is used and the returned counts will be 4x
* the encoder spec'd value since all rising and