@Test public void testReadDebounced() { gpioTester.testReadDebounced(pin.as(DigitalInput.class), mock); }
public Signal readDebounced(int debounceTime) { long startTime = System.currentTimeMillis(); long delta = 0; Signal currentState = read(); int counter = 0; while (delta < debounceTime) { Signal reading = read(); if (reading == currentState && counter > 0) { counter--; } if (reading != currentState) { counter++; } if (counter >= MAX_DEBOUNCE_COUNT) { counter = 0; currentState = reading; return currentState; } delta = System.currentTimeMillis() - startTime; } return currentState; }
AbstractDigitalInput extends AbstractPinFeature implements DigitalInput { public Signal readDebounced(int debounceTime) { long startTime = System.currentTimeMillis(); long delta = 0; Signal currentState = read(); int counter = 0; while (delta < debounceTime) { Signal reading = read(); if (reading == currentState && counter > 0) { counter--; } if (reading != currentState) { counter++; } if (counter >= MAX_DEBOUNCE_COUNT) { counter = 0; currentState = reading; return currentState; } delta = System.currentTimeMillis() - startTime; } return currentState; } }
AbstractDigitalInput extends AbstractPinFeature implements DigitalInput { public Signal readDebounced(int debounceTime) { long startTime = System.currentTimeMillis(); long delta = 0; Signal currentState = read(); int counter = 0; while (delta < debounceTime) { Signal reading = read(); if (reading == currentState && counter > 0) { counter--; } if (reading != currentState) { counter++; } if (counter >= MAX_DEBOUNCE_COUNT) { counter = 0; currentState = reading; return currentState; } delta = System.currentTimeMillis() - startTime; } return currentState; } AbstractDigitalInput(Pin pin); }
AbstractDigitalInput extends AbstractPinFeature implements DigitalInput { public Signal readDebounced(int debounceTime) { long startTime = System.currentTimeMillis(); long delta = 0; Signal currentState = read(); int counter = 0; while (delta < debounceTime) { Signal reading = read(); if (reading == currentState && counter > 0) { counter--; } if (reading != currentState) { counter++; } if (counter >= MAX_DEBOUNCE_COUNT) { counter = 0; currentState = reading; return currentState; } delta = System.currentTimeMillis() - startTime; } return currentState; } AbstractDigitalInput(Pin pin); String getName(); void setInterruptTrigger(Edge edge); void setInterruptDebounceMs(int milliSeconds); int getInterruptDebounceMs(); Edge getInterruptTrigger(); void addInterruptListener(InterruptListener listener); void removeInterruptListener(InterruptListener listener); List<InterruptListener> getInterruptListeners(); void clearInterruptListeners(); void fireInterruptEvent(InterruptEventArgs args); Signal readDebounced(int debounceTime); boolean areInterruptsEnabled(); void enableInterrupts(); void disableInterrupts(); }
AbstractDigitalInput extends AbstractPinFeature implements DigitalInput { public Signal readDebounced(int debounceTime) { long startTime = System.currentTimeMillis(); long delta = 0; Signal currentState = read(); int counter = 0; while (delta < debounceTime) { Signal reading = read(); if (reading == currentState && counter > 0) { counter--; } if (reading != currentState) { counter++; } if (counter >= MAX_DEBOUNCE_COUNT) { counter = 0; currentState = reading; return currentState; } delta = System.currentTimeMillis() - startTime; } return currentState; } AbstractDigitalInput(Pin pin); String getName(); void setInterruptTrigger(Edge edge); void setInterruptDebounceMs(int milliSeconds); int getInterruptDebounceMs(); Edge getInterruptTrigger(); void addInterruptListener(InterruptListener listener); void removeInterruptListener(InterruptListener listener); List<InterruptListener> getInterruptListeners(); void clearInterruptListeners(); void fireInterruptEvent(InterruptEventArgs args); Signal readDebounced(int debounceTime); boolean areInterruptsEnabled(); void enableInterrupts(); void disableInterrupts();  }