Merge pull request #8 from chrivers/comments

Comments
This commit is contained in:
thomasfredericks
2014-10-14 10:42:12 -04:00
+4 -5
View File
@@ -53,19 +53,18 @@ bool Bounce::update()
}
return state & _BV(STATE_CHANGED);
#else
// Lire l'etat de l'interrupteur dans une variable temporaire.
// Read the state of the switch in a temporary variable.
bool currentState = digitalRead(pin);
state &= ~_BV(STATE_CHANGED);
// Redemarrer le compteur timeStamp tant et aussi longtemps que
// la lecture ne se stabilise pas.
// If the reading is different from last reading, reset the debounce counter
if ( currentState != (bool)(state & _BV(UNSTABLE_STATE)) ) {
previous_millis = millis();
state ^= _BV(UNSTABLE_STATE);
} else
if ( millis() - previous_millis >= interval_millis ) {
// Rendu ici, la lecture est stable
// Est-ce que la lecture est différente de l'etat emmagasine de l'interrupteur?
// We have passed the threshold time, so the input is now stable
// If it is different from last state, set the STATE_CHANGED flag
if ((bool)(state & _BV(DEBOUNCED_STATE)) != currentState) {
previous_millis = millis();
state ^= _BV(DEBOUNCED_STATE);