12 #include <hal/Types.h>
13 #include <wpi/raw_ostream.h>
15 #include "frc/MotorSafety.h"
16 #include "frc/smartdashboard/Sendable.h"
17 #include "frc/smartdashboard/SendableHelper.h"
21 class SendableBuilder;
71 explicit PWM(
int channel);
81 PWM& operator=(
PWM&&) =
default;
84 void StopMotor()
override;
94 virtual void SetRaw(uint16_t value);
103 virtual uint16_t
GetRaw()
const;
142 virtual void SetSpeed(
double speed);
196 void SetBounds(
double max,
double deadbandMax,
double center,
197 double deadbandMin,
double min);
212 void SetRawBounds(
int max,
int deadbandMax,
int center,
int deadbandMin,
228 void GetRawBounds(int32_t* max, int32_t* deadbandMax, int32_t* center,
229 int32_t* deadbandMin, int32_t* min);
231 int GetChannel()
const;
238 hal::Handle<HAL_DigitalHandle> m_handle;
Class implements the PWM generation in the FPGA.
Definition: PWM.h:40
void EnableDeadbandElimination(bool eliminateDeadband)
Optionally eliminate the deadband from a speed controller.
void SetBounds(double max, double deadbandMax, double center, double deadbandMin, double min)
Set the bounds on the PWM pulse widths.
Don't skip pulses.
Definition: PWM.h:50
virtual uint16_t GetRaw() const
Get the PWM value directly from the hardware.
Skip every other pulse.
Definition: PWM.h:54
virtual void SetSpeed(double speed)
Set the PWM value based on a speed.
This base class runs a watchdog timer and calls the subclass's StopMotor() function if the timeout ex...
Definition: MotorSafety.h:24
PWM(int channel)
Allocate a PWM given a channel number.
virtual double GetSpeed() const
Get the PWM value in terms of speed.
virtual void SetPosition(double pos)
Set the PWM value based on a position.
PeriodMultiplier
Represents the amount to multiply the minimum servo-pulse pwm period by.
Definition: PWM.h:46
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
void SetPeriodMultiplier(PeriodMultiplier mult)
Slow down the PWM signal for old devices.
~PWM() override
Free the PWM channel.
Interface for Sendable objects.
Definition: Sendable.h:17
void GetRawBounds(int32_t *max, int32_t *deadbandMax, int32_t *center, int32_t *deadbandMin, int32_t *min)
Get the bounds on the PWM values.
virtual void SetDisabled()
Temporarily disables the PWM output.
A class that enforces constraints on the differential drive kinematics.
Definition: SPIAccelerometerSim.h:16
virtual void SetRaw(uint16_t value)
Set the PWM value directly to the hardware.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:47
A class for driving addressable LEDs, such as WS2812s and NeoPixels.
Definition: AddressableLED.h:28
virtual double GetPosition() const
Get the PWM value in terms of a position.
void SetRawBounds(int max, int deadbandMax, int center, int deadbandMin, int min)
Set the bounds on the PWM values.
A helper class for use with objects that add themselves to SendableRegistry.
Definition: SendableHelper.h:28
Definition: SendableBuilder.h:23
Skip three out of four pulses.
Definition: PWM.h:58