diff --git a/hal/src/main/java/edu/wpi/first/hal/PowerDistributionVersion.java b/hal/src/main/java/edu/wpi/first/hal/PowerDistributionVersion.java index fdd1233b25..bfb5ff2d0e 100644 --- a/hal/src/main/java/edu/wpi/first/hal/PowerDistributionVersion.java +++ b/hal/src/main/java/edu/wpi/first/hal/PowerDistributionVersion.java @@ -4,18 +4,25 @@ package edu.wpi.first.hal; +/** Power distribution version. */ @SuppressWarnings("MemberName") public class PowerDistributionVersion { + /** Firmware major version number. */ public final int firmwareMajor; + /** Firmware minor version number. */ public final int firmwareMinor; + /** Firmware fix version number. */ public final int firmwareFix; + /** Hardware minor version number. */ public final int hardwareMinor; + /** Hardware major version number. */ public final int hardwareMajor; + /** Unique ID. */ public final int uniqueId; /** diff --git a/hal/src/main/native/include/hal/DMA.h b/hal/src/main/native/include/hal/DMA.h index cfa2f8a870..2d570a4032 100644 --- a/hal/src/main/native/include/hal/DMA.h +++ b/hal/src/main/native/include/hal/DMA.h @@ -138,6 +138,8 @@ void HAL_AddDMACounter(HAL_DMAHandle handle, HAL_CounterHandle counterHandle, /** * Adds timer data for an counter to be collected by DMA. * + * This can only be called if DMA is not started. + * * @param[in] handle the dma handle * @param[in] counterHandle the counter to add * @param[out] status Error status variable. 0 on success. diff --git a/hal/src/main/native/include/hal/PowerDistribution.h b/hal/src/main/native/include/hal/PowerDistribution.h index 701b64d9f5..c2dc3cd705 100644 --- a/hal/src/main/native/include/hal/PowerDistribution.h +++ b/hal/src/main/native/include/hal/PowerDistribution.h @@ -217,12 +217,21 @@ void HAL_SetPowerDistributionSwitchableChannel( HAL_Bool HAL_GetPowerDistributionSwitchableChannel( HAL_PowerDistributionHandle handle, int32_t* status); +/** + * Power distribution version. + */ struct HAL_PowerDistributionVersion { + /// Firmware major version number. uint32_t firmwareMajor; + /// Firmware minor version number. uint32_t firmwareMinor; + /// Firmware fix version number. uint32_t firmwareFix; + /// Hardware minor version number. uint32_t hardwareMinor; + /// Hardware major version number. uint32_t hardwareMajor; + /// Unique ID. uint32_t uniqueId; }; diff --git a/wpilibc/src/main/native/cpp/DMA.cpp b/wpilibc/src/main/native/cpp/DMA.cpp index ce6c5328a6..da45aa3562 100644 --- a/wpilibc/src/main/native/cpp/DMA.cpp +++ b/wpilibc/src/main/native/cpp/DMA.cpp @@ -40,9 +40,9 @@ void DMA::SetPause(bool pause) { FRC_CheckErrorStatus(status, "SetPause"); } -void DMA::SetTimedTrigger(units::second_t seconds) { +void DMA::SetTimedTrigger(units::second_t period) { int32_t status = 0; - HAL_SetDMATimedTrigger(dmaHandle, seconds.value(), &status); + HAL_SetDMATimedTrigger(dmaHandle, period.value(), &status); FRC_CheckErrorStatus(status, "SetTimedTrigger"); } diff --git a/wpilibc/src/main/native/cpp/internal/DriverStationModeThread.cpp b/wpilibc/src/main/native/cpp/internal/DriverStationModeThread.cpp index 40856580f0..78d580e36c 100644 --- a/wpilibc/src/main/native/cpp/internal/DriverStationModeThread.cpp +++ b/wpilibc/src/main/native/cpp/internal/DriverStationModeThread.cpp @@ -23,13 +23,14 @@ DriverStationModeThread::~DriverStationModeThread() { } } -void DriverStationModeThread::InAutonomous(bool entering) { - m_userInAutonomous = entering; -} void DriverStationModeThread::InDisabled(bool entering) { m_userInDisabled = entering; } +void DriverStationModeThread::InAutonomous(bool entering) { + m_userInAutonomous = entering; +} + void DriverStationModeThread::InTeleop(bool entering) { m_userInTeleop = entering; } diff --git a/wpilibc/src/main/native/cpp/simulation/PneumaticsBaseSim.cpp b/wpilibc/src/main/native/cpp/simulation/PneumaticsBaseSim.cpp index 476d07ae73..04aef3a669 100644 --- a/wpilibc/src/main/native/cpp/simulation/PneumaticsBaseSim.cpp +++ b/wpilibc/src/main/native/cpp/simulation/PneumaticsBaseSim.cpp @@ -12,11 +12,6 @@ using namespace frc; using namespace frc::sim; -PneumaticsBaseSim::PneumaticsBaseSim(int module) : m_index{module} {} - -PneumaticsBaseSim::PneumaticsBaseSim(const PneumaticsBase& module) - : m_index{module.GetModuleNumber()} {} - std::shared_ptr PneumaticsBaseSim::GetForType( int module, PneumaticsModuleType type) { switch (type) { @@ -31,3 +26,8 @@ std::shared_ptr PneumaticsBaseSim::GetForType( static_cast(module)); } } + +PneumaticsBaseSim::PneumaticsBaseSim(int module) : m_index{module} {} + +PneumaticsBaseSim::PneumaticsBaseSim(const PneumaticsBase& module) + : m_index{module.GetModuleNumber()} {} diff --git a/wpilibc/src/main/native/cpp/simulation/UltrasonicSim.cpp b/wpilibc/src/main/native/cpp/simulation/UltrasonicSim.cpp index 30a565039c..1016c4bccb 100644 --- a/wpilibc/src/main/native/cpp/simulation/UltrasonicSim.cpp +++ b/wpilibc/src/main/native/cpp/simulation/UltrasonicSim.cpp @@ -18,8 +18,8 @@ UltrasonicSim::UltrasonicSim(int ping, int echo) { m_simRange = deviceSim.GetDouble("Range (in)"); } -void UltrasonicSim::SetRangeValid(bool isValid) { - m_simRangeValid.Set(isValid); +void UltrasonicSim::SetRangeValid(bool valid) { + m_simRangeValid.Set(valid); } void UltrasonicSim::SetRange(units::inch_t range) { diff --git a/wpilibc/src/main/native/include/frc/CAN.h b/wpilibc/src/main/native/include/frc/CAN.h index dc04988f1f..1f5d1682a0 100644 --- a/wpilibc/src/main/native/include/frc/CAN.h +++ b/wpilibc/src/main/native/include/frc/CAN.h @@ -170,7 +170,10 @@ class CAN { */ static uint64_t GetTimestampBaseTime(); + /// Team manufacturer. static constexpr HAL_CANManufacturer kTeamManufacturer = HAL_CAN_Man_kTeamUse; + + /// Team device type. static constexpr HAL_CANDeviceType kTeamDeviceType = HAL_CAN_Dev_kMiscellaneous; diff --git a/wpilibc/src/main/native/include/frc/CompressorConfigType.h b/wpilibc/src/main/native/include/frc/CompressorConfigType.h index 5a5a1c13a1..b9338042b6 100644 --- a/wpilibc/src/main/native/include/frc/CompressorConfigType.h +++ b/wpilibc/src/main/native/include/frc/CompressorConfigType.h @@ -5,10 +5,17 @@ #pragma once namespace frc { +/** + * Compressor config type. + */ enum class CompressorConfigType { + /// Disabled. Disabled = 0, + /// Digital. Digital = 1, + /// Analog. Analog = 2, + /// Hybrid. Hybrid = 3 }; diff --git a/wpilibc/src/main/native/include/frc/Counter.h b/wpilibc/src/main/native/include/frc/Counter.h index 71eebcab5a..3720dde31b 100644 --- a/wpilibc/src/main/native/include/frc/Counter.h +++ b/wpilibc/src/main/native/include/frc/Counter.h @@ -451,17 +451,20 @@ class Counter : public CounterBase, void InitSendable(wpi::SendableBuilder& builder) override; protected: - // Makes the counter count up. + /// Makes the counter count up. std::shared_ptr m_upSource; - // Makes the counter count down. + /// Makes the counter count down. std::shared_ptr m_downSource; - // The FPGA counter object + /// The FPGA counter object hal::Handle m_counter; private: - int m_index = 0; // The index of this counter. + /// The index of this counter. + int m_index = 0; + + /// Distance of travel for each tick. double m_distancePerPulse = 1; friend class DigitalGlitchFilter; diff --git a/wpilibc/src/main/native/include/frc/DMA.h b/wpilibc/src/main/native/include/frc/DMA.h index 1bbf268f77..d09368fb37 100644 --- a/wpilibc/src/main/native/include/frc/DMA.h +++ b/wpilibc/src/main/native/include/frc/DMA.h @@ -17,6 +17,9 @@ class DMASample; class PWM; class PWMMotorController; +/** + * Class for configuring Direct Memory Access (DMA) of FPGA inputs. + */ class DMA { friend class DMASample; @@ -27,32 +30,162 @@ class DMA { DMA& operator=(DMA&& other) = default; DMA(DMA&& other) = default; + /** + * Sets whether DMA is paused. + * + * @param pause True pauses DMA. + */ void SetPause(bool pause); - void SetTimedTrigger(units::second_t seconds); + + /** + * Sets DMA to trigger at an interval. + * + * @param period Period at which to trigger DMA. + */ + void SetTimedTrigger(units::second_t period); + + /** + * Sets number of DMA cycles to trigger. + * + * @param cycles Number of cycles. + */ void SetTimedTriggerCycles(int cycles); + /** + * Adds position data for an encoder to be collected by DMA. + * + * This can only be called if DMA is not started. + * + * @param encoder Encoder to add to DMA. + */ void AddEncoder(const Encoder* encoder); + + /** + * Adds timer data for an encoder to be collected by DMA. + * + * This can only be called if DMA is not started. + * + * @param encoder Encoder to add to DMA. + */ void AddEncoderPeriod(const Encoder* encoder); + /** + * Adds position data for an counter to be collected by DMA. + * + * This can only be called if DMA is not started. + * + * @param counter Counter to add to DMA. + */ void AddCounter(const Counter* counter); + + /** + * Adds timer data for an counter to be collected by DMA. + * + * This can only be called if DMA is not started. + * + * @param counter Counter to add to DMA. + */ void AddCounterPeriod(const Counter* counter); + /** + * Adds a digital source to be collected by DMA. + * + * This can only be called if DMA is not started. + * + * @param digitalSource DigitalSource to add to DMA. + */ void AddDigitalSource(const DigitalSource* digitalSource); + /** + * Adds a digital source to be collected by DMA. + * + * This can only be called if DMA is not started. + * + * @param digitalSource DigitalSource to add to DMA. + */ void AddDutyCycle(const DutyCycle* digitalSource); + /** + * Adds an analog input to be collected by DMA. + * + * This can only be called if DMA is not started. + * + * @param analogInput AnalogInput to add to DMA. + */ void AddAnalogInput(const AnalogInput* analogInput); + + /** + * Adds averaged data of an analog input to be collected by DMA. + * + * This can only be called if DMA is not started. + * + * @param analogInput AnalogInput to add to DMA. + */ void AddAveragedAnalogInput(const AnalogInput* analogInput); + + /** + * Adds accumulator data of an analog input to be collected by DMA. + * + * This can only be called if DMA is not started. + * + * @param analogInput AnalogInput to add to DMA. + */ void AddAnalogAccumulator(const AnalogInput* analogInput); + /** + * Sets an external DMA trigger. + * + * @param source the source to trigger from. + * @param rising trigger on rising edge. + * @param falling trigger on falling edge. + * @return the index of the trigger + */ int SetExternalTrigger(DigitalSource* source, bool rising, bool falling); + + /** + * Sets a DMA PWM edge trigger. + * + * @param pwm the PWM to trigger from. + * @param rising trigger on rising edge. + * @param falling trigger on falling edge. + * @return the index of the trigger + */ int SetPwmEdgeTrigger(PWM* pwm, bool rising, bool falling); + + /** + * Sets a DMA PWMMotorController edge trigger. + * + * @param pwm the PWMMotorController to trigger from. + * @param rising trigger on rising edge. + * @param falling trigger on falling edge. + * @return the index of the trigger + */ int SetPwmEdgeTrigger(PWMMotorController* pwm, bool rising, bool falling); + /** + * Clear all sensors from the DMA collection list. + * + * This can only be called if DMA is not started. + */ void ClearSensors(); + + /** + * Clear all external triggers from the DMA trigger list. + * + * This can only be called if DMA is not started. + */ void ClearExternalTriggers(); + /** + * Starts DMA Collection. + * + * @param queueDepth The number of objects to be able to queue. + */ void Start(int queueDepth); + + /** + * Stops DMA Collection. + */ void Stop(); private: diff --git a/wpilibc/src/main/native/include/frc/DMASample.h b/wpilibc/src/main/native/include/frc/DMASample.h index 7159246506..b2bed41fc7 100644 --- a/wpilibc/src/main/native/include/frc/DMASample.h +++ b/wpilibc/src/main/native/include/frc/DMASample.h @@ -17,8 +17,14 @@ #include "frc/Encoder.h" namespace frc { +/** + * DMA sample. + */ class DMASample : public HAL_DMASample { public: + /** + * DMA read status. + */ enum class DMAReadStatus { /// OK status. kOk = HAL_DMA_OK, @@ -28,22 +34,54 @@ class DMASample : public HAL_DMASample { kError = HAL_DMA_ERROR }; + /** + * Retrieves a new DMA sample. + * + * @param dma DMA object. + * @param timeout Timeout for retrieval. + * @param remaining Number of remaining samples. + * @param status DMA read status. + */ DMAReadStatus Update(const DMA* dma, units::second_t timeout, int32_t* remaining, int32_t* status) { return static_cast( HAL_ReadDMA(dma->dmaHandle, this, timeout.value(), remaining, status)); } + /** + * Returns the DMA sample time in microseconds. + * + * @return The DMA sample time in microseconds. + */ uint64_t GetTime() const { return timeStamp; } + /** + * Returns the DMA sample timestamp. + * + * @return The DMA sample timestamp. + */ units::second_t GetTimeStamp() const { return units::second_t{static_cast(GetTime()) * 1.0e-6}; } + /** + * Returns raw encoder value from DMA. + * + * @param encoder Encoder used for DMA. + * @param status DMA read status. + * @return Raw encoder value from DMA. + */ int32_t GetEncoderRaw(const Encoder* encoder, int32_t* status) const { return HAL_GetDMASampleEncoderRaw(this, encoder->m_encoder, status); } + /** + * Returns encoder distance from DMA. + * + * @param encoder Encoder used for DMA. + * @param status DMA read status. + * @return Encoder distance from DMA. + */ double GetEncoderDistance(const Encoder* encoder, int32_t* status) const { double val = GetEncoderRaw(encoder, status); val *= encoder->DecodingScaleFactor(); @@ -51,41 +89,97 @@ class DMASample : public HAL_DMASample { return val; } + /** + * Returns raw encoder period from DMA. + * + * @param encoder Encoder used for DMA. + * @param status DMA read status. + * @return Raw encoder period from DMA. + */ int32_t GetEncoderPeriodRaw(const Encoder* encoder, int32_t* status) const { return HAL_GetDMASampleEncoderPeriodRaw(this, encoder->m_encoder, status); } + /** + * Returns counter value from DMA. + * + * @param counter Counter used for DMA. + * @param status DMA read status. + * @return Counter value from DMA. + */ int32_t GetCounter(const Counter* counter, int32_t* status) const { return HAL_GetDMASampleCounter(this, counter->m_counter, status); } + /** + * Returns counter period from DMA. + * + * @param counter Counter used for DMA. + * @param status DMA read status. + * @return Counter period from DMA. + */ int32_t GetCounterPeriod(const Counter* counter, int32_t* status) const { return HAL_GetDMASampleCounterPeriod(this, counter->m_counter, status); } + /** + * Returns digital source value from DMA. + * + * @param digitalSource DigitalSource used for DMA. + * @param status DMA read status. + * @return DigitalSource value from DMA. + */ bool GetDigitalSource(const DigitalSource* digitalSource, int32_t* status) const { return HAL_GetDMASampleDigitalSource( this, digitalSource->GetPortHandleForRouting(), status); } + /** + * Returns raw analog input value from DMA. + * + * @param analogInput AnalogInput used for DMA. + * @param status DMA read status. + * @return Raw analog input value from DMA. + */ int32_t GetAnalogInputRaw(const AnalogInput* analogInput, int32_t* status) const { return HAL_GetDMASampleAnalogInputRaw(this, analogInput->m_port, status); } + /** + * Returns analog input voltage from DMA. + * + * @param analogInput AnalogInput used for DMA. + * @param status DMA read status. + * @return Analog input voltage from DMA. + */ double GetAnalogInputVoltage(const AnalogInput* analogInput, int32_t* status) { return HAL_GetAnalogValueToVolts( analogInput->m_port, GetAnalogInputRaw(analogInput, status), status); } + /** + * Returns averaged analog input raw value from DMA. + * + * @param analogInput AnalogInput used for DMA. + * @param status DMA read status. + * @return Averaged analog input raw value from DMA. + */ int32_t GetAveragedAnalogInputRaw(const AnalogInput* analogInput, int32_t* status) const { return HAL_GetDMASampleAveragedAnalogInputRaw(this, analogInput->m_port, status); } + /** + * Returns averaged analog input voltage from DMA. + * + * @param analogInput AnalogInput used for DMA. + * @param status DMA read status. + * @return Averaged analog input voltage from DMA. + */ double GetAveragedAnalogInputVoltage(const AnalogInput* analogInput, int32_t* status) { return HAL_GetAnalogValueToVolts( @@ -93,18 +187,40 @@ class DMASample : public HAL_DMASample { status); } + /** + * Returns analog accumulator value from DMA. + * + * @param analogInput AnalogInput used for DMA. + * @param count Accumulator sample count. + * @param value Accumulator value. + * @param status DMA read status. + */ void GetAnalogAccumulator(const AnalogInput* analogInput, int64_t* count, int64_t* value, int32_t* status) const { return HAL_GetDMASampleAnalogAccumulator(this, analogInput->m_port, count, value, status); } + /** + * Returns raw duty cycle output from DMA. + * + * @param dutyCycle DutyCycle used for DMA. + * @param status DMA read status. + * @return Raw duty cycle output from DMA. + */ int32_t GetDutyCycleOutputRaw(const DutyCycle* dutyCycle, int32_t* status) const { return HAL_GetDMASampleDutyCycleOutputRaw(this, dutyCycle->m_handle, status); } + /** + * Returns duty cycle output (0-1) from DMA. + * + * @param dutyCycle DutyCycle used for DMA. + * @param status DMA read status. + * @return Duty cycle output (0-1) from DMA. + */ double GetDutyCycleOutput(const DutyCycle* dutyCycle, int32_t* status) { return GetDutyCycleOutputRaw(dutyCycle, status) / static_cast(dutyCycle->GetOutputScaleFactor()); diff --git a/wpilibc/src/main/native/include/frc/DriverStation.h b/wpilibc/src/main/native/include/frc/DriverStation.h index dcaf4ad215..b9b683f11b 100644 --- a/wpilibc/src/main/native/include/frc/DriverStation.h +++ b/wpilibc/src/main/native/include/frc/DriverStation.h @@ -355,9 +355,25 @@ class DriverStation final { */ static double GetBatteryVoltage(); + /** + * Copy data from the DS task for the user. If no new data exists, it will + * just be returned, otherwise the data will be copied from the DS polling + * loop. + */ static void RefreshData(); + /** + * Registers the given handle for DS data refresh notifications. + * + * @param handle The event handle. + */ static void ProvideRefreshedDataEventHandle(WPI_EventHandle handle); + + /** + * Unregisters the given handle from DS data refresh notifications. + * + * @param handle The event handle. + */ static void RemoveRefreshedDataEventHandle(WPI_EventHandle handle); /** diff --git a/wpilibc/src/main/native/include/frc/I2C.h b/wpilibc/src/main/native/include/frc/I2C.h index 54c70d5c8f..07f3d4a927 100644 --- a/wpilibc/src/main/native/include/frc/I2C.h +++ b/wpilibc/src/main/native/include/frc/I2C.h @@ -45,7 +45,18 @@ class I2C { I2C(I2C&&) = default; I2C& operator=(I2C&&) = default; + /** + * Returns I2C port. + * + * @return I2C port. + */ Port GetPort() const; + + /** + * Returns I2C device address. + * + * @return I2C device address. + */ int GetDeviceAddress() const; /** diff --git a/wpilibc/src/main/native/include/frc/IterativeRobotBase.h b/wpilibc/src/main/native/include/frc/IterativeRobotBase.h index 79c1de2cbc..be7687d31d 100644 --- a/wpilibc/src/main/native/include/frc/IterativeRobotBase.h +++ b/wpilibc/src/main/native/include/frc/IterativeRobotBase.h @@ -243,6 +243,9 @@ class IterativeRobotBase : public RobotBase { IterativeRobotBase(IterativeRobotBase&&) = default; IterativeRobotBase& operator=(IterativeRobotBase&&) = default; + /** + * Loop function. + */ void LoopFunc(); private: diff --git a/wpilibc/src/main/native/include/frc/Joystick.h b/wpilibc/src/main/native/include/frc/Joystick.h index f8e7e2f7cb..d9c4144119 100644 --- a/wpilibc/src/main/native/include/frc/Joystick.h +++ b/wpilibc/src/main/native/include/frc/Joystick.h @@ -22,10 +22,15 @@ namespace frc { */ class Joystick : public GenericHID { public: + /// Default X axis channel. static constexpr int kDefaultXChannel = 0; + /// Default Y axis channel. static constexpr int kDefaultYChannel = 1; + /// Default Z axis channel. static constexpr int kDefaultZChannel = 2; + /// Default twist axis channel. static constexpr int kDefaultTwistChannel = 2; + /// Default throttle axis channel. static constexpr int kDefaultThrottleChannel = 3; /** diff --git a/wpilibc/src/main/native/include/frc/MotorSafety.h b/wpilibc/src/main/native/include/frc/MotorSafety.h index a17cdc0cab..efe7806a95 100644 --- a/wpilibc/src/main/native/include/frc/MotorSafety.h +++ b/wpilibc/src/main/native/include/frc/MotorSafety.h @@ -93,12 +93,15 @@ class MotorSafety { */ static void CheckMotors(); + /** + * Called to stop the motor when the timeout expires. + */ virtual void StopMotor() = 0; /** - * The return value from this method is printed out when an error occurs + * Returns a description to print when an error occurs. * - * This method must not throw! + * @return Description to print when an error occurs. */ virtual std::string GetDescription() const = 0; diff --git a/wpilibc/src/main/native/include/frc/PWM.h b/wpilibc/src/main/native/include/frc/PWM.h index 0871c9c527..c1f162ee81 100644 --- a/wpilibc/src/main/native/include/frc/PWM.h +++ b/wpilibc/src/main/native/include/frc/PWM.h @@ -144,6 +144,9 @@ class PWM : public wpi::Sendable, public wpi::SendableHelper { */ void SetPeriodMultiplier(PeriodMultiplier mult); + /** + * Latches PWM to zero. + */ void SetZeroLatch(); /** diff --git a/wpilibc/src/main/native/include/frc/PneumaticsBase.h b/wpilibc/src/main/native/include/frc/PneumaticsBase.h index 59f899fabb..52ae9b0bf0 100644 --- a/wpilibc/src/main/native/include/frc/PneumaticsBase.h +++ b/wpilibc/src/main/native/include/frc/PneumaticsBase.h @@ -18,6 +18,10 @@ namespace frc { class Solenoid; class DoubleSolenoid; class Compressor; + +/** + * Base class for pneumatics devices. + */ class PneumaticsBase { public: virtual ~PneumaticsBase() = default; diff --git a/wpilibc/src/main/native/include/frc/PneumaticsModuleType.h b/wpilibc/src/main/native/include/frc/PneumaticsModuleType.h index 7f706620b5..4fb225a217 100644 --- a/wpilibc/src/main/native/include/frc/PneumaticsModuleType.h +++ b/wpilibc/src/main/native/include/frc/PneumaticsModuleType.h @@ -5,5 +5,13 @@ #pragma once namespace frc { -enum class PneumaticsModuleType { CTREPCM, REVPH }; +/** + * Pneumatics module type. + */ +enum class PneumaticsModuleType { + /// CTRE PCM. + CTREPCM, + /// REV PH. + REVPH +}; } // namespace frc diff --git a/wpilibc/src/main/native/include/frc/PowerDistribution.h b/wpilibc/src/main/native/include/frc/PowerDistribution.h index 6c2fbe5ef0..4a6eb4fa18 100644 --- a/wpilibc/src/main/native/include/frc/PowerDistribution.h +++ b/wpilibc/src/main/native/include/frc/PowerDistribution.h @@ -17,6 +17,7 @@ namespace frc { class PowerDistribution : public wpi::Sendable, public wpi::SendableHelper { public: + /// Default module number. static constexpr int kDefaultModule = -1; /** @@ -179,6 +180,11 @@ class PowerDistribution : public wpi::Sendable, bool GetBreakerFault(int channel) const; }; + /** + * Returns the power distribution faults. + * + * @return The power distribution faults. + */ Faults GetFaults() const; struct StickyFaults { @@ -222,6 +228,11 @@ class PowerDistribution : public wpi::Sendable, bool GetBreakerFault(int channel) const; }; + /** + * Returns the power distribution sticky faults. + * + * @return The power distribution sticky faults. + */ StickyFaults GetStickyFaults() const; void InitSendable(wpi::SendableBuilder& builder) override; diff --git a/wpilibc/src/main/native/include/frc/RobotBase.h b/wpilibc/src/main/native/include/frc/RobotBase.h index 504ac810f8..6dff3696cd 100644 --- a/wpilibc/src/main/native/include/frc/RobotBase.h +++ b/wpilibc/src/main/native/include/frc/RobotBase.h @@ -189,7 +189,9 @@ class RobotBase { bool IsTestEnabled() const; /** - * Gets the ID of the main robot thread. + * Returns the main thread ID. + * + * @return The main thread ID. */ static std::thread::id GetThreadId(); diff --git a/wpilibc/src/main/native/include/frc/RobotState.h b/wpilibc/src/main/native/include/frc/RobotState.h index 0489b9bb74..ec8700e34a 100644 --- a/wpilibc/src/main/native/include/frc/RobotState.h +++ b/wpilibc/src/main/native/include/frc/RobotState.h @@ -6,15 +6,53 @@ namespace frc { +/** + * Robot state utility functions. + */ class RobotState { public: RobotState() = delete; + /** + * Returns true if the robot is disabled. + * + * @return True if the robot is disabled. + */ static bool IsDisabled(); + + /** + * Returns true if the robot is enabled. + * + * @return True if the robot is enabled. + */ static bool IsEnabled(); + + /** + * Returns true if the robot is E-stopped. + * + * @return True if the robot is E-stopped. + */ static bool IsEStopped(); + + /** + * Returns true if the robot is in teleop mode. + * + * @return True if the robot is in teleop mode. + */ static bool IsTeleop(); + + /** + * Returns true if the robot is in autonomous mode. + * + * @return True if the robot is in autonomous mode. + */ static bool IsAutonomous(); + + /** + * Returns true if the robot is in test mode. + * + * @return True if the robot is in test mode. + */ static bool IsTest(); }; diff --git a/wpilibc/src/main/native/include/frc/RuntimeType.h b/wpilibc/src/main/native/include/frc/RuntimeType.h index c3a8a0bb71..2be444a60f 100644 --- a/wpilibc/src/main/native/include/frc/RuntimeType.h +++ b/wpilibc/src/main/native/include/frc/RuntimeType.h @@ -5,5 +5,15 @@ #pragma once namespace frc { -enum RuntimeType { kRoboRIO, kRoboRIO2, kSimulation }; +/** + * Runtime type. + */ +enum RuntimeType { + /// roboRIO 1.0. + kRoboRIO, + /// roboRIO 2.0. + kRoboRIO2, + /// Simulation runtime. + kSimulation +}; } // namespace frc diff --git a/wpilibc/src/main/native/include/frc/SPI.h b/wpilibc/src/main/native/include/frc/SPI.h index 7f3ea94e41..5b170bac23 100644 --- a/wpilibc/src/main/native/include/frc/SPI.h +++ b/wpilibc/src/main/native/include/frc/SPI.h @@ -67,6 +67,11 @@ class SPI { SPI(SPI&&) = default; SPI& operator=(SPI&&) = default; + /** + * Returns the SPI port. + * + * @return The SPI port. + */ Port GetPort() const; /** diff --git a/wpilibc/src/main/native/include/frc/Servo.h b/wpilibc/src/main/native/include/frc/Servo.h index 9383641a2c..76b39a0d90 100644 --- a/wpilibc/src/main/native/include/frc/Servo.h +++ b/wpilibc/src/main/native/include/frc/Servo.h @@ -19,6 +19,11 @@ namespace frc { class Servo : public PWM { public: /** + * Constructor. + * + * By default, 2.4 ms is used as the max PWM value and 0.6 ms is used as the + * min PWM value. + * * @param channel The PWM channel to which the servo is attached. 0-9 are * on-board, 10-19 are on the MXP port */ diff --git a/wpilibc/src/main/native/include/frc/TimedRobot.h b/wpilibc/src/main/native/include/frc/TimedRobot.h index f32e7483cf..dcc510af2b 100644 --- a/wpilibc/src/main/native/include/frc/TimedRobot.h +++ b/wpilibc/src/main/native/include/frc/TimedRobot.h @@ -29,6 +29,7 @@ namespace frc { */ class TimedRobot : public IterativeRobotBase { public: + /// Default loop period. static constexpr auto kDefaultPeriod = 20_ms; /** diff --git a/wpilibc/src/main/native/include/frc/Ultrasonic.h b/wpilibc/src/main/native/include/frc/Ultrasonic.h index 137a5b75ae..f06392c931 100644 --- a/wpilibc/src/main/native/include/frc/Ultrasonic.h +++ b/wpilibc/src/main/native/include/frc/Ultrasonic.h @@ -90,6 +90,11 @@ class Ultrasonic : public wpi::Sendable, Ultrasonic(Ultrasonic&&) = default; Ultrasonic& operator=(Ultrasonic&&) = default; + /** + * Returns the echo channel. + * + * @return The echo channel. + */ int GetEchoChannel() const; /** diff --git a/wpilibc/src/main/native/include/frc/drive/DifferentialDrive.h b/wpilibc/src/main/native/include/frc/drive/DifferentialDrive.h index b4303d5b01..ccda6449ac 100644 --- a/wpilibc/src/main/native/include/frc/drive/DifferentialDrive.h +++ b/wpilibc/src/main/native/include/frc/drive/DifferentialDrive.h @@ -65,7 +65,9 @@ class DifferentialDrive : public RobotDriveBase, * Uses normalized voltage [-1.0..1.0]. */ struct WheelSpeeds { + /// Left wheel speed. double left = 0.0; + /// Right wheel speed. double right = 0.0; }; diff --git a/wpilibc/src/main/native/include/frc/drive/MecanumDrive.h b/wpilibc/src/main/native/include/frc/drive/MecanumDrive.h index 6f33f93ab6..6d8ebac444 100644 --- a/wpilibc/src/main/native/include/frc/drive/MecanumDrive.h +++ b/wpilibc/src/main/native/include/frc/drive/MecanumDrive.h @@ -65,9 +65,13 @@ class MecanumDrive : public RobotDriveBase, * Uses normalized voltage [-1.0..1.0]. */ struct WheelSpeeds { + /// Front-left wheel speed. double frontLeft = 0.0; + /// Front-right wheel speed. double frontRight = 0.0; + /// Rear-left wheel speed. double rearLeft = 0.0; + /// Rear-right wheel speed. double rearRight = 0.0; }; diff --git a/wpilibc/src/main/native/include/frc/drive/RobotDriveBase.h b/wpilibc/src/main/native/include/frc/drive/RobotDriveBase.h index 78336103bb..2a746434e4 100644 --- a/wpilibc/src/main/native/include/frc/drive/RobotDriveBase.h +++ b/wpilibc/src/main/native/include/frc/drive/RobotDriveBase.h @@ -77,14 +77,23 @@ class RobotDriveBase : public MotorSafety { std::string GetDescription() const override = 0; protected: + /// Default input deadband. + static constexpr double kDefaultDeadband = 0.02; + + /// Default maximum output. + static constexpr double kDefaultMaxOutput = 1.0; + /** * Renormalize all wheel speeds if the magnitude of any wheel is greater than * 1.0. */ static void Desaturate(std::span wheelSpeeds); - double m_deadband = 0.02; - double m_maxOutput = 1.0; + /// Input deadband. + double m_deadband = kDefaultDeadband; + + /// Maximum output. + double m_maxOutput = kDefaultMaxOutput; }; } // namespace frc diff --git a/wpilibc/src/main/native/include/frc/internal/DriverStationModeThread.h b/wpilibc/src/main/native/include/frc/internal/DriverStationModeThread.h index f4fd11ca82..e646e15b66 100644 --- a/wpilibc/src/main/native/include/frc/internal/DriverStationModeThread.h +++ b/wpilibc/src/main/native/include/frc/internal/DriverStationModeThread.h @@ -8,9 +8,16 @@ #include namespace frc::internal { +/** + * For internal use only. + */ class DriverStationModeThread { public: + /** + * For internal use only. + */ DriverStationModeThread(); + ~DriverStationModeThread(); DriverStationModeThread(const DriverStationModeThread& other) = delete; @@ -19,9 +26,39 @@ class DriverStationModeThread { delete; DriverStationModeThread& operator=(DriverStationModeThread&& other) = delete; - void InAutonomous(bool entering); + /** + * Only to be used to tell the Driver Station what code you claim to be + * executing for diagnostic purposes only. + * + * @param entering If true, starting disabled code; if false, leaving disabled + * code + */ void InDisabled(bool entering); + + /** + * Only to be used to tell the Driver Station what code you claim to be + * executing for diagnostic purposes only. + * + * @param entering If true, starting autonomous code; if false, leaving + * autonomous code + */ + void InAutonomous(bool entering); + + /** + * Only to be used to tell the Driver Station what code you claim to be + * executing for diagnostic purposes only. + * + * @param entering If true, starting teleop code; if false, leaving teleop + * code + */ void InTeleop(bool entering); + + /** + * Only to be used to tell the Driver Station what code you claim to be + * executing for diagnostic purposes only. + * + * @param entering If true, starting test code; if false, leaving test code + */ void InTest(bool entering); private: diff --git a/wpilibc/src/main/native/include/frc/livewindow/LiveWindow.h b/wpilibc/src/main/native/include/frc/livewindow/LiveWindow.h index 3714146c43..2f0a34957a 100644 --- a/wpilibc/src/main/native/include/frc/livewindow/LiveWindow.h +++ b/wpilibc/src/main/native/include/frc/livewindow/LiveWindow.h @@ -19,14 +19,14 @@ namespace frc { class LiveWindow final { public: /** - * Set function to be called when LiveWindow is enabled. + * Sets function to be called when LiveWindow is enabled. * * @param func function (or nullptr for none) */ static void SetEnabledCallback(std::function func); /** - * Set function to be called when LiveWindow is disabled. + * Sets function to be called when LiveWindow is disabled. * * @param func function (or nullptr for none) */ @@ -56,6 +56,11 @@ class LiveWindow final { */ static void EnableAllTelemetry(); + /** + * Returns true if LiveWindow is enabled. + * + * @return True if LiveWindow is enabled. + */ static bool IsEnabled(); /** diff --git a/wpilibc/src/main/native/include/frc/motorcontrol/MotorControllerGroup.h b/wpilibc/src/main/native/include/frc/motorcontrol/MotorControllerGroup.h index a429dda5b0..6ecfe99e24 100644 --- a/wpilibc/src/main/native/include/frc/motorcontrol/MotorControllerGroup.h +++ b/wpilibc/src/main/native/include/frc/motorcontrol/MotorControllerGroup.h @@ -27,9 +27,22 @@ class [[deprecated( public MotorController, public wpi::SendableHelper { public: + /** + * Create a new MotorControllerGroup with the provided MotorControllers. + * + * @tparam MotorControllers The MotorController types. + * @param motorController The first MotorController to add + * @param motorControllers The MotorControllers to add + */ template explicit MotorControllerGroup(MotorController& motorController, MotorControllers&... motorControllers); + + /** + * Create a new MotorControllerGroup with the provided MotorControllers. + * + * @param motorControllers The MotorControllers to add. + */ explicit MotorControllerGroup( std::vector>&& motorControllers); diff --git a/wpilibc/src/main/native/include/frc/motorcontrol/PWMMotorController.h b/wpilibc/src/main/native/include/frc/motorcontrol/PWMMotorController.h index 1d173a9bc4..54a16bbd16 100644 --- a/wpilibc/src/main/native/include/frc/motorcontrol/PWMMotorController.h +++ b/wpilibc/src/main/native/include/frc/motorcontrol/PWMMotorController.h @@ -124,6 +124,7 @@ class PWMMotorController : public MotorController, void InitSendable(wpi::SendableBuilder& builder) override; + /// PWM instances for motor controller. PWM m_pwm; private: diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponent.h b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponent.h index fc15948231..8cb867388b 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponent.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardComponent.h @@ -26,6 +26,13 @@ class ShuffleboardContainer; template class ShuffleboardComponent : public ShuffleboardComponentBase { public: + /** + * Constructs a ShuffleboardComponent. + * + * @param parent The parent container. + * @param title The component title. + * @param type The component type. + */ ShuffleboardComponent(ShuffleboardContainer& parent, std::string_view title, std::string_view type = ""); diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardEventImportance.h b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardEventImportance.h index 1fa9c91f3d..ea251ec915 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardEventImportance.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardEventImportance.h @@ -14,6 +14,11 @@ namespace frc { enum ShuffleboardEventImportance { kTrivial, kLow, kNormal, kHigh, kCritical }; +/** + * Returns name of the given enum. + * + * @return Name of the given enum. + */ inline std::string_view ShuffleboardEventImportanceName( ShuffleboardEventImportance importance) { switch (importance) { diff --git a/wpilibc/src/main/native/include/frc/simulation/DifferentialDrivetrainSim.h b/wpilibc/src/main/native/include/frc/simulation/DifferentialDrivetrainSim.h index c2598c943f..644e348afd 100644 --- a/wpilibc/src/main/native/include/frc/simulation/DifferentialDrivetrainSim.h +++ b/wpilibc/src/main/native/include/frc/simulation/DifferentialDrivetrainSim.h @@ -187,6 +187,13 @@ class DifferentialDrivetrainSim { */ void SetPose(const frc::Pose2d& pose); + /** + * The differential drive dynamics function. + * + * @param x The state. + * @param u The input. + * @return The state derivative with respect to time. + */ Vectord<7> Dynamics(const Vectord<7>& x, const Eigen::Vector2d& u); class State { diff --git a/wpilibc/src/main/native/include/frc/simulation/GenericHIDSim.h b/wpilibc/src/main/native/include/frc/simulation/GenericHIDSim.h index 399e0c16d1..ba56c4d106 100644 --- a/wpilibc/src/main/native/include/frc/simulation/GenericHIDSim.h +++ b/wpilibc/src/main/native/include/frc/simulation/GenericHIDSim.h @@ -136,6 +136,7 @@ class GenericHIDSim { double GetRumble(GenericHID::RumbleType type); protected: + /// GenericHID port. int m_port; }; diff --git a/wpilibc/src/main/native/include/frc/simulation/LinearSystemSim.h b/wpilibc/src/main/native/include/frc/simulation/LinearSystemSim.h index cd586437e4..a4fec0028d 100644 --- a/wpilibc/src/main/native/include/frc/simulation/LinearSystemSim.h +++ b/wpilibc/src/main/native/include/frc/simulation/LinearSystemSim.h @@ -140,11 +140,20 @@ class LinearSystemSim { u, frc::RobotController::GetInputVoltage()); } + /// The plant that represents the linear system. LinearSystem m_plant; + /// State vector. Vectord m_x; - Vectord m_y; + + /// Input vector. Vectord m_u; + + /// Output vector. + Vectord m_y; + + /// The standard deviations of measurements, used for adding noise to the + /// measurements. std::array m_measurementStdDevs; }; } // namespace frc::sim diff --git a/wpilibc/src/main/native/include/frc/simulation/PneumaticsBaseSim.h b/wpilibc/src/main/native/include/frc/simulation/PneumaticsBaseSim.h index 510349f769..f3000f4a3e 100644 --- a/wpilibc/src/main/native/include/frc/simulation/PneumaticsBaseSim.h +++ b/wpilibc/src/main/native/include/frc/simulation/PneumaticsBaseSim.h @@ -177,9 +177,22 @@ class PneumaticsBaseSim { virtual void ResetData() = 0; protected: + /// PneumaticsBase index. const int m_index; - explicit PneumaticsBaseSim(const PneumaticsBase& module); + + /** + * Constructs a PneumaticsBaseSim with the given index. + * + * @param index The index. + */ explicit PneumaticsBaseSim(const int index); + + /** + * Constructs a PneumaticsBaseSim for the given module. + * + * @param module The module. + */ + explicit PneumaticsBaseSim(const PneumaticsBase& module); }; } // namespace frc::sim diff --git a/wpilibc/src/main/native/include/frc/simulation/UltrasonicSim.h b/wpilibc/src/main/native/include/frc/simulation/UltrasonicSim.h index 5db41f7f4d..0d22d87df5 100644 --- a/wpilibc/src/main/native/include/frc/simulation/UltrasonicSim.h +++ b/wpilibc/src/main/native/include/frc/simulation/UltrasonicSim.h @@ -36,14 +36,14 @@ class UltrasonicSim { /** * Sets if the range measurement is valid. * - * @param isValid True if valid + * @param valid True if valid */ - void SetRangeValid(bool isValid); + void SetRangeValid(bool valid); /** - * Sets the range measurement + * Sets the range measurement. * - * @param range The range + * @param range The range. */ void SetRange(units::inch_t range); diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h b/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h index baee6ffaa4..2051d1b5d5 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h @@ -21,6 +21,9 @@ namespace frc { +/** + * Implementation detail for SendableBuilder. + */ class SendableBuilderImpl : public nt::NTSendableBuilder { public: SendableBuilderImpl() = default; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/CAN.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/CAN.java index 0f94e35112..df0be482c2 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/CAN.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/CAN.java @@ -22,7 +22,10 @@ import java.io.Closeable; * calls. */ public class CAN implements Closeable { + /** Team manufacturer. */ public static final int kTeamManufacturer = CANAPITypes.CANManufacturer.kTeamUse.id; + + /** Team device type. */ public static final int kTeamDeviceType = CANAPITypes.CANDeviceType.kMiscellaneous.id; private final int m_handle; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/CompressorConfigType.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/CompressorConfigType.java index 48bb81ffcd..7735cdd579 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/CompressorConfigType.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/CompressorConfigType.java @@ -6,12 +6,18 @@ package edu.wpi.first.wpilibj; import edu.wpi.first.hal.REVPHJNI; +/** Compressor config type. */ public enum CompressorConfigType { + /** Disabled. */ Disabled(REVPHJNI.COMPRESSOR_CONFIG_TYPE_DISABLED), + /** Digital. */ Digital(REVPHJNI.COMPRESSOR_CONFIG_TYPE_DIGITAL), + /** Analog. */ Analog(REVPHJNI.COMPRESSOR_CONFIG_TYPE_ANALOG), + /** Hybrid. */ Hybrid(REVPHJNI.COMPRESSOR_CONFIG_TYPE_HYBRID); + /** CompressorConfigType value. */ public final int value; CompressorConfigType(int value) { @@ -37,6 +43,11 @@ public enum CompressorConfigType { } } + /** + * Returns the CompressorConfigType's value. + * + * @return The CompressorConfigType's value. + */ public int getValue() { return value; } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Counter.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Counter.java index 26f921b3f4..eca3dd5a8f 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Counter.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Counter.java @@ -38,6 +38,7 @@ public class Counter implements CounterBase, Sendable, AutoCloseable { /** mode: external direction. */ kExternalDirection(3); + /** Mode value. */ public final int value; Mode(int value) { @@ -45,13 +46,23 @@ public class Counter implements CounterBase, Sendable, AutoCloseable { } } - protected DigitalSource m_upSource; // /< What makes the counter count up. - protected DigitalSource m_downSource; // /< What makes the counter count down. + /** What makes the counter count up. */ + protected DigitalSource m_upSource; + + /** What makes the counter count down. */ + protected DigitalSource m_downSource; + private boolean m_allocatedUpSource; private boolean m_allocatedDownSource; - int m_counter; // /< The FPGA counter object. - private int m_index; // /< The index of this counter. - private double m_distancePerPulse = 1; // distance of travel for each tick + + /** The FPGA counter object. */ + int m_counter; + + /** The index of this counter. */ + private int m_index; + + /** Distance of travel for each tick. */ + private double m_distancePerPulse = 1; /** * Create an instance of a counter with the given mode. diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/CounterBase.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/CounterBase.java index 60d56909d3..6e03b72356 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/CounterBase.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/CounterBase.java @@ -22,6 +22,7 @@ public interface CounterBase { /** Count rising and falling on both channels. */ k4X(2); + /** EncodingType value. */ public final int value; EncodingType(int value) { diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DMA.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DMA.java index a919da55f0..bd26a7bf5d 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DMA.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DMA.java @@ -7,9 +7,11 @@ package edu.wpi.first.wpilibj; import edu.wpi.first.hal.DMAJNI; import edu.wpi.first.wpilibj.motorcontrol.PWMMotorController; +/** Class for configuring Direct Memory Access (DMA) of FPGA inputs. */ public class DMA implements AutoCloseable { final int m_dmaHandle; + /** Default constructor. */ public DMA() { m_dmaHandle = DMAJNI.initialize(); } @@ -19,50 +21,128 @@ public class DMA implements AutoCloseable { DMAJNI.free(m_dmaHandle); } + /** + * Sets whether DMA is paused. + * + * @param pause True pauses DMA. + */ public void setPause(boolean pause) { DMAJNI.setPause(m_dmaHandle, pause); } + /** + * Sets DMA to trigger at an interval. + * + * @param periodSeconds Period at which to trigger DMA in seconds. + */ public void setTimedTrigger(double periodSeconds) { DMAJNI.setTimedTrigger(m_dmaHandle, periodSeconds); } + /** + * Sets number of DMA cycles to trigger. + * + * @param cycles Number of cycles. + */ public void setTimedTriggerCycles(int cycles) { DMAJNI.setTimedTriggerCycles(m_dmaHandle, cycles); } + /** + * Adds position data for an encoder to be collected by DMA. + * + *

This can only be called if DMA is not started. + * + * @param encoder Encoder to add to DMA. + */ public void addEncoder(Encoder encoder) { DMAJNI.addEncoder(m_dmaHandle, encoder.m_encoder); } + /** + * Adds timer data for an encoder to be collected by DMA. + * + *

This can only be called if DMA is not started. + * + * @param encoder Encoder to add to DMA. + */ public void addEncoderPeriod(Encoder encoder) { DMAJNI.addEncoderPeriod(m_dmaHandle, encoder.m_encoder); } + /** + * Adds position data for an counter to be collected by DMA. + * + *

This can only be called if DMA is not started. + * + * @param counter Counter to add to DMA. + */ public void addCounter(Counter counter) { DMAJNI.addCounter(m_dmaHandle, counter.m_counter); } + /** + * Adds timer data for an counter to be collected by DMA. + * + *

This can only be called if DMA is not started. + * + * @param counter Counter to add to DMA. + */ public void addCounterPeriod(Counter counter) { DMAJNI.addCounterPeriod(m_dmaHandle, counter.m_counter); } + /** + * Adds a digital source to be collected by DMA. + * + *

This can only be called if DMA is not started. + * + * @param digitalSource DigitalSource to add to DMA. + */ public void addDigitalSource(DigitalSource digitalSource) { DMAJNI.addDigitalSource(m_dmaHandle, digitalSource.getPortHandleForRouting()); } + /** + * Adds a duty cycle input to be collected by DMA. + * + *

This can only be called if DMA is not started. + * + * @param dutyCycle DutyCycle to add to DMA. + */ public void addDutyCycle(DutyCycle dutyCycle) { DMAJNI.addDutyCycle(m_dmaHandle, dutyCycle.m_handle); } + /** + * Adds an analog input to be collected by DMA. + * + *

This can only be called if DMA is not started. + * + * @param analogInput AnalogInput to add to DMA. + */ public void addAnalogInput(AnalogInput analogInput) { DMAJNI.addAnalogInput(m_dmaHandle, analogInput.m_port); } + /** + * Adds averaged data of an analog input to be collected by DMA. + * + *

This can only be called if DMA is not started. + * + * @param analogInput AnalogInput to add to DMA. + */ public void addAveragedAnalogInput(AnalogInput analogInput) { DMAJNI.addAveragedAnalogInput(m_dmaHandle, analogInput.m_port); } + /** + * Adds accumulator data of an analog input to be collected by DMA. + * + *

This can only be called if DMA is not started. + * + * @param analogInput AnalogInput to add to DMA. + */ public void addAnalogAccumulator(AnalogInput analogInput) { DMAJNI.addAnalogAccumulator(m_dmaHandle, analogInput.m_port); } @@ -84,26 +164,58 @@ public class DMA implements AutoCloseable { falling); } - public int setPwmEdgeTrigger(PWMMotorController pwm, boolean rising, boolean falling) { - return DMAJNI.setExternalTrigger(m_dmaHandle, pwm.getPwmHandle(), 0, rising, falling); - } - + /** + * Sets a DMA PWM edge trigger. + * + * @param pwm the PWM to trigger from. + * @param rising trigger on rising edge. + * @param falling trigger on falling edge. + * @return the index of the trigger + */ public int setPwmEdgeTrigger(PWM pwm, boolean rising, boolean falling) { return DMAJNI.setExternalTrigger(m_dmaHandle, pwm.getHandle(), 0, rising, falling); } + /** + * Sets a DMA PWMMotorController edge trigger. + * + * @param pwm the PWMMotorController to trigger from. + * @param rising trigger on rising edge. + * @param falling trigger on falling edge. + * @return the index of the trigger + */ + public int setPwmEdgeTrigger(PWMMotorController pwm, boolean rising, boolean falling) { + return DMAJNI.setExternalTrigger(m_dmaHandle, pwm.getPwmHandle(), 0, rising, falling); + } + + /** + * Clear all sensors from the DMA collection list. + * + *

This can only be called if DMA is not started. + */ public void clearSensors() { DMAJNI.clearSensors(m_dmaHandle); } + /** + * Clear all external triggers from the DMA trigger list. + * + *

This can only be called if DMA is not started. + */ public void clearExternalTriggers() { DMAJNI.clearExternalTriggers(m_dmaHandle); } + /** + * Starts DMA Collection. + * + * @param queueDepth The number of objects to be able to queue. + */ public void start(int queueDepth) { DMAJNI.startDMA(m_dmaHandle, queueDepth); } + /** Stops DMA Collection. */ public void stop() { DMAJNI.stopDMA(m_dmaHandle); } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DMASample.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DMASample.java index 7f833b6f10..1435cd36d9 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DMASample.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DMASample.java @@ -7,7 +7,9 @@ package edu.wpi.first.wpilibj; import edu.wpi.first.hal.AnalogJNI; import edu.wpi.first.hal.DMAJNISample; +/** DMA sample. */ public class DMASample { + /** DMA read status. */ public enum DMAReadStatus { /** OK status. */ kOk(1), @@ -22,6 +24,11 @@ public class DMASample { this.value = value; } + /** + * Returns the DMAReadStatus value. + * + * @return The DMAReadStatus value. + */ public int getValue() { return value; } @@ -47,39 +54,77 @@ public class DMASample { /** Default constructor. */ public DMASample() {} + /** + * Retrieves a new DMA sample. + * + * @param dma DMA object. + * @param timeoutSeconds Timeout in seconds for retrieval. + * @return DMA read status. + */ public DMAReadStatus update(DMA dma, double timeoutSeconds) { return DMAReadStatus.getValue(m_dmaSample.update(dma.m_dmaHandle, timeoutSeconds)); } - public int getCaptureSize() { - return m_dmaSample.getCaptureSize(); - } - - public int getTriggerChannels() { - return m_dmaSample.getTriggerChannels(); - } - - public int getRemaining() { - return m_dmaSample.getRemaining(); - } - + /** + * Returns the DMA sample time in microseconds. + * + * @return The DMA sample time in microseconds. + */ public long getTime() { return m_dmaSample.getTime(); } + /** + * Returns the DMA sample timestamp in seconds. + * + * @return The DMA sample timestamp in seconds. + */ public double getTimeStamp() { return getTime() * 1.0e-6; } + /** + * Returns the DMA sample capture size. + * + * @return The DMA sample capture size. + */ + public int getCaptureSize() { + return m_dmaSample.getCaptureSize(); + } + + /** + * Returns the number of DMA trigger channels. + * + * @return The number of DMA trigger channels. + */ + public int getTriggerChannels() { + return m_dmaSample.getTriggerChannels(); + } + + /** + * Returns the number of remaining samples. + * + * @return The number of remaining samples. + */ + public int getRemaining() { + return m_dmaSample.getRemaining(); + } + + /** + * Returns raw encoder value from DMA. + * + * @param encoder Encoder used for DMA. + * @return Raw encoder value from DMA. + */ public int getEncoderRaw(Encoder encoder) { return m_dmaSample.getEncoder(encoder.m_encoder); } /** - * Gets the scaled encoder distance for this sample. + * Returns encoder distance from DMA. * - * @param encoder the encoder to use to read - * @return the distance + * @param encoder Encoder used for DMA. + * @return Encoder distance from DMA. */ public double getEncoderDistance(Encoder encoder) { double val = getEncoderRaw(encoder); @@ -88,43 +133,103 @@ public class DMASample { return val; } + /** + * Returns raw encoder period from DMA. + * + * @param encoder Encoder used for DMA. + * @return Raw encoder period from DMA. + */ public int getEncoderPeriodRaw(Encoder encoder) { return m_dmaSample.getEncoderPeriod(encoder.m_encoder); } + /** + * Returns counter value from DMA. + * + * @param counter Counter used for DMA. + * @return Counter value from DMA. + */ public int getCounter(Counter counter) { return m_dmaSample.getCounter(counter.m_counter); } + /** + * Returns counter period from DMA. + * + * @param counter Counter used for DMA. + * @return Counter period from DMA. + */ public int getCounterPeriod(Counter counter) { return m_dmaSample.getCounterPeriod(counter.m_counter); } + /** + * Returns digital source value from DMA. + * + * @param digitalSource DigitalSource used for DMA. + * @return DigitalSource value from DMA. + */ public boolean getDigitalSource(DigitalSource digitalSource) { return m_dmaSample.getDigitalSource(digitalSource.getPortHandleForRouting()); } + /** + * Returns raw analog input value from DMA. + * + * @param analogInput AnalogInput used for DMA. + * @return Raw analog input value from DMA. + */ public int getAnalogInputRaw(AnalogInput analogInput) { return m_dmaSample.getAnalogInput(analogInput.m_port); } + /** + * Returns analog input voltage from DMA. + * + * @param analogInput AnalogInput used for DMA. + * @return Analog input voltage from DMA. + */ public double getAnalogInputVoltage(AnalogInput analogInput) { return AnalogJNI.getAnalogValueToVolts(analogInput.m_port, getAnalogInputRaw(analogInput)); } + /** + * Returns averaged raw analog input value from DMA. + * + * @param analogInput AnalogInput used for DMA. + * @return Averaged raw analog input value from DMA. + */ public int getAveragedAnalogInputRaw(AnalogInput analogInput) { return m_dmaSample.getAnalogInputAveraged(analogInput.m_port); } + /** + * Returns averaged analog input voltage from DMA. + * + * @param analogInput AnalogInput used for DMA. + * @return Averaged analog input voltage from DMA. + */ public double getAveragedAnalogInputVoltage(AnalogInput analogInput) { return AnalogJNI.getAnalogValueToVolts( analogInput.m_port, getAveragedAnalogInputRaw(analogInput)); } + /** + * Returns raw duty cycle output from DMA. + * + * @param dutyCycle DutyCycle used for DMA. + * @return Raw duty cycle output from DMA. + */ public int getDutyCycleOutputRaw(DutyCycle dutyCycle) { return m_dmaSample.getDutyCycleOutput(dutyCycle.m_handle); } + /** + * Returns duty cycle output (0-1) from DMA. + * + * @param dutyCycle DutyCycle used for DMA. + * @return Duty cycle output (0-1) from DMA. + */ public double getDutyCycleOutput(DutyCycle dutyCycle) { return m_dmaSample.getDutyCycleOutput(dutyCycle.m_handle) / (double) dutyCycle.getOutputScaleFactor(); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DriverStation.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DriverStation.java index 9eb60aa32d..4ee656b419 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DriverStation.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DriverStation.java @@ -1321,10 +1321,20 @@ public final class DriverStation { } } + /** + * Registers the given handle for DS data refresh notifications. + * + * @param handle The event handle. + */ public static void provideRefreshedDataEventHandle(int handle) { m_refreshEvents.add(handle); } + /** + * Unregisters the given handle from DS data refresh notifications. + * + * @param handle The event handle. + */ public static void removeRefreshedDataEventHandle(int handle) { m_refreshEvents.remove(handle); } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DutyCycle.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DutyCycle.java index 2e1795c0c4..8c26d55b80 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/DutyCycle.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/DutyCycle.java @@ -103,6 +103,11 @@ public class DutyCycle implements Sendable, AutoCloseable { return DutyCycleJNI.getFPGAIndex(m_handle); } + /** + * Get the channel of the source. + * + * @return the source channel + */ public int getSourceChannel() { return m_source.getChannel(); } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Encoder.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Encoder.java index 5211e20c06..0aa667ea1f 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Encoder.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Encoder.java @@ -40,6 +40,7 @@ public class Encoder implements CounterBase, Sendable, AutoCloseable { /** Reset on rising edge of the signal. */ kResetOnRisingEdge(3); + /** IndexingType value. */ public final int value; IndexingType(int value) { diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/GenericHID.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/GenericHID.java index d5a3f9cc25..e112e95f12 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/GenericHID.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/GenericHID.java @@ -66,6 +66,7 @@ public class GenericHID { /** HID1stPerson. */ kHID1stPerson(24); + /** HIDType value. */ public final int value; @SuppressWarnings("PMD.UseConcurrentHashMap") @@ -81,6 +82,12 @@ public class GenericHID { } } + /** + * Creates an HIDType with the given value. + * + * @param value HIDType's value. + * @return HIDType with the given value. + */ public static HIDType of(int value) { return map.get(value); } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/I2C.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/I2C.java index 5e40b23558..1ed131b2c7 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/I2C.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/I2C.java @@ -30,6 +30,7 @@ public class I2C implements AutoCloseable { /** MXP (roboRIO MXP) I2C port. */ kMXP(1); + /** Port value. */ public final int value; Port(int value) { @@ -61,10 +62,20 @@ public class I2C implements AutoCloseable { HAL.report(tResourceType.kResourceType_I2C, deviceAddress); } + /** + * Returns I2C port. + * + * @return I2C port. + */ public int getPort() { return m_port; } + /** + * Returns I2C device address. + * + * @return I2C device address. + */ public int getDeviceAddress() { return m_deviceAddress; } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/IterativeRobotBase.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/IterativeRobotBase.java index bbc98a4108..f042545b61 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/IterativeRobotBase.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/IterativeRobotBase.java @@ -288,6 +288,7 @@ public abstract class IterativeRobotBase extends RobotBase { return m_period; } + /** Loop function. */ protected void loopFunc() { DriverStation.refreshData(); m_watchdog.reset(); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Joystick.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Joystick.java index ac929ce628..5536009e32 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Joystick.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Joystick.java @@ -17,10 +17,19 @@ import edu.wpi.first.wpilibj.event.EventLoop; * and the mapping of ports to hardware buttons depends on the code in the Driver Station. */ public class Joystick extends GenericHID { + /** Default X axis channel. */ public static final byte kDefaultXChannel = 0; + + /** Default Y axis channel. */ public static final byte kDefaultYChannel = 1; + + /** Default Z axis channel. */ public static final byte kDefaultZChannel = 2; + + /** Default twist axis channel. */ public static final byte kDefaultTwistChannel = 2; + + /** Default throttle axis channel. */ public static final byte kDefaultThrottleChannel = 3; /** Represents an analog axis on a joystick. */ @@ -36,6 +45,7 @@ public class Joystick extends GenericHID { /** Throttle axis. */ kThrottle(4); + /** AxisType value. */ public final int value; AxisType(int value) { @@ -50,6 +60,7 @@ public class Joystick extends GenericHID { /** kTop. */ kTop(2); + /** ButtonType value. */ public final int value; ButtonType(int value) { diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/MotorSafety.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/MotorSafety.java index 3b1da84f2e..dc969a9c96 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/MotorSafety.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/MotorSafety.java @@ -186,7 +186,13 @@ public abstract class MotorSafety { } } + /** Called to stop the motor when the timeout expires. */ public abstract void stopMotor(); + /** + * Returns a description to print when an error occurs. + * + * @return Description to print when an error occurs. + */ public abstract String getDescription(); } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PS4Controller.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PS4Controller.java index 97d1ed13e2..e000c6f51d 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PS4Controller.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PS4Controller.java @@ -63,6 +63,7 @@ public class PS4Controller extends GenericHID { /** Touchpad click button. */ kTouchpad(14); + /** Button value. */ public final int value; Button(int index) { @@ -102,6 +103,7 @@ public class PS4Controller extends GenericHID { /** Right Trigger 2. */ kR2(4); + /** Axis value. */ public final int value; Axis(int index) { diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PS5Controller.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PS5Controller.java index 17608c0b24..18cb738e88 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PS5Controller.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PS5Controller.java @@ -60,6 +60,7 @@ public class PS5Controller extends GenericHID { /** Touchpad click button. */ kTouchpad(14); + /** Button value. */ public final int value; Button(int index) { @@ -99,6 +100,7 @@ public class PS5Controller extends GenericHID { /** Right Trigger 2. */ kR2(4); + /** Axis value. */ public final int value; Axis(int index) { diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PWM.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PWM.java index 76351560d7..af600eca0a 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PWM.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PWM.java @@ -229,6 +229,7 @@ public class PWM implements Sendable, AutoCloseable { } } + /** Latches PWM to zero. */ public void setZeroLatch() { PWMJNI.latchPWMZero(m_handle); } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PneumaticsBase.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PneumaticsBase.java index d9b493b47c..90f49f53b4 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PneumaticsBase.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PneumaticsBase.java @@ -4,6 +4,7 @@ package edu.wpi.first.wpilibj; +/** Interface for pneumatics devices. */ public interface PneumaticsBase extends AutoCloseable { /** * For internal use to get a module for a specific type. diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PneumaticsControlModule.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PneumaticsControlModule.java index aac16a37c0..4f1d70c516 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PneumaticsControlModule.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PneumaticsControlModule.java @@ -186,10 +186,23 @@ public class PneumaticsControlModule implements PneumaticsBase { return CTREPCMJNI.getSolenoidDisabledList(m_handle); } + /** + * Returns whether the solenoid is currently reporting a voltage fault. + * + * @return True if solenoid is reporting a fault, otherwise false. + * @see #getSolenoidVoltageStickyFault() + */ public boolean getSolenoidVoltageFault() { return CTREPCMJNI.getSolenoidVoltageFault(m_handle); } + /** + * Returns whether the solenoid has reported a voltage fault since sticky faults were last + * cleared. This fault is persistent and can be cleared by ClearAllStickyFaults() + * + * @return True if solenoid is reporting a fault, otherwise false. + * @see #getSolenoidVoltageFault() + */ public boolean getSolenoidVoltageStickyFault() { return CTREPCMJNI.getSolenoidVoltageStickyFault(m_handle); } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PneumaticsModuleType.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PneumaticsModuleType.java index 215a1714ca..e1525c39e2 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PneumaticsModuleType.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PneumaticsModuleType.java @@ -4,7 +4,10 @@ package edu.wpi.first.wpilibj; +/** Pneumatics module type. */ public enum PneumaticsModuleType { + /** CTRE PCM. */ CTREPCM, + /** REV PH. */ REVPH } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PowerDistribution.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PowerDistribution.java index 08beeb7029..57709b77e1 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PowerDistribution.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/PowerDistribution.java @@ -22,6 +22,7 @@ public class PowerDistribution implements Sendable, AutoCloseable { private final int m_handle; private final int m_module; + /** Default module number. */ public static final int kDefaultModule = PowerDistributionJNI.DEFAULT_MODULE; /** Power distribution module type. */ @@ -31,6 +32,7 @@ public class PowerDistribution implements Sendable, AutoCloseable { /** REV Power Distribution Hub (PDH). */ kRev(PowerDistributionJNI.REV_TYPE); + /** ModuleType value. */ public final int value; ModuleType(int value) { @@ -187,14 +189,29 @@ public class PowerDistribution implements Sendable, AutoCloseable { PowerDistributionJNI.setSwitchableChannel(m_handle, enabled); } + /** + * Returns the power distribution version number. + * + * @return The power distribution version number. + */ public PowerDistributionVersion getVersion() { return PowerDistributionJNI.getVersion(m_handle); } + /** + * Returns the power distribution faults. + * + * @return The power distribution faults. + */ public PowerDistributionFaults getFaults() { return PowerDistributionJNI.getFaults(m_handle); } + /** + * Returns the power distribution sticky faults. + * + * @return The power distribution sticky faults. + */ public PowerDistributionStickyFaults getStickyFaults() { return PowerDistributionJNI.getStickyFaults(m_handle); } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Relay.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Relay.java index c1b1c8f1bb..dce3096cc8 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Relay.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Relay.java @@ -59,10 +59,21 @@ public class Relay extends MotorSafety implements Sendable, AutoCloseable { m_prettyValue = prettyValue; } + /** + * Returns the pretty string representation of the value. + * + * @return The pretty string representation of the value. + */ public String getPrettyValue() { return m_prettyValue; } + /** + * Returns the value for a given pretty string. + * + * @param value The pretty string. + * @return The value or an empty optional if there is no corresponding value. + */ public static Optional getValueOf(String value) { return Arrays.stream(Value.values()).filter(v -> v.m_prettyValue.equals(value)).findFirst(); } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotBase.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotBase.java index 4d22d2a051..855b118deb 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotBase.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotBase.java @@ -178,6 +178,11 @@ public abstract class RobotBase implements AutoCloseable { Shuffleboard.disableActuatorWidgets(); } + /** + * Returns the main thread ID. + * + * @return The main thread ID. + */ public static long getMainThreadId() { return m_threadId; } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotState.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotState.java index 44198df1a1..405dfc4bc3 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotState.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotState.java @@ -4,6 +4,7 @@ package edu.wpi.first.wpilibj; +/** Robot state utility functions. */ public final class RobotState { /** * Returns true if the robot is disabled. diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/RuntimeType.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/RuntimeType.java index bd9e4d795a..cad1c51b83 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/RuntimeType.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/RuntimeType.java @@ -6,14 +6,16 @@ package edu.wpi.first.wpilibj; import edu.wpi.first.hal.HALUtil; +/** Runtime type. */ public enum RuntimeType { - /** RoboRio 1.0. */ + /** roboRIO 1.0. */ kRoboRIO(HALUtil.RUNTIME_ROBORIO), - /** RoboRio 2.0. */ + /** roboRIO 2.0. */ kRoboRIO2(HALUtil.RUNTIME_ROBORIO2), /** Simulation runtime. */ kSimulation(HALUtil.RUNTIME_SIMULATION); + /** RuntimeType value. */ public final int value; RuntimeType(int value) { diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/SPI.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/SPI.java index 8f19ec3fe2..1a3bb345a0 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/SPI.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/SPI.java @@ -27,6 +27,7 @@ public class SPI implements AutoCloseable { /** MXP (roboRIO MXP) SPI bus port. */ kMXP(SPIJNI.MXP_PORT); + /** SPI port value. */ public final int value; Port(int value) { @@ -45,6 +46,7 @@ public class SPI implements AutoCloseable { /** Clock idle high, data sampled on rising edge. */ kMode3(SPIJNI.SPI_MODE3); + /** SPI mode value. */ public final int value; Mode(int value) { @@ -71,6 +73,11 @@ public class SPI implements AutoCloseable { HAL.report(tResourceType.kResourceType_SPI, port.value + 1); } + /** + * Returns the SPI port value. + * + * @return SPI port value. + */ public int getPort() { return m_port; } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/SensorUtil.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/SensorUtil.java index 18ee44e975..258fbc7c60 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/SensorUtil.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/SensorUtil.java @@ -47,8 +47,10 @@ public final class SensorUtil { /** Number of PCM Modules. */ public static final int kCTREPCMModules = PortsJNI.getNumCTREPCMModules(); + /** Number of power distribution channels per PH. */ public static final int kREVPHChannels = PortsJNI.getNumREVPHChannels(); + /** Number of PH modules. */ public static final int kREVPHModules = PortsJNI.getNumREVPHModules(); /** diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/SerialPort.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/SerialPort.java index deafb4f737..d978d783da 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/SerialPort.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/SerialPort.java @@ -26,6 +26,7 @@ public class SerialPort implements AutoCloseable { /** USB serial port 2. */ kUSB2(3); + /** Port value. */ public final int value; Port(int value) { @@ -46,6 +47,7 @@ public class SerialPort implements AutoCloseable { /** Parity bit always off. */ kSpace(4); + /** Parity value. */ public final int value; Parity(int value) { @@ -62,6 +64,7 @@ public class SerialPort implements AutoCloseable { /** Two stop bits. */ kTwo(20); + /** StopBits value. */ public final int value; StopBits(int value) { @@ -80,6 +83,7 @@ public class SerialPort implements AutoCloseable { /** DTS/DSR flow control. */ kDtsDsr(4); + /** FlowControl value. */ public final int value; FlowControl(int value) { @@ -94,6 +98,7 @@ public class SerialPort implements AutoCloseable { /** Flush the buffer when it is full. */ kFlushWhenFull(2); + /** WriteBufferMode value. */ public final int value; WriteBufferMode(int value) { diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Servo.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Servo.java index 10f07a1d08..ebd2a8bb6c 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Servo.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Servo.java @@ -23,10 +23,10 @@ public class Servo extends PWM { private static final int kDefaultMinServoPWM = 600; /** - * Constructor.
+ * Constructor. * - *

By default {@value #kDefaultMaxServoPWM} ms is used as the maxPWM value
- * By default {@value #kDefaultMinServoPWM} ms is used as the minPWM value
+ *

By default, {@value #kDefaultMaxServoPWM} ms is used as the max PWM value and {@value + * #kDefaultMinServoPWM} ms is used as the minPWM value. * * @param channel The PWM channel to which the servo is attached. 0-9 are on-board, 10-19 are on * the MXP port diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/StadiaController.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/StadiaController.java index d7bb16473a..d092d8b937 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/StadiaController.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/StadiaController.java @@ -50,6 +50,7 @@ public class StadiaController extends GenericHID { /** Frame button. */ kFrame(15); + /** Button value. */ public final int value; Button(int value) { @@ -85,6 +86,7 @@ public class StadiaController extends GenericHID { /** Right Y axis. */ kRightY(4); + /** Axis value. */ public final int value; Axis(int value) { diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/SynchronousInterrupt.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/SynchronousInterrupt.java index 45a978fb04..8f7886515f 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/SynchronousInterrupt.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/SynchronousInterrupt.java @@ -32,6 +32,7 @@ public class SynchronousInterrupt implements AutoCloseable { /** Both rising and falling edge events. */ kBoth(0x101); + /** WaitResult value. */ public final int value; WaitResult(int value) { diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Threads.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Threads.java index 8b0d1670f9..5ff0540dbf 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Threads.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Threads.java @@ -6,6 +6,7 @@ package edu.wpi.first.wpilibj; import edu.wpi.first.hal.ThreadsJNI; +/** Thread utility functions. */ public final class Threads { /** * Get the thread priority for the current thread. diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/TimedRobot.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/TimedRobot.java index 9bce0bc6c4..12346c445a 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/TimedRobot.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/TimedRobot.java @@ -65,6 +65,7 @@ public class TimedRobot extends IterativeRobotBase { } } + /** Default loop period. */ public static final double kDefaultPeriod = 0.02; // The C pointer to the notifier object. We don't use it directly, it is diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Ultrasonic.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Ultrasonic.java index c5aab1f787..a7b5e71b56 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Ultrasonic.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Ultrasonic.java @@ -108,6 +108,11 @@ public class Ultrasonic implements Sendable, AutoCloseable { SendableRegistry.addLW(this, "Ultrasonic", m_echoChannel.getChannel()); } + /** + * Returns the echo channel. + * + * @return The echo channel. + */ public int getEchoChannel() { return m_echoChannel.getChannel(); } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/counter/EdgeConfiguration.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/counter/EdgeConfiguration.java index d8200d082f..c969249aaf 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/counter/EdgeConfiguration.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/counter/EdgeConfiguration.java @@ -15,9 +15,11 @@ public enum EdgeConfiguration { /** Both rising and falling edge configuration. */ kBoth(true, true); + /** True if triggering on rising edge. */ @SuppressWarnings("MemberName") public final boolean rising; + /** True if triggering on falling edge. */ @SuppressWarnings("MemberName") public final boolean falling; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/DifferentialDrive.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/DifferentialDrive.java index 69e27672a9..2199aa827d 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/DifferentialDrive.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/DifferentialDrive.java @@ -71,7 +71,10 @@ public class DifferentialDrive extends RobotDriveBase implements Sendable, AutoC */ @SuppressWarnings("MemberName") public static class WheelSpeeds { + /** Left wheel speed. */ public double left; + + /** Right wheel speed. */ public double right; /** Constructs a WheelSpeeds with zeroes for left and right speeds. */ diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/MecanumDrive.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/MecanumDrive.java index 2c74f0bde2..236a4fbe93 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/MecanumDrive.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/MecanumDrive.java @@ -77,9 +77,16 @@ public class MecanumDrive extends RobotDriveBase implements Sendable, AutoClosea */ @SuppressWarnings("MemberName") public static class WheelSpeeds { + /** Front-left wheel speed. */ public double frontLeft; + + /** Front-right wheel speed. */ public double frontRight; + + /** Rear-left wheel speed. */ public double rearLeft; + + /** Rear-right wheel speed. */ public double rearRight; /** Constructs a WheelSpeeds with zeroes for all four speeds. */ diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/RobotDriveBase.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/RobotDriveBase.java index 204d89f0d6..a952b2ecaa 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/RobotDriveBase.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/drive/RobotDriveBase.java @@ -12,10 +12,16 @@ import edu.wpi.first.wpilibj.MotorSafety; *

{@link edu.wpi.first.wpilibj.MotorSafety} is enabled by default. */ public abstract class RobotDriveBase extends MotorSafety { + /** Default input deadband. */ public static final double kDefaultDeadband = 0.02; + + /** Default maximum output. */ public static final double kDefaultMaxOutput = 1.0; + /** Input deadband. */ protected double m_deadband = kDefaultDeadband; + + /** Maximum output. */ protected double m_maxOutput = kDefaultMaxOutput; /** The location of a motor on the robot for the purpose of driving. */ @@ -35,6 +41,7 @@ public abstract class RobotDriveBase extends MotorSafety { /** Back motor. */ kBack(2); + /** MotorType value. */ public final int value; MotorType(int value) { diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/internal/DriverStationModeThread.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/internal/DriverStationModeThread.java index 03d6397394..57c6bf7ddf 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/internal/DriverStationModeThread.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/internal/DriverStationModeThread.java @@ -9,9 +9,7 @@ import edu.wpi.first.util.WPIUtilJNI; import edu.wpi.first.wpilibj.DriverStation; import java.util.concurrent.atomic.AtomicBoolean; -/* - * For internal use only. - */ +/** For internal use only. */ public class DriverStationModeThread implements AutoCloseable { private final AtomicBoolean m_keepAlive = new AtomicBoolean(); private final Thread m_thread; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/livewindow/LiveWindow.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/livewindow/LiveWindow.java index 018c4d2ac2..1b9d1ea24a 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/livewindow/LiveWindow.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/livewindow/LiveWindow.java @@ -67,14 +67,29 @@ public final class LiveWindow { throw new UnsupportedOperationException("This is a utility class!"); } + /** + * Sets function to be called when LiveWindow is enabled. + * + * @param runnable function (or null for none) + */ public static synchronized void setEnabledListener(Runnable runnable) { enabledListener = runnable; } + /** + * Sets function to be called when LiveWindow is disabled. + * + * @param runnable function (or null for none) + */ public static synchronized void setDisabledListener(Runnable runnable) { disabledListener = runnable; } + /** + * Returns true if LiveWindow is enabled. + * + * @return True if LiveWindow is enabled. + */ public static synchronized boolean isEnabled() { return liveWindowEnabled; } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/MotorControllerGroup.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/MotorControllerGroup.java index 50bb0a8e3e..a499c3960d 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/MotorControllerGroup.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/MotorControllerGroup.java @@ -37,6 +37,11 @@ public class MotorControllerGroup implements MotorController, Sendable, AutoClos init(); } + /** + * Create a new MotorControllerGroup with the provided MotorControllers. + * + * @param motorControllers The MotorControllers to add. + */ @SuppressWarnings("this-escape") public MotorControllerGroup(MotorController[] motorControllers) { m_motorControllers = Arrays.copyOf(motorControllers, motorControllers.length); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/PWMMotorController.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/PWMMotorController.java index 2f1bff790b..b72cee344f 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/PWMMotorController.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/motorcontrol/PWMMotorController.java @@ -17,6 +17,8 @@ public abstract class PWMMotorController extends MotorSafety implements MotorController, Sendable, AutoCloseable { private boolean m_isInverted; private final ArrayList m_followers = new ArrayList<>(); + + /** PWM instances for motor controller. */ protected PWM m_pwm; /** diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/EventImportance.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/EventImportance.java index 4d64efe55d..0d85ce69dc 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/EventImportance.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/EventImportance.java @@ -38,6 +38,11 @@ public enum EventImportance { m_simpleName = simpleName; } + /** + * Returns name of the given enum. + * + * @return Name of the given enum. + */ public String getSimpleName() { return m_simpleName; } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/SendableCameraWrapper.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/SendableCameraWrapper.java index 150f0dbb6c..bd428cdd00 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/SendableCameraWrapper.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/SendableCameraWrapper.java @@ -74,7 +74,7 @@ public final class SendableCameraWrapper implements Sendable, AutoCloseable { } } - /* + /** * Sets NetworkTable instance used for camera publisher entries. * * @param inst NetworkTable instance diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ShuffleboardComponent.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ShuffleboardComponent.java index 39078f439e..3e1f75acd8 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ShuffleboardComponent.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/shuffleboard/ShuffleboardComponent.java @@ -26,25 +26,53 @@ public abstract class ShuffleboardComponent> private int m_width = -1; private int m_height = -1; + /** + * Constructs a ShuffleboardComponent. + * + * @param parent The parent container. + * @param title The component title. + * @param type The component type. + */ protected ShuffleboardComponent(ShuffleboardContainer parent, String title, String type) { m_parent = requireNonNullParam(parent, "parent", "ShuffleboardComponent"); m_title = requireNonNullParam(title, "title", "ShuffleboardComponent"); m_type = type; } + /** + * Constructs a ShuffleboardComponent. + * + * @param parent The parent container. + * @param title The component title. + */ protected ShuffleboardComponent(ShuffleboardContainer parent, String title) { this(parent, title, null); } + /** + * Returns the parent container. + * + * @return The parent container. + */ public final ShuffleboardContainer getParent() { return m_parent; } + /** + * Sets the component type. + * + * @param type The component type. + */ protected final void setType(String type) { m_type = type; m_metadataDirty = true; } + /** + * Returns the component type. + * + * @return The component type. + */ public final String getType() { return m_type; } @@ -109,6 +137,11 @@ public abstract class ShuffleboardComponent> return (C) this; } + /** + * Builds NT metadata. + * + * @param metaTable The NT metadata table. + */ protected final void buildMetadata(NetworkTable metaTable) { if (!m_metadataDirty) { return; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/DifferentialDrivetrainSim.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/DifferentialDrivetrainSim.java index de2e2f271f..a1216598f2 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/DifferentialDrivetrainSim.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/DifferentialDrivetrainSim.java @@ -301,6 +301,13 @@ public class DifferentialDrivetrainSim { m_x.set(State.kRightPosition.value, 0, 0); } + /** + * The differential drive dynamics function. + * + * @param x The state. + * @param u The input. + * @return The state derivative with respect to time. + */ protected Matrix getDynamics(Matrix x, Matrix u) { // Because G can be factored out of B, we can divide by the old ratio and multiply // by the new ratio to get a new drivetrain model. @@ -380,6 +387,7 @@ public class DifferentialDrivetrainSim { /** Gear ratio of 5.95:1. */ k5p95(5.95); + /** KitbotGearing value. */ public final double value; KitbotGearing(double i) { @@ -406,6 +414,7 @@ public class DifferentialDrivetrainSim { /** Two NEO motors per drive side. */ kDoubleNEOPerSide(DCMotor.getNEO(2)); + /** KitbotMotor value. */ public final DCMotor value; KitbotMotor(DCMotor i) { @@ -422,6 +431,7 @@ public class DifferentialDrivetrainSim { /** Ten inch diameter wheels. */ kTenInch(Units.inchesToMeters(10)); + /** KitbotWheelSize value. */ public final double value; KitbotWheelSize(double i) { diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/GenericHIDSim.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/GenericHIDSim.java index 67ceda766e..9c81be88bd 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/GenericHIDSim.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/GenericHIDSim.java @@ -8,6 +8,7 @@ import edu.wpi.first.wpilibj.GenericHID; /** Class to control a simulated generic joystick. */ public class GenericHIDSim { + /** GenericHID port. */ protected final int m_port; /** diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/LinearSystemSim.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/LinearSystemSim.java index 3a6a4e7cfb..cc4db9cb2e 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/LinearSystemSim.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/LinearSystemSim.java @@ -28,16 +28,19 @@ import org.ejml.simple.SimpleMatrix; * @param Number of outputs of the system. */ public class LinearSystemSim { - // The plant that represents the linear system. + /** The plant that represents the linear system. */ protected final LinearSystem m_plant; - // Variables for state, output, and input. + /** State vector. */ protected Matrix m_x; - protected Matrix m_y; + + /** Input vector. */ protected Matrix m_u; - // The standard deviations of measurements, used for adding noise - // to the measurements. + /** Output vector. */ + protected Matrix m_y; + + /** The standard deviations of measurements, used for adding noise to the measurements. */ protected final Matrix m_measurementStdDevs; /** diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/PneumaticsBaseSim.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/PneumaticsBaseSim.java index 156562b48a..dde69c1891 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/PneumaticsBaseSim.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/PneumaticsBaseSim.java @@ -10,6 +10,7 @@ import edu.wpi.first.wpilibj.PneumaticsModuleType; /** Common base class for pneumatics module simulation classes. */ public abstract class PneumaticsBaseSim { + /** PneumaticsBase index. */ protected final int m_index; /** @@ -30,10 +31,20 @@ public abstract class PneumaticsBaseSim { } } + /** + * Constructs a PneumaticsBaseSim with the given index. + * + * @param index The index. + */ protected PneumaticsBaseSim(int index) { m_index = index; } + /** + * Constructs a PneumaticsBaseSim for the given module. + * + * @param module The module. + */ protected PneumaticsBaseSim(PneumaticsBase module) { this(module.getModuleNumber()); } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/SPISim.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/SPISim.java index 6c0b9e99b5..8ce955418a 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/SPISim.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/SPISim.java @@ -74,6 +74,13 @@ public class SPISim { return new CallbackStore(m_index, uid, SPIDataJNI::cancelWriteCallback); } + /** + * Register a callback to be run whenever an auto receive buffer is received. + * + * @param callback the callback + * @return the {@link CallbackStore} object associated with this callback. Save a reference to + * this object so GC doesn't cancel the callback. + */ public CallbackStore registerReadAutoReceiveBufferCallback( SpiReadAutoReceiveBufferCallback callback) { int uid = SPIDataJNI.registerReadAutoReceiveBufferCallback(m_index, callback); diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/SimHooks.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/SimHooks.java index 053d646b80..f637b01d70 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/SimHooks.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/SimHooks.java @@ -19,14 +19,21 @@ public final class SimHooks { SimulatorJNI.setRuntimeType(type); } + /** Waits until the user program has started. */ public static void waitForProgramStart() { SimulatorJNI.waitForProgramStart(); } + /** Sets that the user program has started. */ public static void setProgramStarted() { SimulatorJNI.setProgramStarted(); } + /** + * Returns true if the user program has started. + * + * @return True if the user program has started. + */ public static boolean getProgramStarted() { return SimulatorJNI.getProgramStarted(); } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/UltrasonicSim.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/UltrasonicSim.java index dc4ebaade1..2ad42e7afa 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/UltrasonicSim.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/UltrasonicSim.java @@ -36,14 +36,29 @@ public class UltrasonicSim { m_simRange = simDevice.getDouble("Range (in)"); } + /** + * Sets if the range measurement is valid. + * + * @param valid True if valid + */ public void setRangeValid(boolean valid) { m_simRangeValid.set(valid); } + /** + * Sets the range measurement. + * + * @param inches The range in inches. + */ public void setRangeInches(double inches) { m_simRange.set(inches); } + /** + * Sets the range measurement. + * + * @param meters The range in meters. + */ public void setRangeMeters(double meters) { m_simRange.set(Units.metersToInches(meters)); } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/MechanismObject2d.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/MechanismObject2d.java index 754bd9256c..3dbcf5c11c 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/MechanismObject2d.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/MechanismObject2d.java @@ -74,6 +74,11 @@ public abstract class MechanismObject2d implements AutoCloseable { */ protected abstract void updateEntries(NetworkTable table); + /** + * Retrieve the object's name. + * + * @return the object's name relative to its parent. + */ public final String getName() { return m_name; } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilderImpl.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilderImpl.java index 94546e9ea1..f15198fd10 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilderImpl.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilderImpl.java @@ -57,6 +57,7 @@ import java.util.function.LongConsumer; import java.util.function.LongSupplier; import java.util.function.Supplier; +/** Implementation detail for SendableBuilder. */ @SuppressWarnings("PMD.CompareObjectsWithEquals") public class SendableBuilderImpl implements NTSendableBuilder { @FunctionalInterface