Trying to debug
Dependencies: mbed TextLCD keypad
keypadandlc.cpp@7:022c8579e8c7, 2019-02-05 (annotated)
- Committer:
- baet6458
- Date:
- Tue Feb 05 00:57:07 2019 +0000
- Revision:
- 7:022c8579e8c7
- Parent:
- 6:d2f4c1f6877c
changed to display index;
Who changed what in which revision?
User | Revision | Line number | New 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> |
baet6458 | 5:7aff70602b66 | 5 | //define lcd pins deafault 16x2 |
baet6458 | 5:7aff70602b66 | 6 | TextLCD lcd(D8,D9, D4, D5, D6, D7); // rs, e, d4, d5, d6, d7 |
reyno1jk | 0:9b646298bdc9 | 7 | // Define your own keypad values |
reyno1jk | 0:9b646298bdc9 | 8 | char Keytable[] = { '1', '2', '3', 'U', // r0 U = up |
reyno1jk | 0:9b646298bdc9 | 9 | '4', '5', '6', 'D', // r1 D = down |
reyno1jk | 0:9b646298bdc9 | 10 | '7', '8', '9', 'S', // r2 S = 2nd |
reyno1jk | 0:9b646298bdc9 | 11 | 'C', '0', ',', 'E' // r3 C = clear, E = enter |
reyno1jk | 0:9b646298bdc9 | 12 | }; |
reyno1jk | 0:9b646298bdc9 | 13 | // c0 c1 c2 c3 |
baet6458 | 1:c57c18e1ca87 | 14 | |
baet6458 | 1:c57c18e1ca87 | 15 | //displayed menu items |
baet6458 | 1:c57c18e1ca87 | 16 | 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 | 5:7aff70602b66 | 17 | |
baet6458 | 5:7aff70602b66 | 18 | //array to display and tracker |
baet6458 | 7:022c8579e8c7 | 19 | char LCDdisplay; |
baet6458 | 5:7aff70602b66 | 20 | int displayTracker=0; |
baet6458 | 1:c57c18e1ca87 | 21 | |
baet6458 | 3:59fc3838d34d | 22 | //key presesed holder |
baet6458 | 1:c57c18e1ca87 | 23 | int keyTracker=0; |
reyno1jk | 0:9b646298bdc9 | 24 | |
baet6458 | 5:7aff70602b66 | 25 | bool special =false; |
baet6458 | 5:7aff70602b66 | 26 | |
baet6458 | 1:c57c18e1ca87 | 27 | |
baet6458 | 1:c57c18e1ca87 | 28 | uint32_t LCDUpdate(uint32_t index) { |
baet6458 | 3:59fc3838d34d | 29 | //see which key is pressed |
baet6458 | 7:022c8579e8c7 | 30 | LCDdisplay= char(index); |
baet6458 | 1:c57c18e1ca87 | 31 | return 0; |
reyno1jk | 0:9b646298bdc9 | 32 | } |
reyno1jk | 0:9b646298bdc9 | 33 | |
baet6458 | 1:c57c18e1ca87 | 34 | |
reyno1jk | 0:9b646298bdc9 | 35 | int main() { |
reyno1jk | 0:9b646298bdc9 | 36 | // r0 r1 r2 r3 c0 c1 c2 c3 |
reyno1jk | 0:9b646298bdc9 | 37 | Keypad keypad(D0, D1, D2, D3, D10, D11, D12, D13); |
baet6458 | 1:c57c18e1ca87 | 38 | keypad.attach(&LCDUpdate); |
baet6458 | 2:c25102764602 | 39 | keypad.start(); |
reyno1jk | 0:9b646298bdc9 | 40 | while (1) { |
baet6458 | 6:d2f4c1f6877c | 41 | lcd.cls(); |
baet6458 | 6:d2f4c1f6877c | 42 | lcd.printf("Please Enter wires:"); |
baet6458 | 6:d2f4c1f6877c | 43 | lcd.locate(0,1); |
baet6458 | 7:022c8579e8c7 | 44 | lcd.putc(LCDdisplay); |
reyno1jk | 0:9b646298bdc9 | 45 | } |
baet6458 | 2:c25102764602 | 46 | |
reyno1jk | 0:9b646298bdc9 | 47 | } |