-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Add: make digitalRead() for RGB_BUILTIN work #9418
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
Closed
Closed
Changes from all commits
Commits
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 hidden or 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 |
---|---|---|
|
@@ -104,14 +104,14 @@ extern void ARDUINO_ISR_ATTR __pinMode(uint8_t pin, uint8_t mode) | |
#endif | ||
|
||
if (pin >= SOC_GPIO_PIN_COUNT) { | ||
log_e("Invalid IO %i selected", pin); | ||
log_e("Invalid pin selected"); | ||
return; | ||
} | ||
|
||
if(perimanGetPinBus(pin, ESP32_BUS_TYPE_GPIO) == NULL){ | ||
perimanSetBusDeinit(ESP32_BUS_TYPE_GPIO, gpioDetachBus); | ||
if(!perimanClearPinBus(pin)){ | ||
log_e("Deinit of previous bus from IO %i failed", pin); | ||
log_e("Deinit of previous bus failed"); | ||
return; | ||
} | ||
} | ||
|
@@ -140,7 +140,7 @@ extern void ARDUINO_ISR_ATTR __pinMode(uint8_t pin, uint8_t mode) | |
} | ||
if(gpio_config(&conf) != ESP_OK) | ||
{ | ||
log_e("IO %i config failed", pin); | ||
log_e("GPIO config failed"); | ||
return; | ||
} | ||
if(perimanGetPinBus(pin, ESP32_BUS_TYPE_GPIO) == NULL){ | ||
|
@@ -151,11 +151,16 @@ extern void ARDUINO_ISR_ATTR __pinMode(uint8_t pin, uint8_t mode) | |
} | ||
} | ||
|
||
#ifdef RGB_BUILTIN | ||
uint8_t RGB_BUILTIN_storage = 0; | ||
#endif | ||
|
||
extern void ARDUINO_ISR_ATTR __digitalWrite(uint8_t pin, uint8_t val) | ||
{ | ||
#ifdef RGB_BUILTIN | ||
if(pin == RGB_BUILTIN){ | ||
//use RMT to set all channels on/off | ||
RGB_BUILTIN_storage=val; | ||
const uint8_t comm_val = val != 0 ? RGB_BRIGHTNESS : 0; | ||
neopixelWrite(RGB_BUILTIN, comm_val, comm_val, comm_val); | ||
return; | ||
|
@@ -164,17 +169,23 @@ extern void ARDUINO_ISR_ATTR __digitalWrite(uint8_t pin, uint8_t val) | |
if(perimanGetPinBus(pin, ESP32_BUS_TYPE_GPIO) != NULL){ | ||
gpio_set_level((gpio_num_t)pin, val); | ||
} else { | ||
log_e("IO %i is not set as GPIO.", pin); | ||
log_e("Pin is not set as GPIO."); | ||
} | ||
} | ||
|
||
extern int ARDUINO_ISR_ATTR __digitalRead(uint8_t pin) | ||
{ | ||
#ifdef RGB_BUILTIN | ||
if(pin == RGB_BUILTIN){ | ||
return RGB_BUILTIN_storage; | ||
} | ||
#endif | ||
|
||
if(perimanGetPinBus(pin, ESP32_BUS_TYPE_GPIO) != NULL){ | ||
return gpio_get_level((gpio_num_t)pin); | ||
} | ||
else { | ||
log_e("IO %i is not set as GPIO.", pin); | ||
log_e("Pin is not set as GPIO."); | ||
return 0; | ||
} | ||
} | ||
|
@@ -204,7 +215,7 @@ extern void __attachInterruptFunctionalArg(uint8_t pin, voidFuncPtrArg userFunc, | |
interrupt_initialized = (err == ESP_OK) || (err == ESP_ERR_INVALID_STATE); | ||
} | ||
if(!interrupt_initialized) { | ||
log_e("IO %i ISR Service Failed To Start", pin); | ||
log_e("GPIO ISR Service Failed To Start"); | ||
return; | ||
} | ||
|
||
|
@@ -256,14 +267,6 @@ extern void __detachInterrupt(uint8_t pin) | |
gpio_set_intr_type((gpio_num_t)pin, GPIO_INTR_DISABLE); | ||
} | ||
|
||
extern void enableInterrupt(uint8_t pin) { | ||
gpio_intr_enable((gpio_num_t)pin); | ||
} | ||
|
||
extern void disableInterrupt(uint8_t pin) { | ||
gpio_intr_disable((gpio_num_t)pin); | ||
} | ||
|
||
Comment on lines
-259
to
-266
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't delete the ISR enabler/disabler |
||
|
||
extern void pinMode(uint8_t pin, uint8_t mode) __attribute__ ((weak, alias("__pinMode"))); | ||
extern void digitalWrite(uint8_t pin, uint8_t val) __attribute__ ((weak, alias("__digitalWrite"))); | ||
|
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.
Please don't simplify the error messages. This will make it more difficult to debug.