WPILibC++ 2024.3.2
frc::sim::DigitalPWMSim Class Reference

Class to control a simulated digital PWM output. More...

#include <frc/simulation/DigitalPWMSim.h>

Public Member Functions

 DigitalPWMSim (const DigitalOutput &digitalOutput)
 Constructs from a DigitalOutput object. More...
 
std::unique_ptr< CallbackStoreRegisterInitializedCallback (NotifyCallback callback, bool initialNotify)
 Register a callback to be run when this PWM output is initialized. More...
 
bool GetInitialized () const
 Check whether this PWM output has been initialized. More...
 
void SetInitialized (bool initialized)
 Define whether this PWM output has been initialized. More...
 
std::unique_ptr< CallbackStoreRegisterDutyCycleCallback (NotifyCallback callback, bool initialNotify)
 Register a callback to be run whenever the duty cycle value changes. More...
 
double GetDutyCycle () const
 Read the duty cycle value. More...
 
void SetDutyCycle (double dutyCycle)
 Set the duty cycle value of this PWM output. More...
 
std::unique_ptr< CallbackStoreRegisterPinCallback (NotifyCallback callback, bool initialNotify)
 Register a callback to be run whenever the pin changes. More...
 
int GetPin () const
 Check the pin number. More...
 
void SetPin (int pin)
 Change the pin number. More...
 
void ResetData ()
 Reset all simulation data. More...
 

Static Public Member Functions

static DigitalPWMSim CreateForChannel (int channel)
 Creates an DigitalPWMSim for a digital I/O channel. More...
 
static DigitalPWMSim CreateForIndex (int index)
 Creates an DigitalPWMSim for a simulated index. More...
 

Detailed Description

Class to control a simulated digital PWM output.

This is for duty cycle PWM outputs on a DigitalOutput, not for the servo style PWM outputs on a PWM channel.

Constructor & Destructor Documentation

◆ DigitalPWMSim()

frc::sim::DigitalPWMSim::DigitalPWMSim ( const DigitalOutput digitalOutput)
explicit

Constructs from a DigitalOutput object.

Parameters
digitalOutputDigitalOutput to simulate

Member Function Documentation

◆ CreateForChannel()

static DigitalPWMSim frc::sim::DigitalPWMSim::CreateForChannel ( int  channel)
static

Creates an DigitalPWMSim for a digital I/O channel.

Parameters
channelDIO channel
Returns
Simulated object
Exceptions
std::out_of_rangeif no Digital PWM is configured for that channel

◆ CreateForIndex()

static DigitalPWMSim frc::sim::DigitalPWMSim::CreateForIndex ( int  index)
static

Creates an DigitalPWMSim for a simulated index.

The index is incremented for each simulated DigitalPWM.

Parameters
indexsimulator index
Returns
Simulated object

◆ GetDutyCycle()

double frc::sim::DigitalPWMSim::GetDutyCycle ( ) const

Read the duty cycle value.

Returns
the duty cycle value of this PWM output

◆ GetInitialized()

bool frc::sim::DigitalPWMSim::GetInitialized ( ) const

Check whether this PWM output has been initialized.

Returns
true if initialized

◆ GetPin()

int frc::sim::DigitalPWMSim::GetPin ( ) const

Check the pin number.

Returns
the pin number

◆ RegisterDutyCycleCallback()

std::unique_ptr< CallbackStore > frc::sim::DigitalPWMSim::RegisterDutyCycleCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback to be run whenever the duty cycle value changes.

Parameters
callbackthe callback
initialNotifywhether to call the callback with the initial state
Returns
the CallbackStore object associated with this callback

◆ RegisterInitializedCallback()

std::unique_ptr< CallbackStore > frc::sim::DigitalPWMSim::RegisterInitializedCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback to be run when this PWM output is initialized.

Parameters
callbackthe callback
initialNotifywhether to run the callback with the initial state
Returns
the CallbackStore object associated with this callback

◆ RegisterPinCallback()

std::unique_ptr< CallbackStore > frc::sim::DigitalPWMSim::RegisterPinCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback to be run whenever the pin changes.

Parameters
callbackthe callback
initialNotifywhether to call the callback with the initial state
Returns
the CallbackStore object associated with this callback

◆ ResetData()

void frc::sim::DigitalPWMSim::ResetData ( )

Reset all simulation data.

◆ SetDutyCycle()

void frc::sim::DigitalPWMSim::SetDutyCycle ( double  dutyCycle)

Set the duty cycle value of this PWM output.

Parameters
dutyCyclethe new value

◆ SetInitialized()

void frc::sim::DigitalPWMSim::SetInitialized ( bool  initialized)

Define whether this PWM output has been initialized.

Parameters
initializedwhether this object is initialized

◆ SetPin()

void frc::sim::DigitalPWMSim::SetPin ( int  pin)

Change the pin number.

Parameters
pinthe new pin number

The documentation for this class was generated from the following file: