Closed
Description
Related area
RGB LED, Blink example
Hardware specification
C3, S3, dev boards with RGB LED
Is your feature request related to a problem?
No issue found
Describe the solution you'd like
Implement LED_BUILTIN
constant for dev boards with RGB LED. Where not applicable print a helpful error message - for example, This board does not have builtin LED
instead of default error: 'LED_BUILTIN' was not declared in this scope
For boards with RGB LED overload function void digitalWrite(uint8_t pin, uint8_t val)
to activate the RGB LED via the appropriate driver.
Sample use of overloaded function:
digitalWrite(LED_BUILTIN, HIGH); // RGB turns full white
digitalWrite(LED_BUILTIN, LOW); // RGB turns off
// Nice to have (1) - ability to control each channel
digitalWrite(RED_LED_BUILTIN, HIGH); // Red channel full brightness
digitalWrite(GREEN_LED_BUILTIN, HIGH); // Green channel full brightness
digitalWrite(BLUE_LED_BUILTIN, HIGH); // Blue channel full brightness
// Similar for LOW -> channel is off
// Nice to have (2) - ability to control brightness
digitalWrite(RED_LED_BUILTIN, 128); // Red channel turns on to 50% brightness
Describe alternatives you've considered
No response
Additional context
No response
I have checked existing list of Feature requests and the Contribution Guide
- I confirm I have checked existing list of Feature requests and Contribution Guide.
Metadata
Metadata
Assignees
Type
Projects
Status
Done
Activity
igrr commentedon May 20, 2022
Regarding
TBH it looks a bit odd from Arduino API perspective. How about using
analogWrite
for this purpose, instead? For a normal GPIO connected to an LED, analogWrite(LED_BUILTIN, value) can be used to control LED brightness by means of a PWM output.me-no-dev commentedon May 20, 2022
This feature is much in line with defining a way for boards to declare what they have on-board. Things like LED, SD/SDMMC, LCD, etc. Also Peripheral Manager :)
Declaring something like (in pins_arduino.h):
Then:
me-no-dev commentedon May 20, 2022
that
COLOR_LED_BUILTIN
idea look odd overall... how would you define the colors? If the user knows they have RGB, then they can use another API to set the color IMHO.igrr commentedon May 20, 2022
I do agree with @me-no-dev that this should be implemented only to provide compatibility with sketches/libraries which use LED_BUILTIN.
More complex functionality such as setting the color could be handled using a dedicated library (like NeoPixel).
PilnyTomas commentedon May 20, 2022
Ok, we can keep it minimalistic and provide only the basic compatibility.
Implement simple RGB driver via digitalWrite; solving #6783 (#6808)
4 remaining items