@@ -190,11 +190,26 @@ void Wippersnapper_DigitalGPIO::deinitDigitalPin(
190190/* *******************************************************************/
191191int Wippersnapper_DigitalGPIO::digitalReadSvc (int pinName) {
192192 // Service using arduino `digitalRead`
193- WS_DEBUG_PRINT (" \t DioPinRead: " );
194- WS_DEBUG_PRINT (pinName);
195193 int pinVal = digitalRead (pinName);
196- WS_DEBUG_PRINT (" =" );
197- WS_DEBUG_PRINT (pinVal);
194+ // how do i check the digital IO pull up state for one of the
195+ // _digital_input_pins, because I'm experiencing issues that resemble the
196+ // situation where the initially set pull up value is no longer in effect
197+ // For ESP32
198+ // #if defined(ESP32)
199+ // #include "driver/gpio.h"
200+ // #include "esp_err.h"
201+ // #include "esp_log.h"
202+ // #include "esp_system.h"
203+ // #include "esp32-hal-log.h"
204+ // #include "esp32-hal-gpio.h"
205+ // gpio_pull_mode_t pull_mode;
206+ // // can't find in idf, but merged issue
207+ // https://github.com/espressif/esp-idf/issues/12176
208+ // esp_err_t result = gpio_get_pull_mode((gpio_num_t)pinName, &pull_mode);
209+ // if (result == ESP_OK) {
210+ // return (pull_mode == GPIO_PULLUP_ONLY);
211+ // }
212+ // #endif
198213 return pinVal;
199214}
200215
@@ -288,8 +303,16 @@ void Wippersnapper_DigitalGPIO::processDigitalInputs() {
288303 } else if (_digital_input_pins[i].period == 0L ) {
289304 // read pin
290305 int pinVal = digitalReadSvc (_digital_input_pins[i].pinName );
291- // only send on-change, but we don't know initial state of feed (prvPinVal at boot)
292- if (_digital_input_pins[i].prvPeriod <= 0 || pinVal != _digital_input_pins[i].prvPinVal ) {
306+ if (curTime - _digital_input_pins[i].prvPeriod > 500 ) {
307+ WS_DEBUG_PRINT (" D" );
308+ WS_DEBUG_PRINT (_digital_input_pins[i].pinName );
309+ WS_DEBUG_PRINT (" is " );
310+ WS_DEBUG_PRINT (pinVal);
311+ }
312+ // only send on-change, but we don't know initial state of feed
313+ // (prvPinVal at boot)
314+ if (_digital_input_pins[i].prvPeriod <= 0 ||
315+ pinVal != _digital_input_pins[i].prvPinVal ) {
293316 WS_DEBUG_PRINT (" Executing state-based event on D" );
294317 WS_DEBUG_PRINTLN (_digital_input_pins[i].pinName );
295318
@@ -328,10 +351,10 @@ void Wippersnapper_DigitalGPIO::processDigitalInputs() {
328351
329352 // reset the digital pin
330353 _digital_input_pins[i].prvPeriod = curTime;
331- } else {
332- WS_DEBUG_PRINT (" Dio: No change on " );
333- WS_DEBUG_PRINT (_digital_input_pins[i].pinName );
334- WS_DEBUG_PRINTLN (" , skipping..." );
354+ // } else {
355+ // WS_DEBUG_PRINT("Dio: No change on ");
356+ // WS_DEBUG_PRINT(_digital_input_pins[i].pinName);
357+ // WS_DEBUG_PRINTLN(", skipping...");
335358 }
336359 }
337360 }
0 commit comments