11

Dependents:   Program_R11

Revision:
13:fb6929fac0db
Parent:
12:e6623f165199
Child:
14:f6c3647bf421
diff -r e6623f165199 -r fb6929fac0db keypad.cpp
--- a/keypad.cpp	Sat Nov 03 23:43:46 2012 +0000
+++ b/keypad.cpp	Sun Nov 04 09:49:35 2012 +0000
@@ -86,6 +86,35 @@
 
     return r * col_count + c;
 }
+int Keypad::DebouncedScanMultiple()
+{
+    /* debounce */
+    int key1 = ScanMultiple();
+    
+    wait_ms(_debounce);
+    
+    int key2 = ScanMultiple();
+    
+    return key1 & key2;
+}
+
+int Keypad::ScanMultiple()
+{
+    int res = 0;    
+    
+    int i = 0;
+    for (int c = 0; c < col_count; c++) {
+        _cols = ~(1 << c);
+        for (int r = 0; r < row_count; r++) {
+            if (*_rows[r] == 0) {
+                res |= 1 << (r * col_count + c);
+            }
+            i++;
+        }
+    }
+    
+    return res;
+}
 
 void Keypad::_callback()
 {