if GPIO.input(p1palm): print "p1palm is pressed" if GPIO.input(p1left): print "p1left is pressed" if GPIO.input(p1center): print "p1center is pressed" if GPIO.input(p1right): print "p1right is pressed" if GPIO.input(p2palm): print "p1palm is pressed" if GPIO.input(p2left): print "p1left is pressed" if GPIO.input(p2center): print "p1center is pressed" if GPIO.input(p2right): print "p1right is pressed" if pitft.Button1: print "Button 1 pressed - screen off" pitft.Backlight(False) if pitft.Button2: print "Button 2 pressed - screen on" pitft.Backlight(True) if pitft.Button3: print "Button 3 pressed" #toggle up one channel if pitft.Button4: print "Button 4 pressed" *#toggle down a channel
try: clf = nfc.ContactlessFrontend('usb') except IOError: print('ERROR: Could not find reader.') sys.exit(-1) # Set some variables used here. id = None idVal = '' bl = True while True: if pitft != None: if pitft.Button1: # Make it possible to dim/brighten the TFT screen. bl ^= bl pitft.Backlight(bl) print('Backlight Toggle') time.sleep(2.0) clear() if pitft.Button2: # Let's provide a physical means from breaking out of the loop. print('Quitting') sys.exit(0) # Define the target tags we want to read and look for them. target = clf.sense(RemoteTarget('106A'), RemoteTarget('106B'), RemoteTarget('212F')) if target is not None: if target.sdd_res != id: # Check if tag has changed, as we don't want a user tagging-in causes multiple cycles. try: # Read the tag and assign the UID to the appropriate variables.