import time
time.sleep(0.1) # Wait for USB to become ready
print("Hello, Pi Pico!")
from ili9341xnew import ILI9341, color565
from machine import Pin, SPI
import tt14
import tt24
import tt32
import glcdfont
import framebuf
# FrameBuffer needs 2 bytes for every RGB565 pixel
fbuf = framebuf.FrameBuffer(bytearray(100 * 10 * 2), 100, 10, framebuf.RGB565)
fbuf.fill(0)
fbuf.text('MicroPython!', 0, 0, 0xffff)
fbuf.hline(0, 9, 96, 0xffff)
def color565(r, g, b):
return (r & 0xf8) << 8 | (g & 0xfc) << 3 | b >> 3
def rgbTo565(rgb):
r=(rgb>>16)&0xff
g=((rgb&0x00FF00)>>8)&0xff
b=rgb&0x0000ff
return color565(r,g,b)
TFT_MISO_PIN=16
TFT_MOSI_PIN=19
TFT_CLK_PIN=18
TFT_CS_PIN=17
TFT_DC_PIN=20
TFT_RST_PIN=21
fonts = [glcdfont,tt14,tt24,tt32]
text = 'Now is the time for all good men to come to the aid of the party.'
spi = SPI(
0,
baudrate=40000000,
miso=Pin(TFT_MISO_PIN),
mosi=Pin(TFT_MOSI_PIN),
sck=Pin(TFT_CLK_PIN))
display = ILI9341(
spi,
cs=Pin(TFT_CS_PIN),
dc=Pin(TFT_DC_PIN),
rst=Pin(TFT_RST_PIN),
w=320,
h=240,
r=0)
display.erase()
display.set_pos(0,0)
#for ff in fonts:
# display.set_font(ff)
# display.print(text)
# time.sleep(2)
# display.set_pos(0,0)
# display.erase()
for y in range(0,24):
for x in range(0,16):
display.fill_rectangle(20+(x*12), 20+(y*12), 10, 10, color565(255,0,0))