예제 #1
0
def adduser(request):
    GPIO.setmode(GPIO.BOARD)
    reader = SM()
    display = lcddriver.lcd()

    if request.method == 'POST':
        first_name = request.POST['first_name']
        last_name = request.POST['last_name']
        try:
            display.lcd_clear()  # Write line of text to first line of display

            display.lcd_display_string(
                "Pointez ici !",
                1)  # Write line of text to first line of display

            id, text = reader.read()
        finally:
            GPIO.cleanup()
        rfid = id

        Utlisateur.objects.create(rfid=rfid,
                                  first_name=first_name,
                                  last_name=last_name)
        return redirect(users)

    else:
        return render(request, 'base2.html', locals())
예제 #2
0
# If you use something from the driver library use the "display." prefix first
display = lcddriver.lcd()
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7,GPIO.OUT)
reader = SM()
URL = "http://127.0.0.1:8000/store/"
# Main body of code
try:
    while True:
        # Remember that your sentences can only be 16 characters long!
        print("Writing to display")
        display.lcd_clear() # Write line of text to first line of display

        display.lcd_display_string("Pointez ici !", 1) # Write line of text to first line of display
        display.lcd_display_string("", 2) # Write line of text to first line of display
        id,text = reader.read()
        print(id)
        print(text)
        
        rfid = id
        PARAMS = {'rfid': rfid }

        r = requests.get(url=URL,params=PARAMS)
        text=r.text
        
        print(text)

        if (text == "OK"):
            print("ok")
            GPIO.output(7,True)
            time.sleep(1)