Skip to content

Commit

Permalink
Added DebouncedInt for #17 storing knob history
Browse files Browse the repository at this point in the history
  • Loading branch information
wraybowling committed Sep 11, 2020
1 parent 931cdd9 commit 53984a1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/DebouncedBoolean.h → src/Debounced.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

#pragma once
#include <Arduino.h>

class DebouncedBoolean {
public:
Expand All @@ -26,3 +27,22 @@ class DebouncedBoolean {
state[2] = {false};
}
};

class DebouncedInt {
public:
DebouncedInt() {}
uint16_t state[2] = {0};

void set(uint16_t value) {
state[0] = state[1];
state[1] = value;
}

uint16_t get() {
return state[1];
}

bool changed() {
return state[0] != state[1];
}
}

0 comments on commit 53984a1

Please sign in to comment.