class Interface: def __init__(self, busnum=-1, addr=0x20, debug=False): self.lcd = LCD(busnum, addr, debug) self.config = Config() self.lcd.backlight(int(self.config.get('Display', 'Colour'))) self.lcd.clear() def scytheHome(self): self.display('<> Scythe L/R\n^v Choose image') def chooseImage(self, imageName): output = 'Image chosen:\n' + imageName self.display(output) def display(self, text): self.lcd.display() self.lcd.backlight(int(self.config.get('Display', 'Colour'))) self.lcd.clear() self.lcd.message(text) def buttons(self): return self.lcd.buttons() def off(self): self.lcd.backlight(self.lcd.OFF) self.lcd.noDisplay()
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 Interface: def __init__(self, busnum=-1, addr=0x20, debug=False): self.lcd = LCD(busnum, addr, debug) self.config = Config() self.lcd.backlight(int(self.config.get('Display', 'Colour'))) self.lcd.clear() def scytheHome(self): self.display('<> Scythe L/R\n^v Choose image') def chooseImage(self, imageName): output = 'Image chosen:\n' + imageName self.display(output) def display(self, text): self.lcd.display() self.lcd.backlight(int(self.config.get('Display', 'Colour'))) self.lcd.clear() self.lcd.message(text) def buttons(self): return self.lcd.buttons() def off(self): self.lcd.backlight(self.lcd.OFF) self.lcd.noDisplay()
class SpeedTestCheck(object): def __init__(self): self.current = {} def setup(self): self.lcd = Adafruit_CharLCDPlate() self.lcd.backlight(self.lcd.GREEN) def checkspeed(self): cmd = "speedtest-cli --simple --secure" raw = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) output, errors = raw.communicate() cleaned = filter(None, output.split('\n')) self.current = dict(map(str, x.split(':')) for x in cleaned) print self.current def printspeed(self): self.lcd.clear() self.lcd.backlight(self.lcd.BLUE) msg1 = "D" + self.current['Download'] + '\n' + "U" + self.current['Upload'] self.lcd.message(msg1) def main(self): self.setup() while True: try: self.checkspeed() except Exception as e: print "not sure what happened! %s" %(e) try: self.printspeed() except Exception as e: print "not sure what happened! %s" %(e) time.sleep(3600)
def open_dev(encoder_pins): ''' Opens communication with Arduino, GPIO and lcd :param encoder_pins: contains the GPIO pins to the encoder :type encoder_pins: list of integer :returns: lcd object, arduino object and iterator :rtype: tuple ''' # LCD lcd = Adafruit_CharLCDPlate() lcd.clear() # GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(encoder_pins[0], GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(encoder_pins[1], GPIO.IN, pull_up_down=GPIO.PUD_UP) # Arduino # Init Arduino and iterator lcd.message("Connection de \nl'Arduino ...") board = Arduino('/dev/ttyACM0') lcd.clear() print('Arduino connected') lcd.message("Arduino connecte !") # Création itérateur iter8 = util.Iterator(board) iter8.start() dev = ( lcd, board, ) return dev
class Display(): """ Creates a display command instance. Its update method calles the update method for all the blocks, and hence should be called at the frequency which updates are desired. """ def __init__(self): self.lcd = Adafruit_CharLCDPlate() self.lcd.begin(16,2) self.lcd.clear() self.lcd.home() self.time = TimeBlock(self.lcd) self.status = StatusBlock(self.lcd) self.query = QueryBlock(self.lcd) self.lastState = OFF self.state = OFF def update(self,state=None): self.time.update() self.status.update() # set our own lastState and state based on the query block self.lastState = self.query.lastState if state and state == IDLE: self.state = self.query.update(enterIdleState=True) elif state and state == PROCESS: self.state = self.query.update(enterProcessState=True) elif state and state == QUERY: self.state = self.query.update(enterQueryState=True) else: self.state = self.query.update() if DEBUG: print state,self.state # turn off if we just changed to OFF # turn on if we just changed from OFF if self.state == OFF and self.lastState != OFF: self.off() if self.state != OFF and self.lastState == OFF: self.on() if DEBUG: print self.state def on(self): self.query.update(enterIdleState=True) self.lcd.display() self.lcd.backlight(self.lcd.ON) def off(self): self.lcd.noDisplay() self.lcd.backlight(self.lcd.OFF) def fail(self,message=''): self.lcd.display() self.lcd.clear() self.lcd.home() self.lcd.backlight(self.lcd.ON) self.lcd.message("EPIC FAIL\n%s" % message)
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)
class LCDPlate(): def __init__(self): self.lcd = Adafruit_CharLCDPlate() self.lcd.begin(16, 2) self.lcd.clear() self.lcd.backlight(self.lcd.GREEN) def update_active(self, result, heat, cool, fan): if result == 'cool': self.lcd.backlight(self.lcd.BLUE) elif result == 'heat': self.lcd.backlight(self.lcd.RED) elif result == 'off': self.lcd.backlight(self.lcd.GREEN) def update_temperature(self, temp): self.lcd.clear() self.lcd.message("Temp: %.1fF" % temp) def off(self): self.lcd.backlight(self.lcd.OFF) self.lcd.clear()
class LCDPlate(): def __init__(self): self.lcd = Adafruit_CharLCDPlate() self.lcd.begin(16, 2) self.lcd.clear() self.lcd.backlight(self.lcd.GREEN) def update_active(self, result, heat, cool, fan): if result == 'cool': self.lcd.backlight(self.lcd.BLUE) elif result == 'heat': self.lcd.backlight(self.lcd.RED) elif result == 'off': self.lcd.backlight(self.lcd.GREEN) def update_temperature(self, temp): self.lcd.clear() self.lcd.message("Temp: %.1fF" % temp) def off(self): self.lcd.backlight(self.lcd.OFF) self.lcd.clear()
elif tilt < -1: tilt = -1 elif m==1: panOld=pan tiltOld=tilt pan = "{:.4f}".format(pan) tilt = "{:.4f}".format(tilt) lcd.clear() lcd.message("{}\n{} {}".format(mode[m],pan,tilt)) data = [throttle,turn,pan,tilt,shotD,shotB] convertBit(data) try: global isRunning lcd.begin(16,2) lcd.clear() lcd.backlight(lcd.ON); lcd.message("System Starting") controllerServer = SocketServer.UDPServer(('', portListen), receiverHandler) ser = serial.Serial('/dev/ttyACM0', 9600) data = [0,0,0,0,0,0] convertBit(data) sleep(2) isRunning = True while isRunning: controllerServer.serve_forever() print 'Finished' except KeyboardInterrupt: print 'Terminated' data = [0,0,0,0,0,0] convertBit(data)
for i in range(40): shiftwithinrange(i, 16) general_cmd(0b00011000) # display shift left sleep(0.05) if cmd == "cgram": num = raw_input("CGRAM address? ") setCGRAMadd(int(num)) if cmd == "ramdata": print "fast RAM Data = ", binfill(readfast(True)) # read data from RAM # print "RAM Data = ", lcd.read4bits(True) # read data from RAM if cmd == "mess": str = raw_input("message:") lcd.message(str) if cmd == "9": str = raw_input("9 bits of instruction code:") char_mode = str[0] == "1" # 1 is true str = str[1:].zfill(8) bits = int("0b" + str, 2) print char_mode, str, bits numrpt = raw_input("repeat #:") numrpt = 1 if numrpt == "" else int(numrpt) for count in range(0, numrpt): lcd.write4bits(bits, char_mode) if cmd == "dump": DumpMCP23017Regs()
#!/usr/bin/python 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("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]):
import time lcd = Adafruit_CharLCDPlate() lcd.begin(16, 1) def DOGE(): cryptsy = json.load( urllib2.urlopen( 'http://pubapi.cryptsy.com/api.php?method=singlemarketdata&marketid=132' )) #if cryptsy["success"] != "1": # raise Exception("Cryptsy API failed!") current_price = cryptsy["return"]["markets"]["DOGE"]["lasttradeprice"] # No rollover necessary, but need to figure out how to deal with decimal places return current_price #Add support for switching between currencies by using button code while 1: lcd.clear() #Calls BTC function, gets time and formats price = DOGE() time = datetime.now().strftime('%F %H:%M\n') #Displays time on first line, BTC/USD rate on next line lcd.message(time) lcd.message("DOGE: " + price) #Sleeps until next API call is possible #Needs to be customized per API, add support next sleep(30)
from time import gmtime, strftime import os EMAIL = '*****@*****.**' GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(14, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Initialize the LCD plate. lcd = Adafruit_CharLCDPlate() # Clear display and show greeting, pause 1 sec lcd.clear() lcd.backlight(lcd.ON) lcd.message("Welcome to your\ndoorbell") sleep(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 :)")
from os import chdir import re import liblo target = liblo.Address(2000) messageText = "" messageTime = 0 # 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("microsynth\n") sleep(1) # Cycle through backlight colors #col = lcd.BLUE # #lcd.ON , lcd.OFF) #osc stuff ---------------------------------------------------------------- # create server, listening on port 2001 import liblo try: server = liblo.ServerThread() except liblo.ServerError, err:
signal.signal(signal.SIGTERM, handler) # Determine hardware revision and initialize LCD revision = "unknown" cpuinfo = open("/proc/cpuinfo", "r") for line in cpuinfo: item = line.split(':', 1) if item[0].strip() == "Revision": revision = item[1].strip() if revision.startswith('a'): lcd = Adafruit_CharLCDPlate(busnum=1) else: lcd = Adafruit_CharLCDPlate() lcd.begin(16, 2) lcd.message(" Naomi Project\n Ver. 1.4.") sleep(2) # Try to import game list script, if it fails, signal error on LCD try: from gamelist import games except (SyntaxError, ImportError) as e: lcd.clear() lcd.message("Game List Error!\n Check Syntax") sleep(5) games = {} # Purge game dictionary of game files that can't be found missing_games = [] for key, value in games.iteritems(): if not os.path.isfile(rom_dir + value):
# -*- coding: cp1252 -*- #utveckling för att använda fler LED import RPi.GPIO as GPIO from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate from class_led import Led 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()
""" p = subprocess.Popen(["ifconfig"], stdout=subprocess.PIPE) ifc_resp = p.communicate() patt = re.compile(r'inet\s*\w*\S*:\s*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})') resp = patt.findall(ifc_resp[0]) print resp return resp # 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("Adafruit RGB LCD\nPlate w/Keypad!") sleep(1) lcd.clear() 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),
v71 = "7.1.1" v6 = "6.0.2" v61 = "6.1.6" v5 = "obsolete" def up2date(iOSVer): sayStuf("You seem to be up to date with version " + iOSVer + ", but do not worry, we have a backup",True) if debug['glob'] == True: print("You are runing: " + iOSVer) if iOSVer == v7: up2date(v7) if iOSVer == v71: up2date(v71) if iOSVer == v6: up2date(v6) if iOSVer == v61: up2date(v61) if iOSVer == v5: up2date(v5) if __name__ == "__main__": while True: main() print("Sleeping") sleep(.5) lcd.clear() lcd.backlight(lcd.GREEN) if debug['lcd']: lcd.message(datetime.now().strftime('%b %d\n %H:%M:%S\n'))
GPIO.setmode(GPIO.BCM) GPIO.setup(23, GPIO.IN) lcd = Adafruit_CharLCDPlate(busnum=1) numScreens = 4 choosenScreen = 3 lastButtonPress = time.time() lastRefresh = time.time() timerRun = False timerStart = datetime.datetime.now() timerStop = timerStart prevDispMessage = "" lcd.clear() lcd.backlight(lcd.TEAL) lcd.message("Raspberry Pi\nOven Mitt!") time.sleep(2) beatCount = 0 prevBeat = datetime.datetime.now() beatTotalTime = prevBeat - prevBeat #Setting total time to 0 heartQueue = deque() configArray = [1, 1, 1] def TempConfig(): selection = configArray[0] if selection == 0: #avoid modulus of 0 or negative problems selection = 2 selection = selection % 2
class Display(): BARRIER = [ [[0b00000, # Frame 0 0b00000, 0b00000, 0b00100, 0b01110, 0b01110, 0b11111, 0b11111], [0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000]], [[0b00000, # Frame 1 in 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000], [0b00000, 0b00000, 0b00000, 0b01000, 0b11100, 0b11100, 0b11110, 0b11110]], [[0b00000, # Frame 1 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00001, 0b00001], [0b00000, 0b00000, 0b00000, 0b10000, 0b11000, 0b11000, 0b11100, 0b11100]], [[0b00000, # Frame 2 in 0b00000, 0b00000, 0b00000, 0b00001, 0b00001, 0b00011, 0b00011], [0b00000, 0b00000, 0b00000, 0b00000, 0b10000, 0b10000, 0b11000, 0b11000]], [[0b00000, # Frame 2 0b00000, 0b00000, 0b00001, 0b00011, 0b00011, 0b00111, 0b00111], [0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b10000, 0b10000]], [[0b00000, # Frame 3 0b00000, 0b00000, 0b00010, 0b00111, 0b00111, 0b01111, 0b01111], [0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000]]] RUNNER = [ [[0b00000, # Frame 0 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000], [0b00000, 0b00000, 0b00000, 0b01110, 0b11111, 0b10101, 0b11111, 0b01110]], [[0b00000, # Frame 1 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000], [0b00000, 0b00000, 0b00000, 0b01110, 0b11111, 0b10101, 0b11111, 0b01110]], [[0b00000, # Frame 2 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000], [0b00100, 0b01110, 0b11111, 0b10101, 0b11111, 0b01110, 0b01110, 0b00000]], [[0b00000, # Frame 3 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b01110], [0b11111, 0b10101, 0b11111, 0b01110, 0b00100, 0b00000, 0b00000, 0b00000]], [[0b00000, # Frame 4 0b00000, 0b00000, 0b00000, 0b00000, 0b01110, 0b01110, 0b10101], [0b11111, 0b01110, 0b00100, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000]], [[0b00000, # Frame 5 0b00000, 0b00000, 0b00000, 0b01110, 0b11111, 0b10101, 0b11111], [0b01110, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000]], [[0b00000, # Frame 6 0b00000, 0b01110, 0b11111, 0b10101, 0b11111, 0b01110, 0b01110], [0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000]], [[0b00000, # Frame 7 0b01110, 0b10101, 0b11111, 0b01110, 0b00000, 0b00000, 0b00000], [0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000]], [[0b01110, # Frame 8 0b10101, 0b11111, 0b01110, 0b00000, 0b00000, 0b00000, 0b00000], [0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000]], [[0b11111, # Frame 9 0b10101, 0b01110, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000], [0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000]]] def __init__(self): # Init LCD self.lcdString = [[' ' for col in range(Layer.WIDTH)] for row in range(Layer.HEIGHT)] # Init layer self.canvas = Layer() self.runner = Layer() self.barrier = Layer() # Init pixelSet self.pixelSet = [list(Layer.EMPTY) for i in range(8)] # Init LCD self.lcd = Adafruit_CharLCDPlate() self.lcd.begin(16, 2) self.lcd.backlight(Adafruit_CharLCDPlate.ON) # Init Game self.game = Game(self.lcd) def mergeLayers(self): # Merge layer to canvas #self.canvas.mergeLayer(self.runner).mergeLayer(self.barrier) self.canvas.mergeLayer(self.barrier) self.canvas.mergeLayer(self.runner) def updateLcdString(self): # Update game screen count = 0 for row in range(Layer.HEIGHT): for col in range(Layer.WIDTH): if self.canvas.bitmap[row][col] == Layer.EMPTY: self.lcdString[row][col] = ' ' else: index = self.findInPixelSet(self.canvas.bitmap[row][col], count) #print '[', str(row), '][', str(col), ']: ' + str(index) #print self.canvas.bitmap[row][col] if index == -1: self.pixelSet[count] = list(self.canvas.bitmap[row][col]) self.lcdString[row][col] = chr(count) count += 1 else: self.lcdString[row][col] = chr(index) # Update score board score = str(self.game.score) index = 0 for i in range(Layer.WIDTH - len(score), Layer.WIDTH): self.lcdString[0][i] = score[index] index += 1 def loadCharset(self): for i, item in enumerate(self.pixelSet): self.lcd.createChar(i, item) def findInPixelSet(self, pixel, count): for i in range(count): if self.pixelSet[i] == pixel: return i return -1 def draw(self): if self.game.state == Game.STATE_START: self.lcd.message('Press SELECT to\n START GAME ') elif self.game.state == Game.STATE_END: self.lcd.message(' SCORE ' + str(self.game.score) + '\n GAME OVER ') else: line_1 = ''.join(self.lcdString[0]) line_2 = ''.join(self.lcdString[1]) self.lcd.message(line_1 + '\n' + line_2) self.loadCharset() def drawBarriers(self): for barrier in self.game.barriers: self.barrier.drawPointX(barrier[1], barrier[0], self.game.frame, self.BARRIER[self.game.frame]) def drawRunner(self): self.runner.drawPointY(1, 0, self.RUNNER[self.game.runner]) def run(self): while True: self.game.tick() if self.game.state == Game.STATE_RUNNING: self.drawBarriers() self.drawRunner() self.mergeLayers() self.updateLcdString() self.game.gameOver(self.barrier.bitmap[1][1], self.runner.bitmap[1][1]) self.draw() self.canvas = Layer() self.runner = Layer() self.barrier = Layer() sleep(.03)
import sys sys.path.append( '/home/pi/py/Adafruit-Raspberry-Pi-Python-Code/Adafruit_CharLCDPlate') from time import sleep from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate import mcp3008 lcd = Adafruit_CharLCDPlate() while True: m = mcp3008.readadc(5) try: lcd.home() lcd.message("Moisture level:\n%d " % m) if m < 150: lcd.backlight(lcd.RED) elif m < 500: lcd.backlight(lcd.YELLOW) else: lcd.backlight(lcd.GREEN) except IOError as e: print e sleep(.5)
#!/usr/bin/python from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate import bluetooth from time import sleep target_name = "My Phone" target_address = "78:52:1A:4F:4E:6A" lcd = Adafruit_CharLCDPlate() lcd.backlight(lcd.RED) lcd.message("Jeeps-Berry-Pi\n Online") lcd.scrollDisplayRight() sleep(2) lcd.clear() lcd.backlight(lcd.BLUE) lcd.message(" Searching for\n passengers") nearby_devices = bluetooth.discover_devices() for bdaddr in nearby_devices: if target_name == bluetooth.lookup_name( bdaddr ): target_address = bdaddr break if target_address is not None: print "found target bluetooth device with address ", target_address lcd.clear() lcd.backlight(lcd.GREEN) lcd.message(" Found Jaron") else:
# pass '0' for early 256 MB Model B boards or '1' for all later versions lcd = Adafruit_CharLCDPlate() colors = { 'red' : lcd.RED, 'yellow' : lcd.YELLOW, 'green' : lcd.GREEN, 'teal' : lcd.TEAL, 'blue' : lcd.BLUE, 'violet' : lcd.VIOLET, 'white' : lcd.WHITE, 'on' : lcd.ON, 'off' : lcd.OFF } # Initialize the argument parser parser = argparse.ArgumentParser() parser.add_argument("m", help="The message to display on the LCD") parser.add_argument("c", type=str, help="BLUE, RED") args = parser.parse_args() # Assign variables message = args.m color = colors[args.c] # Clear display and show greeting, pause 1 sec lcd.clear() lcd.message(message) lcd.backlight(color)
hw = abbrev(summary.get("Hardware Errors",{})) s1 = 'A:%s R:%s H:%s' % (acc, rej, hw) s2 = 'avg:%s' % hashrate(float(summary.get("GHS av",{}))) lcd.clear() lcd.message(s1 + '\n' + s2) except Exception as e: lcd.clear() print e lcd.message("Waiting for" + '\n' + "cgminer ") #Check for network connection at startup t = time.time() while True: lcd.clear() lcd.message('checking network\nconnection ...') if (time.time() - t) > 120: # No connection reached after 2 minutes lcd.clear() lcd.message('network is\nunavailable') time.sleep(30) exit(0) try: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(('8.8.8.8', 0)) lcd.backlight(lcd.ON) lcd.clear() lcd.message('IP address:\n' + s.getsockname()[0]) time.sleep(5) break # Success except:
#!/usr/bin/python from time import sleep from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate import subprocess, glob, os, commands # 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() lcd.backlight(lcd.ON) # Clear display and show greeting, pause 1 sec lcd.clear() lcd.message("HELLO!\nMAKE SELECTION") # Poll buttons, display message & set backlight accordingly btn = ((lcd.LEFT, ''), (lcd.UP, ''), (lcd.DOWN, ''), (lcd.RIGHT, ''), (lcd.SELECT, '')) def mySleep(amt=0.5): sleep(amt) LOCK_OFFSET = 0 SCROLL_LOCK = False IS_FLASHING = False BOX_IP = commands.getoutput("/home/pi/myip.sh") def myScrollDisplayLeft():
b20yellow = Button(20) b16green = Button(16) b12white = Button(12) # Initialize the LCD plate. try: lcd = Adafruit_CharLCDPlate() lcd.clear() lcdIsOperational = True except: lcdIsOperational = False if lcdIsOperational: # Clear display and show greeting, pause 1 sec lcd.clear() lcd.backlight(lcd.ON) lcd.message("Welcome to your\ndoorbell") else: print("LCD is not operational") def internet_on(): """This function tests if there is a connection to the internet. Will return a boolean, true when connected, false if there is no connection.""" try: urllib2.urlopen('http://www.google.com', timeout=10) return True except urllib2.URLError: pass return False
# saving data) must be done before calling this function. python = sys.executable os.execl(python, python, * sys.argv) # Define a signal handler to turn off LCD before shutting down def handler(signum = None, frame = None): lcd = Adafruit_CharLCDPlate() lcd.clear() lcd.stop() sys.exit(0) signal.signal(signal.SIGTERM , handler) # Initialize LCD lcd = Adafruit_CharLCDPlate() lcd.begin(16, 2) lcd.message("NetDIMM Tools\nVersion 2.0") # Initialize parameters ---------- ---------- ---------- parser=SafeConfigParser() # Read parameters from file ---------- ---------- ---------- config_file_read="./netdimmtools.cfg" config_file_verify="" while config_file_verify != config_file_read: if os.path.isfile(config_file_read): config_file_verify=config_file_read parser.read(config_file_read) config_file_read=parser.get("Parameters", "Parameters File") else: # No config available lcd.clear()
import time import fcntl import os import RPi.GPIO as GPIO import nfc from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate from Adafruit_CharLCDPlate2 import Adafruit_CharLCDPlate2 emptyLine = " " lcd1 = Adafruit_CharLCDPlate() lcd2 = Adafruit_CharLCDPlate2() lcd1.begin(20, 4) lcd2.begin(20, 4); lcd1.clear() lcd2.clear() lcd1.message("Welcome.\nStarting...") lcd1.backlight(lcd.ON) time.sleep(2) def sendPOST (message): params = urllib.urlencode({'@number': message, '@type': 'issue', '@action': 'show'}) headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"} conn = httplib.HTTPConnection("bugs.python.org") conn.request("POST", "", params, headers) response = conn.getresponse() print response.status, response.reason data = response.read() conn.close() return data def getch():
#!/usr/bin/python from time import sleep from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate #from get_temp_c import temp_c lcd = Adafruit_CharLCDPlate() lcd.clear() lcd.message(" Proba Homero\n 2013.09.21 ") sleep(2) lcd.clear() # Temp meter begin import os, signal, sys import glob import time from time import gmtime, strftime version = 0.03 maxtemp = 0 mintemp = 100 counter = 0 deltaT = 0 deltaTold = 0 deltaTnew = 0 deltaTcount = 0 # File Create
#!/usr/bin/python import time import os from time import sleep from subprocess import call 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("Bus number reader") sleep(1) filename = "/home/pi/bus_number.txt" killCommand = ["/home/pi/bus-number/killnode.sh"] nodeCommand = "/usr/local/bin/node /home/pi/bus-number/bus.js " broadcastNumberText = "Broadcasting " debounceTime = 100 f = open(filename, 'r') line = f.readline() f.close()
# 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() # Turn on LCD lcd.clear() lcd.backlight(lcd.ON) # Display Warning last = int(time()) message_num = 2 waiting = True while waiting: if int(time()) >= last + 2: lcd.clear() last = int(time()) if message_num == 2: lcd.message("USB Light cable\nis disconnected!") message_num = 1 elif message_num == 1: lcd.message("Plug in and\npress \"Select\".") message_num = 2 if lcd.buttonPressed(lcd.SELECT): waiting = False # Button has been pressed, try again. lcd.clear() sleep(2) process = Popen('/etc/rc.local',stdout=PIPE)
# 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
sock_path = "/run/lcd/socket" print('Use socket : ' + sock_path) # 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() atexit.register(lcd.stop) lcd.backlight(True) lcd.createChar(0, Sprites.horizontalLines) # Clear display and show greeting, pause 1 sec lcd.clear() lcd.message("Adafruit RGB LCD\nPlate w/Keypad!\x00") sleep(1) # Cycle through backlight colors col = (lcd.RED , lcd.YELLOW, lcd.GREEN, lcd.TEAL, lcd.BLUE, lcd.VIOLET, lcd.WHITE, lcd.OFF) for c in col: lcd.ledRGB(c) sleep(.5) # Poll buttons, display message & set backlight accordingly buttonState = 0 rm = RecvMsg(sock_path) ledBlink, ledColor, ledGreenPulseModulo = False, lcd.OFF, 0 menu_manager = MenuMgr() while True:
import subprocess from time import sleep from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate lcd = Adafruit_CharLCDPlate(busnum=1) lcd.backlight(lcd.OFF) # Very Linux Specific arg = 'ip route list' p = subprocess.Popen(arg, shell=True, stdout=subprocess.PIPE) data = p.communicate() split_data = data[0].split() ipaddr = split_data[split_data.index('src') + 1] lcd.clear() lcd.backlight(lcd.BLUE) lcd.message("My IP is: \n" + ipaddr) sleep(2) lcd.backlight(lcd.GREEN) sleep(2) lcd.backlight(lcd.TEAL) sleep(2) lcd.backlight(lcd.VIOLET) sleep(2) lcd.backlight(lcd.YELLOW) exit()
trellis.readSwitches() # 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() # Setup the LCD buttons as an array btn = (lcd.LEFT,lcd.UP,lcd.DOWN,lcd.RIGHT,lcd.SELECT) # Clear display and show greeting, pause 1 sec lcd.clear() lcd.backlight(lcd.RED) #lcd.message("Kyma\nby Scott McGrath") #sleep(1) lcd.message ("Loading sounds..") songs = [] sounds = [] # Read in all of the songs from internal storage for root, dirs, files in os.walk(mypath): path = root.split('/') songs.append (os.path.basename(root)) # songs.sort() # Read in all of the songs from external storage for root, dirs, files in os.walk(mypathsd): path = root.split('/') if os.path.basename(root):
#!/usr/bin/python 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(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]):
################## Check for train times CSV file ############### if exists("/tmp/trains.csv") == True: updatecsv() display() sleep(2) display() sleep(2) display() sleep(2) elif exists("/tmp/trains.csv") == False: lcd.clear() lcd.backlight(lcd.RED) lcd.message("Downloading DATA") downloaddue() sleep(10) lcd.message("Importing DATA") empty() importdue() display() # close the cursor object cursor.close() # close the connection connection.close() # exit the program sys.exit()
##***IMPORTS***## import os, re from time import sleep from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate ##***END IMPORTS***## ##***BEGIN STARTUP PAGENTRY***## # 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 3 sec lcd.clear() lcd.backlight(lcd.RED) lcd.message("Welcome to the..\n{Raspberry Pwn!}") sleep(5) # lcd.backlight(lcd.ON) # show options lcd.clear() lcd.message("loading...") sleep(5) lcd.clear() lcd.message("drivers loaded\ndevice ready") sleep(4) lcd.clear() lcd.message("{Raspberry Pwn!}\n Main Menu ") # Cycle through backlight colors col = (lcd.OFF, lcd.YELLOW, lcd.GREEN, lcd.TEAL, lcd.BLUE, lcd.VIOLET, lcd.RED, lcd.GREEN)
# Use GPIO numbering GPIO.setmode(GPIO.BCM) # Set GPIO for camera LED CAMLED = 5 # Set GPIO to output GPIO.setup(CAMLED, GPIO.OUT, initial=False) for sig in [signal.SIGTERM, signal.SIGINT, signal.SIGQUIT]: signal.signal(sig, handler) lcd.clear() lcd.backlight(lcd.GREEN) 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:
from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate import RPi.GPIO as GPIO import time from time import gmtime, strftime GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(14, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Initialize the LCD plate. lcd = Adafruit_CharLCDPlate() # Clear display and show greeting, pause 1 sec lcd.clear() lcd.backlight(lcd.ON) lcd.message("Welcome to your\ndoorbell") sleep(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:
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)
return prefix def DOGE_cryptsy(): cryptsy = json.load(urllib2.urlopen('http://data.mtgox.com/api/1/BTCUSD/ticker')) if cryptsy["result"] != "1": raise Exception("Cryptsy API failed!") #Prefix for display prefix = "DOGE/BTC: " current_price = cryptsy["return"]["markets"]["DOGE"]["lasttradeprice"] # No rollover necessary, but need to figure out how to deal with decimal places return final_price return prefix #Add support for switching between currencies by using button code while 1: lcd.clear() #Calls function, gets time and formats. try: price = input_var() except Exception: lcd.message("API failed!") time = datetime.now().strftime( '%F %H:%M\n' ) #Displays time on first line, BTC/USD rate on next line lcd.message(time) lcd.message(prefix + price) # Length of sleep between API call sleep(30)
if (int(round(float(current_price))) > 1000): gox_price = int(round(float(current_price))) else: gox_price = current_price return gox_price def STAMP(): stamp = json.load(urllib2.urlopen('https://www.bitstamp.net/api/ticker/')) current_price = stamp["last"] # > $1000 rollover, Rounds/Converts to int if (int(round(float(current_price))) > 1000): stamp_price = int(round(float(current_price))) else: stamp_price = current_price return stamp_price while 1: lcd.backlight(lcd.GREEN) lcd.clear() #Calls BTC function, gets time and formats. gox = GOX() stamp = STAMP() time = datetime.now().strftime('%F %H:%M\n') #Displays time on first line, BTC/USD rate on next line. lcd.message(time) lcd.message("$" + stamp + "||" "$" + gox) #Sleeps until next API call can be made. sleep(30)
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(busnum=1) # Clear display and show greeting, pause 1 sec seq = ["INITALIZING.", "INITALIZING..", "INITALIZING...", "INITALIZING...."] lcd.clear() s = 0 t = 0 while True: lcd.message(seq[s]) sleep(.75) lcd.clear() s += 1 t += 1 if (s == 4): s = 0 if (t == 14): break lcd.clear() lcd.backlight(lcd.ON) lcd.message("HELLO WORLD!") # Cycle through backlight colors sleep(2)
import sys sys.path.append('/home/pi/py/Adafruit-Raspberry-Pi-Python-Code/Adafruit_CharLCDPlate') from time import sleep from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate import mcp3008 lcd = Adafruit_CharLCDPlate() while True: m = mcp3008.readadc(5) try: lcd.home() lcd.message("Moisture level:\n%d " % m) if m < 150: lcd.backlight(lcd.RED) elif m < 500: lcd.backlight(lcd.YELLOW) else: lcd.backlight(lcd.GREEN) except IOError as e: print e sleep(.5)
)) #if cryptsy["success"] != "1": # raise Exception("Cryptsy API failed!") current_price = cryptsy["return"]["markets"]["DOGE"]["lasttradeprice"] # No rollover necessary, but need to figure out how to deal with decimal places return current_price #Add support for switching between currencies by using button code while 1: lcd.clear() #Calls BTC function, gets time and formats. try: price = BTC() except Exception: lcd.message("BitStamp API failed! :(") time = datetime.now().strftime('%x %I:%M%p\n') #Displays time on first line, BTC/USD rate on next line lcd.message(time) lcd.message("BTC/USD: " + "$" + price) #Sleeps until next API call is possible #Needs to be customized per API, add support next sleep(15) price = DOGE() time = datetime.now().strftime('%x %I:%M%p\n') #Displays time on first line, BTC/USD rate on next line lcd.message(time) lcd.message("DOGE: " + price) #Sleeps until next API call is possible #Needs to be customized per API, add support next
'Start OpenVPN': 'openVPNStart', 'Stop OpenVPN': 'openVPNStop', 'Start Wifi AP': 'wifiHospotStart', 'Stop Wifi AP': 'wifiHospotStop', 'Start 3G Net': '3GStart', 'Network Test': 'connectivityTest', 'Shutdown Kali': 'shutDown' } displayText = modules.keys() # Clears the display lcd.clear() # Checks if the script has been run as root. menuOption = 0 #lcd.backlight(lcd.BLUE) lcd.message("Kali Linux\nPress Select") #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])
#!/usr/bin/python import urllib2 from time import sleep from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate # Initialize the LCD plate. lcd = Adafruit_CharLCDPlate() # Clear display and show greeting, pause 1 sec lcd.clear() lcd.backlight(lcd.ON) lcd.message("Welcome to your\ndoorbell") sleep(1) def internet_on(): try: urllib2.urlopen('http://www.google.com', timeout=10) return True except urllib2.URLError: pass return False lcd.clear() if internet_on(): lcd.message("Internet is set\nup :)") else: lcd.message("No internet use\nDoorbell wifi")
from time import sleep, strftime, localtime from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate import RPi.GPIO as GPIO import os import sys GPIO.setmode(GPIO.BOARD) GPIO.setwarnings(False) lcd = Adafruit_CharLCDPlate() lcd.backlight(lcd.RED) i = 0 while(True): lcd.message("nugg.ad \nYeah Receiver") sleep(10) lcd.clear() lcd.message("Received Yeah\nfrom ASMI") GPIO.setup(7, GPIO.OUT) GPIO.output(7, False) sleep(5) GPIO.output(7, True) lcd.clear() #lcd.message("Waiting for Yeahs \nsince 23 minutes") #sleep(10) #lcd.clear() i = i+1 t = 0 while(t < 60):
# Initiate Display bus = 1 # Note you need to change the bus number to 0 if running on a revision 1 Raspberry Pi. address = 0x20 # I2C address of the MCP230xx chip. gpio_count = 8 # Number of GPIOs exposed by the MCP230xx chip, should be 8 or 16 depending on chip. mcp = MCP230XX_GPIO(bus, address, gpio_count) # 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_CharLCD(pin_rs=1, pin_e=2, pins_db=[3,4,5,6], GPIO=mcp) # turn lcd off lcd.display() # prepare next message and set LED red led.clear() led.message("ahutest") led.backlight(led.RED) # turn lcd back on lcd.noDisplay() sleep(3) # change lcd mesasge led.clear() led.autoscroll() led.message("Daniel ist doof! super doof! mega doof! hyper doof!") led.autoscroll() sleep(3) led.backlight(led.GREEN) sleep(3)
v = pickle.load(f) f.close() volNew = v[0] defaultStation = v[1] except: defaultStation = None # Show IP address (if network is available). System might be freshly # booted and not have an address yet, so keep trying for a couple minutes # before reporting failure. t = time.time() while True: if (time.time() - t) > 120: # No connection reached after 2 minutes if RGB_LCD: lcd.backlight(lcd.RED) lcd.message('Network is\nunreachable') time.sleep(30) exit(0) try: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(('8.8.8.8', 0)) if RGB_LCD: lcd.backlight(lcd.GREEN) else: lcd.backlight(lcd.ON) lcd.message('My IP address is\n' + s.getsockname()[0]) time.sleep(5) break # Success -- let's hear some music! except: time.sleep(1) # Pause a moment, keep trying # Launch pianobar as pi user (to use same config data, etc.) in background: print('Spawning pianobar...')
os.makedirs(tmpdir) tmpdir = os.path.dirname(preferences.get('longTriggerFile')) if not os.path.exists(tmpdir): os.makedirs(tmpdir) cmd = [ '/bin/bash', '-c', 'ip addr show dev wlan0 | grep -o "inet [0-9.]*" | sed -e "s/inet //g"' ] (rc,stdout,stderr) = shell_capture(cmd) ipAddr = stdout.rstrip('\n') log_info("IP address = '"+ipAddr+"'") while True: try: monitor() except KeyboardInterrupt: g_lcd.clear() g_lcd.message('OUT OF SERVICE') g_lcd.backlight(g_lcd.OFF) print "" print "GAME OVER" break except: print "Unexpected error:", sys.exc_info()[0] print 'traceback:' print traceback.format_exc() time.sleep(10) #END #-----------------------------------------------------------
(lcd.DOWN , 'Down' , lcd.GREEN), (lcd.RIGHT , 'Right' , lcd.VIOLET)) prev=1 # for i in range(16, len(msg)): # sleep(0.25) # lcd.scrollDisplayLeft() while True: try: for b in btn: if lcd.buttonPressed(b[0]): if b is not prev: print b[1] lcd.clear() lcd.message(b[1]) lcd.backlight(b[2]) prev = b break startTime = datetime.time(7,30,0,0) currentTime = datetime.datetime.now().time() endTime = datetime.time(9,15,0,0) if currentTime > startTime and currentTime < endTime: api = urllib2.urlopen("http://mybus.kb.tl/BusTimes/Json") data = json.load(api) arr1 = data['Locations'][0]['Arrivals'][0]
#!/usr/bin/python from time import sleep from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate import subprocess, glob, os, commands # 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() lcd.backlight(lcd.ON) # Clear display and show greeting, pause 1 sec lcd.clear() lcd.message("HELLO!\nMAKE SELECTION") # Poll buttons, display message & set backlight accordingly btn = ((lcd.LEFT , '' ), (lcd.UP , '' ), (lcd.DOWN , '' ), (lcd.RIGHT , '' ), (lcd.SELECT, '' )) def mySleep(amt=0.5): sleep(amt) LOCK_OFFSET = 0 SCROLL_LOCK = False IS_FLASHING = False BOX_IP = commands.getoutput("/home/pi/myip.sh") def myScrollDisplayLeft():
# # Using Adafruit_CharLCD code with the I2C and MCP230xx code aswell #---------------------------------------------------------------- numcolumns = 16 numrows = 2 from time import sleep from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate lcd = Adafruit_CharLCDPlate() lcd.begin(numcolumns, numrows) lcd.backlight(lcd.ON) lcd.message("LCD 20x4\nDemonstration") sleep(2) while True: #Text on each line alone. lcd.clear() lcd.setCursor(0,0) lcd.message("Line 1") sleep(1) lcd.clear() lcd.setCursor(0,1) lcd.message("Line 2") sleep(1) lcd.clear()