#!/usr/bin/env python3

import io
from time import sleep
from PIL import Image, ImageDraw, ImageFont
import lib.display

def start(stop_event, text="Hello World!"):
  #t = 0
  image_buffer = lib.display.matrix.buffer()
  draw = ImageDraw.Draw(image_buffer)
  draw.rectangle( ((0,0),(lib.display.matrix.width-1,lib.display.matrix.height-1)), fill=(0,0,90) )
  draw.text((0, 0), "Hello World", fill=(255, 255, 255), font=lib.display.matrix.font)
  #draw.text((0, 0), f"Hello World {t}", fill=(255, 255, 255), font=lib.display.matrix.font)

  #t += 1
  #print(t)

  lib.display.matrix.show(image_buffer)
  while not stop_event.is_set():

    sleep(1)

