"""
lines.py
Draws lines and rectangles in random colors at random locations on the display.
"""
import random
from machine import Pin, SoftSPI ,SPI
import st7789py as st7789
import gfx
from time import sleep
# SCK 2
# MOSI 3
# MISO NC
# LED NC
# BACKLIGHT NC
disp_sck = 18 # default SCK of SPI(0)
disp_mosi = 19 # default MOSI of SPI(0)
disp_miso = 16 # not use
disp_res = 20
disp_dc = 21
disp_cs = 17
disp_blk = 22
WIDTH = 320
HEIGHT = 240
# Start Function
if __name__=="__main__":
screen_width=320
screen_height=240
# spi = SoftSPI(
spi = SPI(0,
baudrate=20000000,
polarity=1,
phase=0,
sck=Pin(disp_sck),
mosi=Pin(disp_mosi),
miso=Pin(disp_miso))
tft = st7789.ST7789(
spi,
WIDTH,
HEIGHT,
reset=Pin(disp_res, Pin.OUT),
cs=Pin(disp_cs, Pin.OUT),
dc=Pin(disp_dc, Pin.OUT),
backlight=Pin(disp_blk, Pin.OUT),
rotation=0)
#tft.fill(st7789.RED)
tft.rect(40, 10, 120, 100, st7789.WHITE)
sleep(0.1) # 0.1 sec = 100 ms
scale = -5
tft.fill_rect(40+scale, 10+scale, 120+scale, 100+scale, st7789.RED)
sleep(0.1) # 0.1 sec = 100 ms
#graphics = gfx.GFX(screen_width, screen_height, tft.pixel)
#graphics.line(0, 0, 127, 20, 1)
#tft.show()
sleep(0.1) # 0.1 sec = 100 ms