Add display/screen.py
This commit is contained in:
parent
3ac5417b1a
commit
d84a5e8db5
21
display/screen.py
Normal file
21
display/screen.py
Normal file
|
@ -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()
|
Loading…
Reference in a new issue