"""
ILI9341 Pin Raspberry Pi Pico Pin Purpose
VCC 3.3V Power
GND GND Ground
CS GP17 Chip Select
RESET GP16 Reset
DC/RS GP16 Data/Command
MOSI GP11 SP10
SCK GP10 SP10 SCK
LED 3.3V Backlight Power
"""
from machine import Pin, SPI
from ili934xnew import ILI9341, color565
import glcdfont
import time
from draw_rectangle import draw_rectangle
from draw_line import draw_line
# spi setup for the display
spi = SPI(1, baudrate=40000000, sck=Pin(10), mosi=Pin(11))
display = ILI9341(
spi=spi,
cs=Pin(17),
dc=Pin(15),
rst=Pin(16),
w=240,
h=320,
r=0
)
# clear the screen
display.fill_rectangle(0, 0, 240, 320, color565(0, 0, 0))
#draw some text
# display.set_font(glcdfont)
# display.print("Hello World")
yellow = color565(255, 255, 0)
white = color565(255, 255, 255)
red = color565(255, 0, 0)
green = color565(255, 255, 0)
blue = color565(0, 0, 255)
while True:
# draw_rectangle(display, color565)
# horizontal line
draw_line(display, 10, 50, 100, 50, blue)
# vertical line
draw_line(display, 60, 10, 60, 200, yellow)
# positive diagonal line with positive slope
draw_line(display, 0, 0, 100, 100, color565(255, 255, 255))
# diagonal line with a negative slope
draw_line(display, 102, 102, 52, 52, yellow)
time.sleep(100)