9
9
10
10
uart = busio .UART (board .TX , board .RX , baudrate = 57600 )
11
11
12
+ # If using with a computer such as Linux/RaspberryPi, Mac, Windows...
13
+ #import serial
14
+ #uart = serial.Serial("/dev/ttyUSB0", baudrate=57600, timeout=1)
15
+
12
16
finger = adafruit_fingerprint .Adafruit_Fingerprint (uart )
13
17
14
18
##################################################
@@ -31,7 +35,7 @@ def get_fingerprint():
31
35
def get_fingerprint_detail ():
32
36
"""Get a finger print image, template it, and see if it matches!
33
37
This time, print out each error instead of just returning on failure"""
34
- print ("Getting image..." , end = "" )
38
+ print ("Getting image..." , end = "" , flush = True )
35
39
i = finger .get_image ()
36
40
if i == adafruit_fingerprint .OK :
37
41
print ("Image taken" )
@@ -44,7 +48,7 @@ def get_fingerprint_detail():
44
48
print ("Other error" )
45
49
return False
46
50
47
- print ("Templating..." , end = "" )
51
+ print ("Templating..." , end = "" , flush = True )
48
52
i = finger .image_2_tz (1 )
49
53
if i == adafruit_fingerprint .OK :
50
54
print ("Templated" )
@@ -59,7 +63,7 @@ def get_fingerprint_detail():
59
63
print ("Other error" )
60
64
return False
61
65
62
- print ("Searching..." , end = "" )
66
+ print ("Searching..." , end = "" , flush = True )
63
67
i = finger .finger_fast_search ()
64
68
# pylint: disable=no-else-return
65
69
# This block needs to be refactored when it can be tested.
@@ -78,25 +82,25 @@ def enroll_finger(location):
78
82
"""Take a 2 finger images and template it, then store in 'location'"""
79
83
for fingerimg in range (1 , 3 ):
80
84
if fingerimg == 1 :
81
- print ("Place finger on sensor..." , end = "" )
85
+ print ("Place finger on sensor..." , end = "" , flush = True )
82
86
else :
83
- print ("Place same finger again..." , end = "" )
87
+ print ("Place same finger again..." , end = "" , flush = True )
84
88
85
89
while True :
86
90
i = finger .get_image ()
87
91
if i == adafruit_fingerprint .OK :
88
92
print ("Image taken" )
89
93
break
90
94
elif i == adafruit_fingerprint .NOFINGER :
91
- print ("." , end = "" )
95
+ print ("." , end = "" , flush = True )
92
96
elif i == adafruit_fingerprint .IMAGEFAIL :
93
97
print ("Imaging error" )
94
98
return False
95
99
else :
96
100
print ("Other error" )
97
101
return False
98
102
99
- print ("Templating..." , end = "" )
103
+ print ("Templating..." , end = "" , flush = True )
100
104
i = finger .image_2_tz (fingerimg )
101
105
if i == adafruit_fingerprint .OK :
102
106
print ("Templated" )
@@ -117,7 +121,7 @@ def enroll_finger(location):
117
121
while i != adafruit_fingerprint .NOFINGER :
118
122
i = finger .get_image ()
119
123
120
- print ("Creating model..." , end = "" )
124
+ print ("Creating model..." , end = "" , flush = True )
121
125
i = finger .create_model ()
122
126
if i == adafruit_fingerprint .OK :
123
127
print ("Created" )
@@ -128,7 +132,7 @@ def enroll_finger(location):
128
132
print ("Other error" )
129
133
return False
130
134
131
- print ("Storing model #%d..." % location , end = "" )
135
+ print ("Storing model #%d..." % location , end = "" , flush = True )
132
136
i = finger .store_model (location )
133
137
if i == adafruit_fingerprint .OK :
134
138
print ("Stored" )
0 commit comments