Skip to content

added additional functionalities #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions examples/fingerprint_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
led = DigitalInOut(board.D13)
led.direction = Direction.OUTPUT

uart = busio.UART(board.TX, board.RX, baudrate=57600)
#uart = busio.UART(board.TX, board.RX, baudrate=57600)

# If using with a computer such as Linux/RaspberryPi, Mac, Windows...
#import serial
#uart = serial.Serial("/dev/ttyUSB0", baudrate=57600, timeout=1)
uart = serial.Serial("/dev/ttyAMA0", baudrate=57600, timeout=1)

finger = adafruit_fingerprint.Adafruit_Fingerprint(uart)

Expand Down Expand Up @@ -152,10 +153,13 @@ def enroll_finger(location):

def get_num():
"""Use input() to get a valid number from 1 to 127. Retry till success!"""
i = 0
while (i > 127) or (i < 1):
#i = 0
i = -1
#while (i > 127) or (i < 1):
while (i > 999) or (i < 0):
try:
i = int(input("Enter ID # from 1-127: "))
#i = int(input("Enter ID # from 1-127: "))
i = int(input("Enter ID # from 0-999: "))
except ValueError:
pass
return i
Expand All @@ -166,9 +170,14 @@ def get_num():
if finger.read_templates() != adafruit_fingerprint.OK:
raise RuntimeError('Failed to read templates')
print("Fingerprint templates:", finger.templates)
if finger.count_templates() != adafruit_fingerprint.OK:
raise RuntimeError('Failed to read templates')
print("Number of templates: ", finger.template_count)
print("e) enroll print")
print("e) enroll print")
print("f) find print")
print("d) delete print")
print("r) reset library")
print("----------------")
c = input("> ")

Expand All @@ -184,3 +193,9 @@ def get_num():
print("Deleted!")
else:
print("Failed to delete")
if c == 'r':
finger._send_packet([adafruit_fingerprint._EMPTY])
if finger._get_packet(12)[0] == adafruit_fingerprint.OK:
print("Library empty!")
else:
print("Failed to empty library")