# test of printing multiple fonts to the ILI9341 on an M5Stack using H/W SP
# MIT License; Copyright (c) 2017 Jeffrey N. Magee
from ili934xnew import ILI9341, color565
from machine import Pin, SoftSPI #SPI
import m5stack
import tt14
import glcdfont
import tt14
import tt24
import tt32
fonts = [glcdfont,tt14,tt24,tt32]
print("OK1")
text = 'Now is the time for all good men to come to the aid of the party.'
print("OK2")
power = Pin(m5stack.TFT_LED_PIN, Pin.OUT)
power.value(1)
print("OK3")
max_clk = const(26)
max_cs = const(25)
max_din = const(33)
spi = SoftSPI(sck=max_clk, mosi=max_din, miso=14)
#spi = SPI(
# 2,
# baudrate=32000000, #40000000,
# miso=Pin(m5stack.TFT_MISO_PIN),
# mosi=Pin(m5stack.TFT_MOSI_PIN),
# sck=Pin(m5stack.TFT_CLK_PIN))
print("OK4")
display = ILI9341(
spi,
cs=Pin(m5stack.TFT_CS_PIN),
dc=Pin(m5stack.TFT_DC_PIN),
rst=Pin(m5stack.TFT_RST_PIN),
w=320,
h=240,
r=3)
print("OK5")
display.erase()
print("OK6")
display.set_pos(0,0)
print("OK7")
display.set_font(tt14)
display.print(text)
print(text)
print("OK8")
#for ff in fonts:
# display.set_font(ff)
# display.print(text)