Skip to content

boards: support common-cathode PWM RGB LED - #402

Open
KenRouKoro wants to merge 1 commit into
adafruit:masterfrom
KenRouKoro:fix/rgb-common-cathode
Open

boards: support common-cathode PWM RGB LED#402
KenRouKoro wants to merge 1 commit into
adafruit:masterfrom
KenRouKoro:fix/rgb-common-cathode

Conversation

@KenRouKoro

Copy link
Copy Markdown

Checklist

By completing this PR sufficiently, you help us to review this Pull Request quicker and also help improve the quality of Release Notes

  • Please provide specific title of the PR describing the change

Description of Change

The PWM LED driver assumes a common-anode LED: on nRF52 PWM (Up mode) duty == 0 leaves the pin HIGH, so "larger duty == brighter" only holds when the pin sinks current (common-anode). A common-cathode RGB LED is driven the opposite way and ends up fully lit with no state response.

Add an opt-in LED_RGB_COMMON_CATHODE macro. When defined, the duty is inverted in led_pwm_duty_cycle() and the redundant LED_STATE_ON inversion in led_tick() is skipped to avoid a double inversion. When undefined (default) behavior is unchanged from upstream (common-anode).

Verified on a common-cathode RGB board: previously all three channels stayed fully lit; with the fix the status color shows and the primary LED breathes correctly. Common-anode boards (e.g. particle_argon, feather_nrf52840_express) still build and behave identically.

The PWM LED driver assumes a common-anode LED: on nRF52 PWM (Up mode)
duty == 0 leaves the pin HIGH, so "larger duty == brighter" only holds
when the pin sinks current (common-anode). A common-cathode RGB LED is
driven the opposite way and ends up fully lit with no state response.

Add an opt-in LED_RGB_COMMON_CATHODE macro. When defined, the duty is
inverted in led_pwm_duty_cycle() and the redundant LED_STATE_ON inversion
in led_tick() is skipped to avoid a double inversion. When undefined
(default) behavior is unchanged from upstream (common-anode).

Verified on a common-cathode RGB board: previously all three channels
stayed fully lit; with the fix the status color shows and the primary
LED breathes correctly. Common-anode boards (e.g. particle_argon,
feather_nrf52840_express) still build and behave identically.
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