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

Conversation

DanPeled
Copy link

@DanPeled DanPeled commented Feb 18, 2025

Mostly to for the buffer to be able to be used with the sim class

without this, it is needed to create a helper method / seperate buffer for using the AddressableLEDSim class, such as the folllowing:

public static byte[] toByteArray(AddressableLEDBuffer buffer) {
    int length = buffer.getLength();
    byte[] byteArray = new byte[length * 4];

    for (int i = 0; i < length; i++) {
      byteArray[i * 4] = (byte) buffer.getBlue(i);
      byteArray[(i * 4) + 1] = (byte) buffer.getGreen(i);
      byteArray[(i * 4) + 2] = (byte) buffer.getRed(i);
      byteArray[(i * 4) + 3] = 0; // The last byte is always 0
    }

    return byteArray;
  }

@DanPeled DanPeled requested a review from a team as a code owner February 18, 2025 16:33
@github-actions github-actions bot added the component: wpilibj WPILib Java label Feb 18, 2025
Copy link
Contributor

@spacey-sooty spacey-sooty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs C++ port

@calcmogul calcmogul added the help: needs C++ Java exists, needs C++ port label Feb 19, 2025
@PeterJohnson
Copy link
Member

It doesn't need a C++ port because C++ doesn't have AddressableLEDBuffer; the data is directly accessible.

@PeterJohnson PeterJohnson removed the help: needs C++ Java exists, needs C++ port label Feb 19, 2025
@spacey-sooty
Copy link
Contributor

It doesn't need a C++ port because C++ doesn't have AddressableLEDBuffer; the data is directly accessible.

Whoops missed that when looking at the C++ version

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants