Skip to content

Improve RGB Driverย #6968

Closed
Closed
@santaimpersonator

Description

@santaimpersonator

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_BUILTIN variable in the implementation
  • Removes the need for BOARD_HAS_NEOPIXEL
  • Also, rename LED_BRIGHTNESS to match new variable name RGB_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:

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

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions