8000 Merge pull request #692 from toxuin/gpio-check · micki0271/esp32-snippets@51e943f · GitHub
[go: up one dir, main page]

Skip to content

Commit 51e943f

Browse files
authored
Merge pull request nkolban#692 from toxuin/gpio-check
GPIO: Add checks for bool returns
2 parents d9a31c2 + 009d003 commit 51e943f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cpp_utils/GPIO.cpp

Lines changed: 2 additions & 2 deletions
< 75D3 td data-grid-cell-id="diff-03859245c79d541c6768b0d0a74c120ee74a7779446bb88a7895c53618ac09b8-129-129-1" data-selected="false" role="gridcell" style="background-color:var(--bgColor-default);text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative diff-line-number-neutral left-side">129
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ void ESP32CPP::GPIO::low(gpio_num_t pin) {
124124
* @return True if the pin is high, false if the pin is low.
125125
*/
126126
bool ESP32CPP::GPIO::read(gpio_num_t pin) {
127-
return ::gpio_get_level(pin);
127+
return ::gpio_get_level(pin) == 1;
128128
} // read
129

130130

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

0 commit comments

Comments
 (0)
0