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