Package edu.wpi.first.wpilibj.simulation
Class AddressableLEDSim
java.lang.Object
edu.wpi.first.wpilibj.simulation.AddressableLEDSim
Class to control a simulated addressable LED.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs for the first addressable LED.AddressableLEDSim(AddressableLED addressableLED) Constructs from an AddressableLED object. -
Method Summary
Modifier and TypeMethodDescriptionstatic AddressableLEDSimcreateForChannel(int pwmChannel) Creates an AddressableLEDSim for a PWM channel.static AddressableLEDSimcreateForIndex(int index) Creates an AddressableLEDSim for a simulated index.byte[]getData()Get the LED data.booleanCheck if initialized.intGet the length of the LED strip.intGet the output port.booleanCheck if the LEDs are running.registerDataCallback(ConstBufferCallback callback) Register a callback on the LED data.registerInitializedCallback(NotifyCallback callback, boolean initialNotify) Register a callback on the Initialized property.registerLengthCallback(NotifyCallback callback, boolean initialNotify) Register a callback on the length.registerOutputPortCallback(NotifyCallback callback, boolean initialNotify) Register a callback on the output port.registerRunningCallback(NotifyCallback callback, boolean initialNotify) Register a callback on whether the LEDs are running.voidReset all simulation data for this LED object.voidsetData(byte[] data) Change the LED data.voidsetInitialized(boolean initialized) Change the Initialized value of the LED strip.voidsetLength(int length) Change the length of the LED strip.voidsetOutputPort(int outputPort) Change the output port.voidsetRunning(boolean running) Change whether the LEDs are active.
-
Constructor Details
-
AddressableLEDSim
public AddressableLEDSim()Constructs for the first addressable LED. -
AddressableLEDSim
Constructs from an AddressableLED object.- Parameters:
addressableLED- AddressableLED to simulate
-
-
Method Details
-
createForChannel
Creates an AddressableLEDSim for a PWM channel.- Parameters:
pwmChannel- PWM channel- Returns:
- Simulated object
- Throws:
NoSuchElementException- if no AddressableLED is configured for that channel
-
createForIndex
Creates an AddressableLEDSim for a simulated index. The index is incremented for each simulated AddressableLED.- Parameters:
index- simulator index- Returns:
- Simulated object
-
registerInitializedCallback
Register a callback on the Initialized property.- Parameters:
callback- the callback that will be called whenever the Initialized property is changedinitialNotify- if true, the callback will be run on the initial value- Returns:
- the
CallbackStoreobject associated with this callback.
-
getInitialized
Check if initialized.- Returns:
- true if initialized
-
setInitialized
Change the Initialized value of the LED strip.- Parameters:
initialized- the new value
-
registerOutputPortCallback
Register a callback on the output port.- Parameters:
callback- the callback that will be called whenever the output port is changedinitialNotify- if true, the callback will be run on the initial value- Returns:
- the
CallbackStoreobject associated with this callback.
-
getOutputPort
Get the output port.- Returns:
- the output port
-
setOutputPort
Change the output port.- Parameters:
outputPort- the new output port
-
registerLengthCallback
Register a callback on the length.- Parameters:
callback- the callback that will be called whenever the length is changedinitialNotify- if true, the callback will be run on the initial value- Returns:
- the
CallbackStoreobject associated with this callback.
-
getLength
Get the length of the LED strip.- Returns:
- the length
-
setLength
Change the length of the LED strip.- Parameters:
length- the new value
-
registerRunningCallback
Register a callback on whether the LEDs are running.- Parameters:
callback- the callback that will be called whenever the LED state is changedinitialNotify- if true, the callback will be run on the initial value- Returns:
- the
CallbackStoreobject associated with this callback.
-
getRunning
Check if the LEDs are running.- Returns:
- true if they are
-
setRunning
Change whether the LEDs are active.- Parameters:
running- the new value
-
registerDataCallback
Register a callback on the LED data.- Parameters:
callback- the callback that will be called whenever the LED data is changed- Returns:
- the
CallbackStoreobject associated with this callback.
-
getData
Get the LED data.- Returns:
- the LED data
-
setData
Change the LED data.- Parameters:
data- the new data
-
resetData
Reset all simulation data for this LED object.
-