45 |
45 |
46 while(_started) |
46 while(_started) |
47 { |
47 { |
48 // activate column col |
48 // activate column col |
49 _columns[col].write(1); |
49 _columns[col].write(1); |
50 ThisThread::sleep_for(5); |
50 ThisThread::sleep_for(5ms); |
51 for(row=0; row<_nrows; row++) |
51 for(row=0; row<_nrows; row++) |
52 { |
52 { |
53 if (_rows[row].read()) |
53 if (_rows[row].read()) |
54 { |
54 { |
55 if (_keys[row + _nrows*col] < 2) // ensure only one key is pressed in this column |
55 if (_keys[row + _nrows*col] < 2) // ensure only one key is pressed in this column |
69 } |
69 } |
70 } |
70 } |
71 } |
71 } |
72 _columns[col].write(0); |
72 _columns[col].write(0); |
73 col = (col+1) % _ncols; |
73 col = (col+1) % _ncols; |
74 ThisThread::sleep_for(5); |
74 ThisThread::sleep_for(5ms); |
75 } |
75 } |
76 } |
76 } |
77 |
77 |
78 void Keypad::attach(const keyevent_callback_t& kp_callback, |
78 void Keypad::attach(const keyevent_callback_t& kp_callback, |
79 const keyevent_callback_t& kr_callback) |
79 const keyevent_callback_t& kr_callback) |