Author Topic: 2.4 tft screen ILI9342 problems, help me please !  (Read 7692 times)

0 Members and 1 Guest are viewing this topic.

Offline topnullusTopic starter

  • Newbie
  • Posts: 7
  • Country: fr
2.4 tft screen ILI9342 problems, help me please !
« on: April 26, 2017, 12:21:30 pm »
Hello,

sorry for my poor english.

ILI9342 is for screen 320 x 240 pixels (WxH) and
ILI9341 is for screen 240 x 320 pixels (WxH)

I do not find one library for ILI9342.
I tryed a lot of libraries for ILI9341, none works, except maybe one.

I say maybe because :
- colors are inverted, black is 0xFFFF and wite 0X0000 , rgb565.
- texte is miroired and biggining from right side
- portrait screen is displayed and splited in lanscape screen or lanscape screen is diplayed and splited in portrait screen

This library "SPFD5408-master.zip" for ILI9341 come from https://github.com/JoaoLopesF/SPFD5408

Now, datasheet are too technical for me.
datasheet for ILI9341 : http://www.buydisplay.com/download/ic/ILI9341.pdf
datasheet for ILI9342 : http://www.buydisplay.com/download/ic/ILI9342.pdf

Can you help me :
- finding library working well
 or
- understanding datasheet
 or
- explain me how and where change something in witch files from  SPFD5408-master.zip
 ?

Thank you very much.



PS:
This is a picture of my 2.4 tft screen,
U2 and U3 are DP74HC245 FOR SDcard reader..

« Last Edit: April 26, 2017, 03:36:56 pm by topnullus »
 
The following users thanked this post: Mechatrommer

Offline dmills

  • Super Contributor
  • ***
  • Posts: 2093
  • Country: gb
Re: 2.4 tft screen ILI9342 problems, help me please !
« Reply #1 on: April 26, 2017, 01:03:47 pm »
None of that stuff is hard to fix (Unless you are doing video, then those ILI chips are a pain in the arse).

the MADCTL command has bits for memory readout direction setting this register appropriately will get your text the right way around (Page 127 of the datasheet).

There is a display invert on command that fixes the negative image (We found the the IPS panels we use needed this while the TFT did not), but it probably depends on how the panel is wired to the chip.

No idea about your libraries I just wrote my own.

Regards, Dan.
 
The following users thanked this post: topnullus

Offline topnullusTopic starter

  • Newbie
  • Posts: 7
  • Country: fr
Re: 2.4 tft screen ILI9342 problems, help me please !
« Reply #2 on: April 26, 2017, 03:17:43 pm »
Thank you Dan for your answer.

I use google translate to understand you.

It is a good new about "None of that stuff is hard to fix (Unless you are doing video, then those ILI chips are a pain in the arse)." bacause I do not want use video.
But for me, it is not so easy. I study C and COBOL 30 years ago, not c++ and I do not know POO.

With sketch "spfd5408_graphicstest.ino" extracted from library "SPFD5408-master.zip"

This is normal screen in landscape


The same code give me this ...


« Last Edit: April 26, 2017, 03:35:58 pm by topnullus »
 

Offline bktemp

  • Super Contributor
  • ***
  • Posts: 1616
  • Country: de
Re: 2.4 tft screen ILI9342 problems, help me please !
« Reply #3 on: April 26, 2017, 08:06:22 pm »
Every reputable manufacturer should provide the register settings for the display.
This is really important, because every display is a bit different, requiring different voltage levels and timings. Using the code from a similar display often works, but colors are often slightly off (wrong gamma, reduced contrast and many other problems like image sticking).

If you didn't draw the faint horizontal stripes in the first image on purpose, it looks like some settings are completely wrong.
But I have no idea how to fix this, only the manufacturer knows the correct settings.
That's what you get when you buy a cheap display, you get what you pay for: You have to figure out the best settings yourself (and that is nearly impossible without being an expert, knowing exactly what you are doing). The only thing you can do is trying many different codes and using the one that gives the best colours (display a grayscale bar and look for an even gradient with a good dark and white colour).

Inverting the display can be done by setting the REV bit in DISCTRL register (or changing the bit from the current setting).
Mirroring/rotating the display by 180° can be done by changing the MX/MY bits in MADCTL. Setting the MV bit is neccessary if you want to switch from landscape to portrait mode.
 
The following users thanked this post: topnullus

Offline topnullusTopic starter

  • Newbie
  • Posts: 7
  • Country: fr
Re: 2.4 tft screen ILI9342 problems, help me please !
« Reply #4 on: April 28, 2017, 04:33:06 pm »
Thank you Dan for your answer.

I use google translate to understand you.

I search DISCTRL or REV in *.h an d *.ccp for setting the REV bit in DISCTRL register , but I find nothing.

Mirroring is not same as rotating.
« Last Edit: April 28, 2017, 10:13:10 pm by topnullus »
 

Offline madires

  • Super Contributor
  • ***
  • Posts: 7765
  • Country: de
  • A qualified hobbyist ;)
Re: 2.4 tft screen ILI9342 problems, help me please !
« Reply #5 on: April 28, 2017, 04:48:05 pm »
The controller offers comands to rotate the screen by 90°, to flip the screen horizontally and to flip it vertically. So check the lib you're using for those commands and try them.
 
The following users thanked this post: topnullus

Offline topnullusTopic starter

  • Newbie
  • Posts: 7
  • Country: fr
Re: 2.4 tft screen ILI9342 problems, help me please !
« Reply #6 on: April 28, 2017, 07:35:53 pm »
Thank you madires for your answer.

I use google translate to understand you.

tft.setRotation(int x) rotate screen x*90°.

I do not found something to flip screen.

on datasheet of ili9342  § 8.2.6 (page 92), there is something about command , parameter , Left to right , Reverse mode , BGR or RBG

How can I read and modify or write theese data ?

In my file, I only find that :

#define MADCTL  0x36
#define MADCTL_MY  0x80
#define MADCTL_MX  0x40
#define MADCTL_MV  0x20
#define MADCTL_ML  0x10
#define MADCTL_RGB 0x00
#define MADCTL_BGR 0x08
#define MADCTL_MH  0x04

« Last Edit: April 28, 2017, 07:43:48 pm by topnullus »
 

Offline topnullusTopic starter

  • Newbie
  • Posts: 7
  • Country: fr
Re: 2.4 tft screen ILI9342 problems, help me please !
« Reply #7 on: April 28, 2017, 09:52:18 pm »
after a very lot of test, by changing value of MADCTL_MY  MADCTL_MX   MADCTL_MV   MADCTL_ML  MADCTL_RGB  MADCTL_BGR define MADCTL_MH 

add this line  writeRegister8(INVERTON, 0);

switched value of #define TFTWIDTH   240  #define TFTHEIGHT  480

now, ladies and gentlemen, I have what I need ! :phew:

tomorrow
- I shall test trace line, circle etc,
- I shall test tactile, 
- I shall test draw or paint,
- I shall test to show bipmap from sdcard.

I hope I make the more difficult by configuring right the "driver".
« Last Edit: April 29, 2017, 07:57:54 am by topnullus »
 

Offline topnullusTopic starter

  • Newbie
  • Posts: 7
  • Country: fr
Re: 2.4 tft screen ILI9342 problems, help me please !
« Reply #8 on: April 29, 2017, 07:56:39 am »
I am sad, I have not solved my problem.  |O

I test tactile and I have only bad (x,y) nothing about pressure (z) ...

I test sd card and it is good for read it and list repertories\files
I can load a picture, color and orientation are good.
But if I want rotate it, result is bad.
If I restore originals values
#define MADCTL  0x36
#define MADCTL_MY  0x80
#define MADCTL_MX  0x40
#define MADCTL_MV  0x20
#define MADCTL_ML  0x10
#define MADCTL_RGB 0x00
#define MADCTL_BGR 0x08
#define MADCTL_MH  0x04
Color and rotate are good, but picture are mirored.
Maybe I have only one value to change miror whith writing in register, but witch, where and how ?

 

Offline bktemp

  • Super Contributor
  • ***
  • Posts: 1616
  • Country: de
Re: 2.4 tft screen ILI9342 problems, help me please !
« Reply #9 on: April 29, 2017, 09:02:19 am »
For ILI9342 TFTWIDTH should be 320 and TFTHEIGHT should be 240.
Do not change ILI9341_MADCTL_MV anywhere in the code, otherwise it will break the drawing functions of the lib.
If the image is still mirrored after using setRotation() with parameters 0 or 2, you need to add | ILI9341_MADCTL_MY in line 778 and 781 and | ILI9341_MADCTL_MX in line 784.
This should mirror the image.

I doubt writeRegister8(INVERTON, 0); works, because the first parameter is the register address and the second one are the register settings. The REV bit is in DISCTRL register, this register needs 4 parameter bytes, so you need to use writeRegister32 function like so:
writeRegister32(ILI9341_DISPLAYFUNC, 0x0A822704);
This should invert colours.
 

Offline topnullusTopic starter

  • Newbie
  • Posts: 7
  • Country: fr
Re: 2.4 tft screen ILI9342 problems, help me please !
« Reply #10 on: May 08, 2017, 11:41:31 am »
I doubt writeRegister8(INVERTON, 0); works, because the first parameter is the register address and the second one are the register settings.

I retreive web where I find it
http://electronicopen.blogspot.fr/2016/08/interface-arduino-uno-clone-with-24-tft.html
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf