コード例 #1
0
ファイル: attendance.py プロジェクト: loliktry/attendance
def printDateToDisplay():
    while True:
        #Display current time on display, until global variable is set
        if displayTime!=True:
            thread.exit()
        display.lcdWriteFirstLine(time.strftime("%d.%m. %H:%M:%S", time.localtime()))
        onScreen(time.strftime("%d.%m.%Y %H:%M:%S", time.localtime()))
        time.sleep(1)
コード例 #2
0
ファイル: attendance.py プロジェクト: Insaida/attendance
def printDateToDisplay():
    while True:
        #Display current time on display, until global variable is set
        if displayTime!=True:
            thread.exit()
        display.lcdWriteFirstLine(time.strftime("%d.%m. %H:%M:%S", time.localtime()))
        onScreen(time.strftime("%d.%m.%Y %H:%M:%S", time.localtime()))
        time.sleep(1)
コード例 #3
0
ファイル: attendance.py プロジェクト: johannkraus/attendance
def Interrupt(channel):
    global displayTime
    displayTime = False
    if(channel==10):
        logging.info("Button poweroff")
        display.lcdWriteSecondLine("Power off")
        display.lcdWriteFirstLine("")
        time.sleep(1)
        display.lcdWriteSecondLine("")
        os.system("./dumpdb.sh") # first dump db with timestamp
        os.system("poweroff -f") # this is handled by tinycorelinux
	time.sleep(60) # just sleep until shutdown
    if(channel==3):
        readNfc(55)
    if(channel==5):
        readNfc(57)
    displayTime = True
コード例 #4
0
ファイル: nfc.py プロジェクト: prabh13/nfcpay
def main():
    #GPIO.cleanup()
    try:
        #display.initGpio()
        display.init()
        while True:
            display.lcdWriteFirstLine("Welcome..")
            display.lcdWriteSecondLine("Choose an action...")
            print "choose an action"
            
            global displayTime
            displayTime=True
            #Start new thread to show curent datetime on display
            # and wait for user input on keyboard
            #thr = thread.start_new_thread(printDateToDisplay, ())
            a = getOneKey()
            displayTime=False
            if 47 < a < 58:
                readNfc(a)
    except KeyboardInterrupt:
        GPIO.cleanup()
        pass
    GPIO.cleanup()
コード例 #5
0
ファイル: attendance.py プロジェクト: johannkraus/attendance
def main():
    try:
        initGpio()
        mysqlite.init()
        display.init()
        display.lcdWriteSecondLine("Willkommen")

        global displayTime
        displayTime = True
        
        while 1:
            while displayTime:
                printTimeToDisplay()
                time.sleep(1)

            #Start new thread to show curent datetime on display
            # and wait for user input on keyboard
            #thr = thread.start_new_thread(printDateToDisplay, ())
            #a = getOneKey()
            #displayTime=False
            #if 47 < a < 58:
            #    readNfc(a)

    except KeyboardInterrupt:
        print "Good-bye!"
        logging.info("Keyboard interrupt")
        display.lcdWriteFirstLine("Good-bye!")
        display.lcdWriteSecondLine("")
        time.sleep(1)
        display.lcdWriteFirstLine("")

    except:
        print "Fatal Error!"
        logging.info("Fatal Error")
        display.lcdWriteFirstLine("Fatal Error!")
        display.lcdWriteSecondLine("")
        time.sleep(1)
        display.lcdWriteFirstLine("")

    finally:
        GPIO.cleanup()
