Skip to content

platform/build_hat: Add support for LEDs.#467

Merged
dlech merged 1 commit intopybricks:masterfrom
dlech:build-hat-leds
Mar 30, 2026
Merged

platform/build_hat: Add support for LEDs.#467
dlech merged 1 commit intopybricks:masterfrom
dlech:build-hat-leds

Conversation

@dlech
Copy link
Copy Markdown
Member

@dlech dlech commented Mar 30, 2026

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

@dlech dlech requested a review from Copilot March 30, 2026 02:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.light on the Build HAT hub type using the system status light (pbsys_status_light_main).
  • Add a new pwm_pico driver and Build HAT platform data to drive the two LED GPIOs via PWM and the existing led_pwm RGB 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
@dlech dlech merged commit 8e9299f into pybricks:master Mar 30, 2026
14 checks passed
@dlech dlech deleted the build-hat-leds branch March 30, 2026 02:39
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.

[Feature] Build HAT lights

2 participants