Skip to content

Commit

Permalink
Merge pull request #2 from cycloon/master
Browse files Browse the repository at this point in the history
Implement command "empty" and add a compile fix for Arduino 1.0
  • Loading branch information
ladyada committed Oct 19, 2012
2 parents db806ea + c594744 commit 67f6b0f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
27 changes: 27 additions & 0 deletions Adafruit_Fingerprint.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ uint8_t Adafruit_Fingerprint::storeModel(uint16_t id) {
return packet[1];
}

uint8_t Adafruit_Fingerprint::emptyDatabase(void) {
uint8_t packet[] = {FINGERPRINT_EMPTY};
writePacket(theAddress, FINGERPRINT_COMMANDPACKET, sizeof(packet)+2, packet);
uint8_t len = getReply(packet);

if ((len != 1) && (packet[0] != FINGERPRINT_ACKPACKET))
return -1;
return packet[1];
}

uint8_t Adafruit_Fingerprint::fingerFastSearch(void) {
fingerID = 0xFFFF;
confidence = 0xFFFF;
Expand All @@ -123,6 +133,23 @@ uint8_t Adafruit_Fingerprint::fingerFastSearch(void) {
return packet[1];
}

uint8_t Adafruit_Fingerprint::getTemplateCount(void) {
templateCount = 0xFFFF;
// get number of templates in memory
uint8_t packet[] = {FINGERPRINT_TEMPLATECOUNT};
writePacket(theAddress, FINGERPRINT_COMMANDPACKET, sizeof(packet)+2, packet);
uint8_t len = getReply(packet);

if ((len != 1) && (packet[0] != FINGERPRINT_ACKPACKET))
return -1;

templateCount = packet[2];
templateCount <<= 8;
templateCount |= packet[3];

return packet[1];
}



void Adafruit_Fingerprint::writePacket(uint32_t addr, uint8_t packettype,
Expand Down
6 changes: 5 additions & 1 deletion Adafruit_Fingerprint.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@
#define FINGERPRINT_IMAGE2TZ 0x02
#define FINGERPRINT_REGMODEL 0x05
#define FINGERPRINT_STORE 0x06
#define FINGERPRINT_EMPTY 0x0D
#define FINGERPRINT_VERIFYPASSWORD 0x13
#define FINGERPRINT_HISPEEDSEARCH 0x1B
#define FINGERPRINT_TEMPLATECOUNT 0x1D

//#define FINGERPRINT_DEBUG

Expand All @@ -81,12 +83,14 @@ class Adafruit_Fingerprint {
uint8_t getImage(void);
uint8_t image2Tz(uint8_t slot = 1);
uint8_t createModel(void);
uint8_t emptyDatabase(void);
uint8_t storeModel(uint16_t id);
uint8_t fingerFastSearch(void);
uint8_t getTemplateCount(void);
void writePacket(uint32_t addr, uint8_t packettype, uint16_t len, uint8_t *packet);
uint8_t getReply(uint8_t packet[], uint16_t timeout=DEFAULTTIMEOUT);

uint16_t fingerID, confidence;
uint16_t fingerID, confidence, templateCount;

private:
uint32_t thePassword;
Expand Down
Binary file added documentation/fingerprint_en.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions examples/enroll/enroll.pde
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

#include <Adafruit_Fingerprint.h>
#if ARDUINO >= 100
#include <NewSoftSerial.h>
#else
#include <SoftwareSerial.h>
#else
#include <NewSoftSerial.h>
#endif

uint8_t getFingerprintEnroll(uint8_t id);
Expand Down

0 comments on commit 67f6b0f

Please sign in to comment.