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

Class to control a simulated addressable LED. More...

#include <frc/simulation/AddressableLEDSim.h>

Public Member Functions

 AddressableLEDSim ()
 Constructs for the first addressable LED. More...
 
 AddressableLEDSim (const AddressableLED &addressableLED)
 Constructs from an AddressableLED object. More...
 
std::unique_ptr< CallbackStoreRegisterInitializedCallback (NotifyCallback callback, bool initialNotify)
 Register a callback on the Initialized property. More...
 
bool GetInitialized () const
 Check if initialized. More...
 
void SetInitialized (bool initialized)
 Change the Initialized value of the LED strip. More...
 
std::unique_ptr< CallbackStoreRegisterOutputPortCallback (NotifyCallback callback, bool initialNotify)
 Register a callback on the output port. More...
 
int GetOutputPort () const
 Get the output port. More...
 
void SetOutputPort (int outputPort)
 Change the output port. More...
 
std::unique_ptr< CallbackStoreRegisterLengthCallback (NotifyCallback callback, bool initialNotify)
 Register a callback on the length. More...
 
int GetLength () const
 Get the length of the LED strip. More...
 
void SetLength (int length)
 Change the length of the LED strip. More...
 
std::unique_ptr< CallbackStoreRegisterRunningCallback (NotifyCallback callback, bool initialNotify)
 Register a callback on whether the LEDs are running. More...
 
int GetRunning () const
 Check if the LEDs are running. More...
 
void SetRunning (bool running)
 Change whether the LEDs are active. More...
 
std::unique_ptr< CallbackStoreRegisterDataCallback (ConstBufferCallback callback, bool initialNotify)
 Register a callback on the LED data. More...
 
int GetData (struct HAL_AddressableLEDData *data) const
 Get the LED data. More...
 
void SetData (struct HAL_AddressableLEDData *data, int length)
 Change the LED data. More...
 

Static Public Member Functions

static AddressableLEDSim CreateForChannel (int pwmChannel)
 Creates an AddressableLEDSim for a PWM channel. More...
 
static AddressableLEDSim CreateForIndex (int index)
 Creates an AddressableLEDSim for a simulated index. More...
 

Detailed Description

Class to control a simulated addressable LED.

Constructor & Destructor Documentation

◆ AddressableLEDSim() [1/2]

frc::sim::AddressableLEDSim::AddressableLEDSim ( )

Constructs for the first addressable LED.

◆ AddressableLEDSim() [2/2]

frc::sim::AddressableLEDSim::AddressableLEDSim ( const AddressableLED addressableLED)
explicit

Constructs from an AddressableLED object.

Parameters
addressableLEDAddressableLED to simulate

Member Function Documentation

◆ CreateForChannel()

static AddressableLEDSim frc::sim::AddressableLEDSim::CreateForChannel ( int  pwmChannel)
static

Creates an AddressableLEDSim for a PWM channel.

Parameters
pwmChannelPWM channel
Returns
Simulated object
Exceptions
std::out_of_rangeif no AddressableLED is configured for that channel

◆ CreateForIndex()

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

Creates an AddressableLEDSim for a simulated index.

The index is incremented for each simulated AddressableLED.

Parameters
indexsimulator index
Returns
Simulated object

◆ GetData()

int frc::sim::AddressableLEDSim::GetData ( struct HAL_AddressableLEDData data) const

Get the LED data.

Parameters
dataoutput parameter to fill with LED data
Returns
the length of the LED data

◆ GetInitialized()

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

Check if initialized.

Returns
true if initialized

◆ GetLength()

int frc::sim::AddressableLEDSim::GetLength ( ) const

Get the length of the LED strip.

Returns
the length

◆ GetOutputPort()

int frc::sim::AddressableLEDSim::GetOutputPort ( ) const

Get the output port.

Returns
the output port

◆ GetRunning()

int frc::sim::AddressableLEDSim::GetRunning ( ) const

Check if the LEDs are running.

Returns
true if they are

◆ RegisterDataCallback()

std::unique_ptr< CallbackStore > frc::sim::AddressableLEDSim::RegisterDataCallback ( ConstBufferCallback  callback,
bool  initialNotify 
)

Register a callback on the LED data.

Parameters
callbackthe callback that will be called whenever the LED data is changed
initialNotifyif true, the callback will be run on the initial value
Returns
the CallbackStore object associated with this callback

◆ RegisterInitializedCallback()

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

Register a callback on the Initialized property.

Parameters
callbackthe callback that will be called whenever the Initialized property is changed
initialNotifyif true, the callback will be run on the initial value
Returns
the CallbackStore object storing this callback

◆ RegisterLengthCallback()

std::unique_ptr< CallbackStore > frc::sim::AddressableLEDSim::RegisterLengthCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback on the length.

Parameters
callbackthe callback that will be called whenever the length is changed
initialNotifyif true, the callback will be run on the initial value
Returns
the CallbackStore object associated with this callback

◆ RegisterOutputPortCallback()

std::unique_ptr< CallbackStore > frc::sim::AddressableLEDSim::RegisterOutputPortCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback on the output port.

Parameters
callbackthe callback that will be called whenever the output port is changed
initialNotifyif true, the callback will be run on the initial value
Returns
the CallbackStore object associated with this callback

◆ RegisterRunningCallback()

std::unique_ptr< CallbackStore > frc::sim::AddressableLEDSim::RegisterRunningCallback ( NotifyCallback  callback,
bool  initialNotify 
)

Register a callback on whether the LEDs are running.

Parameters
callbackthe callback that will be called whenever the LED state is changed
initialNotifyif true, the callback will be run on the initial value
Returns
the CallbackStore object associated with this callback

◆ SetData()

void frc::sim::AddressableLEDSim::SetData ( struct HAL_AddressableLEDData data,
int  length 
)

Change the LED data.

Parameters
datathe new data
lengththe length of the LED data

◆ SetInitialized()

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

Change the Initialized value of the LED strip.

Parameters
initializedthe new value

◆ SetLength()

void frc::sim::AddressableLEDSim::SetLength ( int  length)

Change the length of the LED strip.

Parameters
lengththe new value

◆ SetOutputPort()

void frc::sim::AddressableLEDSim::SetOutputPort ( int  outputPort)

Change the output port.

Parameters
outputPortthe new output port

◆ SetRunning()

void frc::sim::AddressableLEDSim::SetRunning ( bool  running)

Change whether the LEDs are active.

Parameters
runningthe new value

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