So far it's only in early testing. I've been using Luma.OLED and PIL.
I can get text to scroll across the screen so far but eventually I want each screen to be configured through the the config file to only show one METAR from a selected airport and update alongside the rest of the code every 5 minutes.
What do you think?
import time
from demo_opts import get_device
from luma.core.virtual import viewport
from luma.core.render import canvas
from PIL import Image, ImageDraw, ImageFont
metar = 'METAR YBBN 080000Z 15006KT 110V190 9999 FEW049 22/11 Q1030'
def main():
fnt = ImageFont.truetype("Pillow/Tests/fonts/FreeMono.ttf", 28)
x = device.width
# First measure the text size
with canvas(device) as draw:
w, h = draw.textsize(metar, fnt)
virtual = viewport(device, width=max(device.width, w + x + x), height=max(h, device.height))
for _ in range(2):
with canvas(virtual) as draw:
for i, line in enumerate(metar.split("\n")):
draw.text((0 + (i * 10), 0), font=fnt, text=line, fill="white")
time.sleep(2)
# update the viewport one position below, causing a refresh,
# giving a rolling up scroll effect when done repeatedly
for x in range(int(w / 2)):
virtual.set_position((x * 2, 0))
time.sleep(0.01)
while __name__ == "__main__":
try:
device = get_device()
main()
except ValueError:
print('OLED not found!')
G'day Scott,
I've been working to try and add some little OLED I2C screens like this
https://www.livesectional.com/oled-displays-add-on/
So far it's only in early testing. I've been using Luma.OLED and PIL.
I can get text to scroll across the screen so far but eventually I want each screen to be configured through the the config file to only show one METAR from a selected airport and update alongside the rest of the code every 5 minutes.
What do you think?