Esempio n. 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")
Esempio n. 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")
Esempio n. 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")
Esempio n. 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")
Esempio n. 5
0
import pcd8544.lcd as lcd
import time, sys ,os, subprocess
from datetime import datetime

    # optional load of drivers if not listed in /etc/modules
#os.system('modprobe w1-gpio')
#os.system('modprobe w1-therm')

    #Initiate LCD
lcd.init()
        # Turn backlight on/off. The number corrensponds to backlight
        # brightness, 0 being light off, 10 being the brightest.
lcd.backlight(5)
lcd.set_contrast(512)
        # Prepare degrees celsius symbol
lcd.define_custom_char([0x00, 0x07, 0x05, 0x07, 0x00])

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-000004e4b880/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:])
Esempio n. 6
0
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)

Esempio n. 7
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()
Esempio n. 8
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()
Esempio n. 9
0
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)
    # 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)
Esempio n. 10
0
import pcd8544.lcd as lcd
import time, sys, os, subprocess
from datetime import datetime

# optional load of drivers if not listed in /etc/modules
#os.system('modprobe w1-gpio')
#os.system('modprobe w1-therm')

#Initiate LCD
lcd.init()
# Turn backlight on/off. The number corrensponds to backlight
# brightness, 0 being light off, 10 being the brightest.
lcd.backlight(5)
lcd.set_contrast(512)
# Prepare degrees celsius symbol
lcd.define_custom_char([0x00, 0x07, 0x05, 0x07, 0x00])


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-000004e4b880/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.