Skip to content

Commit 73e097b

Browse files
authored
Fix logical issues
1 parent ba35f4c commit 73e097b

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

cores/esp32/esp32-hal-touch-ng.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,12 @@ bool touchDisable() {
117117
if (!enabled) { // Already disabled
118118
return true;
119119
}
120-
if (!running && (touch_sensor_disable(touch_sensor_handle) != ESP_OK)) {
121-
log_e("Touch sensor still running or disable failed!");
120+
if (running) {
121+
log_e("Touch sensor still running!");
122+
return false;
123+
}
124+
if (touch_sensor_disable(touch_sensor_handle) != ESP_OK) {
125+
log_e("Touch sensor disable failed!");
122126
return false;
123127
}
124128
enabled = false;
@@ -129,8 +133,12 @@ bool touchStart() {
129133
if (running) { // Already running
130134
return true;
131135
}
132-
if (!enabled && (touch_sensor_start_continuous_scanning(touch_sensor_handle) != ESP_OK)) {
133-
log_e("Touch sensor not enabled or failed to start continuous scanning failed!");
136+
if (!enabled) {
137+
log_e("Touch sensor not enabled!");
138+
return false;
139+
}
140+
if (touch_sensor_start_continuous_scanning(touch_sensor_handle) != ESP_OK) {
141+
log_e("Touch sensor failed to start continuous scanning!");
134142
return false;
135143
}
136144
running = true;

0 commit comments

Comments
 (0)