![]() |
WPILibC++ 2027.0.0-alpha-2
|
Class implements the PWM generation in the FPGA. More...
#include <frc/PWM.h>
Public Types | |
enum | OutputPeriod { kOutputPeriod_5Ms = 1 , kOutputPeriod_10Ms = 2 , kOutputPeriod_20Ms = 4 } |
Represents the output period in microseconds. More... | |
Public Member Functions | |
PWM (int channel, bool registerSendable=true) | |
Allocate a PWM given a channel number. | |
PWM (PWM &&)=default | |
PWM & | operator= (PWM &&)=default |
~PWM () override | |
Free the PWM channel. | |
void | SetPulseTime (units::microsecond_t time) |
Set the PWM pulse time directly to the hardware. | |
units::microsecond_t | GetPulseTime () const |
Get the PWM pulse time directly from the hardware. | |
void | SetDisabled () |
Temporarily disables the PWM output. | |
void | SetOutputPeriod (OutputPeriod mult) |
Sets the PWM output period. | |
int | GetChannel () const |
void | SetSimDevice (HAL_SimDeviceHandle device) |
Indicates this input is used by a simulated device. | |
![]() | |
virtual constexpr | ~Sendable ()=default |
![]() | |
constexpr | SendableHelper (const SendableHelper &rhs)=default |
constexpr | SendableHelper (SendableHelper &&rhs) |
constexpr SendableHelper & | operator= (const SendableHelper &rhs)=default |
constexpr SendableHelper & | operator= (SendableHelper &&rhs) |
Protected Member Functions | |
void | InitSendable (wpi::SendableBuilder &builder) override |
Initializes this Sendable object. | |
![]() | |
constexpr | SendableHelper ()=default |
constexpr | ~SendableHelper () |
Friends | |
class | AddressableLED |
Class implements the PWM generation in the FPGA.
The values supplied as arguments for PWM outputs range from -1.0 to 1.0. They are mapped to the microseconds to keep the pulse high, with a range of 0 (off) to 4096. Changes are immediately sent to the FPGA, and the update occurs at the next FPGA cycle (5.05ms). There is no delay.
|
explicit |
Allocate a PWM given a channel number.
Checks channel value range and allocates the appropriate channel. The allocation is only done to help users ensure that they don't double assign channels.
channel | The PWM channel number. 0-9 are on-board, 10-19 are on the MXP port |
registerSendable | If true, adds this instance to SendableRegistry |
|
default |
|
override |
int frc::PWM::GetChannel | ( | ) | const |
units::microsecond_t frc::PWM::GetPulseTime | ( | ) | const |
|
overrideprotectedvirtual |
void frc::PWM::SetDisabled | ( | ) |
Temporarily disables the PWM output.
The next set call will re-enable the output.
void frc::PWM::SetOutputPeriod | ( | OutputPeriod | mult | ) |
Sets the PWM output period.
mult | The output period to apply to this channel |
void frc::PWM::SetPulseTime | ( | units::microsecond_t | time | ) |
void frc::PWM::SetSimDevice | ( | HAL_SimDeviceHandle | device | ) |
Indicates this input is used by a simulated device.
device | simulated device handle |
|
friend |