Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import time,threading,sys
- import mraa
- import SSD1306
- import Image
- import ImageDraw
- import ImageFont
- import subprocess
- #----Import All Needed Modules
- disp = SSD1306.SSD1306_128_64()
- disp.begin()
- disp.clear()
- disp.display()
- #----Init, do not touch before here
- width = disp.width
- height = disp.height
- image = Image.new('1', (width, height))
- draw = ImageDraw.Draw(image)
- #----Prepare and Clear Screen
- font1 = ImageFont.truetype("fonts/Sarpanch.otf", 20)
- font2 = ImageFont.truetype('fonts/Naughty Cartoons.ttf',10)
- #----Sets Fonts
- #
- #----Can draw static area here
- #
- #_____________________________________
- #----Screen Updates after here
- i=0
- #Loop for updating screen numbers
- def screenDraw():
- while 1:
- global i
- i += 1
- mcuTemp = int(subprocess.check_output("cat /sys/class/thermal/thermal_zone1/temp", shell=True).rstrip())/1000
- # mcuTemp = int(subprocess.check_output("cat /sys/class/thermal/thermal_zone1/temp", shell=True).rstrip())
- cpu1Temp = int(subprocess.check_output("cat /sys/class/thermal/thermal_zone3/temp", shell=True).rstrip())/1000
- cpu2Temp = int(subprocess.check_output("cat /sys/class/thermal/thermal_zone4/temp", shell=True).rstrip())/1000
- print "ID#:",i," Pot:"
- print "CPU1:",cpu1Temp," CPU2:",cpu2Temp," MCU:",mcuTemp
- draw.rectangle([0,-8,128,128], fill=0, outline=0)
- draw.text((0,-8),"Ba:"+str(i), font=ImageFont.truetype("fonts/Sarpanch.otf", 18), fill=255)
- draw.text((70,-8)," MC:"+str(mcuTemp), font=ImageFont.truetype("fonts/Sarpanch.otf", 18), fill=255)
- draw.text((63,12)," CPU1: "+str(cpu1Temp), font=ImageFont.truetype("fonts/Sarpanch.otf", 15), fill=255)
- draw.text((59,26)," CPU2: "+str(cpu2Temp), font=ImageFont.truetype("fonts/Sarpanch.otf", 15), fill=255)
- # Display image.
- disp.image(image)
- disp.display()
- def senPotRead():
- # potVal = mraa.Aio(5).read()
- #LCD Screen works until above this is uncommented
- #Terminal still scrolls, showing output
- time.sleep(5)
- #________________________________
- #----Call for Threads to start
- def runtime():
- threading.Timer(0, screenDraw).start()
- threading.Timer(0, senPotRead).start()
- runtime()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement