Display problem with unsupported LCD module

Hi everyone,

I am trying to use UTFT library to light up a 3.5" LCD with ST7796 driver.
But the image showed up gradually from screen mess after couple loops.(in attachment)
The sketch I use to test is modified from example (UTFT_Bitmap_128x128)

I just wonder if the initial code (in attachment) should be modified for use? such as clk...?
Besides, the original initial code is listed below, it seems to be used for SPI ?

LCD_SPI_REG(0xf0); //Enable command 2
LCD_SPI_DATA(0xc3);

But what I use now is 8080-8-bit interface, is it still work on?

Any suggestion is highly appreciated.

Gary

#include <UTFT.h>

UTFT myGLCD(ST7796, 38, 39, 40, 41); // Remember to change the model parameter to suit your display module!

extern unsigned short tux[0x1000];
int ledPin = 9;
void setup()
{
  pinMode(13, OUTPUT);//For RD
  digitalWrite(13, HIGH);
  analogWrite(ledPin, 200);//For LED
  myGLCD.InitLCD();
}

void loop()
{
  // Draw a 64x64 icon in double size.
  myGLCD.drawBitmap (0, 0, 64, 64, tux, 2);
  delay(200);
}

initlcd.h (3.64 KB)

screen mess.JPG

After weeks trying, it finally shows what I want.
I modified the interface pixel format to 16-bit in initial code firstly, and those weird background gone.
But it came up with strange color compare to the original picture.
Then I just change the R-G-B order, everything OK with UTFT library so far.

However, this successfully test is worked on my new LCD, which can be set to 8/16 bit interface.
Because one of the databus in my old LCD was broken, I have no idea if these modified works on my old one (8-bit fixed format).

You should post your modifications to the library so that someone else may use it.

Modified initial code for 16-bit interface.

initlcd.h (3.38 KB)

I am trying to compile this file in the Arduino IDE having added a new macro for the ST7796 driver and module in UTFT.h. The compiler is having trouble recognizing "ST7796" as the first input when the UTFT object is created. Did you run into a similar problem Gary_chien?

Did you define the ST7796 in UTFT.h and UTFT.cpp?
It looks like the definition problem.
Besides, don't forget to put this file in the right direction.

  1. Create a st7796 folder under UTFT/tft_drivers/ path.
  2. Put this file and copy the setxy.h from st7735s into the st7796 folder
    Just make sure the st7796 driver is similar to st7735s one.

BTW, I have not touched these stuff in Arduino over a year, and just answer it with my poor memory. :o

I had created a new st7796 and moved the two files into it though, thank you for the quick response.

I defined both the LCD module and the driver in the .h file, though I wasn't sure exactly what to put for the module ID. I am using a different module manufactured by Truly.

I wasn't entirely sure which part of UTFT.cpp to edit to define the ST7796, so I followed the structure of the file and edited the #ifndef DISABLE...includes.

When I try to edit the module field in the Arduino file to ST7796 it doesn't seem to get recognized.

The definition in UTFT.h file (around Line.140)

#define DMTFT18101      30  // HX8353C  (Serial 5Pin)
#define TFT18SHLD       31 // ST7735 (Serial 5Pin) Alternative Init
#define ST7796          32  // ST7796   (16bit)

The definition in UTFT.cpp file (around Line.95)

UTFT::UTFT(byte model, int RS, int WR, int CS, int RST, int SER)
{ 
 word dsx[] = {239, 239, 239, 239, 239, 239, 175, 175, 239, 127, 127, 239, 271, 479, 239, 239, 239, 0, 0, 239, 479, 319, 239, 175, 127, 239, 239, 319, 319, 799, 127, 127, 319};
 word dsy[] = {319, 399, 319, 319, 319, 319, 219, 219, 399, 159, 127, 319, 479, 799, 319, 319, 319, 0, 0, 319, 799, 479, 319, 219, 159, 319, 319, 479, 479, 479, 159, 159, 479};
 byte dtm[] = {16, 16, 16, 8, 8, 16, 8, SERIAL_4PIN, 16, SERIAL_5PIN, SERIAL_5PIN, 16, 16, 16, 8, 16, LATCHED_16, 0, 0, 8, 16, 16, 16, 8, SERIAL_5PIN, SERIAL_5PIN, SERIAL_4PIN, 16, 16, 16, SERIAL_5PIN, SERIAL_5PIN,16};

If the LCM driver is ST7796, and the interface is supported by 8080-16 bit, it should be OK.

Thanks for the help:

I added the definition in UTFT.cpp where you had it, but there still seems to be no recognition of the ST7796 driver in the lcddriver.ino file

#include <UTFT.h>

UTFT myGLCD(ST7769, 12, 13, 15, 36); 00// Rememb1er to change the model parameter to suit your display module!

extern unsigned short tux[0x1000];
int ledPin = 9;
void setup()
{
  pinMode(13, OUTPUT);//For RD
  digitalWrite(13, HIGH);
  analogWrite(ledPin, 200);//For LED
  myGLCD.InitLCD();
}

void loop()
{
  // Draw a 64x64 icon in double size.
  myGLCD.drawBitmap (0, 0, 64, 64, tux, 2);
  delay(200);
}
[code]

[/code]

I am using the ST7796S LCD driver with a teensy3.6 microcontroller programmed using the Arduino IDE with teensyduino installed. The Truly interface should be supported by 8080-16 bit, and I have attached the datasheet for your reference.

1.9 inch LCM applicationnoteV0.1.pdf (618 KB)

Maybe just try to modify the ID "ST7769" to "ST7796" will make it work. :confused:

Sorry, i meant to say "ST7796" in that part.

The problem persists :frowning:

Fixed my issue! turns out it wasn't reading the correct UTFT library in the first place.

Now the bug I'm getting is with the "tux" variable you've declared.

Where is the bitmapdata loaded in?

Well, tux can be found in most UTFT example.
e.g. UTFT\examples\Arduino (ARM) + Teensy\UTFT_Bitmap
And don't forget to copy the tux.c to your project direction.

I have fixed the wiring and am sniffing signals from the driver to my arduino!

The CS is working correctly but the SDA and SCL data is corrupted because the ST7796 clock is active low, sampled on rising edge and this seems to conflict with the TFT firmware.

Did you have to reconfigure any parameters in the UTFT library to account for the active high clock (CPOL =0) and data on clock leading edge (CPHA =0)?