11

Dependents:   Program_R11

Revision:
16:a9feaa7ac039
Parent:
15:873a9a452ef1
--- a/keypad.cpp	Sun Nov 04 09:56:24 2012 +0000
+++ b/keypad.cpp	Thu Nov 08 19:04:08 2012 +0000
@@ -44,16 +44,9 @@
 int Keypad::DebouncedScan()
 {
     /* debounce */
-    int key1 = Scan();
-    
     wait_ms(_debounce);
-    
-    int key2 = Scan();
-    
-    if (key1 != key2)
-        return -1;
-    else
-        return key1;
+
+    return Scan();
 }
 
 int Keypad::Scan()
@@ -69,7 +62,7 @@
     if (!(0 <= r && r < row_count))
         return -1;
 
-    /* scan columns to find out which one pulls down the row */ 
+    /* scan columns to find out which one pulls down the row */
     int c = -1;
     for (c = 0; c < col_count; c++) {
         _cols = ~(1 << c);
@@ -86,21 +79,18 @@
 
     return r * col_count + c;
 }
+
 int Keypad::DebouncedScanMultiple()
 {
     /* debounce */
-    int key1 = ScanMultiple();
-    
     wait_ms(_debounce);
-    
-    int key2 = ScanMultiple();
-    
-    return key1 & key2;
+
+    return ScanMultiple();
 }
 
 int Keypad::ScanMultiple()
 {
-    int res = 0;    
+    int res = 0;
     for (int c = 0; c < col_count; c++) {
         _cols = ~(1 << c);
         for (int r = 0; r < row_count; r++) {
@@ -109,7 +99,7 @@
             }
         }
     }
-    
+
     return res;
 }
 
@@ -117,7 +107,7 @@
 {
     /* lookup */
     int position = DebouncedScan();
-    
+
     /* call back a valid position */
     if (position >= 0)
         _input.call(position);