Newer
Older
#!/usr/bin/env python3
# see also https://luma-oled.readthedocs.io/en/latest/python-usage.html
# use libraries luma libraries
from luma.core.interface.serial import i2c
from luma.core.render import canvas
from luma.oled.device import sh1106
import time
# the OLED displays provided in the course is a SH1106 and uses
# by default address 0x3C and port 1
serial = i2c(port=1, address=0x3C)
device = sh1106(serial)
# draw
with canvas(device) as draw:
# SH1106 supports black and white color
# frame
draw.rectangle(device.bounding_box, outline="white", fill="black")
# text message
draw.text((15, 20), "I like \nEmbedded Systems!", fill="white")
# keep content for 10 seconds
time.sleep(10.0)
# switch off device
device.cleanup()