コード例 #6
0
ファイル: attendance.py プロジェクト: Insaida/attendance
def readNfc(action):
    if(action==55):#7 - Incomming
        onScreen("Logging In...")
        display.lcdWriteFirstLine("Prichod...")
        display.lcdWriteSecondLine("Swipe your Card")
        cardId=read()
        logging.info("Incomming - %s",cardId)
        name = mysql.insertReading(cardId,Actions.incomming)
        display.lcdWriteSecondLine(name)
    if(action==57):#9 - outcomming
        onScreen("...")
        display.lcdWriteFirstLine("Logging out...")
        display.lcdWriteSecondLine("Swipe your Card")
        cardId=read()
        logging.info("Outcomming - %s",cardId)
        name = mysql.insertReading(cardId,Actions.outcomming)
        display.lcdWriteSecondLine(name)
    if(action==49):#1 - break start
        onScreen("Zacatek pauzy...")
        display.lcdWriteFirstLine("Pauza zacatek...")
        display.lcdWriteSecondLine("Swipe your Card")
        cardId=read()
        logging.info("Break start - %s",cardId)
        name = mysql.insertReading(cardId,Actions.breakstart)
        display.lcdWriteSecondLine(name)
    if(action==51):#3 - break end
        onScreen("Konec pauzy...")
        display.lcdWriteFirstLine("Pauza konec...")
        display.lcdWriteSecondLine("Swipe your Card")
        cardId=read()
        logging.info("Break end - %s",cardId)
        name = mysql.insertReading(cardId,Actions.breakend)
        display.lcdWriteSecondLine(name)
    if(action==53):#5 - Deletion of last inserted action
        onScreen("Delete the last entry...")
        display.lcdWriteFirstLine("Deleting...")
        display.lcdWriteSecondLine("")
        cardId=read()
        logging.info("Deleting last action - %s",cardId)
        (lastTime,lastAction)=mysql.getLastReading(cardId) or (None, None)

        if(lastTime == None or lastAction == None):
            display.lcdWriteSecondLine("Unknown Event")
            logging.info("Action not found")
            time.sleep(1)

        else:
            display.lcdWriteFirstLine("Delete Event?")
            if(lastAction==Actions.incomming):
                display.lcdWriteSecondLine("Check In")
            elif(lastAction==Actions.outcomming):
                display.lcdWriteSecondLine("Check Out")
            elif(lastAction==Actions.breakstart):
                display.lcdWriteSecondLine("Pauza zacatek")
            elif(lastAction==Actions.breakend):
                display.lcdWriteSecondLine("End of Pause?")
            a=getOneKey()
            if(a==49):#1
                onScreen("Mazu")
                logging.info(" - Deleting action %s (cas: %s)",lastAction, lastTime)
                mysql.deleteLastReading(cardId)
                display.lcdWriteSecondLine("Deleted!")
            else:
                onScreen("Not Deleted")
                logging.info(" - Deleting canceled")
                display.lcdWriteSecondLine("Not deleted!")

    #Sleep a little, so the information about last action on display is readable by humans
    time.sleep(1)
コード例 #7
0
def readNfc(action):
    if (action == 55):  #7 - Incomming
        onScreen("Logging In...")
        display.lcdWriteFirstLine("Prichod...")
        display.lcdWriteSecondLine("Swipe your Card")
        cardId = read()
        logging.info("Incomming - %s", cardId)
        name = mysql.insertReading(cardId, Actions.incomming)
        display.lcdWriteSecondLine(name)
    if (action == 57):  #9 - outcomming
        onScreen("...")
        display.lcdWriteFirstLine("Logging out...")
        display.lcdWriteSecondLine("Swipe your Card")
        cardId = read()
        logging.info("Outcomming - %s", cardId)
        name = mysql.insertReading(cardId, Actions.outcomming)
        display.lcdWriteSecondLine(name)
    if (action == 49):  #1 - break start
        onScreen("Zacatek pauzy...")
        display.lcdWriteFirstLine("Pauza zacatek...")
        display.lcdWriteSecondLine("Swipe your Card")
        cardId = read()
        logging.info("Break start - %s", cardId)
        name = mysql.insertReading(cardId, Actions.breakstart)
        display.lcdWriteSecondLine(name)
    if (action == 51):  #3 - break end
        onScreen("Konec pauzy...")
        display.lcdWriteFirstLine("Pauza konec...")
        display.lcdWriteSecondLine("Swipe your Card")
        cardId = read()
        logging.info("Break end - %s", cardId)
        name = mysql.insertReading(cardId, Actions.breakend)
        display.lcdWriteSecondLine(name)
    if (action == 53):  #5 - Deletion of last inserted action
        onScreen("Delete the last entry...")
        display.lcdWriteFirstLine("Deleting...")
        display.lcdWriteSecondLine("")
        cardId = read()
        logging.info("Deleting last action - %s", cardId)
        (lastTime, lastAction) = mysql.getLastReading(cardId) or (None, None)

        if (lastTime == None or lastAction == None):
            display.lcdWriteSecondLine("Unknown Event")
            logging.info("Action not found")
            time.sleep(1)

        else:
            display.lcdWriteFirstLine("Delete Event?")
            if (lastAction == Actions.incomming):
                display.lcdWriteSecondLine("Check In")
            elif (lastAction == Actions.outcomming):
                display.lcdWriteSecondLine("Check Out")
            elif (lastAction == Actions.breakstart):
                display.lcdWriteSecondLine("Pauza zacatek")
            elif (lastAction == Actions.breakend):
                display.lcdWriteSecondLine("End of Pause?")
            a = getOneKey()
            if (a == 49):  #1
                onScreen("Mazu")
                logging.info(" - Deleting action %s (cas: %s)", lastAction,
                             lastTime)
                mysql.deleteLastReading(cardId)
                display.lcdWriteSecondLine("Deleted!")
            else:
                onScreen("Not Deleted")
                logging.info(" - Deleting canceled")
                display.lcdWriteSecondLine("Not deleted!")

    #Sleep a little, so the information about last action on display is readable by humans
    time.sleep(1)
