Exemplo n.º 1
0
def main():
   #Create unix pipe
   main_pipe, fingerpint_pipe = Pipe()
   LCD_IN, LCD_OUT = Pipe()
   
   # Initializes LCD and LED
   LCD.init()
   LED.init()
   # Create an object of the class Parser and Poller
   parser = Parser()
   poller = Poller(parser, fingerpint_pipe, 1)
   # Create child process
   pid = os.fork()

   # Parent process
   if pid:
      try:
         # start the individual threads for LCD, NFC and poller
         lcd_thread = threading.Thread(target=LCD.new_start, args=(LCD_IN,))
         lcd_thread.daeomon = True
         lcd_thread.start()
         nfc_thread = threading.Thread(target=nfcread.readNFC, args=(parser, fingerpint_pipe, LCD_OUT,))
         nfc_thread.daeomon = True
         nfc_thread.start()
         poll_thread = threading.Thread(target=poller.startPolling)
         poll_thread.daeomon = True
         poll_thread.start()
      except:
         print "Error: unable to start thread"
      try:
         # Poll fingerprint pipe
         while 1:
            if fingerpint_pipe.poll(1):
               parser.course_id = fingerpint_pipe.recv()
      # Kill the threads and clears the LCD screen
      except KeyboardInterrupt:
         LCD.clear()
         os.kill(pid, signal.SIGKILL)
         os.kill(os.getpid(), signal.SIGKILL)
         sys.exit()
         
         
   else:
      # Start fingerprint on child procces
      try:
         fingerprint = Fingerprint()
         fingerprint.start(parser, main_pipe, LCD_OUT)
      # Clear the screen
      except KeyboardInterrupt:
         LCD.clear()
         sys.exit()
Exemplo n.º 2
0
class Test:
	def __init__(self):
		self._last_update = None

	def callback(self, text):
		print("[Message] %s" % text)

		return False	

	def progress(self, rec, chunk):
		now = time.time()

		if not self._last_update or (now - self._last_update) > 0.5:
			self._lcd.line2("%s %d/%d" % (('R' if rec.recording else ' '), rec._intensity(chunk), rec._silence_threshold))

			self._last_update = now

	def do_test(self):
		self._lcd = LCD()
		self._lcd.init()

		rec = SpeechRec(debug = True)
		rec.start()
		rec.listen(self.callback, progress = self.progress)
Exemplo n.º 3
0
from time import sleep

from lcd import LCD

A = [0, 1, 0, 0, 0, 0, 0, 1]
ones = [1, 1, 1, 1, 1, 1, 1, 1]
zeroes = [0, 0, 0, 0, 0, 0, 0, 0]

try:
    lcd = LCD()
    lcd.init()
    while True:
        lcd.send(ones)
        sleep(2)
        lcd.send(zeroes)

    lcd.cleanup()
except:
    lcd.cleanup()
Exemplo n.º 4
0
# Licensed under MIT License

import nfc.MFRC522 as MFRC522
from network.Parser import Parser
from fingerprint.Fingerprint import Fingerprint
import lcd.LCD as LCD
import time

# Create parser
parser = Parser()
# Create an object of the class MFRC522
MIFAREReader = MFRC522.MFRC522()
finerprint_scanner = Fingerprint()
print("Scan your card to identify yourself")

LCD.init()

while (True):
    LCD.write("SCAN CARD")
    # Scan for cards
    (status, TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)
    if status == MIFAREReader.MI_OK:
        # Get the UID of the card
        (status, uid) = MIFAREReader.MFRC522_Anticoll()
        # UID saved as nfcData
        nfc_data = str(uid[0]) + str(uid[1]) + str(uid[2]) + str(uid[3]) + str(
            uid[4])
        print("Card                               Detected")
        LCD.write("CARD DETECTED")
        time.sleep(1)
        LCD.write("SCAN FINGER")