-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Description
Related area
Implement RGB_BUILTIN variable for (#6808)
Hardware specification
Boards with standard LED and RGB LED
Is your feature request related to a problem?
With the implemented solution (#6808) to issue #6783, users are limited to only controlling a regular LED or RGB LED. Boards with both types of LEDs are now constrained to only utilizing one as the built-in LED.
Describe the solution you'd like
Define a new variable RGB_BUILTIN for the new RGB driver feature (#6808)
- Replaces the use of the
LED_BUILTINvariable in the implementation - Removes the need for
BOARD_HAS_NEOPIXEL - Also, rename
LED_BRIGHTNESSto match new variable nameRGB_BRIGHTNESS
static const uint8_t LED_BUILTIN = SOC_GPIO_PIN_COUNT+2;
#define BUILTIN_LED LED_BUILTIN // backward compatibility
#define LED_BUILTIN LED_BUILTIN
#define RGB_BUILTIN LED_BUILTIN
#define RGB_BRIGHTNESS 65
This way users that have a regular LED and RGB LED, will be able to utilize the digitalWrite functionality on both LEDs. Also, the Blink.ino and BlinkRGB.ino example sketches could operate on the LEDs separately.
static const uint8_t LED_BUILTIN = 13;
static const uint8_t RGB_BUILTIN = SOC_GPIO_PIN_COUNT+2;
#define BUILTIN_LED LED_BUILTIN // backward compatibility
#define LED_BUILTIN LED_BUILTIN
#define RGB_BUILTIN RGB_BUILTIN
#define RGB_BRIGHTNESS 65
Affected files/lines of code:
- https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-gpio.c#L94-L99
#ifdef RGB_BUILTIN if (pin == RGB_BUILTIN){ __pinMode( RGB_BUILTIN-SOC_GPIO_PIN_COUNT, mode); return; } #endif - https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-gpio.c#L137-L144
#ifdef RGB_BUILTIN if(pin == RGB_BUILTIN){ //use RMT to set all channels on/off const uint8_t comm_val = val != 0 ? RGB_BRIGHTNESS : 0; neopixelWrite(RGB_BUILTIN, comm_val, comm_val, comm_val); return; } #endif - https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-rgb-led.c#L10-L14
#ifdef RGB_BUILTIN if(pin == RGB_BUILTIN){ _pin = RGB_BUILTIN-SOC_GPIO_PIN_COUNT; } #endif - https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-rgb-led.h#L10-L12
#ifndef RGB_BRIGHTNESS #define RGB_BRIGHTNESS 64 #endif - https://github.com/espressif/arduino-esp32/blob/master/libraries/ESP32/examples/GPIO/BlinkRGB/BlinkRGB.ino
- Replace
LED_BUILTINwithRGB_BUILTIN - Replace
LED_BRIGHTNESSwithRGB_BRIGHTNESS
- Replace
- Update pin definitions for the ESP32-S2, ESP32-S3, ESP32-C3
- Remove
BOARD_HAS_NEOPIXEL - Add
#define RGB_BUILTIN LED_BUILTIN - Replace
LED_BRIGHTNESSwithRGB_BRIGHTNESS
- Remove
I've tested the proposed changes with the regular Blink.ino and BlinkRGB.ino example sketches, with the following pin definitions:
- Regular and RGB LED:
static const uint8_t LED_BUILTIN = 13; static const uint8_t RGB_BUILTIN = SOC_GPIO_PIN_COUNT+2; #define BUILTIN_LED LED_BUILTIN // backward compatibility #define LED_BUILTIN LED_BUILTIN #define RGB_BUILTIN RGB_BUILTIN #define RGB_BRIGHTNESS 65 - Only RGB LED:
static const uint8_t LED_BUILTIN = SOC_GPIO_PIN_COUNT+2; #define BUILTIN_LED LED_BUILTIN // backward compatibility #define LED_BUILTIN LED_BUILTIN #define RGB_BUILTIN LED_BUILTIN #define RGB_BRIGHTNESS 65 - Only regular LED:
static const uint8_t LED_BUILTIN = 13; #define BUILTIN_LED LED_BUILTIN // backward compatibility #define LED_BUILTIN LED_BUILTIN
Both sketches operate as expected.
Describe alternatives you've considered
No response
Additional context
I have a pull request ready; however, I thought that I'd start with creating a feature request first.
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
Labels
Type
Projects
Status