Package edu.wpi.first.wpilibj.simulation
Class AddressableLEDSim
- java.lang.Object
-
- edu.wpi.first.wpilibj.simulation.AddressableLEDSim
-
public class AddressableLEDSim extends Object
Class to control a simulated addressable LED.
-
-
Constructor Summary
Constructors Constructor Description AddressableLEDSim()
Constructs for the first addressable LED.AddressableLEDSim(AddressableLED addressableLED)
Constructs from an AddressableLED object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AddressableLEDSim
createForChannel(int pwmChannel)
Creates an AddressableLEDSim for a PWM channel.static AddressableLEDSim
createForIndex(int index)
Creates an AddressableLEDSim for a simulated index.byte[]
getData()
Get the LED data.boolean
getInitialized()
Check if initialized.int
getLength()
Get the length of the LED strip.int
getOutputPort()
Get the output port.boolean
getRunning()
Check if the LEDs are running.CallbackStore
registerDataCallback(ConstBufferCallback callback)
Register a callback on the LED data.CallbackStore
registerInitializedCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on the Initialized property.CallbackStore
registerLengthCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on the length.CallbackStore
registerOutputPortCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on the output port.CallbackStore
registerRunningCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on whether the LEDs are running.void
resetData()
Reset all simulation data for this LED object.void
setData(byte[] data)
Change the LED data.void
setInitialized(boolean initialized)
Change the Initialized value of the LED strip.void
setLength(int length)
Change the length of the LED strip.void
setOutputPort(int outputPort)
Change the output port.void
setRunning(boolean running)
Change whether the LEDs are active.
-
-
-
Constructor Detail
-
AddressableLEDSim
public AddressableLEDSim()
Constructs for the first addressable LED.
-
AddressableLEDSim
public AddressableLEDSim(AddressableLED addressableLED)
Constructs from an AddressableLED object.- Parameters:
addressableLED
- AddressableLED to simulate
-
-
Method Detail
-
createForChannel
public static AddressableLEDSim createForChannel(int pwmChannel)
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
public static AddressableLEDSim createForIndex(int index)
Creates an AddressableLEDSim for a simulated index. The index is incremented for each simulated AddressableLED.- Parameters:
index
- simulator index- Returns:
- Simulated object
-
registerInitializedCallback
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify)
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
CallbackStore
object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getInitialized
public boolean getInitialized()
Check if initialized.- Returns:
- true if initialized
-
setInitialized
public void setInitialized(boolean initialized)
Change the Initialized value of the LED strip.- Parameters:
initialized
- the new value
-
registerOutputPortCallback
public CallbackStore registerOutputPortCallback(NotifyCallback callback, boolean initialNotify)
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
CallbackStore
object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getOutputPort
public int getOutputPort()
Get the output port.- Returns:
- the output port
-
setOutputPort
public void setOutputPort(int outputPort)
Change the output port.- Parameters:
outputPort
- the new output port
-
registerLengthCallback
public CallbackStore registerLengthCallback(NotifyCallback callback, boolean initialNotify)
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
CallbackStore
object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getLength
public int getLength()
Get the length of the LED strip.- Returns:
- the length
-
setLength
public void setLength(int length)
Change the length of the LED strip.- Parameters:
length
- the new value
-
registerRunningCallback
public CallbackStore registerRunningCallback(NotifyCallback callback, boolean initialNotify)
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
CallbackStore
object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getRunning
public boolean getRunning()
Check if the LEDs are running.- Returns:
- true if they are
-
setRunning
public void setRunning(boolean running)
Change whether the LEDs are active.- Parameters:
running
- the new value
-
registerDataCallback
public CallbackStore registerDataCallback(ConstBufferCallback callback)
Register a callback on the LED data.- Parameters:
callback
- the callback that will be called whenever the LED data is changed- Returns:
- the
CallbackStore
object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getData
public byte[] getData()
Get the LED data.- Returns:
- the LED data
-
setData
public void setData(byte[] data)
Change the LED data.- Parameters:
data
- the new data
-
resetData
public void resetData()
Reset all simulation data for this LED object.
-
-