callisto/display/oled_display.py

21 lines
630 B
Python
Raw Permalink Normal View History

2025-05-16 18:28:37 +02:00
from PIL import Image, ImageDraw
import adafruit_ssd1306
2025-05-16 15:40:21 +02:00
import board
import busio
class OLEDDisplay:
2025-05-16 18:28:37 +02:00
def __init__(self):
2025-05-16 15:40:21 +02:00
i2c = busio.I2C(board.SCL, board.SDA)
2025-05-16 18:28:37 +02:00
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))
2025-05-16 15:40:21 +02:00
self.draw = ImageDraw.Draw(self.image)
def clear(self):
self.draw.rectangle((0, 0, self.display.width, self.display.height), outline=0, fill=0)
2025-05-16 18:28:37 +02:00
def render(self):
2025-05-16 15:40:21 +02:00
self.display.image(self.image)
self.display.show()