[docs] Add missing docs to enum fields (NFC) (#6150)

Co-authored-by: Tyler Veness <calcmogul@gmail.com>
This commit is contained in:
m10653
2024-01-05 00:36:26 -05:00
committed by GitHub
parent 4210f5635d
commit 13f4460e00
49 changed files with 665 additions and 26 deletions

View File

@@ -20,8 +20,11 @@ namespace frc {
class DMASample : public HAL_DMASample {
public:
enum class DMAReadStatus {
/// OK status.
kOk = HAL_DMA_OK,
/// Timeout status.
kTimeout = HAL_DMA_TIMEOUT,
/// Error status.
kError = HAL_DMA_ERROR
};

View File

@@ -25,7 +25,17 @@ namespace frc {
class DoubleSolenoid : public wpi::Sendable,
public wpi::SendableHelper<DoubleSolenoid> {
public:
enum Value { kOff, kForward, kReverse };
/**
* Possible values for a DoubleSolenoid.
*/
enum Value {
/// Off position.
kOff,
/// Forward position.
kForward,
/// Reverse position.
kReverse
};
/**
* Constructs a double solenoid for a specified module of a specific module

View File

@@ -22,9 +22,31 @@ namespace frc {
*/
class DriverStation final {
public:
enum Alliance { kRed, kBlue };
enum MatchType { kNone, kPractice, kQualification, kElimination };
/**
* The robot alliance that the robot is a part of.
*/
enum Alliance {
/// Red alliance.
kRed,
/// Blue alliance.
kBlue
};
/**
* The type of robot match that the robot is part of.
*/
enum MatchType {
/// None.
kNone,
/// Practice.
kPractice,
/// Qualification.
kQualification,
/// Elimination.
kElimination
};
/// Number of Joystick ports.
static constexpr int kJoystickPorts = 6;
/**

View File

@@ -42,10 +42,17 @@ class Encoder : public CounterBase,
friend class DMASample;
public:
/**
* Encoder indexing types.
*/
enum IndexingType {
/// Reset while the signal is high.
kResetWhileHigh,
/// Reset while the signal is low.
kResetWhileLow,
/// Reset on falling edge of the signal.
kResetOnFallingEdge,
/// Reset on rising edge of the signal.
kResetOnRisingEdge
};

View File

@@ -23,25 +23,55 @@ class EventLoop;
*/
class GenericHID {
public:
enum RumbleType { kLeftRumble, kRightRumble, kBothRumble };
/**
* Represents a rumble output on the Joystick.
*/
enum RumbleType {
/// Left rumble motor.
kLeftRumble,
/// Right rumble motor.
kRightRumble,
/// Both left and right rumble motors.
kBothRumble
};
/**
* USB HID interface type.
*/
enum HIDType {
/// Unknown.
kUnknown = -1,
/// XInputUnknown.
kXInputUnknown = 0,
/// XInputGamepad.
kXInputGamepad = 1,
/// XInputWheel.
kXInputWheel = 2,
/// XInputArcadeStick.
kXInputArcadeStick = 3,
/// XInputFlightStick.
kXInputFlightStick = 4,
/// XInputDancePad.
kXInputDancePad = 5,
/// XInputGuitar.
kXInputGuitar = 6,
/// XInputGuitar2.
kXInputGuitar2 = 7,
/// XInputDrumKit.
kXInputDrumKit = 8,
/// XInputGuitar3.
kXInputGuitar3 = 11,
/// XInputArcadePad.
kXInputArcadePad = 19,
/// HIDJoystick.
kHIDJoystick = 20,
/// HIDGamepad.
kHIDGamepad = 21,
/// HIDDriving.
kHIDDriving = 22,
/// HIDFlight.
kHIDFlight = 23,
/// HID1stPerson.
kHID1stPerson = 24
};

View File

@@ -22,7 +22,15 @@ namespace frc {
*/
class I2C {
public:
enum Port { kOnboard = 0, kMXP };
/**
* I2C connection ports.
*/
enum Port {
/// Onboard I2C port.
kOnboard = 0,
/// MXP (roboRIO MXP) I2C port.
kMXP
};
/**
* Constructor.

View File

@@ -28,8 +28,31 @@ class Joystick : public GenericHID {
static constexpr int kDefaultTwistChannel = 2;
static constexpr int kDefaultThrottleChannel = 3;
enum AxisType { kXAxis, kYAxis, kZAxis, kTwistAxis, kThrottleAxis };
enum ButtonType { kTriggerButton, kTopButton };
/**
* Represents an analog axis on a joystick.
*/
enum AxisType {
/// X axis.
kXAxis,
/// Y axis.
kYAxis,
/// Z axis.
kZAxis,
/// Twist axis.
kTwistAxis,
/// Throttle axis.
kThrottleAxis
};
/**
* Represents a digital button on a joystick.
*/
enum ButtonType {
/// kTrigger.
kTriggerButton,
/// kTop.
kTopButton
};
/**
* Construct an instance of a joystick.

View File

@@ -503,29 +503,55 @@ class PS4Controller : public GenericHID {
*/
BooleanEvent Touchpad(EventLoop* loop) const;
/**
* Represents a digital button on a PS4Controller.
*/
struct Button {
/// Square button.
static constexpr int kSquare = 1;
/// X button.
static constexpr int kCross = 2;
/// Circle button.
static constexpr int kCircle = 3;
/// Triangle button.
static constexpr int kTriangle = 4;
/// Left Trigger 1 button.
static constexpr int kL1 = 5;
/// Right Trigger 1 button.
static constexpr int kR1 = 6;
/// Left Trigger 2 button.
static constexpr int kL2 = 7;
/// Right Trigger 2 button.
static constexpr int kR2 = 8;
/// Share button.
static constexpr int kShare = 9;
/// Option button.
static constexpr int kOptions = 10;
/// Left stick button.
static constexpr int kL3 = 11;
/// Right stick button.
static constexpr int kR3 = 12;
/// PlayStation button.
static constexpr int kPS = 13;
/// Touchpad click button.
static constexpr int kTouchpad = 14;
};
/**
* Represents an axis on a PS4Controller.
*/
struct Axis {
/// Left X axis.
static constexpr int kLeftX = 0;
/// Left Y axis.
static constexpr int kLeftY = 1;
/// Right X axis.
static constexpr int kRightX = 2;
/// Right Y axis.
static constexpr int kRightY = 5;
/// Left Trigger 2.
static constexpr int kL2 = 3;
/// Right Trigger 2.
static constexpr int kR2 = 4;
};
};

View File

@@ -503,29 +503,55 @@ class PS5Controller : public GenericHID {
*/
BooleanEvent Touchpad(EventLoop* loop) const;
/**
* Represents a digital button on a PS5Controller.
*/
struct Button {
/// Square button.
static constexpr int kSquare = 1;
/// X button.
static constexpr int kCross = 2;
/// Circle button.
static constexpr int kCircle = 3;
/// Triangle button.
static constexpr int kTriangle = 4;
/// Left trigger 1 button.
static constexpr int kL1 = 5;
/// Right trigger 1 button.
static constexpr int kR1 = 6;
/// Left trigger 2 button.
static constexpr int kL2 = 7;
/// Right trigger 2 button.
static constexpr int kR2 = 8;
/// Create button.
static constexpr int kCreate = 9;
/// Options button.
static constexpr int kOptions = 10;
/// Left stick button.
static constexpr int kL3 = 11;
/// Right stick button.
static constexpr int kR3 = 12;
/// PlayStation button.
static constexpr int kPS = 13;
/// Touchpad click button.
static constexpr int kTouchpad = 14;
};
/**
* Represents an axis on a PS5Controller.
*/
struct Axis {
/// Left X axis.
static constexpr int kLeftX = 0;
/// Left Y axis.
static constexpr int kLeftY = 1;
/// Right X axis.
static constexpr int kRightX = 2;
/// Right Y axis.
static constexpr int kRightY = 5;
/// Left Trigger 2.
static constexpr int kL2 = 3;
/// Right Trigger 2.
static constexpr int kR2 = 4;
};
};

View File

@@ -18,7 +18,16 @@ class PowerDistribution : public wpi::Sendable,
public wpi::SendableHelper<PowerDistribution> {
public:
static constexpr int kDefaultModule = -1;
enum class ModuleType { kCTRE = 1, kRev = 2 };
/**
* Power distribution module type.
*/
enum class ModuleType {
/// CTRE (Cross The Road Electronics) CTRE Power Distribution Panel (PDP).
kCTRE = 1,
/// REV Power Distribution Hub (PDH).
kRev = 2
};
/**
* Constructs a PowerDistribution object.

View File

@@ -31,8 +31,31 @@ class Relay : public MotorSafety,
public wpi::Sendable,
public wpi::SendableHelper<Relay> {
public:
enum Value { kOff, kOn, kForward, kReverse };
enum Direction { kBothDirections, kForwardOnly, kReverseOnly };
/**
* The state to drive a Relay to.
*/
enum Value {
/// Off.
kOff,
/// On.
kOn,
/// Forward.
kForward,
/// Reverse.
kReverse
};
/**
* The Direction(s) that a relay is configured to operate in.
*/
enum Direction {
/// Both directions are valid.
kBothDirections,
/// Only forward is valid.
kForwardOnly,
/// Only reverse is valid.
kReverseOnly
};
/**
* Relay constructor given a channel.

View File

@@ -25,14 +25,34 @@ class DigitalSource;
*/
class SPI {
public:
enum Port { kOnboardCS0 = 0, kOnboardCS1, kOnboardCS2, kOnboardCS3, kMXP };
/**
* SPI port.
*/
enum Port {
/// Onboard SPI bus port CS0.
kOnboardCS0 = 0,
/// Onboard SPI bus port CS1.
kOnboardCS1,
/// Onboard SPI bus port CS2.
kOnboardCS2,
/// Onboard SPI bus port CS3.
kOnboardCS3,
/// MXP (roboRIO MXP) SPI bus port.
kMXP
};
/**
* SPI mode.
*/
enum Mode {
kMode0 = HAL_SPI_kMode0, /*!< Clock idle low, data sampled on rising edge */
kMode1 =
HAL_SPI_kMode1, /*!< Clock idle low, data sampled on falling edge */
kMode2 =
HAL_SPI_kMode2, /*!< Clock idle high, data sampled on falling edge */
kMode3 = HAL_SPI_kMode3 /*!< Clock idle high, data sampled on rising edge */
/// Clock idle low, data sampled on rising edge.
kMode0 = HAL_SPI_kMode0,
/// Clock idle low, data sampled on falling edge.
kMode1 = HAL_SPI_kMode1,
/// Clock idle high, data sampled on falling edge.
kMode2 = HAL_SPI_kMode2,
/// Clock idle high, data sampled on rising edge.
kMode3 = HAL_SPI_kMode3
};
/**

View File

@@ -26,30 +26,73 @@ namespace frc {
*/
class SerialPort {
public:
/**
* Serial port.
*/
enum Port {
/// Onboard serial port on the roboRIO.
kOnboard = 0,
/// MXP (roboRIO MXP) serial port.
kMXP = 1,
/// USB serial port (same as KUSB1).
kUSB = 2,
/// USB serial port 1.
kUSB1 = 2,
/// USB serial port 2.
kUSB2 = 3
};
/**
* Represents the parity to use for serial communications.
*/
enum Parity {
/// No parity.
kParity_None = 0,
/// Odd parity.
kParity_Odd = 1,
/// Even parity.
kParity_Even = 2,
/// Parity bit always on.
kParity_Mark = 3,
/// Parity bit always off.
kParity_Space = 4
};
/**
* Represents the number of stop bits to use for Serial Communication.
*/
enum StopBits {
/// One stop bit.
kStopBits_One = 10,
/// One and a half stop bits.
kStopBits_OnePointFive = 15,
/// Two stop bits.
kStopBits_Two = 20
};
/**
* Represents what type of flow control to use for serial communication.
*/
enum FlowControl {
/// No flow control.
kFlowControl_None = 0,
/// XON/XOFF flow control.
kFlowControl_XonXoff = 1,
/// RTS/CTS flow control.
kFlowControl_RtsCts = 2,
/// DTS/DSR flow control.
kFlowControl_DtrDsr = 4
};
enum WriteBufferMode { kFlushOnAccess = 1, kFlushWhenFull = 2 };
enum Port { kOnboard = 0, kMXP = 1, kUSB = 2, kUSB1 = 2, kUSB2 = 3 };
/**
* Represents which type of buffer mode to use when writing to a serial port.
*/
enum WriteBufferMode {
/// Flush the buffer on each access.
kFlushOnAccess = 1,
/// Flush the buffer when it is full.
kFlushWhenFull = 2
};
/**
* Create an instance of a Serial Port class.

View File

@@ -514,28 +514,53 @@ class StadiaController : public GenericHID {
*/
BooleanEvent RightTrigger(EventLoop* loop) const;
/**
* Represents a digital button on a StadiaController.
*/
struct Button {
/// A button.
static constexpr int kA = 1;
/// B button.
static constexpr int kB = 2;
/// X button.
static constexpr int kX = 3;
/// Y button.
static constexpr int kY = 4;
/// Left bumper button.
static constexpr int kLeftBumper = 5;
/// Right bumper button.
static constexpr int kRightBumper = 6;
/// Left stick button.
static constexpr int kLeftStick = 7;
/// Right stick button.
static constexpr int kRightStick = 8;
/// Ellipses button.
static constexpr int kEllipses = 9;
/// Hamburger button.
static constexpr int kHamburger = 10;
/// Stadia button.
static constexpr int kStadia = 11;
/// Right trigger button.
static constexpr int kRightTrigger = 12;
/// Left trigger button.
static constexpr int kLeftTrigger = 13;
/// Google button.
static constexpr int kGoogle = 14;
/// Frame button.
static constexpr int kFrame = 15;
};
/**
* Represents an axis on a StadiaController.
*/
struct Axis {
/// Left X axis.
static constexpr int kLeftX = 0;
/// Right X axis.
static constexpr int kRightX = 4;
/// Left Y axis.
static constexpr int kLeftY = 1;
/// Right Y axis.
static constexpr int kRightY = 5;
};
};

View File

@@ -25,9 +25,13 @@ class SynchronousInterrupt {
* Event trigger combinations for a synchronous interrupt.
*/
enum WaitResult {
/// Timeout event.
kTimeout = 0x0,
/// Rising edge event.
kRisingEdge = 0x1,
/// Falling edge event.
kFallingEdge = 0x100,
/// Both rising and falling edge events.
kBoth = 0x101,
};

View File

@@ -5,10 +5,17 @@
#pragma once
namespace frc {
/**
* Edge configuration.
*/
enum class EdgeConfiguration {
/// No edge configuration (neither rising nor falling).
kNone = 0,
/// Rising edge configuration.
kRisingEdge = 0x1,
/// Falling edge configuration.
kFallingEdge = 0x2,
/// Both rising and falling edges configuration.
kBoth = 0x3
};
} // namespace frc

View File

@@ -23,12 +23,19 @@ class RobotDriveBase : public MotorSafety {
* The location of a motor on the robot for the purpose of driving.
*/
enum MotorType {
/// Front-left motor.
kFrontLeft = 0,
/// Front-right motor.
kFrontRight = 1,
/// Rear-left motor.
kRearLeft = 2,
/// Rear-right motor.
kRearRight = 3,
/// Left motor.
kLeft = 0,
/// Right motor.
kRight = 1,
/// Back motor.
kBack = 2
};

View File

@@ -210,32 +210,54 @@ class DifferentialDrivetrainSim {
*/
class KitbotGearing {
public:
/// Gear ratio of 12.75:1.
static constexpr double k12p75 = 12.75;
/// Gear ratio of 10.71:1.
static constexpr double k10p71 = 10.71;
/// Gear ratio of 8.45:1.
static constexpr double k8p45 = 8.45;
/// Gear ratio of 7.31:1.
static constexpr double k7p31 = 7.31;
/// Gear ratio of 5.95:1.
static constexpr double k5p95 = 5.95;
};
/**
* Represents common motor layouts of the kit drivetrain.
*/
class KitbotMotor {
public:
/// One CIM motor per drive side.
static constexpr frc::DCMotor SingleCIMPerSide = frc::DCMotor::CIM(1);
/// Two CIM motors per drive side.
static constexpr frc::DCMotor DualCIMPerSide = frc::DCMotor::CIM(2);
/// One Mini CIM motor per drive side.
static constexpr frc::DCMotor SingleMiniCIMPerSide =
frc::DCMotor::MiniCIM(1);
/// Two Mini CIM motors per drive side.
static constexpr frc::DCMotor DualMiniCIMPerSide = frc::DCMotor::MiniCIM(2);
/// One Falcon 500 motor per drive side.
static constexpr frc::DCMotor SingleFalcon500PerSide =
frc::DCMotor::Falcon500(1);
/// Two Falcon 500 motors per drive side.
static constexpr frc::DCMotor DualFalcon500PerSide =
frc::DCMotor::Falcon500(2);
/// One NEO motor per drive side.
static constexpr frc::DCMotor SingleNEOPerSide = frc::DCMotor::NEO(1);
/// Two NEO motors per drive side.
static constexpr frc::DCMotor DualNEOPerSide = frc::DCMotor::NEO(2);
};
/**
* Represents common wheel sizes of the kit drivetrain.
*/
class KitbotWheelSize {
public:
/// Six inch diameter wheels.
static constexpr units::meter_t kSixInch = 6_in;
/// Eight inch diameter wheels.
static constexpr units::meter_t kEightInch = 8_in;
/// Ten inch diameter wheels.
static constexpr units::meter_t kTenInch = 10_in;
};