def lcd_loop(self): from time import sleep from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate # Initialize the LCD plate. Should auto-detect correct I2C bus. If not, # pass '0' for early 256 MB Model B boards or '1' for all later versions lcd = Adafruit_CharLCDPlate() # Clear display and show greeting, pause 1 sec lcd.clear() lcd.message("Deuce Jockey") sleep(1) # Cycle through backlight colors col = (lcd.RED , lcd.YELLOW, lcd.GREEN, lcd.TEAL, lcd.BLUE, lcd.VIOLET, lcd.ON , lcd.OFF) for c in col: lcd.backlight(c) sleep(.1) # Poll buttons, display message & set backlight accordingly # lcd.backlight(lcd.RED) while True: if lcd.buttonPressed(lcd.UP): print('UP') self.sensitivity_up() elif lcd.buttonPressed(lcd.DOWN): print('DOWN') self.sensitivity_down() if lcd.buttonPressed(lcd.UP) or lcd.buttonPressed(lcd.DOWN): sleep(.1) lcd.clear() lcd.message("Deuce Jockey\nSensitivity: "+repr(round(self.sensitivity * 100))) lcd.backlight(lcd.RED)
class TimelapseUi(object): def __init__(self): self._lcd = Adafruit_CharLCDPlate() #self._lcd = FakeCharLCDPlate() def update(self, text): self._lcd.clear() self._lcd.message(text) print(text) def show_config(self, configs, current): config = configs[current] self.update("Timelapse\nT: %s ISO: %s" % (config[1], config[3])) def show_status(self, shot, config): self.update("Shot %d\nT: %s ISO: %s" % (shot, config[1], config[3])) def show_error(self, text): self.update(text[0:16] + "\n" + text[16:]) while not self._lcd.buttonPressed(self._lcd.SELECT): sself.backlight(self._lcd.RED) sleep(1) def main(self, configs, current, network_status): while not self._lcd.buttonPressed(self._lcd.SELECT): pass ready = False while not ready: while True: if (type(self._lcd) == type(FakeCharLCDPlate())): self._lcd.fakeonly_getch() if self._lcd.buttonPressed(self._lcd.UP): print "UP" current -= 1 if current < 0: current = 0 break if self._lcd.buttonPressed(self._lcd.DOWN): print "DOWN" current += 1 if current >= len(configs): current = len(configs) - 1 break if self._lcd.buttonPressed(self._lcd.SELECT): print "SELECT" ready = True break print "end" self.show_config(configs, current) return current
class LCD(): # All avalaible colors COLOR_RED = 0 COLOR_YELLOW = 1 COLOR_GREEN = 2 COLOR_TEAL = 3 COLOR_BLUE = 4 COLOR_VIOLET = 5 COLOR_ON = 6 COLOR_OFF = 7 def __init__(self): self.__lcd = Adafruit_CharLCDPlate() self.__buttons = ( self.__lcd.LEFT, self.__lcd.UP, self.__lcd.DOWN, self.__lcd.RIGHT, self.__lcd.SELECT, ) self.__col = ( self.__lcd.RED, self.__lcd.YELLOW, self.__lcd.GREEN, self.__lcd.TEAL, self.__lcd.BLUE, self.__lcd.VIOLET, self.__lcd.ON, self.__lcd.OFF ) def stop(self): self.changeColor(7) self.__lcd.clear() def clear(self, clearBackground): if clearBackground: self.changeColor(6) self.__lcd.clear() def changeColor(self, index): self.__lcd.backlight(self.__col[index]) def setMessage(self, msg): self.__lcd.message(msg) def buttonPressed(self): return self.__lcd.buttonPressed(self.__buttons[0])
class Display(): def __init__(self): self.lcd = Adafruit_CharLCDPlate(busnum=1) def clear(self): self.lcd.clear() def start(self): self.lcd.begin(16, 2) self.lcd.backlight(self.lcd.ON) def stop(self): self.clear() self.lcd.backlight(self.lcd.OFF) def message(self, message=""): self.start() self.lcd.message(message) def button_pressed(self, button=None): if self.lcd.buttonPressed(button): time.sleep(.2) return(True) else: return(False) def button_left(self): return(self.button_pressed(self.lcd.LEFT)) def button_right(self): return(self.button_pressed(self.lcd.RIGHT)) def button_up(self): return(self.button_pressed(self.lcd.UP)) def button_down(self): return(self.button_pressed(self.lcd.DOWN)) def button_select(self): return(self.button_pressed(self.lcd.SELECT)) def blink_cursor(self): self.lcd.blink() def move_cursor(self, col=0, row=0): self.lcd.setCursor(col, row)
reset_target_available=1 # enable command "Reset Target" (some games only accept in service menu) select_target_available=1 # enable command "Select Target" (select target from available targets) restart_program_available=1 # enable command "Restart Program" (restart pyhton program) restart_system_available=1 # enable command "Restart System" (restart raspberry pi) shutdown_system_available=1 # enable command "Shutdown System" (shutdown raspberry pi) sleep (sleep_message) # Startup wait ---------- ---------- ---------- # Wait for [OK] at startup if startup_wait is 1: lcd.setCursor(12, 1) lcd.message("[OK]") pressedButtons=[] while lcd.SELECT not in pressedButtons: # Handle SELECT if lcd.buttonPressed(lcd.SELECT): pressedButtons.append(lcd.SELECT) if lcd.SELECT in pressedButtons: pressedButtons.append(lcd.SELECT) lcd.clear() # Blink ON lcd.ToggleBlink() # Scan targets ---------- ---------- ---------- lcd.clear() lcd.message("Scanning\nTargets...") if targets_discover is 1: #Purge unavailable targets targets_found=[]
eval(self.curFolder.items[self.curSelectedItem].function+'()') # now start things up uiItems = Folder('root','') dom = parse(configfile) # parse an XML file by name top = dom.documentElement ProcessNode(top, uiItems) display = Display(uiItems) display.display() while 1: if (lcd.buttonPressed(lcd.LEFT)): display.update('l') display.display() if (lcd.buttonPressed(lcd.UP)): display.update('u') display.display() if (lcd.buttonPressed(lcd.DOWN)): display.update('d') display.display() if (lcd.buttonPressed(lcd.RIGHT)): display.update('r') display.display()
lcd.message("Timelapse\nRaspberry Pi") sleep(5) lcd.backlight(lcd.OFF) # Start with the Info menu menu[menu_item][1]() dir = '' thread_stop = False thread_show_progress = False progressThread = ProgressThread() progressThread.start() try: previous_button = -1 while True: sleep(0.5) for button in (lcd.LEFT, lcd.UP, lcd.DOWN, lcd.RIGHT, lcd.SELECT): if lcd.buttonPressed(button): if button is not previous_button: button2cmd(button) #previous_button = button break except KeyboardInterrupt: print 'Interrupt...' action_stop_timelapse() stop_progress_thread() #progressThread.join() print 'Exiting...'
'Connectivity\nTest': 'connectivityTest'} displayText = modules.keys() # Clears the display lcd.clear() # Checks if the script has been run as root. if os.getuid() == 0: menuOption = 0 #lcd.backlight(lcd.BLUE) lcd.message("SlyPi\nPress Select") else: lcd.backlight(lcd.BLUE) lcd.message("Be sure to\nRun as root") #The following while loop controls the LCD menu and the control using the keypad through the menu. while True: if lcd.buttonPressed(lcd.SELECT): sleep(0.5) lcd.clear() lcd.message(displayText[menuOption]) while True: lcd.backlight(lcd.BLUE) if lcd.buttonPressed(lcd.DOWN): menuOption = menuOption + 1 if menuOption > len(modules) - 1: menuOption = 0 lcd.clear() lcd.message(displayText[menuOption]) sleep(0.5) if lcd.buttonPressed(lcd.UP): menuOption = menuOption - 1 if menuOption < 0:
lcd.message(str(get_ipv4_address()[0])) sleep(10) # Cycle through backlight colors col = (lcd.RED , lcd.YELLOW, lcd.GREEN, lcd.TEAL, lcd.BLUE, lcd.VIOLET, lcd.ON , lcd.OFF) for c in col: lcd.backlight(c) sleep(.5) # Poll buttons, display message & set backlight accordingly btn = ((lcd.LEFT , get_time() , lcd.ON), (lcd.UP , str(get_ipv4_address()[0]) , lcd.ON), (lcd.DOWN , 'I see fields\nof green' , lcd.ON), (lcd.RIGHT , 'Purple mountain\nmajesties', lcd.ON), (lcd.SELECT, '' , lcd.OFF)) prev = -1 while True: for b in btn: if lcd.buttonPressed(b[0]): if b is not prev: if not lcd.buttonPressed(lcd.LEFT): lcd.clear() lcd.message(b[1]) lcd.backlight(b[2]) prev = b else: lcd.clear() lcd.message(get_time()) lcd.backlight(b[2]) break
if switch_pressed: # if trellis.readSwitches(): # go through every button for i in range(numKeys): # if it was pressed... if trellis.justPressed(i): print 'v{0}'.format(i) # print files[i] # print "files is ",len(files) do_sound_function(i) # Handle the Pi Plate buttons for b in btn: if lcd.buttonPressed(b): if b is lcd.SELECT: longpress_timer-=1 print "Shutdown ",longpress_timer if longpress_timer < 1: display ("Shutdown",1) #os.system("shutdown -h now") subprocess.Popen(["/sbin/shutdown"]) # We now launch this as a separate process os._exit(-1) # Must terminate the program or the shutdown doesn't happen. if b is prev and debounce_timer is not 0: # print "debounce_timer is ",debounce_timer break if b is not prev:
refreshLCD() def shutdown(): lcd.clear() os.system("poweroff") def refreshLCD(): textToShow = broadcastNumberText + str(broadcastingNumber) + "\n" + str(busNumber) lcd.clear() lcd.message(textToShow) previousPressedTime = getTime() restartNodeWithThisNumber(busNumber) while True: if lcd.buttonPressed(lcd.UP) and shouldIProcessThisPress(): busNumber += 1 refreshLCD() saveNumberToFile(busNumber) elif lcd.buttonPressed(lcd.DOWN) and shouldIProcessThisPress(): busNumber -= 1 refreshLCD() saveNumberToFile(busNumber) elif lcd.buttonPressed(lcd.RIGHT) and shouldIProcessThisPress(): restartNodeWithThisNumber(busNumber) elif lcd.buttonPressed(lcd.SELECT) and shouldIProcessThisPress(): shutdown()
print "Waiting for player to decide on a number..." lcd.clear() time.sleep(1) start = False chosen = False tempTime = time.time() messArr = (("Think of a \npositive integer"), ("To skip guessing\npress SELECT"), ("Press anything\nelse to begin.")) messCounter = 0 lcd.message(messArr[messCounter]) #loop for input while not start: if lcd.buttonPressed(lcd.SELECT): start = True print " Player chose to quit.\n" elif lcd.buttonPressed(lcd.UP) or lcd.buttonPressed(lcd.DOWN) or lcd.buttonPressed(lcd.LEFT) or lcd.buttonPressed(lcd.RIGHT): start = True chosen = True print " Player chose a number.\n" elif (time.time() - tempTime) >= 3: tempTime = time.time() lcd.clear() lcd.message(messArr[messCounter]) messCounter += 1 if messCounter > 2: messCounter = 0 lcd.clear()
dispError = True else: sleep(1) DisplayThread().start() globError = False while True: try: if checkRun() == False: break sleep(.1) nothingPressed = True for i in range(5): if lcd.buttonPressed(buttons[i]): nothingPressed = False if i != curPressed: buttonPressed(i) curPressed = i break if nothingPressed: curPressed = -1 globError = False except Exception, err: if globError == False: logging.exception('') globError = True else: sleep(1)
class menuLCD(treeList): OFFTIME = 20 EXITFILE = '/tmp/menuLCD.exit' def __init__(self): sleep(.5) self.lcd = Adafruit_CharLCDPlate(busnum=1) sleep(.5) self.lcd.begin(16, 2) sleep(.5) self.lcd.clear() self.lcd.message("Menu LCD library \nversion 1.0!") treeList.__init__(self) self.button = ((self.lcd.SELECT, 'Select'), (self.lcd.LEFT , 'Left' ), (self.lcd.UP , 'Up' ), (self.lcd.DOWN , 'Down' ), (self.lcd.RIGHT , 'Right' )) self.elapsed = 0 self.time2Sleep = 0 self.displayOn = False if os.path.isfile(self.EXITFILE): os.remove(self.EXITFILE) sleep(1) ################################################################################################################## def exitMenu(self): if self.ynQuestion('are you sure?'): self.shutdown() sys.exit(0) ################################################################################################################## def ynQuestion(self, text): self.lcd.clear() sleep(.1) self.lcd.message(text+'\n'+'left(n) right(y)') response = False exitLoop = False while not exitLoop: for btn in self.button: if self.lcd.buttonPressed(btn[0]): if btn[0] == self.lcd.RIGHT: exitLoop = True response = True if btn[0] == self.lcd.LEFT: exitLoop = True response = False sleep(.1) return response ################################################################################################################## def keyUp(self): response = False for btn in self.button: if self.lcd.buttonPressed(btn[0]): if btn[0] == self.lcd.UP: response=True return response ################################################################################################################## def keyDown(self): response = False for btn in self.button: if self.lcd.buttonPressed(btn[0]): if btn[0] == self.lcd.DOWN: response=True return response ################################################################################################################## def keyRight(self): response = False for btn in self.button: if self.lcd.buttonPressed(btn[0]): if btn[0] == self.lcd.RIGHT: response=True return response ################################################################################################################## def keyLeft(self): response = False for btn in self.button: if self.lcd.buttonPressed(btn[0]): if btn[0] == self.lcd.LEFT: response=True return response ################################################################################################################## def keySelect(self): response = False for btn in self.button: if self.lcd.buttonPressed(btn[0]): if btn[0] == self.lcd.SELECT: response=True return response ################################################################################################################## def keyPressed(self): response = False for btn in self.button: if self.lcd.buttonPressed(btn[0]): if btn[0] == self.lcd.RIGHT or btn[0] == self.lcd.LEFT or btn[0] == self.lcd.UP or btn[0] == self.lcd.DOWN: response=True return response ################################################################################################################## def shutdown(self): self.turnOnDisplay() self.clearLCD() self.message2LCD('Exiting...') sleep(2) self.turnOffDisplay() ################################################################################################################## def setTime2Sleep(self,t): self.OFFTIME = t ################################################################################################################## def message2LCD(self, msn): self.lcd.message(msn) ################################################################################################################## def clearLCD(self): self.lcd.clear() ################################################################################################################## def turnOffDisplay(self): if self.displayOn: self.lcd.noDisplay() self.lcd.backlight(self.lcd.OFF) self.displayOn = False ################################################################################################################## def turnOnDisplay(self): if not self.displayOn: self.lcd.display() self.lcd.backlight(self.lcd.ON) self.displayOn = True ################################################################################################################## def resetTime2Sleep(self): self.elapsed = time() self.time2Sleep = 0 ################################################################################################################## def lcdRefresh(self): self.turnOnDisplay() self.lcd.clear() sleep(.1) menuString = '%s\n[%s]'%(treeList.activeItemString(self),treeList.activePosition(self)) self.lcd.message(menuString) sleep(.1) ################################################################################################################## def checkButtons(self): for btn in self.button: if self.lcd.buttonPressed(btn[0]): self.resetTime2Sleep() if self.displayOn: if btn[0] == self.lcd.RIGHT: treeList.goNext(self) if btn[0] == self.lcd.LEFT: treeList.goPrev(self) if btn[0] == self.lcd.DOWN: if treeList.activeEntryHasItems(self): treeList.goDown(self) else: treeList.goNext(self) if btn[0] == self.lcd.UP: treeList.goUp(self) if btn[0] == self.lcd.SELECT: if treeList.typeOfActiveItem(self) == treeList.CMD: treeList.command(self)() self.resetTime2Sleep() self.lcdRefresh() ################################################################################################################## def check2Sleep(self): if self.time2Sleep < self.OFFTIME: self.time2Sleep = time() - self.elapsed else: self.turnOffDisplay() ################################################################################################################## def check4Exit(self): returnValue = True if os.path.isfile(self.EXITFILE): os.remove(self.EXITFILE) returnValue=False return returnValue ################################################################################################################## def play(self): treeList.goTop(self) self.lcdRefresh() self.resetTime2Sleep() while self.check4Exit(): self.check2Sleep() self.checkButtons() self.shutdown() sys.exit(0) ################################################################################################################## def addExitEntry(self, *parentName): if len(parentName)>0: treeList.addItem(self,parentName[0],'Exit', self.exitMenu) else: treeList.addItem(self,treeList.ROOT,'Exit', self.exitMenu)
# setup GPIO pins to interface with shift register GPIO.setmode(GPIO.BCM) GPIO.setup(pin_sr_clk, GPIO.OUT) GPIO.setup(pin_sr_noe, GPIO.OUT) disableShiftRegisterOutput() GPIO.setup(pin_sr_dat, GPIO.OUT) GPIO.setup(pin_sr_lat, GPIO.OUT) setShiftRegister(values) enableShiftRegisterOutput() display = Display(uiItems) display.display() ShowHome() while (not(lcd.buttonPressed(lcd.SELECT))) & (not(lcd.buttonPressed(lcd.LEFT))): continue lastButtonPressed = datetime.now() if DEBUG: print('start while') while 1: if ((datetime.now() - lastButtonPressed).total_seconds() >= 30): ShowHome() lcd.backlight(lcd.OFF) lastButtonPressed = datetime.now() while (not(lcd.buttonPressed(lcd.SELECT))) & (not(lcd.buttonPressed(lcd.LEFT))): continue
lcd.backlight(lcd.RED) subprocess.call('sudo python get_current_price_ltc.py', shell = True) from get_current_price_ltc import price_litecoin lcd.message('Litecoin is:\n$' + price_litecoin + '/ltc') time.sleep(5) def cleanScreen(): lcd.clear() lcd.backlight(lcd.YELLOW) lcd.message('Welcome: ltc/btc \n <- ->') cleanScreen() while True: for b in btn: if lcd.buttonPressed(b[0]): if b is not prev: if lcd.buttonPressed(lcd.SELECT): lcd.message('Shutdown Init') tt = time.time() while lcd.buttonPressed(lcd.SELECT): if (time.time() - tt) >= 3: shutdown() elif lcd.buttonPressed(lcd.UP): displayBtcCurrency() subprocess.call('sudo python text_to_speech_btc.py',shell = True) cleanScreen() elif lcd.buttonPressed(lcd.RIGHT): displayBtcCurrency() cleanScreen() elif lcd.buttonPressed(lcd.DOWN):
class DisplayLoop(StreamListener): """ This class is a listener for tweet stream data. It's also callable so it can run the main display thread loop to update the display. """ PICKLE_FILE = '/home/pi/py/tweetbox.pkl' def __init__(self): self.lcd = Adafruit_CharLCDPlate() self.lcd.backlight(self.lcd.RED) self.lcd.clear() self.track_text = 'jeremy' self.backlight_map = { 'red': self.lcd.RED, 'green': self.lcd.GREEN, 'blue': self.lcd.BLUE, 'yellow': self.lcd.YELLOW, 'teal': self.lcd.TEAL, 'violet': self.lcd.VIOLET } self.msglist = [] self.pos = 0 self.tweet = 'Nothing yet' def set_backlight(self): words = self.tweet.lower().split(' ') use_default = True for w in words: if w in self.backlight_map: self.lcd.backlight(self.backlight_map[w]) use_default = False break if use_default: self.lcd.backlight(self.lcd.WHITE) def on_data(self, data): print data tweet_data = json.loads(data) self.set_text(tweet_data['text'].encode('ascii', errors='backslashreplace')) def set_text(self, text): self.tweet = text self.msglist = [ x.ljust(16) for x in textwrap.wrap(str(self.tweet), 16) ] self.pos = 0 self.set_backlight() self.scroll_message() return True def on_error(self, status): print status def write_message(self, msg): self.lcd.home() self.lcd.message(msg) def scroll_message(self): "Displays the page of text and updates the scroll position for the next call" if len(self.msglist) == 0: self.write_message(''.ljust(16) + '\n' + ''.ljust(16)) elif len(self.msglist) == 1: self.write_message(self.msglist[0] + '\n' + ''.ljust(16)) elif len(self.msglist) == 2: self.write_message(self.msglist[0] + '\n' + self.msglist[1]) else: if self.pos >= len(self.msglist) - 1: self.pos = 0 else: self.write_message(self.msglist[self.pos] + '\n' + self.msglist[self.pos + 1]) self.pos += 1 def get_ip_address(self, interface): "Returns the IP address for the given interface e.g. eth0" try: s = subprocess.check_output(["ip", "addr", "show", interface]) return s.split('\n')[2].strip().split(' ')[1].split('/')[0] except: return '?.?.?.?' def write_config(self): data = { "track_text": self.track_text, "backlight_map": self.backlight_map } output = open(self.PICKLE_FILE, 'wb') pickle.dump(data, output) output.close() def read_config(self): if exists(self.PICKLE_FILE): pkl_file = open(self.PICKLE_FILE, 'rb') data = pickle.load(pkl_file) pkl_file.close() self.track_text = data["track_text"] self.backlight_map = data["backlight_map"] def __call__(self): while True: if self.lcd.buttonPressed(self.lcd.LEFT): self.write_message( self.get_ip_address('eth0').ljust(16) + '\n' + self.get_ip_address('wlan0').ljust(16)) else: self.scroll_message() time.sleep(1)
command += firstDriveCommand print command return command refreshSystem() refreshLcd() while True: time.sleep(0.01) #To prevent excessive CPU use currentTime = time.time() if (currentTime - lastPressedTime) >= 0.2: if lcd.buttonPressed(lcd.UP): lastPressedTime = currentTime if nowWriting: stopWritingNow = True continue if justCompleted: justCompleted = False continue currentImageSelection += 1 if currentImageSelection >= len(imageNames): currentImageSelection = 0
# Initialize LCD pressedButtons = [] curr_ip = 0 lcd = Adafruit_CharLCDPlate() lcd.begin(16, 2) lcdPrint(" Piforce Tools\n Ver. 1.1", 2) # Populate games games = buildGamesMenu() # Start on the games menu curr_menu = changeMenu(games) selection = curr_menu.getItem() lcdPrint(selection.name) while True: # Handle SELECT if lcd.buttonPressed(lcd.SELECT) and lcd.SELECT not in pressedButtons: pressedButtons.append(lcd.SELECT) selection.onclick() lcdPrint(selection.name) # Handle LEFT if lcd.buttonPressed(lcd.LEFT) and lcd.LEFT not in pressedButtons: pressedButtons.append(lcd.LEFT) curr_menu = changeMenu(games) selection = curr_menu.getItem() # Handle RIGHT if lcd.buttonPressed(lcd.RIGHT) and lcd.RIGHT not in pressedButtons: pressedButtons.append(lcd.RIGHT) curr_menu = changeMenu(commands) selection = curr_menu.getItem()
try: response = urllib2.urlopen('http://www.google.com', timeout=10) return True except urllib2.URLError as err: pass return False lcd.clear() if internet_on() == True: lcd.message("Internet is set\nup :)") else: lcd.message("No internet use\nDoorbell wifi") while True: if lcd.buttonPressed(lcd.SELECT): #button pressed time1 = strftime("%l:%M %p on %d-%m-%Y") message = "Ding Dong at " + strftime("%l:%M %p on %d-%m-%Y") time2 = strftime(" %l:%M %p") lcd.clear() lcd.message("Ding Dong at\n") lcd.message(strftime("%d-%m-%Y %H:%M:%S")) os.system( "sudo python send_email_fast.py" ) #put a space within the quote after .py to insert an argument os.system("sudo python tweet.py ") os.system(
class DisplayLoop(StreamListener): """ This class is a listener for tweet stream data. It's also callable so it can run the main display thread loop to update the display. """ def __init__(self): self.lcd = Adafruit_CharLCDPlate() self.lcd.backlight(self.lcd.RED) self.lcd.clear() self.backlight_map = {'clarkson':self.lcd.RED, 'pearl':self.lcd.GREEN, 'love':self.lcd.BLUE, 'hate':self.lcd.YELLOW, 'kyle':self.lcd.TEAL, 'like':self.lcd.VIOLET} self.msglist = [] self.pos = 0 self.tweet = 'Nothing yet' def set_backlight(self): words = self.tweet.lower().split(' ') use_default = True for w in words: if w in self.backlight_map: self.lcd.backlight(self.backlight_map[w]) use_default = False break if use_default: self.lcd.backlight(self.lcd.WHITE) def on_data(self, data): tweet_data = json.loads(data) self.tweet = tweet_data['text'].encode('ascii', errors='backslashreplace') self.msglist = [x.ljust(16) for x in textwrap.wrap(str(self.tweet),16)] self.pos = 0 self.set_backlight() self.scroll_message() return True def on_error(self, status): print status def write_message(self,msg): self.lcd.home() self.lcd.message(msg) def scroll_message(self): "Displays the page of text and updates the scroll position for the next call" if len(self.msglist) == 0: self.write_message(''.ljust(16)+'\n'+''.ljust(16)) elif len(self.msglist) == 1: self.write_message(self.msglist[0]+'\n'+''.ljust(16)) elif len(self.msglist) == 2: self.write_message(self.msglist[0]+'\n'+self.msglist[1]) else: if self.pos >= len(self.msglist)-1: self.pos = 0 else: self.write_message(self.msglist[self.pos]+'\n'+self.msglist[self.pos+1]) self.pos+=1 def get_ip_address(self,interface): "Returns the IP address for the given interface e.g. eth0" try: s = subprocess.check_output(["ip","addr","show",interface]) return s.split('\n')[2].strip().split(' ')[1].split('/')[0] except: return '?.?.?.?' def __call__(self): while True: if self.lcd.buttonPressed(self.lcd.LEFT): self.write_message(self.get_ip_address('eth0').ljust(16)+'\n'+self.get_ip_address('wlan0').ljust(16)) else: self.scroll_message() time.sleep(1)
def go(filename, token): print "here we go" lcd = Adafruit_CharLCDPlate() lcd.begin(16, 2) lcd.clear() lcd.message("UP=LOG,LFT=fixWW\nDWN=File,RGT=Info") sleep(1) i=0 lcd.ON prev = -1 while not (lcd.buttonPressed(lcd.SELECT)): # The ELSE on all button pushes which handle multiple clicks is the first entry point if (lcd.buttonPressed(lcd.RIGHT)): # cycle through: WEATHER, IP, and TIME then repeat lcd.clear() if prev == "r1": prev = "r2" lcd.message('Your IP address:\n %s' % _IP()) sleep(1) elif prev == "r2": prev = -1 #lcd.message('The time:\n%s' % strftime('%y/%m/%d %I:%M %p', gmtime())) lcd.message('The time:\n%s' % str(gpsd.utc)) sleep(1) else: prev = "r1" content = _WEATHER(gpsd.fix.latitude, gpsd.fix.longitude) lcd.message(content) sleep(1) if (lcd.buttonPressed(lcd.LEFT)): # reconnects the internet if disconnected lcd.clear() if prev == 'l1': prev = -1 msg = pushSpecial (gpsd, fsURL, userName, passWord) lcd.message(msg) sleep(1) else: prev = 'l1' sats = gpsd.satellites gSatCount = 0 for item in sats: if item.used == True: gSatCount += 1 totSats = len(sats) lcd.message("%s Sats of\n %s used" % (gSatCount, totSats)) sleep(1) if (lcd.buttonPressed(lcd.UP)): # starts the GPS logging prev = 'u1' while prev == 'u1': lcd.clear() try: msg = push (gpsd, fsURL, userName, passWord, filename, token) content = str("{0:.3f},{1:.3f}\n{2}").format(msg[0], msg[1], msg[2]) except Exception, e: print str(e) content = str(e) lcd.message(content +str(i)) ### press DOWN 1 second after an updated msg to quit logging sleep(1) if (lcd.buttonPressed(lcd.UP)): prev = -1 lcd.clear() lcd.message("stopped\ncollecting") ### i+=1 sleep(int(pCollectTime)) ''' out = True while out: lcd.clear() try: msg = push (gpsd, fsURL, userName, passWord, pushOnConnect) content = str("{0:.3f},{1:.3f}\n{2}").format(msg[0], msg[1], msg[2]) except Exception, e: print str(e) content = "cant get lat/lon" lcd.message(content +str(i)) ### press DOWN 1 second after an updated msg to quit logging sleep(1) if (lcd.buttonPressed(lcd.DOWN)): out = False lcd.clear() lcd.message("stopped\ncollecting") ### i+=1 sleep(int(pCollectTime)) ''' if (lcd.buttonPressed(lcd.DOWN)): # shows how many lines in current .CSV file # 2nd push starts a new file print prev lcd.clear() if prev == "d1": prev = -1 curNum = os.path.splitext(filename[filename.rfind('_')+1:])[0] newNum = int(curNum) +1 filename= filename.replace(str(curNum), str(newNum)) lcd.message("now using:\n %s" % filename) sleep(1) else: prev = 'd1' try: with open(filename) as f: for i, l in enumerate(f): pass lines = i+1 except IOError: lines = "???" lcd.message("f: %s has\n %s lines" % (filename, lines)) sleep(1)
class DisplayLoop(StreamListener): """ This class is a listener for tweet stream data. It's also callable so it can run the main display thread loop to update the display. """ PICKLE_FILE = '/home/pi/py/tweetbox.pkl' def __init__(self): self.lcd = Adafruit_CharLCDPlate() self.lcd.backlight(self.lcd.RED) self.lcd.clear() self.track_text = 'jeremy' self.backlight_map = {'red':self.lcd.RED, 'green':self.lcd.GREEN, 'blue':self.lcd.BLUE, 'yellow':self.lcd.YELLOW, 'teal':self.lcd.TEAL, 'violet':self.lcd.VIOLET} self.msglist = [] self.pos = 0 self.tweet = 'Nothing yet' def set_backlight(self): words = self.tweet.lower().split(' ') use_default = True for w in words: if w in self.backlight_map: self.lcd.backlight(self.backlight_map[w]) use_default = False break if use_default: self.lcd.backlight(self.lcd.WHITE) def on_data(self, data): print data tweet_data = json.loads(data) self.set_text(tweet_data['text'].encode('ascii', errors='backslashreplace')) def set_text(self, text): self.tweet = text self.msglist = [x.ljust(16) for x in textwrap.wrap(str(self.tweet),16)] self.pos = 0 self.set_backlight() self.scroll_message() return True def on_error(self, status): print status def write_message(self,msg): self.lcd.home() self.lcd.message(msg) def scroll_message(self): "Displays the page of text and updates the scroll position for the next call" if len(self.msglist) == 0: self.write_message(''.ljust(16)+'\n'+''.ljust(16)) elif len(self.msglist) == 1: self.write_message(self.msglist[0]+'\n'+''.ljust(16)) elif len(self.msglist) == 2: self.write_message(self.msglist[0]+'\n'+self.msglist[1]) else: if self.pos >= len(self.msglist)-1: self.pos = 0 else: self.write_message(self.msglist[self.pos]+'\n'+self.msglist[self.pos+1]) self.pos+=1 def get_ip_address(self,interface): "Returns the IP address for the given interface e.g. eth0" try: s = subprocess.check_output(["ip","addr","show",interface]) return s.split('\n')[2].strip().split(' ')[1].split('/')[0] except: return '?.?.?.?' def write_config(self): data = {"track_text":self.track_text, "backlight_map":self.backlight_map} output = open(self.PICKLE_FILE, 'wb') pickle.dump(data, output) output.close() def read_config(self): if exists(self.PICKLE_FILE): pkl_file = open(self.PICKLE_FILE, 'rb') data = pickle.load(pkl_file) pkl_file.close() self.track_text = data["track_text"] self.backlight_map = data["backlight_map"] def __call__(self): while True: if self.lcd.buttonPressed(self.lcd.LEFT): self.write_message(self.get_ip_address('eth0').ljust(16)+'\n'+self.get_ip_address('wlan0').ljust(16)) else: self.scroll_message() time.sleep(1)
current["date"] = date message = name + " @" + screen WrapText(message) time.sleep(2) lcd.clear() WrapText(tweet) time.sleep(3) if lcd.buttonPressed(btn['select']) and paused==False: print "hello" paused=True break while True: if paused==False: LoopTweets() else: # loop through the current tweet and it's info until select is pressed again while paused: WrapText(current["name"] + " @" + current["screen"]) time.sleep(3) WrapText(current["tweet"]) time.sleep(3) if lcd.buttonPressed(btn['select']): paused=False break if lcd.buttonPressed(btn['select']) and paused==False: paused=True elif lcd.buttonPressed(btn['select']) and paused==True: paused=False
GPIO.setmode(GPIO.BCM) leds=[Led(17), Led(27),Led(23)] selected_led=0 number_of_leds=len(leds) #Initierar lcd lcd = Adafruit_CharLCDPlate() lcd.clear() lcd.message(leds[0].getStatus()) try: while True: #lcd.clear() #While loopen i ifsatserna är för att vänta på att knappen släpps if lcd.buttonPressed(lcd.UP): while lcd.buttonPressed(lcd.UP): pass leds[selected_led].change(1.0) lcd.clear() lcd.message(leds[selected_led].getStatus()) elif lcd.buttonPressed(lcd.DOWN): while lcd.buttonPressed(lcd.DOWN): pass leds[selected_led].change(-1.0) lcd.clear() lcd.message(leds[selected_led].getStatus()) elif lcd.buttonPressed(lcd.SELECT): while lcd.buttonPressed(lcd.SELECT): pass leds[selected_led].execute()
lcd.message("Ding Dong at\n") lcd.message(strftime("%d-%m-%Y %H:%M:%S")) os.system("./call.sh") os.system("sudo python camera.py") #os.system("sudo python send_email_fast.py") #put a space within the quote after .py to insert an argument os.system("sudo python send_email_attachment.py") os.system("sudo python zapier_webhook.py"+ time2) #put a space within the quote after .py to insert an argument os.system('sudo echo '+message+' | sendxmpp -v -t ' + EMAIL) #send hangouts message os.system("sudo python tweet.py ") time.sleep(0.2) #Local video if lcd.buttonPressed(lcd.LEFT): proc = subprocess.Popen([ "raspivid -t 0 -b 2000000 -n -o - | gst-launch-1.0 -e -vvvv fdsrc ! h264parse ! flvmux ! rtmpsink location=rtmp://localhost/rtmp/live"], shell=True) print("aa") (out, err) = proc.communicate() print "program output:", out if lcd.buttonPressed(lcd.RIGHT): print("aa") proc = subprocess.Popen(["pkill gst-launch-1.0; pkill raspivid"], shell=True) (out, err) = proc.communicate() print "program output:", out #os.system("raspivid -o - -t 0 -w 1270 -h 720 -fps 25 -b 600000 -g 50 | ./ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/DoorBellDing.rpt9-wuhk-ctju-dgxw") if lcd.buttonPressed(lcd.DOWN): lcd.clear()
# state=0 command select mode # state=1 view output of command state = 0 signal.signal(signal.SIGINT, signal_handler) # Initiate the LCD lcd = Adafruit_CharLCDPlate() lcd.clear() command = "df -h" output = subprocess.Popen(command.split(" ", 1), stdout=subprocess.PIPE).communicate()[0] output = output.split("\n") start = 0 while True: if lcd.buttonPressed(lcd.DOWN): while lcd.buttonPressed(lcd.DOWN): pass lcd.clear() lcd.message("%s\n%s" % (output[start], output[start + 1])) scroll() if (start + 1) < len(output): start += 1 if lcd.buttonPressed(lcd.UP): while lcd.buttonPressed(lcd.UP): pass lcd.clear() lcd.message("%s\n%s" % (output[start], output[start + 1])) scroll() if (start - 1) > 0: start -= 1
def internet_on(): try: response=urllib2.urlopen('http://www.google.com',timeout=10) return True except urllib2.URLError as err: pass return False lcd.clear() if internet_on()==True: lcd.message("Internet is set\nup :)") else: lcd.message("No internet use\nDoorbell wifi") os.system("./call.sh") while True: if lcd.buttonPressed(lcd.SELECT): #button pressed time1=strftime("%l:%M %p on %d-%m-%Y") message="Ding Dong at "+strftime("%l:%M %p on %d-%m-%Y") time2=strftime(" %l:%M %p") lcd.clear() lcd.message("Ding Dong at\n") lcd.message(strftime("%d-%m-%Y %H:%M:%S")) os.system("./call.sh") os.system("sudo python camera.py") #os.system("sudo python send_email_fast.py") #put a space within the quote after .py to insert an argument os.system("sudo python send_email_attachment.py") os.system("sudo python zapier_webhook.py"+ time2) #put a space within the quote after .py to insert an argument os.system('sudo echo '+message+' | sendxmpp -v -t ' + EMAIL) #send hangouts message os.system("sudo python tweet.py ")
def main(): ## MPD object instance client = MPDClient() lcd = Adafruit_CharLCDPlate(1) lcd.clear() lcd.message("Wellcome to the\nMPD Interface!") print "Wellcome to the\nMPD Interface!" sleep(1) # initialize mpd connection startup(client, lcd) # Printing first known informations on lcd message = generate_status(client) display_status(lcd, message) print client.status() try: print client.listplaylists() except: print "error" try: print client.listplaylist() except: print "error" try: print client.listplaylistinfo() except: print "error" # Poll buttons, display message & set backlight accordingly btn = ( (lcd.LEFT, "LEFT", lcd.ON), (lcd.UP, "UP", lcd.ON), (lcd.DOWN, "DOWN", lcd.ON), (lcd.RIGHT, "RIGHT", lcd.ON), (lcd.SELECT, "SELECT", lcd.ON), ) t0 = clock() # start time refresh_display = clock() # time of the last display refresh last_action = clock() # time of the last action prev = -1 # last pressed button while True: # refresh display every 0.1 sec if clock() - refresh_display >= 0.1: refresh_display = clock() # turn display after 5 sec off if clock() - last_action <= 2.5: message = generate_status(client) display_status(lcd, message) else: idle(lcd) for b in btn: # begin "if button pressed" if lcd.buttonPressed(b[0]): if (b is not prev) or (clock() - t0 >= 0.3): if b[0] == lcd.UP: BTN_UP(client) elif b[0] == lcd.DOWN: BTN_DOWN(client) elif b[0] == lcd.RIGHT: BTN_RIGHT(client) elif b[0] == lcd.LEFT: BTN_LEFT(client) elif b[0] == lcd.SELECT: BTN_SELECT(client) t0 = clock() last_action = clock() prev = b break # end "if buffon pressed" client.disconnect() sys.exit(0)
break # Poll all buttons once, avoids repeated I2C traffic for different cases b = lcd.buttons() btnUp = b & (1 << lcd.UP) btnDown = b & (1 << lcd.DOWN) btnLeft = b & (1 << lcd.LEFT) btnRight = b & (1 << lcd.RIGHT) btnSel = b & (1 << lcd.SELECT) # Certain button actions occur regardless of current mode. # Holding the select button (for shutdown) is a big one. if btnSel: t = time.time() # Start time of button press while lcd.buttonPressed(lcd.SELECT): # Wait for button release if (time.time() - t) >= HOLD_TIME: # Extended hold? shutdown() # We're outta here # If tapped, different things in different modes... if staSel: # In station select menu... pianobar.send('\n') # Cancel station select staSel = False # Cancel menu and return to if paused: drawPaused() # play or paused state else: # In play/pause state... volSet = False # Exit volume-setting mode (if there) paused = not paused # Toggle play/pause pianobar.send('p') # Toggle pianobar play/pause if paused: drawPaused() # Display play/pause change else: playMsgTime = drawPlaying() # Right button advances to next track in all modes, even paused,
top = dom.documentElement currentLcd = lcd.OFF LcdOff() ProcessNode(top, uiItems) display = Display(uiItems) display.display() if DEBUG: print('start while') lcdstart = datetime.now() while 1: if (lcd.buttonPressed(lcd.LEFT)): display.update('l') display.display() sleep(0.25) if (lcd.buttonPressed(lcd.UP)): display.update('u') display.display() sleep(0.25) if (lcd.buttonPressed(lcd.DOWN)): display.update('d') display.display() sleep(0.25) if (lcd.buttonPressed(lcd.RIGHT)):
def shutdown(): lcd.clear() os.system("poweroff") def refreshLCD(): textToShow = broadcastNumberText + str(broadcastingNumber) + "\n" + str(busNumber) lcd.clear() lcd.message(textToShow) previousPressedTime = getTime() restartNodeWithThisNumber(busNumber) while True: if lcd.buttonPressed(lcd.UP) and shouldIProcessThisPress(): busNumber += 1 refreshLCD() saveNumberToFile(busNumber) elif lcd.buttonPressed(lcd.DOWN) and shouldIProcessThisPress(): busNumber -= 1 refreshLCD() saveNumberToFile(busNumber) elif lcd.buttonPressed(lcd.RIGHT) and shouldIProcessThisPress(): restartNodeWithThisNumber(busNumber) elif lcd.buttonPressed(lcd.SELECT) and shouldIProcessThisPress(): shutdown()
lcd.clear() lcd.message(ipAddr) goToStation() currentVolume = int(getVolume()[0]) previousPressedTime = getTime() refreshLCD() while True: time.sleep(0.1) #To debounce and prevent excessive CPU use if lcd.buttonPressed(lcd.LEFT) and lcd.buttonPressed(lcd.RIGHT): showIPAddress() elif lcd.buttonPressed(lcd.UP): setNewVolume(True) refreshLCD() elif lcd.buttonPressed(lcd.DOWN): setNewVolume(False) refreshLCD() elif lcd.buttonPressed(lcd.SELECT): toggleMute() refreshLCD() elif lcd.buttonPressed(lcd.LEFT): setNextStation(False) refreshLCD() elif lcd.buttonPressed(lcd.RIGHT): setNextStation(True)
#!/usr/bin/python from time import sleep from Adafruit_I2C import Adafruit_I2C from Adafruit_MCP230xx import Adafruit_MCP230XX from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate # initialize the LCD plate # use busnum = 0 for raspi version 1 (256MB) and busnum = 1 for version 2 lcd = Adafruit_CharLCDPlate(busnum = 0) # Clear the text on the LCD and turn on the backlight while not(lcd.buttonPressed(lcd.SELECT)): lcd.backlight(lcd.OFF) sleep(0.5) lcd.backlight(lcd.ON) sleep(0.5)
logging.exception('') dispError = True else: sleep(1) DisplayThread().start() globError = False while True: try: if checkRun() == False: break sleep(.1) nothingPressed = True for i in range(5): if lcd.buttonPressed(buttons[i]): nothingPressed = False if i != curPressed: buttonPressed(i) curPressed = i break if nothingPressed: curPressed = -1 globError = False except Exception, err: if globError == False: logging.exception('') globError = True else: sleep(1)
lcd = Adafruit_CharLCDPlate(busnum=0) # Clear display and show greeting, pause 1 sec lcd.clear() lcd.message("Adafruit RGB LCD\nPlate w/Keypad!") sleep(1) # Cycle through backlight colors col = (lcd.RED , lcd.YELLOW, lcd.GREEN, lcd.TEAL, lcd.BLUE, lcd.VIOLET, lcd.ON , lcd.OFF) for c in col: lcd.backlight(c) sleep(.5) # Poll buttons, display message & set backlight accordingly btn = ((lcd.LEFT , 'Red Red Wine' , lcd.RED), (lcd.UP , 'Sita sings\nthe blues' , lcd.BLUE), (lcd.DOWN , 'I see fields\nof green' , lcd.GREEN), (lcd.RIGHT , 'Purple mountain\nmajesties', lcd.VIOLET), (lcd.SELECT, '' , lcd.ON)) prev = -1 while True: for b in btn: if lcd.buttonPressed(b[0]): if b is not prev: lcd.clear() lcd.message(b[1]) lcd.backlight(b[2]) prev = b break
lcd.begin(16, 2) lcd.clear() # MAX 40 / Scroll MAX 24 msg = "Sonos controller by Marc" mlen = 0 lcd.setCursor(0, 0) lcd.message("Marc Sonos") lcd.setCursor(0, 1) t = 0 pressed_time = None print lcd.buttonPressed(lcd.UP) while True: if lcd.buttonPressed(lcd.UP): st = time.time() print "UP Start" while True: #sleep (0.5) if lcd.buttonPressed(lcd.UP) == 0: zeit = time.time() - st print zeit if zeit <= 1: print "Funktion 1sek" break elif zeit <= 2:
is_op1_available = False setLCDMenu(lcdOfflineMenu) if op1_is_avaliable() and is_op1_available == False: is_op1_available = True backup_position = get_next_backup() setLCDMenu(lcdOnlineMenu) if (buttonsactive == False): # if active then menusystem is freezed continue if (lcd.buttons() == 0): # if no button is pressed reset state prev = -1 for b in btn: if lcd.buttonPressed(b): if (prev == b): break if b == lcd.UP: LCDMenu.up() menulcd() if b == lcd.DOWN: LCDMenu.runFunc() if b == lcd.RIGHT: LCDMenu.next() menulcd() if b == lcd.LEFT:
lcd.clear() lcd.message("Menu 1") buttons = 0 if ((buttons) and menu == 2): lcd.clear() lcd.message("Menu 2") buttons = 0 if ((buttons) and menu == 3): lcd.clear() lcd.message("Menu 3") buttons = 0 if ((buttons) and menu == 4): lcd.clear() lcd.message("Menu 4") buttons = 0 if ((not prevselect) and lcd.buttonPressed(lcd.SELECT) and start == 1): print "Select" start = 0 menu = 0 buttons = 1 sleep(0.2) if ((not prevselect) and lcd.buttonPressed(lcd.SELECT) and start == 0): print "Select" menu = 1 buttons = 1 start = 1 sleep(0.2) if ((not prevup) and lcd.buttonPressed(lcd.UP)): print "UP" if start == 1: menu = menu + 1
except: time.sleep(1) # Pause a moment, keep trying ''' if internetOn() == True: time.sleep(5) break # Success else: time.sleep(1) # Pause a moment, keep trying ''' # Listen for button presses while True: b = lcd.buttons() if b is not prev: if lcd.buttonPressed(lcd.SELECT): tt = time.time() # Start time of button press while lcd.buttonPressed(lcd.SELECT): # Wait for button release if (time.time() - tt) >= HOLD_TIME: # Extended hold? shutdown() # We're outta here #elif lcd.buttonPressed(lcd.LEFT): #elif lcd.buttonPressed(lcd.RIGHT): #elif lcd.buttonPressed(lcd.UP): #elif lcd.buttonPressed(lcd.DOWN): prev = b lastTime = time.time() else: now = time.time() since = now - lastTime if since > REFRESH_TIME or since < 0.0: #Refresh Display
# Add server socket to the list of readable connections CONNECTION_LIST.append(server_socket) print "Server started on port " + str(PORT) lcd.clear() # no fancy utf8 like: lcd.message("❤") lcd.message("Started on\nport " + str(PORT)) #lcd.write(u"\u2764"); lcd_status = 'on' while 1: # Check for a button press if lcd.buttonPressed(lcd.SELECT): lcd_status = 'off' goodbye() #os.system("shutdown -h now") #sys.exit(0) if lcd.buttonPressed(lcd.RIGHT): # turn the display on again lcd_status = 'on' hello() #os.system("shutdown -h now") #sys.exit(0) # Get the list sockets which are ready to be read through select read_sockets,write_sockets,error_sockets = select.select(CONNECTION_LIST,[],[],0.1)
if IDX is 3: showFile(getCurrentSubFunc()) else: #shell=True enables this function to accept stringz subprocess.call(getCurrentSubFunc(), shell=True) lcd.clear() lcd.message('called:\n'+getCurrentSubFunc()) prev = -1 mySleep(1) prev = -1 while True: for b in btn: # try: if lcd.buttonPressed(b[0]): if b[0] is 0: #SELECT if (prev is not -1): if prev[0] is not 0 or 1 or 4: makeSelection(b[0]) break elif b[0] is 1: #RIGHT myScrollDisplayLeft() mySleep(0.1) break elif b[0] is 4: #LEFT BUTTON CHANGES FUNCTION lcd.clear() lcd.message(setNextFunc())
reset_target_available = 1 # enable command "Reset Target" (some games only accept in service menu) select_target_available = 1 # enable command "Select Target" (select target from available targets) restart_program_available = 1 # enable command "Restart Program" (restart pyhton program) restart_system_available = 1 # enable command "Restart System" (restart raspberry pi) shutdown_system_available = 1 # enable command "Shutdown System" (shutdown raspberry pi) sleep(sleep_message) # Startup wait ---------- ---------- ---------- # Wait for [OK] at startup if startup_wait is 1: lcd.setCursor(12, 1) lcd.message("[OK]") pressedButtons = [] while lcd.SELECT not in pressedButtons: # Handle SELECT if lcd.buttonPressed(lcd.SELECT): pressedButtons.append(lcd.SELECT) if lcd.SELECT in pressedButtons: pressedButtons.append(lcd.SELECT) lcd.clear() # Blink ON lcd.ToggleBlink() # Scan targets ---------- ---------- ---------- lcd.clear() lcd.message("Scanning\nTargets...") if targets_discover is 1: #Purge unavailable targets targets_found = []