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
def __init__(self): Adafruit_CharLCDPlate.__init__(self) # setup the LCD: self.clear() self.backlight(self.WHITE) self.speed = 0.35 p = op.OptionParser() p.add_option('--sentence','-s',default=None) options,arguments = p.parse_args() msg_tmp = options.sentence.decode('utf8').strip() msg = ''.join([x for x in msg_tmp if ord(x) < 128]) pad = " " n_tot = 2*len(pad)+len(msg) top = pad + pad + msg bot = "" # Set some lines to display: lines=[top,bot] # Create our scroller instance: scroller = Scroller(lines=lines) # Display the first unscrolled message: message = "\n".join(lines) self.clear() #self.message(message) sleep(self.speed) i = 0 while i < n_tot: i = i+1 # Get the updated scrolled lines, and display: message = scroller.scroll() self.message(message) sleep(self.speed) self.clear()
def __init__(self): Adafruit_CharLCDPlate.__init__(self) # setup the LCD: self.clear() self.backlight(self.WHITE) self.speed = 0.35 p = op.OptionParser() p.add_option('--sentence', '-s', default=None) options, arguments = p.parse_args() msg_tmp = options.sentence.decode('utf8').strip() msg = ''.join([x for x in msg_tmp if ord(x) < 128]) pad = " " n_tot = 2 * len(pad) + len(msg) top = pad + pad + msg bot = "" # Set some lines to display: lines = [top, bot] # Create our scroller instance: scroller = Scroller(lines=lines) # Display the first unscrolled message: message = "\n".join(lines) self.clear() #self.message(message) sleep(self.speed) i = 0 while i < n_tot: i = i + 1 # Get the updated scrolled lines, and display: message = scroller.scroll() self.message(message) sleep(self.speed) self.clear()
def InitMenu(self): self.lcd = Adafruit_CharLCDPlate() self.lcd.begin(16, 2) self.isStarted = True # Initialisation du Menu self.menuSequence[self.curIndexMenuSequence] = 'MAIN' self.initMenuSize() self.readConfigFile()
def __init__(self, twitter): Adafruit_CharLCDPlate.__init__(self) threading.Thread.__init__(self) self.twitter = twitter self.query = None self.col = (lcd.RED, lcd.YELLOW, lcd.GREEN, lcd.TEAL, lcd.BLUE, lcd.VIOLET, lcd.ON) self.paused = False
def __init__(self): self.LCDAttached = self.checkPanel() # Initialize the LCD using the pins # see https://learn.adafruit.com/adafruit-16x2-character-lcd-plus-keypad-for-raspberry-pi/usage if (self.LCDAttached == True): Adafruit_CharLCDPlate.__init__(self) self.camera = GPhoto(subprocess) self.idy = Identify(subprocess) self.netinfo = NetworkInfo(subprocess) self.shot = 0 self.displaySet = False
def __init__(self, bm=()): Adafruit_CharLCDPlate.__init__(self) self.backlight(self.OFF) if not bm or type(bm) != list: bm = [] bm += [''] * (4 - len(bm)) self.buttons = dict( left= dict(button=self.LEFT, bg=self.YELLOW, msg=bm[0]), up= dict(button=self.UP, bg=self.ON, msg=bm[1]), down= dict(button=self.DOWN, bg=self.TEAL, msg=bm[2]), right=dict(button=self.RIGHT, bg=self.VIOLET, msg=bm[3]) )
def exit(): """ Exit handler, which clears all custom chars and shuts down the display. """ try: lcd = Adafruit_CharLCDPlate() lcd.backlight(lcd.OFF) clearChars(lcd) lcd.stop() except: # avoids ugly KeyboardInterrupt trace on console... pass
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'
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 __init__(self, imageLocation): print "Setting defaults and initializing software" self.imageLocation = imageLocation self.lcd = Adafruit_CharLCDPlate() self.lcd.message("Initializing\nStickerBOT9000") self.conn = cups.Connection() self.printer = self.conn.getPrinters().keys()[0] self.buttonPin = 4 print "Turning on GPIO" GPIO.setmode(GPIO.BCM) GPIO.setup(self.buttonPin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.add_event_detect(4, GPIO.RISING, bouncetime=3000) BLACK = self.lcd.LEFT RED = self.lcd.RIGHT self.checkFiles()
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 __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'
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])
def __init__(self, prefs, nodeman, games): super(UI_Adafruit, self).__init__() self.__logger = logging.getLogger("UI_Adafruit " + str(id(self))) self.__logger.debug("init logger") self._lcd = Adafruit_CharLCDPlate() MBus.add_handler(GameList_ScanEventMessage, self.handle_GameList_ScanEventMessage) MBus.add_handler(FOAD, self.die) # Let the user know that we're doing things self._lcd.begin(16, 2) self._lcd.message("CANTBoot Loading\n Hold up.") self._games = games self._nodes = nodeman.nodes
def __init__(self): self.LCD = Adafruit_CharLCDPlate(busnum = 0) # self.lcd = Adafruit_CharLCDPlate() self.LCD_QUEUE = Queue() self.stdin_path = '/dev/null' self.stdout_path = '/dev/tty' self.stderr_path = '/dev/tty' self.pidfile_path = '/var/run/testdaemon.pid' self.pidfile_timeout = 5
def __init__(self, channel, nickname, server, port=6667,password=None): irc.bot.SingleServerIRCBot.__init__(self, [irc.bot.ServerSpec(server,port,password)], nickname, nickname) self.channel = channel # Create a mutex to handle our calls to the LCD self.lcdmutex = threading.RLock() # And initialize the various properties. with self.lcdmutex: self.lcd = Adafruit_CharLCDPlate() self.lcd.clear() self.lcd.backlight(self.lcd.ON) self.line1 = "INFO: INIT" self.line2 = "IRC Spy v1.0" self.lcd.message("{0:<16}\n{1:<16}".format(self.line1,self.line2)) self.startpause = 3 # This causes the message to pause 3 extra ticks at the start. Write to it to change this delay. self.endpause = 3 # This causes the message to pause 3 extra ticks at the end. Write to it to change this delay. self.line1offset = -self.startpause self.line2offset = -self.startpause self.manifold.execute_every(.2,self._do_lcd)
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 __init__(self, items, display=Adafruit_CharLCDPlate(), select_callback=None): self.select_callback = select_callback self.display = display self.items = items self.index = -1 self.colours = {'Red' : self.display.RED , 'Yellow': self.display.YELLOW, 'Green' : self.display.GREEN, 'Teal': self.display.TEAL, 'Blue' : self.display.BLUE, 'Violet': self.display.VIOLET}
def __init__(self): self.command('mpc stop') App.__init__( self, Adafruit_CharLCDPlate(), Folder('Pauls iRadio', ( Playlists(self), Folder('Settings', ( Node(self.command('hostname -I')[0]), Timer(), )), )))
def __init__(self): Adafruit_CharLCDPlate.__init__(self) self.backlight(self.GREEN) self.lastTime = time.time() self.timeout = 0 self.DEFAULTIMEOUT = 5 self.lastButton = self.LEFT self.lastBounce = 0 self.DEBOUNCETIME = 0.4 self.FASTDEBOUNCETIME = 0.2 self.timeDebounce = self.DEBOUNCETIME self.CANCEL = self.RIGHT self.screenContent = self.LOADINGMSG self.menuEntries = [] self.currentEntry = 0 self.roll = False self.currentShift = 0 self.shiftTimeout = 0.8 self.lastShiftTime = time.time()
class Notifications: lcd = Adafruit_CharLCDPlate() sub_base = "Alert from " hostname = socket.gethostname() lastTimeN = time.time() now = time.time() slice = now - lastTimeN first = 1 def __init__(self): lastTimeN = time.time() #Select alert and control email send rate def sendAlert(self, alert): if (config.ALERT_ENABLED == 1): self.now = time.time() self.since = self.now - self.lastTimeN if (self.since > config.ALERT_TIME or self.since < 0.0 or self.first == 1): self.lastTimeN = self.now if (self.first == 1): self.first = 0 self.lcd.backlight(self.lcd.RED) if (alert == 0): self.S_HashAlert() if (alert == 1): self.S_MinerAlert() if (alert == 3): self.S_TempAlert() #Send Hash Alert def S_HashAlert(self): subject = self.sub_base + self.hostname text = "Alert hash rate below threshold on miner " + self.hostname html = "Alert hash rate below threshold on miner <B>" + self.hostname + "</B>" E.send_email(config.GMAIL_USER, config.GMAIL_PASS, config.SMTP_SERVER, config.SMTP_PORT, config.RECIPIENT, subject, text, html) #Send Miner Alert def S_MinerAlert(self): subject = self.sub_base + self.hostname text = "Alert miner not running " + self.hostname html = "Alert miner not running <B>" + self.hostname + "</B>" E.send_email(config.GMAIL_USER, config.GMAIL_PASS, config.SMTP_SERVER, config.SMTP_PORT, config.RECIPIENT, subject, text, html) #Send Miner Temp Alert def S_TempAlert(self): subject = self.sub_base + self.hostname text = "Alert miner temp above threshold on " + self.hostname html = "Alert miner temp above threshold on <B>" + self.hostname + "</B>" E.send_email(config.GMAIL_USER, config.GMAIL_PASS, config.SMTP_SERVER, config.SMTP_PORT, config.RECIPIENT, subject, text, html)
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 main(): initLog() file_logger = logging.getLogger('file-logger') try: lcd = Adafruit_CharLCDPlate() lcd.backlight(lcd.WHITE) lcd.noCursor() lcd.noAutoscroll() updateDisplay(lcd, "GPS Logger\nInitalizing...") except: lcd = None logging.info("No LCD available") num_satellites = -1 session = gps.gps("localhost", "2947") session.stream(gps.WATCH_ENABLE | gps.WATCH_NEWSTYLE) while True: try: report = session.next() if report["class"] == "DEVICE": updateDisplay(lcd, "GPS Logger\nConnected...", "green") elif report["class"] == "TPV": if num_satellites > 0: report["sat"] = num_satellites msg = parseTime(report) + "\n" if report["mode"] >= 2: msg += parseLatLon(report) lcdcolor = "blue" else: msg += parseSearching(num_satellites) lcdcolor = "red" updateDisplay(lcd, msg, lcdcolor) file_logger.info(json.dumps(report.__dict__)) elif report["class"] == "SKY": num_satellites = 0 for satellite in report.get("satellites", []): if satellite["used"] is True: num_satellites += 1 except KeyError: pass except KeyboardInterrupt: logging.info("Quit - keyboard interrupt") updateDisplay(lcd, "GPS Logger\nKeyb. interrupt", "off") quit() except StopIteration: logging.info("Quit - stop iteration (GPSD has terminated)") updateDisplay(lcd, "GPS Logger\nStop Iteration", "off") session = None except Exception, e: logging.info("Unknown Error: " + str(e)) updateDisplay(lcd, "GPS Logger\nUnknown error", "red")
def __init__(self, bgColor, txt): self.bgColor = bgColor self.lcd = Adafruit_CharLCDPlate() self.lcd.clear() self.lcd.backlight(bgColor) self.lcd.message(txt) # Create custom characters for LCD for big clock display # Create some custom characters self.lcd.createChar(0, [0, 0, 0, 0, 0, 0, 0, 0]) self.lcd.createChar(1, [16, 24, 24, 24, 24, 24, 24, 16]) self.lcd.createChar(2, [1, 3, 3, 3, 3, 3, 3, 1]) self.lcd.createChar(3, [17, 27, 27, 27, 27, 27, 27, 17]) self.lcd.createChar(4, [31, 31, 0, 0, 0, 0, 0, 0]) self.lcd.createChar(5, [0, 0, 0, 0, 0, 0, 31, 31]) self.lcd.createChar(6, [31, 31, 0, 0, 0, 0, 0, 31]) self.lcd.createChar(7, [31, 0, 0, 0, 0, 0, 31, 31]) self.timeSinceAction = 0 # The time since the last keypress. Use timeout to start switching screens # self.switchScreenTime = 8 #Number of seconds between switching screens self.lastScreenTime = time.time() # time since last screen switch self.prevStr = "" self.screens = ((self.bigTimeView,6), # Rotating list of views on LCD with how many seconds to display each display. Round robin style. (self.connectedUserView,4), (self.bigTimeView,6), (self.precisionView,4), (self.bigTimeView,6), (self.ntptimeInfo,5), (self.bigTimeView,6), (self.clockperfView,5), ) # list of all views for rotation self.nrofscreens = len(self.screens) self.currentScreen = 0
def testConfigs(): print "Testing Configs" camera = GPhoto(subprocess) for config in CONFIGS: print "Testing camera setting: Shutter: %s ISO %d" % (config[1], config[3]) camera.set_shutter_speed(secs=config[1]) camera.set_iso(iso=str(config[3])) time.sleep(SLEEP_TIME) lcd = Adafruit_CharLCDPlate() lcd.clear() lcd.backlight(lcd.TEAL)
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 __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)
import urllib2 from time import sleep from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate import RPi.GPIO as GPIO import time 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
import socket import json import sys, subprocess, time, urllib2, socket from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate from CgminerAPI import CgminerAPI HOLD_TIME = 3.0 #Time (seconds) to hold select button for shut down REFRESH_TIME= 3.0 #Time (seconds) between data updates HALT_ON_EXIT= False lcd = Adafruit_CharLCDPlate() prevCol = -1 prev = -1 lastTime = time.time() def shutdown(): lcd.clear() lcd.backlight(lcd.OFF) exit(0) def abbrev(v): v = int(v) if v >= 1000: va = float(v) / 1000.0 vs = '%.1f' % va vs = vs + 'k' return vs elif v >= 1000000: va = float(v) / 1000000.0
from time import sleep from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate from subprocess import call, Popen, PIPE 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
imagePath = "images/" imageNames = [] currentImageSelection = 0 listOfDrives = [] writeStatusLine = "" justCompleted = False nowWriting = False stopWritingNow = False lastPressedTime = time.time() lcd = Adafruit_CharLCDPlate() lcd.begin(COLUMNS, ROWS) lcd.clear() def getConnectedDrives(): commandOutput = runCommandAndGetStdout( "lsblk -d | awk -F: '{print $1}' | awk '{print $1}'") splitted = commandOutput.splitlines() drives = [] for drive in splitted: if drive != "NAME" and not drive.startswith("mmc"): drives.append(drive)
#!/usr/bin/python import platform, os, os.path, shutil, syslog, sys, subprocess, json from time import sleep from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate from LCDMenu import LCDMenu from subprocess import * from time import sleep, strftime from datetime import datetime root = '/op1-backup/' op1 = '/media/usb0' lcd = Adafruit_CharLCDPlate() btn = (lcd.LEFT, lcd.UP, lcd.DOWN, lcd.RIGHT, lcd.SELECT) prev = -1 buttonsactive = True is_op1_available = None backup_position = "" def logger(msg): syslog.syslog(msg) print(msg) def load_radio(): os.system("sudo modprobe snd_bcm2835") os.system("sudo mpd") os.system("sudo mpc clear") def run_cmd(cmd):
#!/usr/bin/python from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate from subprocess import * from time import sleep, strftime from datetime import datetime import json import urllib2 import time lcd = Adafruit_CharLCDPlate() lcd.begin(16,1) #Add support for user prompt on launch to select between different APIs/Currencies print "OPTIONS: BTC_mtgox, BTC_btce, BTC_bitstamp, DOGE_cryptsy" input_var = input("Enter your choice (Case Sensitive): ") print ("You entered: " + input_var) def BTC_mtgox(): mtgox = json.load(urllib2.urlopen('http://data.mtgox.com/api/1/BTCUSD/ticker')) if mtgox["result"] != "success": raise Exception("MtGox API failed!") current_price = mtgox["return"]["last"]["value"] #Prefix for display prefix = "BTC/USD: $" # > $1000 rollover, Rounds/Converts to int if (int(round(float(current_price))) > 1000):
def __init__(self): self._lcd = Adafruit_CharLCDPlate(busnum=0) #self._lcd = FakeCharLCDPlate() self._lcd.backlight(self._lcd.ON)
class TimelapseUi(object): def __init__(self): self._lcd = Adafruit_CharLCDPlate(busnum=0) #self._lcd = FakeCharLCDPlate() self._lcd.backlight(self._lcd.ON) 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: %d" % (config[0], config[1])) def show_status(self, shot, configs, current): config = configs[current] self.update("Shot %d\nT: %s ISO: %d" % (shot, config[0], config[1])) def show_error(self, text): self.update(text[0:16] + "\n" + text[16:]) while not self._lcd.buttonPressed(self._lcd.SELECT): self.backlight_on() sleep(1) self.backlight_off() sleep(1) self.backlight_off() def backlight_on(self): self._lcd.backlight(self._lcd.ON) def backlight_off(self): self._lcd.backlight(self._lcd.OFF) def main(self, configs, current, network_status): self.backlight_on() self.update(network_status) while not self._lcd.buttonPressed(self._lcd.SELECT): pass ready = False while not ready: self.show_config(configs, current) while True: if (type(self._lcd) == type(FakeCharLCDPlate())): self._lcd.fakeonly_getch() if self._lcd.buttonPressed(self._lcd.UP): current -= 1 if current < 0: current = 0 break if self._lcd.buttonPressed(self._lcd.DOWN): current += 1 if current >= len(configs): current = len(configs) - 1 break if self._lcd.buttonPressed(self._lcd.SELECT): ready = True break return current
#!/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]):
# # Future plans will be to both handle proper cariage returns and to # cut at the spaces as to not leave partial words. # # Orginal was written by Adafruit Industries. # Under MIT license. # # "This is essentially a complete rewrite, but the calling syntax # and constants are based on code from lrvick and LiquidCrystal. # lrvic - https://github.com/lrvick/raspi-hd44780/blob/master/hd44780.py # LiquidCrystal - https://github.com/arduino/Arduino/blob/master/libraries/LiquidCrystal/LiquidCrystal.cpp" #---------------------------------------------------------------- from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate lcd = Adafruit_CharLCDPlate() class LCD_EoL_Handling(Adafruit_CharLCDPlate): def __init__(self, cols=20, rows=4): # Defaulted to 20x4 displays self.numrows = rows self.numcols = cols # Added a var for the column count to act as the line length limit (say that 10x fast) def message(self, text, limitMode = 0): """ Send string to LCD. Newline wraps to next line""" lines = str(text).split('\n') # Split at newline(s) for i, line in enumerate(lines): # For each substring... if i == 1: # If newline(s), lcd.write(0xC0) # set DDRAM address to 2nd line elif i == 2:
#!/usr/bin/python from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate from subprocess import * from time import sleep, strftime from datetime import datetime import json import urllib2 import time lcd = Adafruit_CharLCDPlate() lcd.begin(16, 1) def BTC(): 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 def DOGE(): cryptsy = json.load( urllib2.urlopen( 'http://pubapi.cryptsy.com/api.php?method=singlemarketdata&marketid=132' ))
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()
#!/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:
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()
#!/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")
def __init__(self, curMenu = 0, debug = False): # Init EventMethods self.AUTO_REFRESH_PERIOD = 5 self.EventMethods = { 'EventMethods_0_1': self.EventMethods_SystemInfo, 'EventMethods_1_1': self.EventMethods_NetworkInfo, 'EventMethods_1_2': self.EventMethods_NetworkInfo_Up, 'EventMethods_1_3': self.EventMethods_NetworkInfo_Down, 'EventMethods_2_1': self.EventMethods_Temperature, 'EventMethods_3_1': self.EventMethods_DiskInfo, 'EventMethods_4_1': self.EventMethods_Tools, 'EventMethods_4_2': self.EventMethods_Tools_Up, 'EventMethods_4_3': self.EventMethods_Tools_Down, 'EventMethods_4_4': self.EventMethods_Tools_One, 'EventMethods_4_5': self.EventMethods_Tools_Two, 'EventMethods_4_6': self.EventMethods_Tools_Excute_One, 'EventMethods_4_7': self.EventMethods_Tools_Excute_Two, 'EventMethods_5_1': self.EventMethods_Weather, 'EventMethods_98_1': self.EventMethods_Setting, 'EventMethods_98_2': self.EventMethods_Setting_Up, 'EventMethods_98_3': self.EventMethods_Setting_Down, 'EventMethods_98_4': self.EventMethods_Setting_One, 'EventMethods_98_5': self.EventMethods_Setting_Two, 'EventMethods_98_6': self.EventMethods_Setting_Excute_One, 'EventMethods_98_7': self.EventMethods_Setting_Excute_Two, 'EventMethods_99_1': self.EventMethods_Exit_No, 'EventMethods_99_2': self.EventMethods_Exit_Yes, 'EventMethods_99_3': self.EventMethods_Exit } self.TOOLS_NUM = 2 self.TOOLS_LIST = ( {'name':'Reboot', 'handle':self.EventMethods_Reboot }, {'name':'Power Off', 'handle':self.EventMethods_PowerOff } ) self.SETTING_NUM = 3 self.SETTING_LIST = ( {'name':'Backlight', 'handle':self.EventMethods_Backlight }, {'name':'Auto Refresh', 'handle':self.EventMethods_AutoRefresh }, {'name':'Weather Report', 'handle':self.EventMethods_Backlight } ) # Init LCD self.lcd = Adafruit_CharLCDPlate() self.lcd.begin(16, 2) self.lcd.backlight(Adafruit_CharLCDPlate.RED) sleep(1) self.lcd.backlight(Adafruit_CharLCDPlate.GREEN) sleep(1) self.lcd.backlight(Adafruit_CharLCDPlate.BLUE) sleep(1) self.lcd.backlight(Adafruit_CharLCDPlate.ON) # Init Char Set self.loadCharset() # Set default screen self.curMenu = curMenu self.curPage = 0 self.debug = debug # Init AutoRefeashMethods self.AutoRefreshMethod = None thread.start_new_thread(self.autoRefresh, ())
rs = "/root/bubblePi/tunnel.sh" # Camera script location spycam = "/root/bubblePi/cam.sh" #--------------- CHANGE IF NECESSARY --------------- # INI file config file # Load in user name and IP address of command center # for the reverse shell test parser = SafeConfigParser() parser.read('/root/bubblePi/shell.conf') ccIP = parser.get('reverse_shell', 'reverseDest') # initialize the LCD plate # use busnum = 0 for raspi version 1 (256MB) and busnum = 1 for version 2 lcd = Adafruit_CharLCDPlate(busnum=1) def TimeoutException(): lcd.clear() lcd.backlight(lcd.OFF) exit() def timeout(signum, frame): raise TimeoutException() # Function which gets the IP address of a network interface def get_ip_address(ifname): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
class Display(): CHAR_SET ={'default': [ [0b00000, # 0 <- 0b00010, 0b00110, 0b01110, 0b00110, 0b00010, 0b00000, 0b00000], [0b00000, # 1 -> 0b01000, 0b01100, 0b01110, 0b01100, 0b01000, 0b00000, 0b00000], [0b00000, # 2 ^ 0b00000, 0b00100, 0b01110, 0b11111, 0b00000, 0b00000, 0b00000], [0b00000, # 3 v 0b00000, 0b11111, 0b01110, 0b00100, 0b00000, 0b00000, 0b00000], [0b00110, # 4 Degree 0b01001, 0b01001, 0b00110, 0b00000, 0b00000, 0b00000, 0b00000], [0b11111, # 5 Black Block 0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111], [0b10101, # 6 Gray Block 0b01010, 0b10101, 0b01010, 0b10101, 0b01010, 0b10101, 0b01010], [0b10010, # 7 Light Gray Block 0b01001, 0b00100, 0b10010, 0b01001, 0b00100, 0b10010, 0b01001] ], 'TemperatureExtend': [ [0b11111, # 0 Black Block 0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111], [0b11111, # 1 Dark Gray Block 0b01101, 0b10110, 0b11011, 0b01101, 0b10110, 0b11011, 0b11111], [0b11111, # 2 Gray Block 0b01010, 0b10101, 0b01010, 0b10101, 0b01010, 0b10101, 0b11111], [0b11111, # 3 Light Gray Block 0b01001, 0b00100, 0b10010, 0b01001, 0b00100, 0b10010, 0b11111], [0b00111, # 4 Left 0b01000, 0b10000, 0b10000, 0b10000, 0b10000, 0b01000, 0b00111], [0b11100, # 5 Right 0b11110, 0b11111, 0b11111, 0b11111, 0b11111, 0b11110, 0b11100], [0b00110, # 6 Degree 0b01001, 0b01001, 0b00110, 0b00000, 0b00000, 0b00000, 0b00000] ]} OPSET = (Adafruit_CharLCDPlate.LEFT, Adafruit_CharLCDPlate.RIGHT, Adafruit_CharLCDPlate.UP, Adafruit_CharLCDPlate.DOWN, Adafruit_CharLCDPlate.SELECT) OPLANG = {Adafruit_CharLCDPlate.LEFT:'LEFT', Adafruit_CharLCDPlate.RIGHT:'RIGHT', Adafruit_CharLCDPlate.UP:'UP', Adafruit_CharLCDPlate.DOWN:'DOWN', Adafruit_CharLCDPlate.SELECT:'SELECT'} MENU = {0:' SELECT ' + chr(1) + ' \nSystem Info', 1:' ' + chr(0) + ' SELECT ' + chr(1) + ' \nNetwork Info', 2:' ' + chr(0) + ' SELECT ' + chr(1) + ' \nTemperature', 3:' ' + chr(0) + ' SELECT ' + chr(1) + ' \nDisk Info', 4:' ' + chr(0) + ' SELECT ' + chr(1) + ' \nSystem Tools', 5:' ' + chr(0) + ' SELECT ' + chr(1) + ' \nWeather', 98:' ' + chr(0) + ' SELECT ' + chr(1) + ' \nSetting', 99:' ' + chr(0) + ' SELECT \nExit'} # State transition table STT = { # MENU_0 SYSTEM INFO 0:{ 0:{ Adafruit_CharLCDPlate.RIGHT : (1, 0), Adafruit_CharLCDPlate.SELECT: (0, 1) }, # DEFAULT 1:{ Adafruit_CharLCDPlate.LEFT: (0, 0) } }, # MENU_1 NETWORK INFO 1:{ 0:{ Adafruit_CharLCDPlate.LEFT : (0, 0), Adafruit_CharLCDPlate.RIGHT : (2, 0), Adafruit_CharLCDPlate.SELECT: (1, 1) }, # DEFAULT 1:{ Adafruit_CharLCDPlate.LEFT : (1, 0), Adafruit_CharLCDPlate.UP : (1, 2), Adafruit_CharLCDPlate.DOWN : (1, 3) }, # PAGE UP 2:{ Adafruit_CharLCDPlate.LEFT : (1, 0), Adafruit_CharLCDPlate.UP : (1, 2), Adafruit_CharLCDPlate.DOWN : (1, 3) }, # PAGE DOWN 3:{ Adafruit_CharLCDPlate.LEFT : (1, 0), Adafruit_CharLCDPlate.UP : (1, 2), Adafruit_CharLCDPlate.DOWN : (1, 3) } }, # MENU_2 TEMPERATURE 2:{ 0:{ Adafruit_CharLCDPlate.LEFT : (1, 0), Adafruit_CharLCDPlate.RIGHT : (3, 0), Adafruit_CharLCDPlate.SELECT: (2, 1) }, # DEFAULT 1:{ Adafruit_CharLCDPlate.LEFT: (2, 0) } }, # MENU_3 DISK INFO 3:{ 0:{ Adafruit_CharLCDPlate.LEFT : (2, 0), Adafruit_CharLCDPlate.RIGHT : (4, 0), Adafruit_CharLCDPlate.SELECT: (3, 1) }, # DEFAULT 1:{ Adafruit_CharLCDPlate.LEFT: (3, 0) } }, # MENU_4 SYSTEM TOOLS 4:{ 0:{ Adafruit_CharLCDPlate.LEFT : (3, 0), Adafruit_CharLCDPlate.RIGHT : (5, 0), Adafruit_CharLCDPlate.SELECT: (4, 1) }, # TOOL LIST 1:{ Adafruit_CharLCDPlate.LEFT : (4, 0), Adafruit_CharLCDPlate.UP : (4, 2), Adafruit_CharLCDPlate.DOWN : (4, 3), Adafruit_CharLCDPlate.SELECT: (4, 4) }, # TOOL LIST UP 2:{ Adafruit_CharLCDPlate.LEFT : (4, 0), Adafruit_CharLCDPlate.UP : (4, 2), Adafruit_CharLCDPlate.DOWN : (4, 3), Adafruit_CharLCDPlate.SELECT: (4, 4) }, # TOOL LIST DOWN 3:{ Adafruit_CharLCDPlate.LEFT : (4, 0), Adafruit_CharLCDPlate.UP : (4, 2), Adafruit_CharLCDPlate.DOWN : (4, 3), Adafruit_CharLCDPlate.SELECT: (4, 4) }, # TOOL DIALOG SELECT ONE 4:{ Adafruit_CharLCDPlate.SELECT: (4, 6), Adafruit_CharLCDPlate.RIGHT : (4, 5) }, # TOOL DIALOG SELECT TWO 5:{ Adafruit_CharLCDPlate.SELECT: (4, 7), Adafruit_CharLCDPlate.LEFT : (4, 4) }, # TOOL DIALOG SELECT EXCUTE ONE 6:{ Adafruit_CharLCDPlate.SELECT: (4, 1) }, # TOOL DIALOG SELECT EXCUTE TWO 7:{ Adafruit_CharLCDPlate.SELECT: (4, 1) } }, # MENU_5 WEATHER 5:{ 0:{ Adafruit_CharLCDPlate.LEFT : (4, 0), Adafruit_CharLCDPlate.RIGHT : (98, 0), Adafruit_CharLCDPlate.SELECT: (5, 1) }, # DEFAULT 1:{ Adafruit_CharLCDPlate.LEFT: (5, 0) } }, # MENU_98 SETTING 98:{ 0:{ Adafruit_CharLCDPlate.LEFT : (4, 0), Adafruit_CharLCDPlate.RIGHT : (99, 0), Adafruit_CharLCDPlate.SELECT: (98, 1) }, # SETTING LIST 1:{ Adafruit_CharLCDPlate.LEFT : (98, 0), Adafruit_CharLCDPlate.UP : (98, 2), Adafruit_CharLCDPlate.DOWN : (98, 3), Adafruit_CharLCDPlate.SELECT: (98, 4) }, # SETTING LIST UP 2:{ Adafruit_CharLCDPlate.LEFT : (98, 0), Adafruit_CharLCDPlate.UP : (98, 2), Adafruit_CharLCDPlate.DOWN : (98, 3), Adafruit_CharLCDPlate.SELECT: (98, 4) }, # SETTING LIST DOWN 3:{ Adafruit_CharLCDPlate.LEFT : (98, 0), Adafruit_CharLCDPlate.UP : (98, 2), Adafruit_CharLCDPlate.DOWN : (98, 3), Adafruit_CharLCDPlate.SELECT: (98, 4) }, # SETTING DIALOG SELECT ONE 4:{ Adafruit_CharLCDPlate.SELECT: (98, 6), Adafruit_CharLCDPlate.RIGHT : (98, 5) }, # SETTING DIALOG SELECT TWO 5:{ Adafruit_CharLCDPlate.SELECT: (98, 7), Adafruit_CharLCDPlate.LEFT : (98, 4) }, # SETTING DIALOG SELECT EXCUTE ONE 6:{ Adafruit_CharLCDPlate.SELECT: (98, 1) }, # SETTING DIALOG SELECT EXCUTE TWO 7:{ Adafruit_CharLCDPlate.SELECT: (98, 1) } }, # MENU_99 EXIT 99:{ 0:{ Adafruit_CharLCDPlate.LEFT : (98, 0), Adafruit_CharLCDPlate.SELECT: (99, 1) }, # NO 1:{ Adafruit_CharLCDPlate.SELECT: (99, 0), Adafruit_CharLCDPlate.RIGHT : (99, 2) }, # YES 2:{ Adafruit_CharLCDPlate.SELECT: (99, 3), Adafruit_CharLCDPlate.LEFT : (99, 1) }, # EXIT 3:{ } } } def __init__(self, curMenu = 0, debug = False): # Init EventMethods self.AUTO_REFRESH_PERIOD = 5 self.EventMethods = { 'EventMethods_0_1': self.EventMethods_SystemInfo, 'EventMethods_1_1': self.EventMethods_NetworkInfo, 'EventMethods_1_2': self.EventMethods_NetworkInfo_Up, 'EventMethods_1_3': self.EventMethods_NetworkInfo_Down, 'EventMethods_2_1': self.EventMethods_Temperature, 'EventMethods_3_1': self.EventMethods_DiskInfo, 'EventMethods_4_1': self.EventMethods_Tools, 'EventMethods_4_2': self.EventMethods_Tools_Up, 'EventMethods_4_3': self.EventMethods_Tools_Down, 'EventMethods_4_4': self.EventMethods_Tools_One, 'EventMethods_4_5': self.EventMethods_Tools_Two, 'EventMethods_4_6': self.EventMethods_Tools_Excute_One, 'EventMethods_4_7': self.EventMethods_Tools_Excute_Two, 'EventMethods_5_1': self.EventMethods_Weather, 'EventMethods_98_1': self.EventMethods_Setting, 'EventMethods_98_2': self.EventMethods_Setting_Up, 'EventMethods_98_3': self.EventMethods_Setting_Down, 'EventMethods_98_4': self.EventMethods_Setting_One, 'EventMethods_98_5': self.EventMethods_Setting_Two, 'EventMethods_98_6': self.EventMethods_Setting_Excute_One, 'EventMethods_98_7': self.EventMethods_Setting_Excute_Two, 'EventMethods_99_1': self.EventMethods_Exit_No, 'EventMethods_99_2': self.EventMethods_Exit_Yes, 'EventMethods_99_3': self.EventMethods_Exit } self.TOOLS_NUM = 2 self.TOOLS_LIST = ( {'name':'Reboot', 'handle':self.EventMethods_Reboot }, {'name':'Power Off', 'handle':self.EventMethods_PowerOff } ) self.SETTING_NUM = 3 self.SETTING_LIST = ( {'name':'Backlight', 'handle':self.EventMethods_Backlight }, {'name':'Auto Refresh', 'handle':self.EventMethods_AutoRefresh }, {'name':'Weather Report', 'handle':self.EventMethods_Backlight } ) # Init LCD self.lcd = Adafruit_CharLCDPlate() self.lcd.begin(16, 2) self.lcd.backlight(Adafruit_CharLCDPlate.RED) sleep(1) self.lcd.backlight(Adafruit_CharLCDPlate.GREEN) sleep(1) self.lcd.backlight(Adafruit_CharLCDPlate.BLUE) sleep(1) self.lcd.backlight(Adafruit_CharLCDPlate.ON) # Init Char Set self.loadCharset() # Set default screen self.curMenu = curMenu self.curPage = 0 self.debug = debug # Init AutoRefeashMethods self.AutoRefreshMethod = None thread.start_new_thread(self.autoRefresh, ()) def loadCharset(self, charset = 'default'): for i, item in enumerate(self.CHAR_SET[charset]): self.lcd.createChar(i, item) def autoRefresh(self): if(self.debug): print 'Auto refresh thread started!' while True: if self.AutoRefreshMethod != None: try: self.EventMethods[self.AutoRefreshMethod]() except Exception, e: if(self.debug): print str(e) if(self.debug): print self.AutoRefreshMethod, ' fired!' sleep(self.AUTO_REFRESH_PERIOD)
#!/usr/bin/python from time import sleep from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate from Adafruit_MCP230xx import MCP230XX_GPIO from Adafruit_CharLCD import Adafruit_CharLCD # Initiate CharLCDPlate led = Adafruit_CharLCDPlate() # clear screen led.clear() # turn LED off led.backlight(led.OFF) # 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)
#!/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=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 import subprocess import datetime import ConfigParser import traceback # Adafruit LCD plate I2C library sys.path.append('/root/garage/Adafruit-Raspberry-Pi-Python-Code/Adafruit_CharLCDPlate') from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate # Prowl notification library sys.path.append('/root/garage/prowlpy') import prowlpy # GLOBALS g_lcd = Adafruit_CharLCDPlate() g_logFD = None g_ledOverrideCounter = 0 # CONSTANTS YESTERYEAR = datetime.datetime(1999, 12, 31) # TIMING PERIOD_STATUS = 5 PERIOD_LOG = 600 PERIOD_TEST = None DEBOUNCE = 8 LOOP_TIME = 0.25 NOTIFICATION_VISUAL_DELAY = 2.5 # BUTTONS
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 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():
class PiMinerDisplay: col = [] prevCol = 0 lcd = Adafruit_CharLCDPlate() info = None mode = 1 offset = 0 maxOffset = 0 screen = [] def __init__(self): self.lcd.clear() self.col = (self.lcd.ON, self.lcd.OFF, self.lcd.YELLOW, self.lcd.OFF, self.lcd.GREEN, self.lcd.OFF, self.lcd.TEAL, self.lcd.OFF, self.lcd.BLUE, self.lcd.OFF, self.lcd.VIOLET, self.lcd.OFF, self.lcd.RED, self.lcd.OFF) self.lcd.backlight(self.col[self.prevCol]) #Show initial info (call after network connected) def initInfo(self): self.info = PiMinerInfo() self.dispLocalInfo() #Display Local Info - Accepted, Rejected, HW Errors \n Average Hashrate def dispLocalInfo(self): self.dispScreen(self.info.screen1) #Display Pool Name \n Remote hashrate def dispPoolInfo(self): self.dispScreen(self.info.screen2) #Display Rewards (confirmed + unconfirmed) \n Current Hash def dispRewardsInfo(self): self.dispScreen(self.info.screen3) #Display Error rate & Uptime def dispUptimeInfo(self): self.dispScreen(self.info.screen4) #Display rewards & price def dispValueInfo(self): self.dispScreen(self.info.screen5) #Send text to display def dispScreen(self, newScreen): self.screen = newScreen try: self.maxOffset = max((len(self.screen[0]) - 16), (len(self.screen[1]) - 16)) self.lcd.clear() s = self.screen[0] + '\n' + self.screen[1] self.lcd.message(s) except TypeError: self.lcd.clear() self.lcd.message('connecting\nto cgminer ...') #Cycle Backlight Color / On/Off def backlightStep(self): if self.prevCol is (len(self.col) -1): self.prevCol = -1 newCol = self.prevCol + 1 self.lcd.backlight(self.col[newCol]) self.prevCol = newCol #Offset text to the right def scrollLeft(self): if self.offset >= self.maxOffset: return self.lcd.scrollDisplayLeft() self.offset += 1 #Offset text to the left def scrollRight(self): if self.offset <= 0: return self.lcd.scrollDisplayRight() self.offset -= 1 #Display next info screen def modeUp(self): self.mode += 1 if self.mode > 4: self.mode = 0 self.update() #Display previous info screen def modeDown(self): self.mode -= 1 if self.mode < 0: self.mode = 4 self.update() #Update display def update(self): self.info.refresh() if self.mode == 0: self.dispPoolInfo() elif self.mode == 1: self.dispLocalInfo() elif self.mode == 2: self.dispRewardsInfo() elif self.mode == 3: self.dispUptimeInfo() elif self.mode == 4: self.dispValueInfo()