def __init__(self): self.display = SSD1306() self.display.begin() self.off() self.xpos = 6 self.ypos = 2 self.image = Image.new('1', (self.display.width, self.display.height)) self.draw = ImageDraw.Draw(self.image) self.font = ImageFont.load_default() (_, self.fontheight) = self.font.getsize("A")
def __init__ (self): self.display = SSD1306() self.display.begin() self.display.clear() self.display.display() self.xpos = 4 self.ypos = 4 self.width = self.display.width self.height = self.display.height self.image = Image.new('1', (self.width, self.height)) self.draw = ImageDraw.Draw(self.image) self.font = ImageFont.load_default() (_, self.textheight) = self.draw.textsize("Text", font=self.font)
def Receiver (): global disp rf95.spi_write(REG_0C_LNA, LNA_BOOST_MAX) # TODO: find a better place for this # taken from https://github.com/PiInTheSky/lora-gateway/blob/master/gateway.c#L118 disp = SSD1306() disp.begin() disp.clear() disp.display() xpos = 4 ypos = 4 width = disp.width height = disp.height image = Image.new('1', (width, height)) draw = ImageDraw.Draw(image) font = ImageFont.load_default() (_, textheight) = draw.textsize("Text", font=font) while True: while not rf95.available(): pass draw.rectangle((0,0,width,height), outline=0, fill=255) y = ypos draw.text((xpos, y), "Zeit: {}".format(time.strftime("%X")), font=font, fill=0) data = rf95.recv() Log("RSSI: {}".format(rf95.last_rssi)) str = "".join(map(chr, data)) Log("{}\n".format(str)) y += textheight draw.text((xpos, y), "RSSI: {}".format(rf95.last_rssi)) y += textheight draw.text((xpos, y), "{}".format(str[:20])) disp.image(image) disp.display()
cgps -s """ import csv import sys import time from PIL import Image from PIL import ImageDraw from PIL import ImageFont sys.path.append('../../libs') from actuators.SSD1306 import SSD1306 disp = SSD1306() disp.begin() disp.clear() disp.display() xpos = 4 ypos = 4 width = disp.width height = disp.height image = Image.new('1', (width, height)) draw = ImageDraw.Draw(image) font = ImageFont.load_default() _, fontheight = font.getsize("A") from gps3.agps3threaded import AGPS3mechanism agps_thread = AGPS3mechanism() agps_thread.stream_data()