Eugene Gonzalez
/
GT511C3_demo
small GT511C3 demo that enrolls a finger by downloading the template then setting the template.
main.cpp@0:4bbfc068d864, 2015-12-01 (annotated)
- Committer:
- beanmachine44
- Date:
- Tue Dec 01 18:20:31 2015 +0000
- Revision:
- 0:4bbfc068d864
- Child:
- 1:4c720110a2a8
Initial commit;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
beanmachine44 | 0:4bbfc068d864 | 1 | #include "mbed.h" |
beanmachine44 | 0:4bbfc068d864 | 2 | #include "GT511C3.hpp" |
beanmachine44 | 0:4bbfc068d864 | 3 | |
beanmachine44 | 0:4bbfc068d864 | 4 | Serial debug(USBTX,USBRX); |
beanmachine44 | 0:4bbfc068d864 | 5 | |
beanmachine44 | 0:4bbfc068d864 | 6 | DigitalOut myled(LED1); |
beanmachine44 | 0:4bbfc068d864 | 7 | GT511C3 finger(p28,p27); |
beanmachine44 | 0:4bbfc068d864 | 8 | |
beanmachine44 | 0:4bbfc068d864 | 9 | int progress(int status,char *msg) |
beanmachine44 | 0:4bbfc068d864 | 10 | { |
beanmachine44 | 0:4bbfc068d864 | 11 | debug.printf("%s",msg); |
beanmachine44 | 0:4bbfc068d864 | 12 | return 0; |
beanmachine44 | 0:4bbfc068d864 | 13 | } |
beanmachine44 | 0:4bbfc068d864 | 14 | |
beanmachine44 | 0:4bbfc068d864 | 15 | int main() { |
beanmachine44 | 0:4bbfc068d864 | 16 | int sts = 0; |
beanmachine44 | 0:4bbfc068d864 | 17 | int ID = 0; |
beanmachine44 | 0:4bbfc068d864 | 18 | |
beanmachine44 | 0:4bbfc068d864 | 19 | debug.format(8,Serial::None,1); |
beanmachine44 | 0:4bbfc068d864 | 20 | debug.baud(115200); |
beanmachine44 | 0:4bbfc068d864 | 21 | |
beanmachine44 | 0:4bbfc068d864 | 22 | debug.printf("Fingerprint reader module \"GT-511C3 / GT-511C31\" test program.\n"); |
beanmachine44 | 0:4bbfc068d864 | 23 | debug.printf("Build: %s %s\n",__DATE__,__TIME__); |
beanmachine44 | 0:4bbfc068d864 | 24 | |
beanmachine44 | 0:4bbfc068d864 | 25 | debug.printf("Open\n"); |
beanmachine44 | 0:4bbfc068d864 | 26 | sts = finger.Open(); |
beanmachine44 | 0:4bbfc068d864 | 27 | debug.printf("sts = %d\n",sts); |
beanmachine44 | 0:4bbfc068d864 | 28 | if(sts == 0){ |
beanmachine44 | 0:4bbfc068d864 | 29 | int i; |
beanmachine44 | 0:4bbfc068d864 | 30 | debug.printf("FirmwareVersion = %lx\n",finger.FirmwareVersion); |
beanmachine44 | 0:4bbfc068d864 | 31 | debug.printf("IsoAreaMaxSize = %ld\n",finger.IsoAreaMaxSize); |
beanmachine44 | 0:4bbfc068d864 | 32 | debug.printf("DeviceSerialNumber = "); |
beanmachine44 | 0:4bbfc068d864 | 33 | for(i = 0; i < sizeof(finger.DeviceSerialNumber);i++){ |
beanmachine44 | 0:4bbfc068d864 | 34 | debug.printf("%02X",finger.DeviceSerialNumber[i]); |
beanmachine44 | 0:4bbfc068d864 | 35 | } |
beanmachine44 | 0:4bbfc068d864 | 36 | debug.printf("\n"); |
beanmachine44 | 0:4bbfc068d864 | 37 | } |
beanmachine44 | 0:4bbfc068d864 | 38 | |
beanmachine44 | 0:4bbfc068d864 | 39 | finger.DeleteAllIDs(); |
beanmachine44 | 0:4bbfc068d864 | 40 | int EnrollID = -1; |
beanmachine44 | 0:4bbfc068d864 | 41 | finger.Enroll(EnrollID,progress); |
beanmachine44 | 0:4bbfc068d864 | 42 | unsigned char data[496]; |
beanmachine44 | 0:4bbfc068d864 | 43 | finger.SetTemplate(11,data,496); |
beanmachine44 | 0:4bbfc068d864 | 44 | |
beanmachine44 | 0:4bbfc068d864 | 45 | |
beanmachine44 | 0:4bbfc068d864 | 46 | finger.CmosLed(1); |
beanmachine44 | 0:4bbfc068d864 | 47 | while(1) { |
beanmachine44 | 0:4bbfc068d864 | 48 | debug.printf("Press finger for Identify\n"); |
beanmachine44 | 0:4bbfc068d864 | 49 | finger.WaitPress(1); |
beanmachine44 | 0:4bbfc068d864 | 50 | if(finger.Capture(1) != 0) |
beanmachine44 | 0:4bbfc068d864 | 51 | continue; |
beanmachine44 | 0:4bbfc068d864 | 52 | ID = finger.Identify(); |
beanmachine44 | 0:4bbfc068d864 | 53 | debug.printf("ID = %d\n",ID); |
beanmachine44 | 0:4bbfc068d864 | 54 | debug.printf("Remove finger\n"); |
beanmachine44 | 0:4bbfc068d864 | 55 | finger.WaitPress(0); |
beanmachine44 | 0:4bbfc068d864 | 56 | } |
beanmachine44 | 0:4bbfc068d864 | 57 | } |