# This is an adapted version of the ILI934X driver as below.
# It works with multiple fonts and also works with the esp32 H/W SPI implementation
# Also includes a word wrap print function
# Proportional fonts are generated by Peter Hinch's Font-to-py
# MIT License; Copyright (c) 2017 Jeffrey N. Magee

# This file is part of MicroPython ILI934X driver
# Copyright (c) 2016 - 2017 Radomir Dopieralski, Mika Tuupola
#
# Licensed under the MIT license:
#   http://www.opensource.org/licenses/mit-license.php
#
# Project home:
#   https://github.com/tuupola/micropython-ili934x


"""
sample:


from gbd import *
d = gbd()

s = FbSprite(20, 20)
s.fill(0)
s.fill_circle(10, 10, 9, color565(0, 255, 0))
s.draw_circle(10, 10, 9, color565( 255, 0, 0))
d.blit(s, 20, 20, 0)
d.blit(s, 30, 30, 0)
d.show()


"""



import framebuf
from lib.display.displaybase import *
from machine import Pin, SPI

import time
import ustruct
from micropython import const
#from math import cos, sin, pi, radians
from lib.display.displayext import *
from lib.display.DISPLAY import *
import random



random.seed(time.ticks_ms())

def test():
  d = getbuffereddisplay()
  d.line(10, 10, 100, 100, 0xffff)
  s = FbSprite(29, 29)
  s.fill(0)
  s.fill_circle(14, 14, 14, color565( 255, 0, 0))
  s.fill_circle(14, 14, 11, color565(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)))
  s.fill_circle(14, 14, 6, color565( 0, 0, 255))
  s.fill_circle(14, 14, 3, color565( 0, 255, 0))
  d.blit(s, random.randint(0, 230), random.randint(0, 310), 0)
  d.blit(s, random.randint(0, 230), random.randint(0, 310), 0)
  d.show()

test()
test()
test()
test()
