[wpilib] PWMSpeedController: Use PWM by composition (#3248)

This cleans up the user experience by removing lower-level functions from the
interface.

Also remove MotorSafety from "raw" PWM.
This commit is contained in:
Peter Johnson
2021-03-21 11:12:49 -07:00
committed by GitHub
parent 160fb740f4
commit 9550777b9d
32 changed files with 242 additions and 252 deletions

View File

@@ -7,9 +7,8 @@
#include <stdint.h>
#include <hal/Types.h>
#include <wpi/raw_ostream.h>
#include "frc/MotorSafety.h"
#include "frc/ErrorBase.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
@@ -34,7 +33,7 @@ class SendableBuilder;
* - 1 = minimum pulse width (currently 0.5ms)
* - 0 = disabled (i.e. PWM output is held low)
*/
class PWM : public MotorSafety, public Sendable, public SendableHelper<PWM> {
class PWM : public ErrorBase, public Sendable, public SendableHelper<PWM> {
public:
friend class AddressableLED;
/**
@@ -64,8 +63,10 @@ class PWM : public MotorSafety, public Sendable, public SendableHelper<PWM> {
*
* @param channel The PWM channel number. 0-9 are on-board, 10-19 are on the
* MXP port
* @param registerSendable If true, adds this instance to SendableRegistry
* and LiveWindow
*/
explicit PWM(int channel);
explicit PWM(int channel, bool registerSendable = true);
/**
* Free the PWM channel.
@@ -77,10 +78,6 @@ class PWM : public MotorSafety, public Sendable, public SendableHelper<PWM> {
PWM(PWM&&) = default;
PWM& operator=(PWM&&) = default;
// MotorSafety interface
void StopMotor() override;
void GetDescription(wpi::raw_ostream& desc) const override;
/**
* Set the PWM value directly to the hardware.
*