main.cpp is a direct example, waits for an input and then process it. test.cpp is modified, only process when there's a pressure

Dependencies:   GT511C3 mbed

Fork of GT511C3test by Toshihisa T

Files at this revision

API Documentation at this revision

Comitter:
inezraharjo
Date:
Sun Dec 06 22:32:12 2015 +0000
Parent:
7:8b9ef3211cd0
Commit message:
main.cpp is a direct example, after registering fingerprint it waits for the platform to be pressed. test.cpp is my modified version, instead of being stuck in a while loop of 'waiting to be pressed' it will trigger only if there's pressure

Changed in this revision

test.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 8b9ef3211cd0 -r ef4e75a5c00a test.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test.cpp	Sun Dec 06 22:32:12 2015 +0000
@@ -0,0 +1,69 @@
+#include "mbed.h"
+#include "GT511C3.hpp"
+
+Serial debug(USBTX,USBRX);
+
+DigitalOut myled(LED1);
+GT511C3 finger(p28,p27);
+
+int progress(int status,char *msg)
+{
+    debug.printf("%s",msg);
+    return 0;
+}
+
+int main() {
+    int sts = 0;
+    int ID = 0;
+
+    debug.format(8,Serial::None,1);
+    debug.baud(115200);
+
+    debug.printf("Fingerprint reader module \"GT-511C3 / GT-511C31\" test program.\n");
+    debug.printf("Build: %s %s\n",__DATE__,__TIME__);
+
+    debug.printf("Open\n");
+    sts = finger.Open();
+    debug.printf("sts = %d\n",sts);
+    if(sts == 0){
+        int i;
+        debug.printf("FirmwareVersion = %lx\n",finger.FirmwareVersion);
+        debug.printf("IsoAreaMaxSize = %ld\n",finger.IsoAreaMaxSize);
+        debug.printf("DeviceSerialNumber = ");
+        for(i = 0; i < sizeof(finger.DeviceSerialNumber);i++){
+            debug.printf("%02X",finger.DeviceSerialNumber[i]);
+        }
+        debug.printf("\n");
+    }
+    
+    /* 
+    STEPS:
+    First configuration: enter a code to get ready to register fingerprint
+    LED flashing/alarm buzzing to indicate start/finish of fingerprint
+    When a finger is detected, matched with what is recorded, act similar to code
+    */
+
+    if(1){
+        int EnrollID = 11;
+        if(finger.CheckEnrolled(EnrollID) == 0){
+            debug.printf("EnrollID(%d) is already enrolled.Delete!\n",EnrollID);
+            if(finger.DeleteID(EnrollID) == 0){
+                debug.printf("Delete OK!\n");
+            }
+        }
+        finger.Enroll(EnrollID,progress);
+    }
+
+    finger.CmosLed(1);
+    
+    debug.printf("Press finger to identify\r\n");
+    while(1) {
+        if (finger.IsPress()){
+            ID = finger.Identify();
+            debug.printf("ID = %d\n",ID); 
+            debug.printf("Remove finger\n");
+        }
+        finger.WaitPress(0);
+        
+    }
+}