diff options
| author | Selene ToyKeeper | 2017-12-11 19:56:15 -0700 |
|---|---|---|
| committer | Selene ToyKeeper | 2017-12-11 19:56:15 -0700 |
| commit | d50c46d08a6d7f52dffb9b43784c62b11d78df8c (patch) | |
| tree | ba93cc6fa1d3f681e850d57ed92721e859b4ff30 /spaghetti-monster/fsm-pcint.c | |
| parent | Working toward a FW3A release now. Made strobes use Nx7135 (when available) ... (diff) | |
| download | anduril-d50c46d08a6d7f52dffb9b43784c62b11d78df8c.tar.gz anduril-d50c46d08a6d7f52dffb9b43784c62b11d78df8c.tar.bz2 anduril-d50c46d08a6d7f52dffb9b43784c62b11d78df8c.zip | |
Greatly improved button debouncing. Helps a lot on FW3A and my light saber.
Debouncing isn't 100% yet though.
Diffstat (limited to 'spaghetti-monster/fsm-pcint.c')
| -rw-r--r-- | spaghetti-monster/fsm-pcint.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/spaghetti-monster/fsm-pcint.c b/spaghetti-monster/fsm-pcint.c index 763c1fe..c04375a 100644 --- a/spaghetti-monster/fsm-pcint.c +++ b/spaghetti-monster/fsm-pcint.c @@ -59,10 +59,25 @@ ISR(PCINT0_vect) { //DEBUG_FLASH; - uint8_t pushed; + /* + uint8_t pressed; // add event to current sequence - if (button_is_pressed()) { + pressed = button_is_pressed(); + PCINT_inner(pressed); + */ + if (! PCINT_since_WDT) { + PCINT_since_WDT = 1; + PCINT_inner(button_is_pressed()); + } +} + +// should only be called from PCINT and WDT +// (is a separate function to reduce code duplication) +void PCINT_inner(uint8_t pressed) { + uint8_t pushed; + + if (pressed) { pushed = push_event(A_PRESS); } else { pushed = push_event(A_RELEASE); @@ -70,7 +85,9 @@ ISR(PCINT0_vect) { // check if sequence matches any defined sequences // if so, send event to current state callback - if (pushed) emit_current_event(0); + if (pushed) { + button_last_state = pressed; + emit_current_event(0); + } } - #endif |
