コード例 #1
0
ファイル: beta1.py プロジェクト: fsahli/RCerezas
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")
コード例 #2
0
ファイル: beta1.py プロジェクト: fsahli/RCerezas
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)
コード例 #3
0
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)
コード例 #4
0
ファイル: lcdmonitor.py プロジェクト: golab35/LCD-Monitor
    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")
コード例 #5
0
ファイル: lcdmonitor.py プロジェクト: bubbl/LCD-Monitor
    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")
コード例 #6
0
ファイル: snippet.py プロジェクト: szabo92/gistable
def putstr(str, x, y):
  lcd.gotorc(y,x)
  lcd.text(str)
コード例 #7
0
ファイル: beta1.py プロジェクト: fsahli/RCerezas
		IDlastbin_uploaded = int(fo.read())
		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()
コード例 #8
0
0x60, 0x78, 0x38, 0x3F, 0x3F, 0x38, 0x38, 0x60, 0x60, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0xF8, 0x7F,   # 0x0130 (304) pixels
0xFF, 0xE0, 0xC1, 0xC3, 0xE7, 0x7F, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   # 0x0140 (320) pixels
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   # 0x0150 (336) pixels
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   # 0x0160 (352) pixels
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x7F, 0xFF, 0xF1, 0xE0, 0xC0, 0x80, 0x01,   # 0x0170 (368) pixels
0x03, 0x9F, 0xFF, 0xF0, 0xE0, 0xE0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0xF0, 0xFF, 0x9F,   # 0x0180 (384) pixels
0x03, 0x01, 0x80, 0xC0, 0xE0, 0xF1, 0x7F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   # 0x0190 (400) pixels
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   # 0x01A0 (416) pixels
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   # 0x01B0 (432) pixels
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,   # 0x01C0 (448) pixels
0x03, 0x03, 0x07, 0x07, 0x0F, 0x1F, 0x1F, 0x3F, 0x3B, 0x71, 0x60, 0x60, 0x60, 0x60, 0x60, 0x71,   # 0x01D0 (464) pixels
0x3B, 0x1F, 0x0F, 0x0F, 0x0F, 0x07, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   # 0x01E0 (480) pixels
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   # 0x01F0 (496) pixels
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
]

try:
  lcd.init()
  lcd.cls()
  lcd.backlight(ON)
  lcd.gotorc(0,0)
  for x in logo:
      lcd.lcd_data(x)
  time.sleep(10)
except KeyboardInterrupt:
  pass
finally:
  lcd.cls()
  lcd.backlight(OFF)

コード例 #9
0
ファイル: temprmonitor.py プロジェクト: golab35/LCD-Monitor
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);
コード例 #10
0
def displayTime():
    #Display Time
    lcd.gotorc(2, 0)
    lcd.text(time.strftime("%I:%M:%S", time.localtime()))
    time.sleep(0.25)
    lcd.cls()
コード例 #11
0
ファイル: rpimonitor.py プロジェクト: golab35/LCD-Monitor
 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")
コード例 #12
0
ファイル: b.py プロジェクト: azat385/rpiplc
  lcd.cls()
  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:
コード例 #13
0
 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")
コード例 #14
0
ファイル: temprmonitor.py プロジェクト: bubbl/LCD-Monitor
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)