Very happy to receive your answer, I based it on your code and tried it on TFT9341 screen but without success, you can see the code below:
# Untitled - By: NguyenQuy - Sun Jan 21 2024
import sensor, image, time, display
from pyb import SPI, Pin
from micropython import const
from ustruct import pack
_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
_INVON = const(0x21) # Inversion On
cs = Pin('P3', Pin.OUT)
dc = Pin('P8', Pin.OUT)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames()
clock = time.clock()
spi = SPI(2, SPI.MASTER, baudrate=54000000)
myLCD=display.SPIDisplay(width=320,height=240,refresh=60,bgr=False,byte_swap=False,triple_buffer=False)
#Note DC is pin 8, CS is pin 3
# ILI9341
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
dc.value(False) #set data/command pin
cs.value(0)
spi.send(bytearray([command]))
cs.value(1)
dc.value(True) #set data/command pin
cs.value(0)
spi.send(data)
cs.value(1)
dc.value(False) #set data/command pin
cs.value(0)
spi.send(bytearray([0x11]))
cs.value(1)
time.sleep(10)
dc.value(False) #set data/command pin
cs.value(0)
spi.send(bytearray([0x29]))
cs.value(1)
dc.value(False) #set data/command pin
cs.value(0)
spi.send(bytearray([_INVON]))#inversion on
cs.value(1)
while(True):
clock.tick()
#show camera image on LCD
myLCD.write(sensor.snapshot())