Do you have a saleae logic probe or something you can decide SPI packets with?
unfortunately No as they are not cheap.
I have made a video to explain the problem well see https://youtu.be/Cqv-jPv-Yz0
I first load a 320x240 BMP file to the screen to show the screen works properly in full screen. I think stream QQVGA 160x120 to a window on the screen to show streaming the fb works fine. I thin show what happens if I try to stream QVGA 320x240 top the screen.
Here is both my bits of code
import sensor, image, time
from MP_ili9341 import ili9341
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
screen = ili9341()
screen.set_window(0,0,320,24 0)
#screen.load_image('bots16_320x240.bmp')
while(True):
clock.tick()
img = sensor.snapshot()
screen.send_spi(img, True)
print(clock.fps())
and
from machine import Pin, SPI
import time
import ustruct
class ili9341():
def send_spi(self,data, is_data):
self.dc.value(is_data) #set data/command pin
self.cs.value(0)
self.hspi.write(data)
self.cs.value(1)
def __init__(self, cs='P3', dc='P9'):
self.hspi = SPI(2, baudrate=54000000)
self.cs = Pin(cs, Pin.OUT)
self.dc = Pin(dc, Pin.OUT)
for command, data in (
(0xef, b'\x03\x80\x02'),
(0xcf, b'\x00\xc1\x30'),
(0xed, b'\x64\x03\x12\x81'),
(0xe8, b'\x85\x00\x78'),
(0xcb, b'\x39\x2c\x00\x34\x02'),
(0xf7, b'\x20'),
(0xea, b'\x00\x00'),
(0xc0, b'\x23'), # Power Control 1, VRH[5:0]
(0xc1, b'\x10'), # Power Control 2, SAP[2:0], BT[3:0]
(0xc5, b'\x3e\x28'), # VCM Control 1
(0xc7, b'\x86'), # VCM Control 2
(0x36, b'\xF8'), # Memory Access Control
(0x3a, b'\x55'), # Pixel Format
(0xb1, b'\x00\x18'), # FRMCTR1
(0xb6, b'\x08\x82\x27'), # Display Function Control
(0xf2, b'\x00'), # 3Gamma Function Disable
(0x26, b'\x01'), # Gamma Curve Selected
(0xe0, b'\x0f\x31\x2b\x0c\x0e\x08\x4e\xf1\x37\x07\x10\x03\x0e\x09\x00'), # Set Gamma
(0xe1, b'\x00\x0e\x14\x03\x11\x07\x31\xc1\x48\x08\x0f\x0c\x31\x36\x0f')): # Set Gamma
self.send_spi(bytearray([command]), False)
self.send_spi(data, True)
self.send_spi(bytearray([0x11]), False)
#time.sleep(10)
self.send_spi(bytearray([0x29]), False)
def set_window(self, x0=0, y0=0, width=320, height=240):
x1=x0+width-1
y1=y0+height-1
self.send_spi(bytearray([0x2A]),False) # set Column addr command
self.send_spi(ustruct.pack(">HH", x0, x1), True) # x_end
self.send_spi(bytearray([0x2B]),False) # set Row addr command
self.send_spi(ustruct.pack(">HH", y0, y1), True) # y_end
self.send_spi(bytearray([0x2C]),False) # set to write to RAM
#chuck size can be increased for faster wiring to the screen at cost of RAM
def load_image(self, image_file, chunk_size=1024):
BMP_file = open(image_file , "rb")
data = BMP_file.read(54) #seek position past header
data = BMP_file.read(chunk_size)
while len(data)>0 : #read data from file to SPI
self.send_spi(data, True)
data = BMP_file.read(chunk_size)
BMP_file.close()