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))
pico:GP0
pico:GP1
pico:GND.1
pico:GP2
pico:GP3
pico:GP4
pico:GP5
pico:GND.2
pico:GP6
pico:GP7
pico:GP8
pico:GP9
pico:GND.3
pico:GP10
pico:GP11
pico:GP12
pico:GP13
pico:GND.4
pico:GP14
pico:GP15
pico:GP16
pico:GP17
pico:GND.5
pico:GP18
pico:GP19
pico:GP20
pico:GP21
pico:GND.6
pico:GP22
pico:RUN
pico:GP26
pico:GP27
pico:GND.7
pico:GP28
pico:ADC_VREF
pico:3V3
pico:3V3_EN
pico:GND.8
pico:VSYS
pico:VBUS
lcd1:VCC
lcd1:GND
lcd1:CS
lcd1:RST
lcd1:D/C
lcd1:MOSI
lcd1:SCK
lcd1:LED
lcd1:MISO