I have had a little play with a 1.77" 160x128 TFT display. I made the PCB to be similar to the official OpenMV LCD shield but except to be in landscape instead of portrait.
For the moment the code is very light and just streams your frame buffer to the screen, there plenty of room to add features.
I might sit down and do the same for a 2.4" 320x240 TFT display as well.
See it in action here - YouTube
and this is the code that was running when the video was taken
import time
from pyb import Pin, SPI
from micropython import const
from ustruct import pack
import sensor, image, time
_SWRESET = const(0x01) # Software Reset
_SLPOUT = const(0x11) # Sleep Out
_COLMOD = const(0x3A) # Colour Mode
_DISPON = const(0x29) # Display On
_MADCTL = const(0x36) # Memory Data Access
_CASET = const(0x2A) # Column Address Set
_RASET = const(0x2B) # Row Address set
_RAMWR = const(0x2C) #write to screen memory
dc = Pin('P8', Pin.OUT_PP) #setup the data/command pin
spi = SPI(2, SPI.MASTER, 54000000) #setup SPI to go as fast as possible
def send_spi(data, is_data):
dc.value(is_data) #set the data/commond pin
spi.send(data)
def init():
send_spi(bytearray([_SWRESET]), False) #software reset
time.sleep(200)
send_spi(bytearray([_SLPOUT]), False) #sleep out
time.sleep(200)
send_spi(bytearray([_COLMOD]), False) #set 16 bit colour
send_spi(bytearray([0x05]),True)
send_spi(bytearray([_DISPON]), False) #display on
send_spi(bytearray([_MADCTL]), False) #set mode for writing to screen
send_spi(bytearray([0b10100000]),True) #this was the mode that I used for my screen
def set_window(x0, y0, width, height):
x1=x0+width-1
y1=y0+height-1
send_spi(bytearray([_CASET]),False) #set width
send_spi(pack(">HH", x0, x1), True) #
send_spi(bytearray([_RASET]),False) #set hieght
send_spi(pack(">HH", y0, y1), True) #
def dump_data(data):
send_spi(bytearray([_RAMWR]), False) #command to write to screen RAM
send_spi(data, True)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
init()
set_window(0,0,160,120)
while True:
clock.tick()
img = sensor.snapshot()
dump_data(img)
print(clock.fps())