data = nfc.readNfc() lcd2.message("Authenticating..\n") response = sendPOST(data) lcd2.message(response) #other actions will follow once you know what to do once the autenthication process suceeded if (ch == "1"): lcd1.clear() lcd1.message("Type password:\n") while (ord(ch) != 10): ch = getch() msg = msg + ch lcd1.message("*") print msg lcd1.noBlink() lcd1.clear() lcd2.clear() lcd2.message("Authenticating..\n") response = sendPOST(msg) lcd2.message(response) print response print "Restarting from scratch in 5 seconds..." time.sleep (5) except KeyboardInterrupt: GPIO.cleanup() lcd1.clear()
lcd.setCursor(0,0) lcd.message("Left to Right:") lcd.setCursor(10,1) lcd.message("Testing") sleep(2) # Enabling the cursor and having it blink lcd.clear() lcd.setCursor(0,0) lcd.cursor() lcd.blink() lcd.message("Cursor is blinking") lcd.setCursor(0,1) sleep(3) lcd.noCursor() lcd.noBlink() # Turning the backlight off and showing a simple count down lcd.clear() lcd.setCursor(0,0) lcd.message("Backlight off in") lcd.setCursor(0,3) lcd.message("Back on in 3sec") lcd.setCursor(17,0) #Reseting the cursor here keeps us from having to clear the screen, this over writes the previous character lcd.message("3") sleep(1) lcd.setCursor(17,0) lcd.message("2") sleep(1)
class fppLCD(): def __init__(self,directory): self.THIS_DIRECTORY = directory self.BACK_COLOR = 0 self.PLAYLIST_DIRECTORY = "/home/pi/media/playlists/" self.SETTINGS_FILE = "/home/pi/media/settings" self.DIRECTION_LEFT = 0 self.DIRECTION_RIGHT = 1 self.MAX_CHARS = 16 self.MAX_STATUS_TIMEOUT = 120 self.NORMAL_STATUS_TIMEOUT = 3 self.FPPD_PLAYER_MODE = "2" self.FPPD_BRIDGE_MODE = "1" self.maxStatusUpdateCount = 5 self.statusUpdateCounter= 5 self.FPPD_STATUS_STOPPED = -1 self.FPPD_STATUS_RUNNING = 1 self.FPPDstatus = 0 self.FPPDplayerStatus = 0; # Status Constants self.STATUS_IDLE = "0" self.STATUS_PLAYING = "1" self.STATUS_STOPPING_GRACEFULLY = "2" self.STATUS_INX_PLAYER_MODE = 0 self.STATUS_INX_STATUS = 1 self.STATUS_INX_NEXT_PLAY_LIST = 3 self.STATUS_INX_CURRENT_PLAY_LIST = 3 self.STATUS_INX_NEXT_TIME = 4 self.STATUS_INX_PL_TYPE = 4 self.STATUS_INX_SEQ_NAME = 5 self.STATUS_INX_SONG_NAME = 6 self.STATUS_INX_SECS_ELASPED = 9 self.STATUS_INX_SECS_REMAINING = 10 # Text to display self.line1="" self.line2="" # Rotation Variables self.rotateEnable = 0 self.tempLine1="" self.tempLine2="" self.rotatePositon1=0 self.rotatePositon2=0 self.rotateSpeed=0 self.rotateCount=0 self.rotateMaxCount=3 self.fixedLocation1=0 self.fixedLocation2=0 self.lcd = Adafruit_CharLCDPlate() #self.lcd = VirtualLCD() self.lcd.noBlink() self.lcd.noCursor() self.lcd.clear() self.sequenceCount=0; self.sequences = () self.playlists = () self.selectedPlaylistIndex = 0 self.MenuIndex=0; self.SubmenuIndex=0; self.MENU_INX_STATUS = 0 self.MENU_INX_STOP_SEQUENCE = 1 self.MENU_INX_PLAYLISTS = 2 self.MENU_INX_PLAYLIST_ENTRIES = 3 self.MENU_INX_SHUTDOWN_REBOOT = 4 self.MENU_INX_BACKGROUND = 5 self.MENU_INX_BACKCOLOR = 6 self.MENU_INX_BACKCOLOR_TIMEOUT = 7 self.COLOR_WHITE = 6 self.TimeMode=0; self.TIMEMODE_ELASPED = 0 self.TIMEMODE_REMAINING = 1 self.BACKGROUND_ALWAYS_ON = 0 self.BACKGROUND_TIMEOUT_ENABLED = 1 self.BACKGROUND_TIMEOUT_MAX_COUNT = 1500 self.BackgroundColor = 0 self.BackgroundTimeout = 1 #self.BACKGROUND_TIMEOUT_ENABLED self.BackgroundTimeoutCount=0 self.MENU_BACKCOLOR_TIMEOUT_COUNT = 2 self.previousBtn = -1 self.MENU_BACKGROUND_COUNT = 2 self.menuBackground=("1)Color ", "2)Mode ") self.MENU_COLOR_COUNT = 7 self.colors=(("Red ",self.lcd.RED), ("Green ",self.lcd.GREEN), ("Blue ",self.lcd.BLUE), ("Yellow ",self.lcd.YELLOW), ("Teal ",self.lcd.TEAL), ("Violet ",self.lcd.VIOLET), ("White ",self.lcd.WHITE)) self.backgroundModes=("Always On ", "Timeout ") def Initialize(self): strColorIndex = self.readSetting("piLCD_BackColor") if strColorIndex.isdigit(): self.BackgroundColor = int(strColorIndex); else: self.BackgroundColor = self.COLOR_WHITE self.SelectColor(self.BackgroundColor); strTimeout = self.readSetting("piLCD_BackgroundTimeout") if strTimeout.isdigit(): self.BackgroundTimeout = int(strTimeout); else: self.BackgroundTimeout = 1 strTimeout = self.readSetting("piLCDtimeMode") if strTimeout.isdigit(): self.TimeMode = int(strTimeout); else: self.TimeMode = 0 version = fpplcd.getFPPversion() self.line1 = self.MakeStringWithLength("FPP Version",16,1); self.line2 = self.MakeStringWithLength(version,16,1); self.UpdateDisplay() time.sleep(4) return def SendCommand(self,command): count =0; max_timeout = 10; #buf="" # Create a UDS socket sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) sock.bind("/tmp/FPP" + str(os.getpid())) sock.settimeout(5) # Connect the socket to the port where the server is listening server_address = "/tmp/FPPD" #print >>sys.stderr, 'connecting to %s' % server_address try: sock.connect(server_address) sock.send(command) buf = sock.recv(1024) sock.close() os.unlink("/tmp/FPP" + str(os.getpid())); except socket.error, msg: #print >>sys.stderr, msg sock.close() os.unlink("/tmp/FPP" + str(os.getpid())); return "false" return buf;
lcd.setCursor(0, 0) lcd.message("Left to Right:") lcd.setCursor(10, 1) lcd.message("Testing") sleep(2) # Enabling the cursor and having it blink lcd.clear() lcd.setCursor(0, 0) lcd.cursor() lcd.blink() lcd.message("Cursor is blinking") lcd.setCursor(0, 1) sleep(3) lcd.noCursor() lcd.noBlink() # Turning the backlight off and showing a simple count down lcd.clear() lcd.setCursor(0, 0) lcd.message("Backlight off in") lcd.setCursor(0, 3) lcd.message("Back on in 3sec") lcd.setCursor( 17, 0 ) #Reseting the cursor here keeps us from having to clear the screen, this over writes the previous character lcd.message("3") sleep(1) lcd.setCursor(17, 0) lcd.message("2")
class fppLCD(): def __init__(self, directory): self.THIS_DIRECTORY = directory self.BACK_COLOR = 0 self.PLAYLIST_DIRECTORY = "/home/pi/media/playlists/" self.SETTINGS_FILE = "/home/pi/media/settings" self.DIRECTION_LEFT = 0 self.DIRECTION_RIGHT = 1 self.MAX_CHARS = 16 self.MAX_STATUS_TIMEOUT = 120 self.NORMAL_STATUS_TIMEOUT = 3 self.FPPD_PLAYER_MODE = "2" self.FPPD_BRIDGE_MODE = "1" self.maxStatusUpdateCount = 5 self.statusUpdateCounter = 5 self.FPPD_STATUS_STOPPED = -1 self.FPPD_STATUS_RUNNING = 1 self.FPPDstatus = 0 self.FPPDplayerStatus = 0 # Status Constants self.STATUS_IDLE = "0" self.STATUS_PLAYING = "1" self.STATUS_STOPPING_GRACEFULLY = "2" self.STATUS_INX_PLAYER_MODE = 0 self.STATUS_INX_STATUS = 1 self.STATUS_INX_NEXT_PLAY_LIST = 3 self.STATUS_INX_CURRENT_PLAY_LIST = 3 self.STATUS_INX_NEXT_TIME = 4 self.STATUS_INX_PL_TYPE = 4 self.STATUS_INX_SEQ_NAME = 5 self.STATUS_INX_SONG_NAME = 6 self.STATUS_INX_SECS_ELASPED = 9 self.STATUS_INX_SECS_REMAINING = 10 # Text to display self.line1 = "" self.line2 = "" # Rotation Variables self.rotateEnable = 0 self.tempLine1 = "" self.tempLine2 = "" self.rotatePositon1 = 0 self.rotatePositon2 = 0 self.rotateSpeed = 0 self.rotateCount = 0 self.rotateMaxCount = 3 self.fixedLocation1 = 0 self.fixedLocation2 = 0 self.lcd = Adafruit_CharLCDPlate() #self.lcd = VirtualLCD() self.lcd.noBlink() self.lcd.noCursor() self.lcd.clear() self.sequenceCount = 0 self.sequences = () self.playlists = () self.selectedPlaylistIndex = 0 self.MenuIndex = 0 self.SubmenuIndex = 0 self.MENU_INX_STATUS = 0 self.MENU_INX_STOP_SEQUENCE = 1 self.MENU_INX_PLAYLISTS = 2 self.MENU_INX_PLAYLIST_ENTRIES = 3 self.MENU_INX_SHUTDOWN_REBOOT = 4 self.MENU_INX_BACKGROUND = 5 self.MENU_INX_BACKCOLOR = 6 self.MENU_INX_BACKCOLOR_TIMEOUT = 7 self.COLOR_WHITE = 6 self.TimeMode = 0 self.TIMEMODE_ELASPED = 0 self.TIMEMODE_REMAINING = 1 self.BACKGROUND_ALWAYS_ON = 0 self.BACKGROUND_TIMEOUT_ENABLED = 1 self.BACKGROUND_TIMEOUT_MAX_COUNT = 1500 self.BackgroundColor = 0 self.BackgroundTimeout = 1 #self.BACKGROUND_TIMEOUT_ENABLED self.BackgroundTimeoutCount = 0 self.MENU_BACKCOLOR_TIMEOUT_COUNT = 2 self.previousBtn = -1 self.MENU_BACKGROUND_COUNT = 2 self.menuBackground = ("1)Color ", "2)Mode ") self.MENU_COLOR_COUNT = 7 self.colors = (("Red ", self.lcd.RED), ("Green ", self.lcd.GREEN), ("Blue ", self.lcd.BLUE), ("Yellow ", self.lcd.YELLOW), ("Teal ", self.lcd.TEAL), ("Violet ", self.lcd.VIOLET), ("White ", self.lcd.WHITE)) self.backgroundModes = ("Always On ", "Timeout ") def Initialize(self): if os.path.exists("/home/fpp/media"): self.PLAYLIST_DIRECTORY = "/home/fpp/media/playlists/" self.SETTINGS_FILE = "/home/fpp/media/settings" strColorIndex = self.readSetting("piLCD_BackColor") if strColorIndex.isdigit(): self.BackgroundColor = int(strColorIndex) else: self.BackgroundColor = self.COLOR_WHITE self.SelectColor(self.BackgroundColor) strTimeout = self.readSetting("piLCD_BackgroundTimeout") if strTimeout.isdigit(): self.BackgroundTimeout = int(strTimeout) else: self.BackgroundTimeout = 1 strTimeout = self.readSetting("piLCDtimeMode") if strTimeout.isdigit(): self.TimeMode = int(strTimeout) else: self.TimeMode = 0 version = fpplcd.getFPPversion() self.line1 = self.MakeStringWithLength("FPP Version", 16, 1) self.line2 = self.MakeStringWithLength(version, 16, 1) self.UpdateDisplay() time.sleep(4) return def SendCommand(self, command): count = 0 max_timeout = 10 #buf="" # Create a UDS socket sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) sock.bind("/tmp/FPP" + str(os.getpid())) sock.settimeout(5) # Connect the socket to the port where the server is listening server_address = "/tmp/FPPD" #print >>sys.stderr, 'connecting to %s' % server_address try: sock.connect(server_address) sock.send(command) buf = sock.recv(1024) sock.close() os.unlink("/tmp/FPP" + str(os.getpid())) except socket.error, msg: #print >>sys.stderr, msg sock.close() os.unlink("/tmp/FPP" + str(os.getpid())) return "false" return buf