-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathFingerprintScannerShield.cpp
More file actions
88 lines (73 loc) · 1.88 KB
/
FingerprintScannerShield.cpp
File metadata and controls
88 lines (73 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
Project: 1Sheeld Library
File: FingerprintScannerShield.cpp
Version: 1.9.3
Compiler: Arduino avr-gcc 4.3.2
Author: Integreight
Date: 2016.11
*/
#define FROM_ONESHEELD_LIBRARY
#include "OneSheeld.h"
#include "FingerprintScannerShield.h"
//Constructor
FingerprintScannerShield::FingerprintScannerShield() : ShieldParent(FINGERPRINT_ID)
{
isFingerVerified = false;
isNewFingerprintScanned= false;
isErrorCallbackAssigned= false;
isFingerprintCallbackAssigned = false;
}
void FingerprintScannerShield::scan()
{
OneSheeld.sendShieldFrame(FINGERPRINT_ID,0,FINGERPRINT_SCAN,0);
}
bool FingerprintScannerShield::isNewFingerScanned()
{
return isNewFingerprintScanned;
}
bool FingerprintScannerShield::isVerified()
{
isNewFingerprintScanned = false;
return isFingerVerified;
}
//Process Input Data
void FingerprintScannerShield::processData()
{
byte functionID = getOneSheeldInstance().getFunctionId();
if(functionID==FINGERPRINT_GET)
{
isNewFingerprintScanned = true;
isFingerVerified = getOneSheeldInstance().getArgumentData(0)[0];
//Invoke User Function
if(!isInACallback())
{
if(isFingerprintCallbackAssigned)
{
enteringACallback();
(*fingerprintCallback)(isFingerVerified);
exitingACallback();
}
}
}
else if(functionID==FINGERPRINT_GET_ERROR && !isInACallback())
{
byte errorNumber=getOneSheeldInstance().getArgumentData(0)[0];
//Invoke User Function
if(isErrorCallbackAssigned)
{
enteringACallback();
(*errorCallback)(errorNumber);
exitingACallback();
}
}
}
void FingerprintScannerShield::setOnError(void (*userFunction)(byte))
{
errorCallback=userFunction;
isErrorCallbackAssigned=true;
}
void FingerprintScannerShield::setOnNewFingerScanned(void (*userFunction)(bool))
{
fingerprintCallback=userFunction;
isFingerprintCallbackAssigned=true;
}