#!/usr/bin/env python3

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

import datetime
import locale
locale.setlocale(locale.LC_TIME, "de_DE.UTF-8")

def start(stop_event, args):
  image_buffer = lib.display.matrix.buffer()
  draw = ImageDraw.Draw(image_buffer)

  #print(int(args.get('red', 0)))

  # All to color
  draw.rectangle( 
    ( (0,0), (lib.display.matrix.width-1,lib.display.matrix.height-1) ),
    fill=(
      int(args.get('red', 0)),
      int(args.get('green', 0)),
      int(args.get('blue', 0))
      )
    )
  lib.display.matrix.show(image_buffer)

  while not stop_event.is_set():
    sleep(0.5)

