FRDM-K64F fork of David Smart's RA8875 TFT Display with onscreen QWERTY touch keypad Demo
Dependencies: Keypad RA8875 SDFileSystem mbed
Fork of RA8875_Demo by
Revision 14:d71b1aa3c8bf, committed 2016-02-23
- Comitter:
- unix_guru
- Date:
- Tue Feb 23 03:50:39 2016 +0000
- Parent:
- 13:3f6204d6140a
- Commit message:
- FRDM-K64F variant of David Smart's RA8875 KeyPad demo
Changed in this revision
Keypad.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 3f6204d6140a -r d71b1aa3c8bf Keypad.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Keypad.lib Tue Feb 23 03:50:39 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/WiredHome/code/Keypad/#9b0b4ae5b47a
diff -r 3f6204d6140a -r d71b1aa3c8bf main.cpp --- a/main.cpp Tue Feb 23 02:49:18 2016 +0000 +++ b/main.cpp Tue Feb 23 03:50:39 2016 +0000 @@ -1,6 +1,8 @@ -#include "mbed.h" // v112 -#include "RA8875.h" // v102 +#include "mbed.h" +#include "RA8875.h" +#include "Keypad.h" + #include "MyFont18x32.h" #include "BPG_Arial08x08.h" #include "BPG_Arial10x10.h" @@ -19,47 +21,86 @@ Serial pc(USBTX, USBRX); // And a little feedback +RA8875 lcd(PTD2, PTD3, PTD1, PTD0, NC, "tft"); // MOSI, MISO, SCK, /ChipSelect, /reset, name +Keypad kp(lcd); // Associate Virtual keypad with the RA8875 TFT + + +void CalibrateTS(void) +{ + FILE * fh; + tpMatrix_t matrix; + RetCode_t r; + + r = lcd.TouchPanelCalibrate("Calibrate the touch panel", &matrix); + if (r == noerror) { + fh = fopen("/sd/tpcal.cfg", "wb"); + if (fh) { + fwrite(&matrix, sizeof(tpMatrix_t), 1, fh); + fclose(fh); + } else { + } + } else { + } +} + + +void InitTS(void) +{ + FILE * fh; + tpMatrix_t matrix; + + fh = fopen("/sd/tpcal.cfg", "rb"); + if (fh) { + fread(&matrix, sizeof(tpMatrix_t), 1, fh); + fclose(fh); + lcd.TouchPanelSetMatrix(&matrix); + pc.printf("Touch Panel calibration set\r\n"); + } else { + CalibrateTS(); + } +} + + int main() { -// RA8875 lcd(p5, p6, p7, p12, NC, "tft"); // MOSI, MISO, SCK, /ChipSelect, /reset, name -RA8875 lcd(PTD2, PTD3, PTD1, PTD0, NC, "tft"); // MOSI, MISO, SCK, /ChipSelect, /reset, name - - pc.baud(115200); - pc.printf("\r\nRA8875 Soft Fonts - Build " __DATE__ " " __TIME__ "\r\n"); - + char name1[20], name2[20]; + + pc.baud(115200); + pc.printf("\r\nDev Keypad - Build " __DATE__ " " __TIME__ "\r\n"); + lcd.init(); - - - // ************************** - //RunTestSet(lcd, pc); // If the library was compiled for test mode... - - lcd.foreground(RGB(255,255,0)); + lcd.foreground(Yellow); + lcd.background(Black); lcd.puts(0,0, "RA8875 Soft Fonts - Build " __DATE__ " " __TIME__ "\r\n"); - - lcd.SelectUserFont(Dave_Smart18x32); - lcd.puts("**** ! Soft Fonts ! **** 0123456789\r\n"); - lcd.puts("ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n"); - //lcd.puts("abcdefghijklmnopqrstuvwxyz\r\n"); - lcd.SelectUserFont(); - lcd.puts("Back to normal\r\n"); - lcd.SelectUserFont(BPG_Arial08x08); - lcd.puts("BPG_Arial08x08 ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n"); - //lcd.puts("BPG_Arial08x08 abcdefghijklmnopqrstuvwxyz\r\n"); - lcd.SelectUserFont(BPG_Arial10x10); - lcd.puts("BPG_Arial10x10 ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n"); - //lcd.puts("BPG_Arial10x10 abcdefghijklmnopqrstuvwxyz\r\n"); - lcd.SelectUserFont(BPG_Arial20x20); - lcd.puts("BPG_Arial20x20 "); - lcd.SelectUserFont(BPG_Arial31x32); - lcd.puts("BPG_Arial31x32\r\n"); - lcd.SelectUserFont(BPG_Arial63x63); - lcd.puts("BPG_Arial63x63"); - - pc.printf("PrintScreen activated ...\r\n"); - RetCode_t r = lcd.PrintScreen(0,0,480,272,"/sd/file.bmp"); + InitTS(); + while(1) { + lcd.foreground(Yellow); + lcd.background(Black); + lcd.cls(); + lcd.puts(0,20, "Enter username and password\r\n"); + if (kp.GetString(name1, 20, "Username:")) { + pc.printf("PrintScreen activated ...\r\n"); + RetCode_t r = lcd.PrintScreen(0,0,480,272,"/sd/file2.bmp"); pc.printf(" PrintScreen returned %d\r\n", r); - - while(1) { - ; // end + lcd.printf("username: %s\r\n", name1); + if (kp.GetString(name2, 20, "Password:", '*')) { + lcd.printf("password: %s\r\n", name2); + kp.Erase(); + lcd.foreground(BrightRed); + lcd.background(Black); + lcd.cls(); + lcd.SetTextFontSize(2); + lcd.SetTextCursor(0,30); + lcd.printf("username: %s\r\npassword: %s\r\n", name1, name2); + lcd.SetTextFontSize(); + + + } + } else { + kp.Erase(); + pc.printf("<esc>\r\n"); + } + wait(5); } } + \ No newline at end of file