Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 1:db0e3fb4d3c4, committed 2019-04-10
- Comitter:
- peps
- Date:
- Wed Apr 10 22:08:13 2019 +0000
- Parent:
- 0:aed236b6c48e
- Commit message:
- Improved keyboard handling.
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r aed236b6c48e -r db0e3fb4d3c4 main.cpp
--- a/main.cpp Mon May 21 21:59:31 2018 +0000
+++ b/main.cpp Wed Apr 10 22:08:13 2019 +0000
@@ -7,10 +7,10 @@
DigitalOut* _rows[4];
DigitalIn* _cols[4];
-TextLCD lcd(D2,D3,D4,D5,D6,D7);
+TextLCD lcd(D2,D3,D4,D5,D6,D7);
// Define your own keypad values
-char Keytable[] = {
+char Keytable[] = {
'1', '2', '3', 'A', // r0
'4', '5', '6', 'B', // r1
'7', '8', '9', 'C', // r2
@@ -20,9 +20,9 @@
int getKeyIndex() {
int result = -1;
- for (int r = 0; r < 4; r++) {
+ for (int r = 0; r < 4 && result == -1; r++) {
_rows[r]->write(1);
- for(int c = 0;c < 4 ;c++){
+ for(int c = 0; c < 4 && result == -1; c++){
DigitalIn *col = _cols[c];
if(col->read() == 1) {
result = r*4+c;
@@ -51,10 +51,10 @@
int main() {
char key;
lcd.locate(0,0);
- lcd.printf("Clean");
-
- init();
-
+ lcd.printf("Clean");
+
+ init();
+
while(1) {
key = getKey();
lcd.locate(0,1);