from PIL import Image, ImageDraw import adafruit_ssd1306 import board import busio class OLEDDisplay: def __init__(self): i2c = busio.I2C(board.SCL, board.SDA) self.display = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c) self.display.fill(0) self.display.show() self.image = Image.new("1", (self.display.width, self.display.height)) self.draw = ImageDraw.Draw(self.image) def clear(self): self.draw.rectangle((0, 0, self.display.width, self.display.height), outline=0, fill=0) def render(self): self.display.image(self.image) self.display.show()