@@ -99,6 +99,12 @@ void Wippersnapper_DigitalGPIO::initDigitalPin(
9999 if (pull == wippersnapper_pin_v1_ConfigurePinRequest_Pull_PULL_UP) {
100100 WS_DEBUG_PRINTLN (" with internal pull-up enabled" );
101101 pinMode (pinName, INPUT_PULLUP);
102+ #ifdef INPUT_PULLDOWN
103+ } else if (pull ==
104+ wippersnapper_pin_v1_ConfigurePinRequest_Pull_PULL_DOWN) {
105+ WS_DEBUG_PRINTLN (" with internal pull-down enabled" );
106+ pinMode (pinName, INPUT_PULLDOWN);
107+ #endif
102108 } else {
103109 pinMode (pinName, INPUT);
104110 WS_DEBUG_PRINT (" \n " );
@@ -125,6 +131,11 @@ void Wippersnapper_DigitalGPIO::initDigitalPin(
125131 _digital_input_pins[i].pinName = pinName;
126132 _digital_input_pins[i].period = periodMs;
127133 _digital_input_pins[i].prvPeriod = curTime - periodMs;
134+ if (pull == wippersnapper_pin_v1_ConfigurePinRequest_Pull_PULL_UP) {
135+ _digital_input_pins[i].prvPinVal = HIGH;
136+ } else {
137+ _digital_input_pins[i].prvPinVal = LOW;
138+ }
128139 break ;
129140 }
130141 }
@@ -311,8 +322,7 @@ void Wippersnapper_DigitalGPIO::processDigitalInputs() {
311322 }
312323 // only send on-change, but we don't know initial state of feed
313324 // (prvPinVal at boot)
314- if (_digital_input_pins[i].prvPeriod <= 0 ||
315- pinVal != _digital_input_pins[i].prvPinVal ) {
325+ if (pinVal != _digital_input_pins[i].prvPinVal ) {
316326 WS_DEBUG_PRINT (" Executing state-based event on D" );
317327 WS_DEBUG_PRINTLN (_digital_input_pins[i].pinName );
318328
0 commit comments