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.
Dependencies: mbed TextLCD keypad
Revision 5:7aff70602b66, committed 2019-01-31
- Comitter:
- baet6458
- Date:
- Thu Jan 31 00:40:37 2019 +0000
- Parent:
- 4:865b08b6fc74
- Child:
- 6:d2f4c1f6877c
- Commit message:
- Updated keypad algorithm. 2nd key now changes comma to a dash.; Hopefully fixed array clear. Need to check
Changed in this revision
| keypadandlc.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/keypadandlc.cpp Wed Jan 30 03:55:27 2019 +0000
+++ b/keypadandlc.cpp Thu Jan 31 00:40:37 2019 +0000
@@ -2,6 +2,8 @@
#include "mbed.h"
#include "Keypad.h"
#include <string>
+//define lcd pins deafault 16x2
+TextLCD lcd(D8,D9, D4, D5, D6, D7); // rs, e, d4, d5, d6, d7
// Define your own keypad values
char Keytable[] = { '1', '2', '3', 'U', // r0 U = up
'4', '5', '6', 'D', // r1 D = down
@@ -12,14 +14,29 @@
//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"};
+
+ //array to display and tracker
+ char LCDdisplay[16];
+ int displayTracker=0;
//key presesed holder
int keyTracker=0;
+ bool special =false;
+
//enter function
void enterFunc(){
//do something eventually
}
+
+void updateDisplayArray(int pos, bool comma=false){
+ if (comma == false)
+ LCDdisplay[displayTracker]=Keytable[pos];
+ else
+ LCDdisplay[displayTracker]='-';
+
+ special=false;
+ }
uint32_t LCDUpdate(uint32_t index) {
@@ -37,16 +54,26 @@
//if 2nd button is pressed
case 11:
- // do something
+ //say if 2nd is pressed
+ special=!special;
break;
//if clear is pressed
case 12:
//reset key Tracker
keyTracker=0;
+ //put blanks back in array
+ for(int i=0;i<16;i++){
+ LCDdisplay[i]='\b';
+ }
break;
//if comma is pressed
case 14:
- //do something
+ //if 2nd is pressed put in dash
+ if (special==true)
+ updateDisplayArray(index,special);
+ else
+ //otherwise it is a comma
+ updateDisplayArray(index);
break;
//if enter is pressed
case 15:
@@ -55,10 +82,17 @@
break;
default://update the keypressed
+
+ //may remove this later
keyTracker=keyTracker*10+int(Keytable[index]);
+
+ updateDisplayArray(index);
+
}
-
+ displayTracker++;
+ if(displayTracker>16)
+ displayTracker=0;
return 0;
}