#!/usr/bin/env python # coding=utf-8 # import libs from lib_oled96 import ssd1306 from smbus import SMBus from PIL import ImageFont import sys # setup display i2cbus = SMBus(1) # 0 = Raspberry Pi 1, 1 = Raspberry Pi > 1 oled = ssd1306(i2cbus) # const draw = oled.canvas # Schriftarten festlegen FreeSans12 = ImageFont.truetype('FreeSans.ttf', 12) FreeSans20 = ImageFont.truetype('FreeSans.ttf', 20) FreeSansBold30 = ImageFont.truetype('FreeSansBold.ttf', 30) #variables to set #for thext #offset temperature is the temperature that will be used to display a real LCD temp #best value is 53 offsettemp=53 #for diagram #mintemp is room temperature in Celsius for your area mintemp=18.0 #maxtemp is the temperature the diagram should scale to #you should use 120°C-offsettemp=maxtemp maxtemp=67 # delete display at startup oled.cls() oled.display() draw.rectangle((2, oled.height-float(sys.argv[1]), 10, oled.height-1), outline=1, fill=1) # Rechteck draw.rectangle((12, oled.height-float(sys.argv[2]), 20, oled.height-1), outline=1, fill=1) # Rechteck draw.rectangle((22, oled.height-float(sys.argv[3]), 30, oled.height-1), outline=1, fill=1) # Rechteck draw.rectangle((32, oled.height-float(sys.argv[4]), 40, oled.height-1), outline=1, fill=1) # Rechteck draw.rectangle((42, oled.height-float(sys.argv[5]), 50, oled.height-1), outline=1, fill=1) # Rechteck draw.text((64, 1), str(int(float(sys.argv[1]))+int(offsettemp)), font=FreeSansBold30, fill=1) draw.text((64, 32), "\xb0C", font=FreeSansBold30, fill=1) # write data to display oled.display()