コード例 #8
0
ファイル: attendance.py プロジェクト: johannkraus/attendance
def printTimeToDisplay():
    display.lcdWriteFirstLine(time.strftime("%d.%m. %H:%M:%S", time.localtime()))
コード例 #9
0
ファイル: attendance.py プロジェクト: loliktry/attendance
def readNfc(action):
    if(action==55):#7 - Incomming
        onScreen("Prichod...")
        display.lcdWriteFirstLine("Prichod...")
        display.lcdWriteSecondLine("Prilozte kartu")
        cardId=read()
        logging.info("Incomming - %s",cardId)
        name = mysql.insertReading(cardId,Actions.incomming)
        display.lcdWriteSecondLine(name)
    if(action==57):#9 - outcomming
        onScreen("Odchod...")
        display.lcdWriteFirstLine("Odchod...")
        display.lcdWriteSecondLine("Prilozte kartu")
        cardId=read()
        logging.info("Outcomming - %s",cardId)
        name = mysql.insertReading(cardId,Actions.outcomming)
        display.lcdWriteSecondLine(name)
    if(action==49):#1 - break start
        onScreen("Zacatek pauzy...")
        display.lcdWriteFirstLine("Pauza zacatek...")
        display.lcdWriteSecondLine("Prilozte kartu")
        cardId=read()
        logging.info("Break start - %s",cardId)
        name = mysql.insertReading(cardId,Actions.breakstart)
        display.lcdWriteSecondLine(name)
    if(action==51):#3 - break end
        onScreen("Konec pauzy...")
        display.lcdWriteFirstLine("Pauza konec...")
        display.lcdWriteSecondLine("Prilozte kartu")
        cardId=read()
        logging.info("Break end - %s",cardId)
        name = mysql.insertReading(cardId,Actions.breakend)
        display.lcdWriteSecondLine(name)
    if(action==53):#5 - Deletion of last inserted action
        onScreen("Smazat posledni akci...")
        display.lcdWriteFirstLine("Mazani...")
        display.lcdWriteSecondLine("")
        cardId=read()
        logging.info("Deleting last action - %s",cardId)
        (lastTime,lastAction)=mysql.getLastReading(cardId) or (None, None)

        if(lastTime == None or lastAction == None):
            display.lcdWriteSecondLine("Akce nenalezena")
            logging.info("Action not found")
            time.sleep(1)

        else:
            display.lcdWriteFirstLine("Smazat akci?")
            if(lastAction==Actions.incomming):
                display.lcdWriteSecondLine("Prichod")
            elif(lastAction==Actions.outcomming):
                display.lcdWriteSecondLine("Odchod")
            elif(lastAction==Actions.breakstart):
                display.lcdWriteSecondLine("Pauza zacatek")
            elif(lastAction==Actions.breakend):
                display.lcdWriteSecondLine("Pauza konec")
            a=getOneKey()
            if(a==49):#1
                onScreen("Mazu")
                logging.info(" - Deleting action %s (cas: %s)",lastAction, lastTime)
                mysql.deleteLastReading(cardId)
                display.lcdWriteSecondLine("Smazano!")
            else:
                onScreen("Nemazu")
                logging.info(" - Deleting canceled")
                display.lcdWriteSecondLine("Nemazu nic!")

    #Sleep a little, so the information about last action on display is readable by humans
    time.sleep(1)
コード例 #10
0
import RPi.GPIO as GPIO
import time
import display

try:
	display.init()
	display.lcdWriteFirstLine("Hello, World!")
	while True:
		display.lcdWriteSecondLine(time.strftime("%d.%m. %H:%M:%S", time.localtime()))
		time.sleep(1)

except KeyboardInterrupt:
	print "Bye!"

except:
	print "Fatal error!"

finally:
	GPIO.cleanup()

コード例 #11
0
ファイル: test-RC522.py プロジェクト: johannkraus/attendance
import RPi.GPIO as GPIO
import time
import display
import MFRC522

try:
	display.init()
	display.lcdWriteFirstLine("Card, please.")
	reading = True
	while reading:
		MIFAREReader = MFRC522.MFRC522()
		(status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)
		(status,backData) = MIFAREReader.MFRC522_Anticoll()
		if status == MIFAREReader.MI_OK:
			MIFAREReader.AntennaOff()
			reading = False
			display.lcdWriteFirstLine("Your card ID is:")
			display.lcdWriteSecondLine(str(backData[0])+str(backData[1])+str(backData[2])+str(backData[3])+str(backData[4]))

except KeyboardInterrupt:
	print "Bye!"

except:
	print "Fatal error!"

finally:
	GPIO.cleanup()

コード例 #12
0
ファイル: nfc.py プロジェクト: prabh13/nfcpay
def readNfc(action):
    if(action==48):#0 - Incomming
        onScreen("Logging In...")
        display.lcdWriteFirstLine("Hello..")
        onScreen("Hello..")
    
        display.lcdWriteSecondLine("Swipe your Card")
          
        onScreen('Swipe your card')
        
        uid=""
        
        while True:
        
            try:
                #GPIO.cleanup()
                mifare = nxppy.Mifare()
                uid = mifare.select()
                if uid != "": 
                    break
                #print(uid)
            except nxppy.SelectError:
        # SelectError is raised if no card is in the field.
                 pass

            time.sleep(1)

        
        
        mysql.insertReading(uid,Actions.incomming,1)
        cardcheck=mysql.checkcard(uid)
        if cardcheck==0:
            
            display.lcdWriteFirstLine("Hello.USER")
            display.lcdWriteSecondLine(uid) 
            print "Hello User, ",uid
            #print (uid)
            time.sleep(3)
	

            display.lcdWriteFirstLine("Processing...")
            display.lcdWriteSecondLine("Plz wait...")
            time.sleep(4)
            temp=input("Press any key to continue  ")
            res=0
            while True:
                res=mysql.checkamtpay(uid)
                if res!= 0 :
                    break

            print res
            display.lcdWriteFirstLine("Amount to pay : ")
            display.lcdWriteSecondLine(str(res))
            time.sleep(3)
            display.lcdWriteFirstLine("Enter pin to ")
            display.lcdWriteSecondLine("confirm")
            time.sleep(1)
            pin=""
            pin=getpass.getpass("Enter pin to confirm   ")
            pin=str(pin)
            pin=hashlib.md5(pin).hexdigest()
            bal=mysql.authenticat(uid)
            if bal[1]==pin:
            
        
                if bal[0]>=res:
            
                    mysql.payment(bal[0]-res,uid)
                    mysql.clearvalues()
                    display.lcdWriteFirstLine("Tranx Success")
                    display.lcdWriteSecondLine("Thank You !!")
                    
                    time.sleep(4)
            
                else:
                    display.lcdWriteFirstLine("Tranx failed")
                    display.lcdWriteSecondLine("Insuffient balance")
                    mysql.clearvalues()
                    time.sleep(3)


            else:
                display.lcdWriteFirstLine("Tranx failed")
                display.lcdWriteSecondLine("Wrong pin")
                mysql.clearvalues()
                time.sleep(3)




        elif cardcheck==1:
            display.lcdWriteFirstLine("Tranx failed")
            display.lcdWriteSecondLine("Invalid Card")
            mysql.clearvalues()
            time.sleep(3)

    #Sleep a little, so the information about last action on display is readable by humans
    time.sleep(1)