2.4 tft screen ILI9342 problems, help me please ! - Page 1
Forum section: electronics / general

author: topnullus
author_rank: Newbie
timestamp: April 26, 2017, 12:21:30 pm
content: Hello,sorry for my poor english.ILI9342 is for screen 320 x 240 pixels (WxH) andILI9341 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 screenThis library "SPFD5408-master.zip" for ILI9341 come fromhttps://github.com/JoaoLopesF/SPFD5408Now, datasheet are too technical for me.datasheet for ILI9341 :http://www.buydisplay.com/download/ic/ILI9341.pdfdatasheet for ILI9342 :http://www.buydisplay.com/download/ic/ILI9342.pdfCan you help me :- finding library working wellor- understanding datasheetor- 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..

author: dmills
author_rank: Super Contributor
timestamp: April 26, 2017, 01:03:47 pm
content: 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.

author: topnullus
author_rank: Newbie
timestamp: April 26, 2017, 03:17:43 pm
content: 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 landscapeThe same code give me this ...

author: bktemp
author_rank: Super Contributor
timestamp: April 26, 2017, 08:06:22 pm
content: 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.

author: topnullus
author_rank: Newbie
timestamp: April 28, 2017, 04:33:06 pm
content: 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.

author: madires
author_rank: Super Contributor
timestamp: April 28, 2017, 04:48:05 pm
content: 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.

author: topnullus
author_rank: Newbie
timestamp: April 28, 2017, 07:35:53 pm
content: 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 aboutcommand,parameter,Left to right,Reverse mode,BGRorRBGHow 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

author: topnullus
author_rank: Newbie
timestamp: April 28, 2017, 09:52:18 pm
content: after a very lot of test, by changing value of MADCTL_MY MADCTL_MX MADCTL_MV MADCTL_ML MADCTL_RGB MADCTL_BGR define MADCTL_MHadd this line writeRegister8(INVERTON, 0);switched value of #define TFTWIDTH 240 #define TFTHEIGHT 480now, ladies and gentlemen, I have what I need !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".

author: topnullus
author_rank: Newbie
timestamp: April 29, 2017, 07:56:39 am
content: I am sad, I have not solved my problem.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\filesI 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 0x04Color 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 ?

author: bktemp
author_rank: Super Contributor
timestamp: April 29, 2017, 09:02:19 am
content: 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.

author: topnullus
author_rank: Newbie
timestamp: May 08, 2017, 11:41:31 am
content: Quote from: bktemp on April 29, 2017, 09:02:19 amI retreive web where I find ithttp://electronicopen.blogspot.fr/2016/08/interface-arduino-uno-clone-with-24-tft.html