-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Implement simple RGB driver via digitalWrite; solving #6783 #6808
Merged
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6967d8f
Initial implementation of RGB driver via digitalWrite
PilnyTomas cd31356
Moved constants to pins_arduino.h
PilnyTomas 51ce37d
Changed pin definition + added example
PilnyTomas 1e363b7
Wrapped BlinkRGB in #ifdef BOARD_HAS_NEOPIXEL
PilnyTomas 50b6356
Removed forgotten log from example
PilnyTomas 583e030
Moved RGBLedWrite to new file esp32-hal-rgb-led and created pinMode i…
PilnyTomas 8786e83
Updated example - lowered single channel brightness to LED_BRIGHTNESS
PilnyTomas 10205b0
Changed function name from RGBLedWrite to neopixelWrite + code polishing
PilnyTomas c0aa3b8
Moved pinSetup portion related to RGB back to common file
PilnyTomas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
BlinkRGB | ||
|
||
Demonstrates usage of onboard RGB LED on some ESP dev boards. | ||
|
||
Calling digitalWrite(LED_BUILTIN, HIGH) will use hidden RGB driver. | ||
|
||
RGBLedWrite demonstrates controll of each channel: | ||
void RGBLedWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue_val) | ||
|
||
WARNING: After using digitalWrite to drive RGB LED it will be impossible to drive the same pin | ||
with normal HIGH/LOW level | ||
*/ | ||
//#define LED_BRIGHTNESS 64 // Change white brightness (max 255) | ||
|
||
// the setup function runs once when you press reset or power the board | ||
|
||
void setup() { | ||
// No need to initialize the RGB LED | ||
} | ||
|
||
// the loop function runs over and over again forever | ||
void loop() { | ||
digitalWrite(LED_BUILTIN, HIGH); // Turn the RGB LED white | ||
delay(1000); | ||
log_w("LED LOW"); | ||
digitalWrite(LED_BUILTIN, LOW); // Turn the RGB LED off | ||
delay(1000); | ||
|
||
RGBLedWrite(LED_BUILTIN,255,0,0); // Red | ||
delay(1000); | ||
RGBLedWrite(LED_BUILTIN,0,255,0); // Green | ||
delay(1000); | ||
RGBLedWrite(LED_BUILTIN,0,0,255); // Blue | ||
delay(1000); | ||
RGBLedWrite(LED_BUILTIN,0,0,0); // Off / black | ||
delay(1000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could we consider moving the board-specific code to the
variants
folder?I'm worried that the more similar features we add for specific boards, the more complex the core code will become. It would be better to handle this in the board variant folder. It would also demonstrate authors of 3rd party board packages how to add such custom functionality.
To avoid duplication of code, you can still define
RGBLedWrite
somewhere in the core, but preferably in a separate source file (esp32-hal-rgb-led.c?)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'm a little bit confused about what should go where.
pinMode
->variants/
... new file?RGBLedWrite
->esp32-hal-rgb-led.c
?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.
Should be solved in 583e030