-
Notifications
You must be signed in to change notification settings - Fork 2k
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
drivers/led: Allow LEDn_ON to be disabled by other modules #20833
drivers/led: Allow LEDn_ON to be disabled by other modules #20833
Conversation
4813afc
to
4fe4a0e
Compare
Test output for
And with
(And by the way we're doing way too much with preprocessor macros, which have a terrible user experience in terms of typos and other errors -- I've gone through all kinds of how one could do things wrong in the ifdef, and never has any tool complained.) Marking this as ready-for-review and to build. |
4fe4a0e
to
94745c4
Compare
94745c4
to
c7d0285
Compare
The latest update fixes building on native (which I had not tested), where the new condition would have led to an attempt to initialize a pin from an undefined macro. The new condition for setup is "the LED is present and has a pin associated". I ran the described tests again, let's see if CI comes up with anything more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for finding and fixing! Just a minor comment below.
Otherwise they show as provided but do not have any effect.
The LEDx_PIN may still be defined (eg. on the particle-mesh family because it is used to configure the PWM pins); the IS_PRESENT macro performs the stricter check ov testing for an _ON function.
731a839
to
739e269
Compare
Contribution description
On the particle-xenon and similar boards, once SAUL is active, LED[012]_ON will not do anything, even though LED[012]_IS_PROVIDED is set. This may not surprise users of LEDn_ON (because it's the established behavior of those to no-op), but when explicitly inspecting LEDn_IS_PROVIDED (like Rust users
willdo), this behavior is confusing.The cause of this is that SAUL's use of the LED pins is through PWM, and (at least on that family) that completely overrides GPIO input.
The change is two-fold:
!(IS_ACTIVE(SAUL_AUTO_INIT) && IS_ACTIVE(SAUL_PWM))
. If that is the case, LED0_ON is not defined, and consequently, led.h does not set LED0_IS_PRESENT.Testing procedure
Alternatives