boards: support common-cathode PWM RGB LED - #402
Open
KenRouKoro wants to merge 1 commit into
Open
Conversation
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.
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.
Checklist
By completing this PR sufficiently, you help us to review this Pull Request quicker and also help improve the quality of Release Notes
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.