Demo of the RA8875 Keypad to enter a username and password.

Dependencies:   mbed RA8875 Keypad

Files at this revision

API Documentation at this revision

Comitter:
WiredHome
Date:
Mon Feb 08 02:47:49 2016 +0000
Child:
1:0fea662d1826
Commit message:
Demo of the Keypad library using an onscreen keypad to enter a username and password.

Changed in this revision

Keypad.lib Show annotated file Show diff for this revision Revisions of this file
RA8875.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Keypad.lib	Mon Feb 08 02:47:49 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/WiredHome/code/Keypad/#9b0b4ae5b47a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RA8875.lib	Mon Feb 08 02:47:49 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/WiredHome/code/RA8875/#8d1d3832a215
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Feb 08 02:47:49 2016 +0000
@@ -0,0 +1,83 @@
+#include "mbed.h"               // v112
+#include "RA8875.h"
+#include "Keypad.h"
+
+LocalFileSystem local("local");     // Because I want <PrintScreen>
+Serial pc(USBTX, USBRX);            // And a little feedback
+
+RA8875 lcd(p5, p6, p7, p12, NC, "tft");    // MOSI, MISO, SCK, /ChipSelect, /reset, name
+Keypad kp(lcd);
+
+
+void CalibrateTS(void)
+{
+    FILE * fh;
+    tpMatrix_t matrix;
+    RetCode_t r;
+
+    r = lcd.TouchPanelCalibrate("Calibrate the touch panel", &matrix);
+    if (r == noerror) {
+        fh = fopen("/local/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("/local/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()
+{
+    char name1[20], name2[20];
+
+    pc.baud(460800);                            // I like a snappy terminal, so crank it up!
+    pc.printf("\r\nDev Keypad - Build " __DATE__ " " __TIME__ "\r\n");
+
+    lcd.init();
+    lcd.foreground(Yellow);
+    lcd.background(Black);
+    lcd.puts(0,0, "RA8875 Soft Fonts - Build " __DATE__ " " __TIME__ "\r\n");
+    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:")) {
+            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);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Feb 08 02:47:49 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/f141b2784e32
\ No newline at end of file