LCD Display Not working

Hi i am using a 2.8’ ili9341 LCD display with my OpenMV camera to do face detection but it is not working. When i use the LCD example the LCD display prints the image in multiple running squares. then i tried using the TFT openmv code from the youtube video but the lcd printed the reverse rbg. i manged to swap the reverse rbg bytes to the camera but then the camera could no longer detect a face. Is there any way to fix this i been looking on the forum but i am a beginner and i am very lost

Hi, all this was answered here:

The default firmware release contains the byte_reverse argument to the LCD driver. Please use it. This will make your face detection work as you will not be destroying the image.

hi thank you so much for the reply sorry for this is that the LCD example in the OpenMV GitHub depository cause when i use that i run into a separate issue the screen starts printing multiple running squares across the LCD would you know how to fix that issue

I’m sorry, but, not really. Please keep in mind you are using an LCD shield that’s not official supported by us. I’ve tried to supply some support in our code. But, if you want things to work it’s important that you have some knowledge of the user drivers that you are grabbing and if they do the right thing.

Please note that our default LCD driver can drive these larger shields without relying on a Python user driver… however, the default special register settings of these shields are all different. So, it’s hard to make our driver universal to every display someone could buy.

Thank you so much for the reply im so sorry this is due for a project and was wondering if you could help me i tried the driver used by the guy in the post you gave me and it successful swapped the inverse to the rgb camera instead of the lcd but then i cant run the facial detection software would you know how to change that driver so instead of swapping the bytes its displayed the same one
from machine import Pin, SPI
import time
import ustruct

class ili9341():

def byteswap(r0, r1): # bytearray, len(bytearray)
mov(r3, 1)
lsr(r1, r3) # divide len by 2
mov(r4, r0)
add(r4, 1) # dest address
ldrb(r5, [r0, 0])
ldrb(r6, [r4, 0])
strb(r6, [r0, 0])
strb(r5, [r4, 0])
add(r0, 2)
add(r4, 2)
sub(r1, 1)

def send_spi(self,data, is_data):
self.dc.value(is_data) #set data/command pin

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)
self.send_spi(bytearray([0x29]), False)

def set_window(self, x0=0, y0=0, width=320, height=240):
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 = #seek position past header
data =
while len(data)>0 : #read data from file to SPI
self.send_spi(data, True)
data =
I’m so sorry about all this

Hi, our driver includes byte swapping in it now. You don’t need to do that anymore. Just use our default LCD driver.

However, if you don’t want to use that then byteswap AFTER you detect faces as that operation destroys the image.

Anyway, I would recommend using the lcd driver that’s in the firmware over using Python code that’s driving the SPI bus as you will get much better performance.