Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Allow accessing AddressableLED.LEDData fields #77

Merged
merged 1 commit into from
Feb 18, 2024
Merged

Conversation

auscompgeek
Copy link
Member

@auscompgeek auscompgeek commented Feb 12, 2024

wpilib.AddressableLED.LEDData.setRGB is documented as:

A helper method to set all values of the LED.

But how do you set the individual values of the LED? In C++ you'd be able to set the r, g, and b members. However our bindings currently don't allow that, because we hide the fact that LEDData subclasses the hal.AddressableLEDData struct.

This makes those member variables visible via the base hal.AddressableLEDData.

@auscompgeek
Copy link
Member Author

From the build log:

build/temp.linux-x86_64-cpython-311/gensrc/wpilib_core/AddressableLED.cpp:62:60: error: ‘HAL_AddressableLEDData’ is not a member of ‘frc’; did you mean ‘AddressableLED’?
   62 |     py::class_<typename frc::AddressableLED::LEDData, frc::HAL_AddressableLEDData> cls_LEDData;
      |                                                            ^~~~~~~~~~~~~~~~~~~~~~
      |                                                            AddressableLED

I don't understand why robotpy-build is prefixing the base type with the frc:: namespace.

@virtuald
Copy link
Member

It's doing it because there's no namespace specified for the base, and the child lives in a namespace, so the odds are that the base is going to be in the same namespace.

@virtuald virtuald merged commit 97477e0 into main Feb 18, 2024
31 checks passed
@virtuald virtuald deleted the led-data-attrs branch February 18, 2024 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants