10000 GPIO: Add checks for bool returns by toxuin · Pull Request #692 · nkolban/esp32-snippets · GitHub
[go: up one dir, main page]

Skip to content

GPIO: Add checks for bool returns #692

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

Merged
merged 1 commit into from
Oct 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cpp_utils/GPIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void ESP32CPP::GPIO::low(gpio_num_t pin) {
* @return True if the pin is high, false if the pin is low.
*/
bool ESP32CPP::GPIO::read(gpio_num_t pin) {
return ::gpio_get_level(pin);
return ::gpio_get_level(pin) == 1;
} // read


Expand Down Expand Up @@ -189,7 +189,7 @@ void ESP32CPP::GPIO::setOutput(gpio_num_t pin) {
*/
void ESP32CPP::GPIO::write(gpio_num_t pin, bool value) {
//ESP_LOGD(LOG_TAG, ">> write: pin: %d, value: %d", pin, value);
esp_err_t errRc = ::gpio_set_level(pin, value);
esp_err_t errRc = ::gpio_set_level(pin, value ? 1 : 0);
if (errRc != ESP_OK) {
ESP_LOGE(LOG_TAG, "<< gpio_set_level: pin=%d, rc=%d %s", pin, errRc, GeneralUtils::errorToString(errRc));
}
Expand Down
0