# -*- coding: utf-8 -*- import time import Adafruit_GPIO.SPI as SPI import Adafruit_SSD1306 from PIL import Image from PIL import ImageDraw from PIL import ImageFont #import subprocess RST = None # on the PiOLED this pin isnt used DC = 23 SPI_PORT = 0 SPI_DEVICE = 0 disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST, i2c_address=0x3C) disp.begin() disp.clear() disp.display() width = disp.width height = disp.height image = Image.new('1', (width, height)) draw = ImageDraw.Draw(image) draw.rectangle((0,0,width,height), outline=0, fill=0) padding = -2 top = padding bottom = height-padding x = 0 #font = ImageFont.load_default() font = ImageFont.truetype("fonts-japanese-gothic.ttf", 42) while True: draw.rectangle((0,0,width,height), outline=0, fill=0) #cmd = "hostname -I | cut -d\' \' -f1" #IP = subprocess.check_output(cmd, shell = True ) #draw.text((x, top), "IP:" + str(IP), font=font, fill=255) with open('/home/pi/e7.txt') as f: s = f.read() #print(s) draw.text((x, top+1), s.strip() + "W", font=font, fill=255) disp.image(image) disp.display() time.sleep(10)