From 8e4050b25db4c3535a85f9f082e24e445fed8df8 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 14 Mar 2016 19:43:23 +0100 Subject: wakeup: Do not return until both buttons have been released (closes #3) --- src/system.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/system.cc b/src/system.cc index 37e9ea5..bf18003 100644 --- a/src/system.cc +++ b/src/system.cc @@ -309,17 +309,24 @@ void System::shutdown() // Don't disable PCICR, something else might need it. PCMSK1 &= ~(_BV(PCINT15) | _BV(PCINT11)); - // debounce - _delay_ms(50); - // turn on display loadPattern(current_anim_no); display.enable(); - // ... and modem + // wait for wakeup button(s) to be released + while (!((PINC & _BV(PC3)) && (PINC & _BV(PC7)))) + display.update(); + + // debounce + for (i = 0; i < 50; i++) { + display.update(); + _delay_ms(2); + } + + // finally, turn on the modem... modem.enable(); - // also, reset state machine + // ... and reset the receive state machine rxExpect = START1; } -- cgit v1.2.3