11
Diff: keypad.cpp
- Revision:
- 12:e6623f165199
- Parent:
- 11:a45e64141ce6
- Child:
- 13:fb6929fac0db
--- a/keypad.cpp Sat Nov 03 23:33:52 2012 +0000 +++ b/keypad.cpp Sat Nov 03 23:43:46 2012 +0000 @@ -6,25 +6,21 @@ _row0(row0), _row1(row1), _row2(row2), _row3(row3), _cols(col0, col1, col2, col3) { + _debounce = debounce_ms; _rows[0] = &_row0; _rows[1] = &_row1; _rows[2] = &_row2; _rows[3] = &_row3; - _debounce = debounce_ms; - _row0.mode(PullUp); - _row1.mode(PullUp); - _row2.mode(PullUp); - _row3.mode(PullUp); + for (int r = 0; r < row_count; r++) + _rows[r]->mode(PullUp); _cols.mode(OpenDrain); _cols.output(); } void Keypad::_setupFallTrigger(void) { - _row0.fall(this, &Keypad::_callback); - _row1.fall(this, &Keypad::_callback); - _row2.fall(this, &Keypad::_callback); - _row3.fall(this, &Keypad::_callback); + for (int r = 0; r < row_count; r++) + _rows[r]->fall(this, &Keypad::_callback); } void Keypad::Start(void) @@ -47,9 +43,9 @@ int Keypad::DebouncedScan() { + /* debounce */ int key1 = Scan(); - /* debounce */ wait_ms(_debounce); int key2 = Scan(); @@ -100,4 +96,3 @@ if (position >= 0) _input.call(position); } -