Fork without short circuits

Dependents:   SaveKeypad

Fork of keypad by HM Yoong

No extra hardware is needed besides the wires and switches. The columns are outputs configured with open drain. The rows are inputs configured with pull up resistors. A key press pulls down its row. With scanning the column is determined thereafter.

See SaveKeypad for an example usage.

Revision:
13:fb6929fac0db
Parent:
12:e6623f165199
Child:
14:f6c3647bf421
--- 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()
 {