platform/build_hat: Add support for LEDs.#467
Merged
dlech merged 1 commit intopybricks:masterfrom Mar 30, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Build HAT LED support by introducing an RP2040/Pico PWM backend and wiring it into the status light stack so hub.light.on() works consistently across hubs.
Changes:
- Expose
hub.lighton the Build HAT hub type using the system status light (pbsys_status_light_main). - Add a new
pwm_picodriver and Build HAT platform data to drive the two LED GPIOs via PWM and the existingled_pwmRGB abstraction (blue unused). - Enable the relevant PBIO/PBDRV/PBSYS config flags for light/status-light on Build HAT and register the new driver in the PWM core/build sources.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pybricks/hubs/pb_type_buildhat.c | Adds hub.light attribute backed by pbsys_status_light_main. |
| lib/pbio/platform/build_hat/platform.c | Declares Build HAT PWM + LED PWM platform data (GPIOs 14/15). |
| lib/pbio/platform/build_hat/pbsysconfig.h | Enables system status light for Build HAT. |
| lib/pbio/platform/build_hat/pbioconfig.h | Enables PBIO light support for Build HAT. |
| lib/pbio/platform/build_hat/pbdrvconfig.h | Enables LED/PWM drivers and configures Pico PWM channel count. |
| lib/pbio/drv/pwm/pwm_pico.h | Declares Pico PWM platform data and init hook. |
| lib/pbio/drv/pwm/pwm_pico.c | Implements RP2040 PWM init and duty-setting. |
| lib/pbio/drv/pwm/pwm_core.c | Registers pbdrv_pwm_pico_init() in the PWM driver init sequence. |
| bricks/_common/sources.mk | Adds drv/pwm/pwm_pico.c to common build sources. |
| .vscode/c_cpp_properties.json | Adds compilerPath for the debug IntelliSense configuration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add a new PWM driver for the Pico and use it to control the LEDs on the Build HAT. Even though the LEDs are separate (not a multicolor LED), we still treat is as a single LED to be consistent with the other hubs (i.e. so that hub.light.on() works the same on all hubs). Closes: pybricks/support#2477
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a new PWM driver for the Pico and use it to control the LEDs on the Build HAT.
Even though the LEDs are separate (not a multicolor LED), we still treat is as a single LED to be consistent with the other hubs (i.e. so that hub.light.on() works the same on all hubs).
Closes: pybricks/support#2477