From d84a5e8db51f409f0d861f270ee46356cbdf68a6 Mon Sep 17 00:00:00 2001 From: Xargana Date: Fri, 16 May 2025 15:40:21 +0200 Subject: [PATCH] Add display/screen.py --- display/screen.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 display/screen.py diff --git a/display/screen.py b/display/screen.py new file mode 100644 index 0000000..1d1abb8 --- /dev/null +++ b/display/screen.py @@ -0,0 +1,21 @@ +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()