Trying to debug

Dependencies:   mbed TextLCD keypad

Committer:
baet6458
Date:
Wed Jan 30 03:52:54 2019 +0000
Revision:
3:59fc3838d34d
Parent:
2:c25102764602
Child:
4:865b08b6fc74
updated for all key presses;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
reyno1jk 0:9b646298bdc9 1 #include "TextLCD.h"
reyno1jk 0:9b646298bdc9 2 #include "mbed.h"
reyno1jk 0:9b646298bdc9 3 #include "Keypad.h"
reyno1jk 0:9b646298bdc9 4 #include <string>
reyno1jk 0:9b646298bdc9 5 // Define your own keypad values
reyno1jk 0:9b646298bdc9 6 char Keytable[] = { '1', '2', '3', 'U', // r0 U = up
reyno1jk 0:9b646298bdc9 7 '4', '5', '6', 'D', // r1 D = down
reyno1jk 0:9b646298bdc9 8 '7', '8', '9', 'S', // r2 S = 2nd
reyno1jk 0:9b646298bdc9 9 'C', '0', ',', 'E' // r3 C = clear, E = enter
reyno1jk 0:9b646298bdc9 10 };
reyno1jk 0:9b646298bdc9 11 // c0 c1 c2 c3
baet6458 1:c57c18e1ca87 12
baet6458 1:c57c18e1ca87 13 //displayed menu items
baet6458 1:c57c18e1ca87 14 const char* menu[]={"Select harness:","1. Harness A","2. Harness B","3. Harness C","4. Harness D","5. Harness E","6. Harness F","7. Harness G","8. Harness H","9. Harness I","Test in progress"};
baet6458 1:c57c18e1ca87 15
baet6458 3:59fc3838d34d 16 //key presesed holder
baet6458 1:c57c18e1ca87 17 int keyTracker=0;
reyno1jk 0:9b646298bdc9 18
baet6458 1:c57c18e1ca87 19 //enter function
baet6458 1:c57c18e1ca87 20 void enterFunc(){
baet6458 1:c57c18e1ca87 21 //do something eventually
baet6458 1:c57c18e1ca87 22 }
reyno1jk 0:9b646298bdc9 23
baet6458 1:c57c18e1ca87 24
baet6458 1:c57c18e1ca87 25 uint32_t LCDUpdate(uint32_t index) {
baet6458 3:59fc3838d34d 26 //see which key is pressed
baet6458 3:59fc3838d34d 27 switch (index){
baet6458 3:59fc3838d34d 28 //if up button is presseed
baet6458 3:59fc3838d34d 29 case 3:
baet6458 3:59fc3838d34d 30 //do something
baet6458 3:59fc3838d34d 31 break;
baet6458 3:59fc3838d34d 32
baet6458 3:59fc3838d34d 33 //if down button is pressed
baet6458 3:59fc3838d34d 34 case 7:
baet6458 3:59fc3838d34d 35 //do something
baet6458 3:59fc3838d34d 36 break;
baet6458 3:59fc3838d34d 37
baet6458 3:59fc3838d34d 38 //if 2nd button is pressed
baet6458 3:59fc3838d34d 39 case 11:
baet6458 3:59fc3838d34d 40 // do something
baet6458 3:59fc3838d34d 41 break;
baet6458 3:59fc3838d34d 42 //if clear is pressed
baet6458 3:59fc3838d34d 43 case 12:
baet6458 3:59fc3838d34d 44 //reset key Tracker
baet6458 3:59fc3838d34d 45 keyTracker=0;
baet6458 3:59fc3838d34d 46 break;
baet6458 3:59fc3838d34d 47 //if comma is pressed
baet6458 3:59fc3838d34d 48 case 14:
baet6458 3:59fc3838d34d 49 //do something
baet6458 3:59fc3838d34d 50 break;
baet6458 3:59fc3838d34d 51 //if enter is pressed
baet6458 3:59fc3838d34d 52 case 15:
baet6458 1:c57c18e1ca87 53 //call enter function
baet6458 3:59fc3838d34d 54 enterFunc();
baet6458 3:59fc3838d34d 55 break;
baet6458 3:59fc3838d34d 56
baet6458 3:59fc3838d34d 57 default://update the keypressed
baet6458 3:59fc3838d34d 58 keyTracker=keyTracker*10+int(Keytable[index]);
baet6458 1:c57c18e1ca87 59 }
baet6458 1:c57c18e1ca87 60
baet6458 1:c57c18e1ca87 61
baet6458 1:c57c18e1ca87 62 return 0;
reyno1jk 0:9b646298bdc9 63 }
reyno1jk 0:9b646298bdc9 64
baet6458 1:c57c18e1ca87 65
reyno1jk 0:9b646298bdc9 66 int main() {
reyno1jk 0:9b646298bdc9 67 // r0 r1 r2 r3 c0 c1 c2 c3
reyno1jk 0:9b646298bdc9 68 Keypad keypad(D0, D1, D2, D3, D10, D11, D12, D13);
baet6458 1:c57c18e1ca87 69 keypad.attach(&LCDUpdate);
baet6458 2:c25102764602 70 keypad.start();
reyno1jk 0:9b646298bdc9 71 while (1) {
baet6458 3:59fc3838d34d 72 print(keyTracker);
reyno1jk 0:9b646298bdc9 73 }
baet6458 2:c25102764602 74
reyno1jk 0:9b646298bdc9 75 }