Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Expose AddressableLEDBuffer internal bytes #7801

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,9 @@ public int getBlue(int index) {
public AddressableLEDBufferView createView(int startingIndex, int endingIndex) {
return new AddressableLEDBufferView(this, startingIndex, endingIndex);
}

/** Returns the internal byte array of the buffer */
public byte[] getBytes() {
return m_buffer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import edu.wpi.first.hal.simulation.ConstBufferCallback;
import edu.wpi.first.hal.simulation.NotifyCallback;
import edu.wpi.first.wpilibj.AddressableLED;
import edu.wpi.first.wpilibj.AddressableLEDBuffer;
import java.util.NoSuchElementException;

/** Class to control a simulated addressable LED. */
Expand Down Expand Up @@ -209,6 +210,15 @@ public void setData(byte[] data) {
AddressableLEDDataJNI.setData(m_index, data);
}

/**
* Change the LED data.
*
* @param data the new data
*/
public void setData(AddressableLEDBuffer buffer) {
setData(buffer.getBytes());
}

/** Reset all simulation data for this LED object. */
public void resetData() {
AddressableLEDDataJNI.resetData(m_index);
Expand Down
Loading