def display_weight(ard,lcd): print "Display Weight Thread" time.sleep(1) while 1: if not ard.asking: lcd.gotorc(5,0) lcd.text("%.2f kgs" % ard.last_weight) time.sleep(0.5)
def main(): lcd.init() lcd.set_contrast(190) lcd.backlight(1) lcd.text("adresses:") ip = subprocess.check_output("hostname -I", shell=True) lcd.locate(0,1) lcd.text(str(ip.strip()) )
def Int_shutdown(gpio_id,val): print "Shutdown" ard.ser.write('2') os.system("sudo shutdown -h now") lcd.cls() lcd.gotorc(1,0) lcd.text("Apagando") sys.exit("Apagando")
def main(): lcd.init() lcd.cls() lcd.data(smiley) lcd.locate(2, 2) lcd.data(ch) lcd.locate(3, 0) lcd.text("c.a.h.") lcd.backlight(1)
def main(): lcd.init() lcd.cls() lcd.data(smiley) lcd.locate(2,2) lcd.data(ch) lcd.locate(3,0) lcd.text("c.a.h.") lcd.backlight(1)
def displayTemperatures(): while True: try: cpuTemp = float( os.popen( "cat /sys/class/thermal/thermal_zone0/temp").read()) / 1000 gpuTemp = os.popen( "/opt/vc/bin/vcgencmd measure_temp").read().replace( "temp=", "").replace("'", "") #ip = os.popen("ip addr show eth0 | grep inet").read() ip = commands.getoutput('hostname -I') cpu_usage = str(psutil.cpu_percent()) ram = psutil.phymem_usage() ram_free = str(ram.free / 2**20) #Display Title lcd.gotorc(0, 0) lcd.text("Raspberry Pi") #Display Time lcd.gotorc(2, 0) lcd.text("Time " + time.strftime("%I:%M:%S", time.localtime())) #Display CPU Temp cpu_temperature_display = "{0:0.1f}".format(cpuTemp) lcd.gotorc(3, 0) #lcd.text("") lcd.text("CPU {}C {}%".format(cpu_temperature_display, cpu_usage)) #Display GPU Temp lcd.gotorc(4, 0) #lcd.text(" ") lcd.text("GPU {}".format(gpuTemp)) #*****************Second Page********************** #time.sleep(1) #Display Time #lcd.gotorc(2,0) #lcd.text("Time "+time.strftime("%I:%M:%S", time.localtime())) #Display Free RAM lcd.gotorc(5, 0) lcd.text("RAM " + ram_free + "MB Free") #Display IP #lcd.gotorc(4,0) #lcd.text(ip) time.sleep(1) #lcd.cls() except KeyboardInterrupt: sys.exit(0)
def lcd_blink(text): i=10 lcd.cls() lcd.locate(0,0) lcd.text(text) lcd.locate(0,1) while i<0: lcd.text("after %s sec" % (i)) if i%2: lcd.backlight(1) else: lcd.backlight(0) i-=1 time.sleep(1)
def lcd_blink(text): i = 10 lcd.cls() lcd.locate(0, 0) lcd.text(text) lcd.locate(0, 1) while i < 0: lcd.text("after %s sec" % (i)) if i % 2: lcd.backlight(1) else: lcd.backlight(0) i -= 1 time.sleep(1)
def main(): lcd.init() lcd.backlight(1) sample = CpuTemperature() #sample = LoadAverage() buf = RingBuffer(84) while True: current = sample.data() buf.append(current) lcd.image(render(buf)) lcd.locate(0, 0) lcd.text(sample.format(current)) time.sleep(1)
def run(self): def get_temp(file): # The '28-xxx' in the file name should be changed accordingly # to name in your /sys/bus/w1/devices folder. file = "/sys/bus/w1/devices/28-000004a1c58b/w1_slave" # Open file written to by temp sensor tfile = open(file) # Read all text in file text = tfile.read() # Close file once text is read tfile.close() # Pull out the temperature value temprdata = text.split("\n")[1].split(" ")[9] # The first two characters are "t=", so get rid of those and convert the temperature from a string to a number. temperature = float(temprdata[2:]) # Put the decimal point in the right place and display it. temperature = temperature / 1000 return (temperature) def get_soc(): # Read CPU temperature and extract the numbers only res = os.popen('/opt/vc/bin/vcgencmd measure_temp').readline() return (res.replace("temp=", "").replace("'C", "")) try: rmtemp = get_temp(file) except: rmtemp = "--.-" try: rpitemp = get_soc() except: rpitemp = "--.-" roomtemp = "%s" % rmtemp cputemp = "%s" % rpitemp # Prepare degrees celsius symbol lcd.define_custom_char([0x00, 0x07, 0x05, 0x07, 0x00]) lcd.gotorc(0, 1) lcd.text("Temperature") lcd.centre_text(2, "--Room | RPi--") lcd.gotorc(4, 0) # Display room temperature lcd.text(roomtemp) lcd.gotorc(4, 4) lcd.text("\x7fC") lcd.gotorc(4, 8) # Display CPU temperature lcd.text(cputemp) lcd.gotorc(4, 12) lcd.text("\x7fC")
def run(self): def get_temp(file): # The '28-xxx' in the file name should be changed accordingly # to name in your /sys/bus/w1/devices folder. file = "/sys/bus/w1/devices/28-000004a1c58b/w1_slave" # Open file written to by temp sensor tfile = open(file) # Read all text in file text = tfile.read() # Close file once text is read tfile.close() # Pull out the temperature value temprdata = text.split("\n")[1].split(" ")[9] # The first two characters are "t=", so get rid of those and convert the temperature from a string to a number. temperature = float(temprdata[2:]) # Put the decimal point in the right place and display it. temperature = temperature / 1000 return(temperature) def get_soc(): # Read CPU temperature and extract the numbers only res = os.popen('/opt/vc/bin/vcgencmd measure_temp').readline() return(res.replace("temp=","").replace("'C","")) try: rmtemp = get_temp(file) except: rmtemp = "--.-" try: rpitemp = get_soc() except: rpitemp = "--.-" roomtemp = "%s" %rmtemp cputemp = "%s" %rpitemp # Prepare degrees celsius symbol lcd.define_custom_char([0x00, 0x07, 0x05, 0x07, 0x00]) lcd.gotorc(0,1) lcd.text("Temperature") lcd.centre_text(2,"--Room | RPi--") lcd.gotorc(4,0) # Display room temperature lcd.text(roomtemp) lcd.gotorc(4,4) lcd.text("\x7fC") lcd.gotorc(4,8) # Display CPU temperature lcd.text(cputemp) lcd.gotorc(4,12) lcd.text("\x7fC")
def main(): lcd.init() lcd.backlight(1) sample = CpuTemperature() #sample = LoadAverage() buf = RingBuffer(84) while True: current = sample.data() buf.append(current) lcd.image(render(buf)) lcd.locate(0,0) lcd.text(sample.format(current)) time.sleep(1)
def lcd_press(press): MSL = "%07.2f" % float(msl(float(press))) press = "%07.2f" % float(press) if press[0] == "0": digit_0 = " " else: digit_0 = press[0] lcd.locate(1,3) lcd.text("QFE:"+digit_0+press[1:6]) if MSL[0] == "0": digit_0 = " " else: digit_0 = MSL[0] lcd.locate(1,4) lcd.text("QNH:"+digit_0+MSL[1:6])
def write(self, line): ifInfo() self.lines.insert(0,line[0:N_COLS]) if len(self.lines) == 6: self.lines.pop() for i,l in enumerate(self.lines): lcd.locate(0, i) lcd.text(self.lines[4-i]+" "*(N_COLS-len(self.lines[4-i]))) self.hPos = min(len(self.lines[0]), N_COLS-1) else: lcd.locate(self.hPos, self.vPos) lcd.text(self.lines[0]) self.vPos +=1 if self.vPos == 5: self.vPos =4 self.hPos = min(len(self.lines[0]), N_COLS-1)
def display(aToDisplay): aDisplay=[] lcd.cls() sToDisplay='' for sId in aToDisplay.keys(): sToDisplay=sToDisplay+aToDisplay[sId] aDisplay=splitLineForLCD(sToDisplay,LCD_COLUMNS) y=0 while len(aDisplay)>0: sLine=aDisplay.pop(0) lcd.text(sLine) y=y+1 if y >= LCD_LINES: y=0 time.sleep(5) lcd.cls() lcd.locate(0,y)
def display(aToDisplay): aDisplay = [] lcd.cls() sToDisplay = '' for sId in aToDisplay.keys(): sToDisplay = sToDisplay + aToDisplay[sId] aDisplay = splitLineForLCD(sToDisplay, LCD_COLUMNS) y = 0 while len(aDisplay) > 0: sLine = aDisplay.pop(0) lcd.text(sLine) y = y + 1 if y >= LCD_LINES: y = 0 time.sleep(5) lcd.cls() lcd.locate(0, y)
def lcdstatusupdate(sensor_count, i): date = datetime.now() lcd.locate(3, 0) lcd.text(date.strftime('%d/%m/%y')) lcd.locate(3, 1) lcd.text(date.strftime('%H:%M:%S')) lcd.locate(3, 2) lcd.text("sensr: %s" % sensor_count) lcd.locate(3, 3) lcd.text("Next: %s" % i) lcd.locate(3, 4)
def value2lcd(date,id,desc,value): lcd.cls() lcd.locate(0,0) lcd.text(date) lcd.locate(0,1) lcd.text(id) lcd.locate(0,2) lcd.text(desc) lcd.locate(0,3) lcd.text("Temp: %s" % (value)) lcd.locate(0,4)
def value2lcd(date, id, desc, value): lcd.cls() lcd.locate(0, 0) lcd.text(date) lcd.locate(0, 1) lcd.text(id) lcd.locate(0, 2) lcd.text(desc) lcd.locate(0, 3) lcd.text("Temp: %s" % (value)) lcd.locate(0, 4)
def stats(): lcd.cls() lcd.locate(0,0) lcd.text(cpu_usage()) lcd.locate(0,1) lcd.text(mem_usage()) lcd.locate(0,2) lcd.text(disk_usage('/')) lcd.locate(0,3) lcd.text(network('eth0')) lcd.locate(0,4)
def lcdstatusupdate(sensor_count,i): date = datetime.now() lcd.locate(3,0) lcd.text(date.strftime('%d/%m/%y')) lcd.locate(3,1) lcd.text(date.strftime('%H:%M:%S')) lcd.locate(3,2) lcd.text("sensr: %s" % sensor_count) lcd.locate(3,3) lcd.text("Next: %s" % i) lcd.locate(3,4)
def demo(seconds): lcd.cls() lcd.text("Hello world!") lcd.locate(0, 4) lcd.text("Charlotte :-)") for loop in range(seconds * 4): lcd.locate(0, 1) lcd.text(time.strftime("%d %b %Y", time.localtime())) lcd.locate(0, 2) lcd.text(time.strftime("%H:%M:%S", time.localtime())) time.sleep(0.25)
def ifInfo(): global hb lcd.locate(0, 5) st,out = getstatusoutput('ifconfig | grep "inet addr" | grep -v "127.0.0.1"') lineN=2 if out: for line in [x for x in out.split(" ") if ":" in x and "cast" not in x and "addr" in x]: IP=(line.split(':')[1]) lcd.text(IP+" "*(N_COLS-len(IP))) else: if hb: lcd.text(" "*N_COLS) else: lcd.text(" No network ")
) employees = bamboo.get_employee_directory() try: # initialize the LCD screen lcd.init() lcd.cls() lcd.backlight(ON) # display the name of each employee for employee in employees: # clear the screen lcd.cls() # get the employee first and last name and strip any special character # as they're not supported by the LCD lib first_name = strip_accent(employee.get('firstName', '')) last_name = strip_accent(employee.get('lastName', '')) # display, wait a bit and iterate lcd.text(center_and_strip(environ.get('BAMBOOHR_SUBDOMAIN', ''))) lcd.text(center_and_strip('')) lcd.text(center_and_strip(first_name)) lcd.text(center_and_strip(last_name)) sleep(0.25) except KeyboardInterrupt: pass finally: lcd.cls() lcd.backlight(OFF)
#!/usr/bin/env python # -*- coding: utf-8 -*- import pcd8544.lcd as lcd import time, os, sys if not os.geteuid() == 0: sys.exit('Script must be run as root') ON, OFF = [1, 0] try: lcd.init() lcd.cls() lcd.backlight(ON) lcd.pi_custom_char() lcd.text("\x7f \x7f \x7f \x7f \x7f \x7f \x7f ") lcd.text(" Hello ") lcd.text(" Raspberry Pi") time.sleep(10) except KeyboardInterrupt: pass finally: lcd.cls() lcd.backlight(OFF)
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ] # Initiate LCD lcd.init() # Turn slowly backlight on. To switch backlight off change the below # for loop for lcd.backlight(0) for i in range(0,1000,16): lcd.set_brightness(i) time.sleep(0.025) # Set specific contrast lcd.set_contrast(256) # Display Raspberry logo lcd.cls() lcd.gotorc(0,0) for x in logo: lcd.lcd_data(x) time.sleep(2) lcd.cls() # Display welcome note lcd.define_custom_char([0x19, 0x25, 0x5A, 0x25, 0x19]) lcd.gotorc(0,0) lcd.text("\x7f \x7f \x7f \x7f \x7f \x7f \x7f ") lcd.centre_text(2,"Welcome") lcd.centre_text(3,"Bubbl") lcd.gotorc(5,0) lcd.text("\x7f \x7f \x7f \x7f \x7f \x7f \x7f ") time.sleep(2) lcd.cls() #Start main activity main()
def demo(): lcd.locate(0,0) lcd.text(list(map(chr, list(range(0x20, 0x74)))))
# initialize the LCD screen lcd.init() lcd.cls() lcd.backlight(ON) # display the photo of each employee with his first name # next to it for employee in employees: # get the jpg photo and convert it to a usable bitmap img = urllib.urlretrieve(employee.get('photoUrl'))[0] bmp = Image.open(img) bmp = bmp.resize((48, 84), Image.NEAREST).convert('1') bmp.save('/tmp/employee.bmp') # clear and load the bitmap photo lcd.cls() lcd.load_bitmap('/tmp/employee.bmp') # get the employee first and last name and strip any special character # as they're not supported by the LCD lib first_name = strip_accent(employee.get('firstName', '')) # display the first name, wait a bit and iterate lcd.text(center_and_strip(first_name)) sleep(0.25) except KeyboardInterrupt: pass finally: lcd.cls() lcd.backlight(OFF)
fo.close() #Verifica si es quedo un archivo temp sin guardar en bin. if os.path.isfile(path+'data/temp.csv'): os.rename(path+'data/temp.csv',path+'data/Bin%d.csv' % IDbin) fo = open(path+"data/IDlastbin.txt", "w") fo.write(str(IDbin)) fo.close() IDbin+=1 #Crea el archivo temp.csv ftemp = open(path+"data/temp.csv", "w") ftemp.write("Bin %d\n" % IDbin) ftemp.close() registro = [] lcd.cls() lcd.gotorc(0,0) lcd.text("Listo para leer") nroCajas = 0 while nroCajas<=24: #Espera hasta leer la tarjeta cardID=readCard() #Si es que la tarjeta es para renovar el bin, sale del while y empieza de nuevo if cardID_RUT[cardID]=='nuevobin': break #Verifica que no hayan pasado menos de dos minutos desde la ultima marca cajas = [[registro[i][0],registro[i][3]] for i in range(len(registro)) if registro[i][1]==cardID] print cajas if len(cajas)>0: last_caja_timestamp = datetime.strptime(cajas[-1][0].split(',')[0],"%Y-%m-%d %H:%M:%S") ahora = datetime.now() diff=(ahora-last_caja_timestamp).total_seconds() kgs=sum([cajas[i][1] for i in range(len(cajas))])
handlers = [ (r'/', MainPageHandler), (r'/logger/(.*)', LogDownloadHandler), # arg is log interval (r'/valve', ValveHandler) ] handlers += event_router.urls tornado_settings = { 'static_path': 'static', 'template_path': 'templates', 'debug': True } lcd.init() lcd.gotoxy(0, 0) lcd.set_contrast(disp_contrast_on) lcd.cls() lcd.text("LCD Init") wiringpi.pinMode(BTN_OUT, 1) wiringpi.digitalWrite(BTN_OUT, 1) wiringpi.pinMode(VALVE_GPIO, 1) wiringpi.digitalWrite(VALVE_GPIO, 0) wiringpi.pinMode(BTN_IN, 0) app = TankMonitor(handlers, **tornado_settings) maxbotix = MaxbotixHandler(tank_monitor=app, port='/dev/ttyAMA0', timeout=10) maxbotix.calibrate(appconfig.MAXBOTICS['calibrate_m'], appconfig.MAXBOTICS['calibrate_b']) ioloop = IOLoop.instance() disp_print_cb = PeriodicCallback(app.update_display, callback_time=500, io_loop=ioloop) disp_print_cb.start() button_poll_cb = PeriodicCallback(app.poll_display_button, callback_time=100, io_loop=ioloop) button_poll_cb.start()
#!/usr/bin/env python import pcd8544.lcd as lcd import sys backlight = {'ON': 0, 'OFF': 1} if __name__ == "__main__": lcd.init() lcd.set_contrast(180) if sys.argv[1] == 'text': lcd.locate(int(sys.argv[2]), int(sys.argv[3])) lcd.text(sys.argv[4]) if sys.argv[1] == 'backlight': lcd.backlight(backlight[sys.argv[2].upper()]) if sys.argv[1] == 'cls': lcd.cls()
0x00 ] # Initiate LCD lcd.init() # Turn slowly backlight on. To switch backlight off change the below # for loop for lcd.backlight(0) for i in range(0, 1000, 16): lcd.set_brightness(i) time.sleep(0.025) # Set specific contrast lcd.set_contrast(256) # Display Raspberry logo lcd.cls() lcd.gotorc(0, 0) for x in logo: lcd.lcd_data(x) time.sleep(2) lcd.cls() # Display welcome note lcd.define_custom_char([0x19, 0x25, 0x5A, 0x25, 0x19]) lcd.gotorc(0, 0) lcd.text("\x7f \x7f \x7f \x7f \x7f \x7f \x7f ") lcd.centre_text(2, "Welcome") lcd.centre_text(3, "Bubbl") lcd.gotorc(5, 0) lcd.text("\x7f \x7f \x7f \x7f \x7f \x7f \x7f ") time.sleep(2) lcd.cls() #Start main activity main()
lcd.set_contrast(155) lcd.backlight(ON) LastTime=0 invert_arr=[0,0,0,0,0,0] i_int=-1 while 1: if time.time()-LastTime > 3 : mycpu=" CPU: "+(str(psutil.cpu_percent(0))).rjust(5,' ')+"% " LastTime=time.time() i_int+=1 if i_int>5: i_int=0 for i in range(0,len(invert_arr)): if i==i_int: invert_arr[i]=1 else: invert_arr[i]=0 lcd.gotorc(0,0) lcd.text(" 0.RPI PLC ",invert=invert_arr[0]) lcd.gotorc(1,0) lcd.text(mycpu, invert=invert_arr[1]) #print mycpu,"\r", lcd.gotorc(2,0) lcd.text(" "+time.strftime("%d %b %Y", time.localtime())+" ", invert=invert_arr[2]) lcd.gotorc(3,0) lcd.text(" Time: ",invert=invert_arr[3]) lcd.gotorc(4,0) lcd.text(" "+time.strftime("%H:%M:%S", time.localtime())+" ",invert=invert_arr[4]) lcd.gotorc(5,0) lcd.text(cyrstr(" Меню Alarms "),invert=invert_arr[5]) time.sleep(0.25) except KeyboardInterrupt: pass
def lcd_temp(temp): lcd.locate(1,2) lcd.text(temp) lcd.text('.', special_FONT) lcd.text('C')
def lcd_time(ltime): lcd.locate(1,1) lcd.text(ltime[11:19])
def lcd_date(date): lcd.locate(1,0) # Date in database is ISO format yyyy-mm-dd # Date displayed is EUR format dd/mm/yyyy lcd.text(date[8:10]+"/"+date[5:7]+"/"+date[0:4])
def daemon(): client = InfluxDBClient('localhost', 8086, 'USER', 'PASSWORD', DBNAME, timeout=30) ow.init('localhost:4304') lcd.init() logging.debug("Daemon starting") logging.debug("Create INFLUX database: " + DBNAME) errors = 0 try: client.create_database(DBNAME) except InfluxDBClientError: logging.debug("%s DB already exist" % DBNAME) pass except: logging.exception("Error") lcd.text("Exception") try: client.create_retention_policy('awesome_policy', '3d', 3, default=True) except InfluxDBClientError: logging.debug("%s policy already exist" % DBNAME) pass for i in range(10): try: devices = ow.Sensor('/').sensorList() date = datetime.now() points = [] for o in read_dht11(): devices.append(o) devices.append(calc_power()) devices.append(read_max6675()) for sensor in devices: name = sensor.address try: value = float(sensor.value) except: value = float(ow.Sensor('/%s' % name).temperature11) desc = name json_body = { "time": date.strftime('%Y-%m-%dT%H:%M:%SZ'), "measurement": "rosma_temps", "tags": { "sensor": name, }, "fields": { "value": value } } points.append(json_body) value2lcd(date.strftime('%d/%m/%y %H:%M:%S'), name, desc, value) logging.debug(json_body) cms = EmonCms(cms_url) cms.append(name, value) #cms_status = cms.post() cms_status = True if cms_status: logging.debug("CMS Post ok") else: logging.debug("CMS Post failed") status = client.write_points(points) if status: lcd.text("Sent<-OK") logging.debug(status) else: lcd.text("Error!") logging.error(status) #Show status s = 0 lcd.cls() while s < sleep: lcdstatusupdate(len(devices), s) time.sleep(1) s += 1 except: logging.exception("Error occurred %s" % sys.exc_info()[1]) lcd.text("%s Exception!" % errors) time.sleep(1) if errors == 10: lcd_blink("Rebooting!") d = threading.Thread(name='beeper', target=beeper) d.setDaemon(True) d.start() #os.system("reboot") d.join() else: errors += 1 logging.debug("Daemon exiting") return (0)
def demo(): lcd.locate(0, 0) lcd.text(map(chr, range(0x20, 0x74)))
def run(self, jsonString): # Parse data as json data = json.loads(jsonString) text1 = "RPi-Monitor" lcd.define_custom_char([0x00, 0x07, 0x05, 0x07, 0x00]) # Try to get data from json or return default value try: rpi_temperature = data['soc_temp'] except: rpi_temperature = "--.--" try: room_temp = data['living_room_temp'] except: room_temp = "--.--" # Construct string to be displayed on screens rpitemp = "%s" % rpi_temperature roomtemp = "%s" % room_temp lcd.centre_text(0, text1) lcd.gotorc(1, 0) lcd.text("RPi Temp:") lcd.gotorc(2, 0) lcd.text(rpitemp) lcd.gotorc(2, 8) lcd.text("\x7fC") lcd.gotorc(4, 0) lcd.text("Room Temp:") lcd.gotorc(5, 0) lcd.text(roomtemp) lcd.gotorc(5, 8) lcd.text("\x7fC")
def run(self, jsonString): # Parse data as json data = json.loads( jsonString ) text1 = "RPi-Monitor" lcd.define_custom_char([0x00, 0x07, 0x05, 0x07, 0x00]) # Try to get data from json or return default value try: rpi_temperature = data['soc_temp'] except: rpi_temperature="--.--" try: room_temp = data['living_room_temp'] except: room_temp="--.--" # Construct string to be displayed on screens rpitemp = "%s" %rpi_temperature roomtemp = "%s" %room_temp lcd.centre_text(0, text1) lcd.gotorc(1,0) lcd.text("RPi Temp:") lcd.gotorc(2,0) lcd.text(rpitemp) lcd.gotorc(2,8) lcd.text("\x7fC") lcd.gotorc(4,0) lcd.text("Room Temp:") lcd.gotorc(5,0) lcd.text(roomtemp) lcd.gotorc(5,8) lcd.text("\x7fC")
import image import maze from pcd8544.font import default_FONT if __name__ == "__main__": lcd.init() lcd.backlight(1) pi_logo.demo() time.sleep(3) alphabet_text.demo() time.sleep(3) image.demo() time.sleep(3) maze.demo(2) clock.demo(10) lcd.cls() lcd.text("For details:") lcd.smooth_hscroll(" https://github.com/rm-hull/pcd8544 ", \ 2, 300, delay=0.25) pi_logo.demo() time.sleep(3) lcd.backlight(0)
while 1: try: tempVal = get_temp(file) # To adjust number of decimal places, change the '1' in "%.1f" value roomtemp = "%.1f" %tempVal cputemp = get_soc() time = datetime.now().strftime('%H:%M:%S') time2 = datetime.today().strftime('%d %b %Y') # Go to first line of screen and print current time lcd.centre_text(0,"Today is:") # Go to third screen line and print CPU temperature lcd.centre_text(1,time2) lcd.centre_text(2,time) # lcd.text("CPU Temp:") lcd.gotorc(5,8) lcd.text(cputemp) lcd.gotorc(5,12) lcd.text("\x7fC") # Go to fifth screen line and print room temperature # lcd.gotorc(4,0) lcd.centre_text(4,"--Room | RPi--") lcd.gotorc(5,0) lcd.text(roomtemp) lcd.gotorc(5,4) lcd.text("\x7fC") except KeyboardInterrupt: # If Ctrl+C has been pressed # turn off the lcd backlight lcd.cls() lcd.backlight(0); # Exit from the program
def displayTime(): #Display Time lcd.gotorc(2, 0) lcd.text(time.strftime("%I:%M:%S", time.localtime())) time.sleep(0.25) lcd.cls()
api_key=environ.get('BAMBOOHR_API_KEY', 'your_api_key')) employees = bamboo.get_employee_directory() try: # initialize the LCD screen lcd.init() lcd.cls() lcd.backlight(ON) # display the name of each employee for employee in employees: # clear the screen lcd.cls() # get the employee first and last name and strip any special character # as they're not supported by the LCD lib first_name = strip_accent(employee.get('firstName', '')) last_name = strip_accent(employee.get('lastName', '')) # display, wait a bit and iterate lcd.text(center_and_strip(environ.get('BAMBOOHR_SUBDOMAIN', ''))) lcd.text(center_and_strip('')) lcd.text(center_and_strip(first_name)) lcd.text(center_and_strip(last_name)) sleep(0.25) except KeyboardInterrupt: pass finally: lcd.cls() lcd.backlight(OFF)
while 1: try: tempVal = get_temp(file) # To adjust number of decimal places, change the '1' in "%.1f" value roomtemp = "%.1f" % tempVal cputemp = get_soc() time = datetime.now().strftime('%H:%M:%S') time2 = datetime.today().strftime('%d %b %Y') # Go to first line of screen and print current time lcd.centre_text(0, "Today is:") # Go to third screen line and print CPU temperature lcd.centre_text(1, time2) lcd.centre_text(2, time) # lcd.text("CPU Temp:") lcd.gotorc(5, 8) lcd.text(cputemp) lcd.gotorc(5, 12) lcd.text("\x7fC") # Go to fifth screen line and print room temperature # lcd.gotorc(4,0) lcd.centre_text(4, "--Room | RPi--") lcd.gotorc(5, 0) lcd.text(roomtemp) lcd.gotorc(5, 4) lcd.text("\x7fC") except KeyboardInterrupt: # If Ctrl+C has been pressed # turn off the lcd backlight lcd.cls() lcd.backlight(0) # Exit from the program
def putstr(str, x, y): lcd.gotorc(y,x) lcd.text(str)
def display_banner(): lcd.locate(0, 5) lcd.text(' @wolfg1969 ')
#lcd.init() # New b-w image im = Image.new('1', (84,48)) # New drawable on image draw = ImageDraw.Draw(im) lcd.cls() lcd.backlight(0) rTitle = str(ch[int(recent['channel']['channelId'])][1]) rAddress = str(ch[int(recent['channel']['channelId'])][0]) song = recent['title'] title = recent['artistName'] draw.text((0,-2), rTitle, fill=1, font=font) draw.text((0,10), rAddress, fill=1, font=font) draw.text((0,20), song, fill=1, font=font) draw.text((0,30), title, fill=1, font=font) # Copy it to the display lcd.show_image(im) # clean up del draw del im if isHolding : lcd.text(" Hold ") else: tea.test(ch[int(recent['channel']['channelId'])][0]) GPIO.cleanup()
if not os.geteuid() == 0: sys.exit('Script must be run as root') ON, OFF = [1, 0] try: lcd.init() lcd.cls() lcd.backlight(ON) # Test a custom character for 0x7f (supposed to be a bell) # . . . - - - - - # . . . - - X - - # . . . - X X X - # . . . - X - X - # . . . X - - - X # . . . X X X X X # . . . - - X X - # . . . - - - - - lcd.define_custom_char([0x30,0x2c,0x66,0x6c,0x30]) lcd.text("\x7f \x7f \x7f \x7f \x7f \x7f \x7f ") lcd.text(" Hello ") lcd.text(" Raspberry Pi") time.sleep(10); except KeyboardInterrupt: pass finally: lcd.cls() lcd.backlight(OFF)