Example #1
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")
Example #2
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")
Example #3
0
    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")
Example #4
0
    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")
Example #5
0
 def run(self):
     tm = datetime.now().strftime('%H:%M')
     tm2 = datetime.today().strftime('%d %b %Y')
     lcd.centre_text(0,"Today is:")
         # Print current time and date on screen
     lcd.centre_text(2,tm2)
     lcd.centre_text(3,tm)
Example #6
0
 def run(self):
     tm = datetime.now().strftime('%H:%M')
     tm2 = datetime.today().strftime('%d %b %Y')
     lcd.centre_text(0, "Today is:")
     # Print current time and date on screen
     lcd.centre_text(2, tm2)
     lcd.centre_text(3, tm)
Example #7
0
#!/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.centre_text(0,"Raspberry Pi")
  while 1:
     lcd.centre_text(2,time.strftime("%d %b %Y", time.localtime()))
     lcd.centre_text(3,time.strftime("%H:%M:%S", time.localtime()))
     time.sleep(0.25)
except KeyboardInterrupt:
  pass
finally:
  lcd.cls()
  lcd.backlight(OFF)

Example #8
0
#!/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.centre_text(2, "contrast")
    for i in range(150, 200, 5):
        lcd.set_contrast(i)
        lcd.centre_text(3, "%d" % i)
        time.sleep(1)
    for i in range(200, 150, -5):
        lcd.set_contrast(i)
        lcd.centre_text(3, "%d" % i)
        time.sleep(1)
except KeyboardInterrupt:
    pass
finally:
    lcd.cls()
    lcd.backlight(OFF)
Example #9
0
 def onenter(self):
   lcd.cls()
   lcd.centre_text(0,'RPi-Monitor')
   lcd.centre_text(3,'key enter')
Example #10
0
 def onright(self):
   lcd.cls()
   lcd.centre_text(0,'RPi-Monitor')
   lcd.centre_text(3,'key right')
Example #11
0
#!/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.centre_text(2,"contrast")
  for i in range(150,200,5):
      lcd.set_contrast(i)
      lcd.centre_text(3,"%d" % i)
      time.sleep(1)
  for i in range(200,150,-5):
      lcd.set_contrast(i)
      lcd.centre_text(3,"%d" % i)
      time.sleep(1)
except KeyboardInterrupt:
  pass
finally:
  lcd.cls()
  lcd.backlight(OFF)

Example #12
0
		RPIO.add_interrupt_callback(22, Int_shutdown2, edge='rising', debounce_timeout_ms=1000)
		RPIO.add_interrupt_callback(25, Int_shutdown, edge='rising', debounce_timeout_ms=1000)
		RPIO.wait_for_interrupts(threaded=True)
	except Exception,e:
		print 'Error al iniciar botones'
		print e
	try:
		print 'Iniciando LCD'
		lcd.init()
		lcd.cls()
		lcd.set_contrast(250)
		lcd.backlight(OFF)
	except:
		print 'Error al iniciar LCD'

	lcd.centre_text(0,"Verificando Internet...")
	print "Verificando Internet"
	if internet_on():
		lcd.cls()
		lcd.centre_text(0,"Bajando Registro de nombres...")
		print "Bajando registro de nombres"
		try:
			dowloadNombreTarjeta()
		except:
			print "No se pudo bajar registro"
	else:
		lcd.cls()
		lcd.centre_text(0,"No hay internet...")
		print "No hay internet"
	if os.path.isfile(path+'data/NombreTarjeta.csv'):
		lcd.cls()
Example #13
0
import Adafruit_BMP.BMP085 as BMP085								
sensor = BMP085.BMP085()								
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.set_contrast(185)

  while 1:
    lcd.centre_text(0,commands.getoutput("hostname"))
    lcd.centre_text(1,commands.getoutput("hostname -I"))
    lcd.centre_text(3,time.strftime("%d %b %Y", time.localtime()))
    lcd.centre_text(4,time.strftime(" %H:%M:%S ", time.localtime()))
    lcd.centre_text(5, "   ")
    temp = '{0:0.2f} *C'.format(sensor.read_temperature())								
    lcd.centre_text(6, temp)
    ii=0
    while ii<4*60:
      lcd.centre_text(3,time.strftime("%d %b %Y", time.localtime()))
      lcd.centre_text(4,time.strftime(" %H:%M:%S ", time.localtime()))
      ii=ii+1
      time.sleep(0.25)

except KeyboardInterrupt:
  pass
Example #14
0
    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()
Example #15
0
        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()
Example #16
0
 def onup(self):
   lcd.cls()
   lcd.centre_text(0,'RPi-Monitor')
   lcd.centre_text(3,'key up')
Example #17
0
  sys.exit('Script must be run as root')

ON, OFF = [1, 0]

#adjust for where your switch is connected
buttonPin = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(buttonPin,GPIO.IN)
started = False


try:
  lcd.init()
  lcd.cls()
  lcd.backlight(ON)
  lcd.centre_text(0,"Raspberry Pi")
  while 1:
     lcd.centre_text(2,time.strftime("%d %b %Y", time.localtime()))
     lcd.centre_text(3,time.strftime("%H:%M:%S", time.localtime()))
     time.sleep(0.25)
     if (GPIO.input(buttonPin) == False):
       os.system("java -jar /home/pi/Robot/robot/Trilateration/robot.jar &")
       
       break
except KeyboardInterrupt:
  pass
finally:
  lcd.cls()
  lcd.backlight(OFF)

time.sleep(1.5)
Example #18
0
 def ondown(self):
   lcd.cls()
   lcd.centre_text(0,'RPi-Monitor')
   lcd.centre_text(3,'key down')
Example #19
0
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",""))


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")
Example #20
0
 def onleft(self):
   lcd.cls()
   lcd.centre_text(0,'RPi-Monitor')
   lcd.centre_text(3,'key left')
Example #21
0
def display_main_screen():
  lcd.cls()
  lcd.centre_text(1,actions.get_text(current))
Example #22
0
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", ""))


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")