-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
samples: fade_led: use all available LEDs #80496
base: main
Are you sure you want to change the base?
Conversation
5ecc8c6
to
0d6f7c4
Compare
@kartben Can we merge? |
Isn't this sample superseded by |
Not sure but the |
/* Support up to 4 LEDs*/ | ||
static const struct pwm_dt_spec pwm_leds[] = {LISTIFY(4, PWM_LED, ())}; |
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.
Why limit up to 4?
I don't think there's any problem with not placing any limitation here.
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.
I can raise the number but there needs to be some cap because there needs to be some sort of iteration over the LEDs.
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.
You can use the DT macros to run for each entry and should be able to construct any length array from that
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.
Can you give an example? In this case there is no matching compatible string for a pwm LED or something like that so I don't understand how this would be done.
samples/basic/fade_led/src/main.c
Outdated
ret = pwm_set_pulse_dt(&pwm_leds[i], pulse_widths[i]); | ||
if (ret) { | ||
printk("Error %d: failed to set pulse width for LED %d\n", ret, i); | ||
return 0; |
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.
It should good to proceed with only what is available here.
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.
done
Refactored the sample code to use all available PWM LEDs Signed-off-by: Yishai Jaffe <[email protected]>
0d6f7c4
to
ab5fb7e
Compare
@yishai1999 Please can you investigate and eventually fill a bug report ? The |
Ok, I understood the problem and open a PR (#82383). |
Refactored the sample code to use all available PWM LEDs