Trying to debug
Dependencies: mbed TextLCD keypad
keypadandlc.cpp
- Committer:
- baet6458
- Date:
- 2019-01-30
- Revision:
- 4:865b08b6fc74
- Parent:
- 3:59fc3838d34d
- Child:
- 5:7aff70602b66
File content as of revision 4:865b08b6fc74:
#include "TextLCD.h" #include "mbed.h" #include "Keypad.h" #include <string> // Define your own keypad values char Keytable[] = { '1', '2', '3', 'U', // r0 U = up '4', '5', '6', 'D', // r1 D = down '7', '8', '9', 'S', // r2 S = 2nd 'C', '0', ',', 'E' // r3 C = clear, E = enter }; // c0 c1 c2 c3 //displayed menu items 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"}; //key presesed holder int keyTracker=0; //enter function void enterFunc(){ //do something eventually } uint32_t LCDUpdate(uint32_t index) { //see which key is pressed switch (index){ //if up button is presseed case 3: //do something break; //if down button is pressed case 7: //do something break; //if 2nd button is pressed case 11: // do something break; //if clear is pressed case 12: //reset key Tracker keyTracker=0; break; //if comma is pressed case 14: //do something break; //if enter is pressed case 15: //call enter function enterFunc(); break; default://update the keypressed keyTracker=keyTracker*10+int(Keytable[index]); } return 0; } int main() { // r0 r1 r2 r3 c0 c1 c2 c3 Keypad keypad(D0, D1, D2, D3, D10, D11, D12, D13); keypad.attach(&LCDUpdate); keypad.start(); while (1) { //do something eventually } }