-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Implement LED_BUILTIN constant + digitalWrite() overload for RGB LED #6783
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
Comments
Regarding // Nice to have (2) - ability to control brightness
digitalWrite(RED_LED_BUILTIN, 128); // Red channel turns on to 50% brightness TBH it looks a bit odd from Arduino API perspective. How about using |
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 :) #define BOARD_HAS_WS2802
#define LED_BUILTIN 18 // maybe we need to add offset so to not prevent using the pin for normal digitalWrite Then: void digitalWrite(uint8_t pin, bool level){
#ifdef BOARD_HAS_WS2802
if(pin == LED_BUILTIN){
//use RMT to set all channels on/off
return;
}
#endif
// regular digitalWrite logic
} |
that |
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). |
Ok, we can keep it minimalistic and provide only the basic compatibility. |
* Initial implementation of RGB driver via digitalWrite * Moved constants to pins_arduino.h * Changed pin definition + added example * Wrapped BlinkRGB in #ifdef BOARD_HAS_NEOPIXEL * Removed forgotten log from example * Moved RGBLedWrite to new file esp32-hal-rgb-led and created pinMode in variatn.cpp * Updated example - lowered single channel brightness to LED_BRIGHTNESS * Changed function name from RGBLedWrite to neopixelWrite + code polishing * Moved pinSetup portion related to RGB back to common file
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 defaulterror: '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:
Describe alternatives you've considered
No response
Additional context
No response
I have checked existing list of Feature requests and the Contribution Guide
The text was updated successfully, but these errors were encountered: