manual key debounceing works now (100ms)
[svn42.git] / firmware / tuer.pde
index 314ade2..ac1a18a 100644 (file)
@@ -22,7 +22,7 @@ byte next_led = 0;
 
 #define MANUAL_OPEN_PIN 12  // keys for manual open and close
 #define MANUAL_CLOSE_PIN 13 // 
-#define DEBOUNCE_DELAY 625  // * 16us = 10ms
+#define DEBOUNCE_DELAY 6250  // * 16us = 100ms
 #define DEBOUNCE_IDLE 0     // currently no debouncing
 #define DEBOUNCE_OPEN 1     // debouncing open key
 #define DEBOUNCE_CLOSE 2    // debouncing close key
@@ -125,8 +125,8 @@ void stop_debounce_timer()
 
 ISR(TIMER0_COMPA_vect)
 {
-  if((debounce_state & DEBOUNCE_OPEN && manual_open_pressed()) ||
-     (debounce_state & DEBOUNCE_CLOSE && manual_close_pressed())) {
+  if(((debounce_state & DEBOUNCE_OPEN) && manual_open_pressed()) ||
+     ((debounce_state & DEBOUNCE_CLOSE) && manual_close_pressed())) {
     if(debounce_cnt) {
       debounce_cnt--;
       return;
@@ -155,7 +155,7 @@ boolean manual_open()
       return true;
     }
   }
-  else {
+  else if(debounce_state & DEBOUNCE_OPEN) {
     stop_debounce_timer();
     debounce_state = DEBOUNCE_IDLE;
   }
@@ -182,7 +182,7 @@ boolean manual_close()
       return true;
     }
   }
-  else {
+  else if(debounce_state & DEBOUNCE_CLOSE) {
     stop_debounce_timer();
     debounce_state = DEBOUNCE_IDLE;
   }