EEVblog Electronics Community Forum
Electronics => Microcontrollers => Topic started by: topnullus 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 (https://github.com/JoaoLopesF/SPFD5408)
Now, datasheet are too technical for me.
datasheet for ILI9341 : http://www.buydisplay.com/download/ic/ILI9341.pdf (http://www.buydisplay.com/download/ic/ILI9341.pdf)
datasheet for ILI9342 : http://www.buydisplay.com/download/ic/ILI9342.pdf (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..
(http://img4.hostingpics.net/pics/521282IMG20170423110406.jpg)
-
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.
-
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
(http://cyaninfinite.com/wp-content/uploads/2015/03/2_4_touch_shield_2.jpg)
The same code give me this ...
(http://img15.hostingpics.net/pics/198032IMG201704261708221.jpg)
-
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.
-
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.
-
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.
-
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
-
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".
-
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 ?
-
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.
-
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 (http://electronicopen.blogspot.fr/2016/08/interface-arduino-uno-clone-with-24-tft.html)