Hi, im using the Sainsmart 3.2" touch panel with UTFT. It uses the ITDB32S driver.
Wonder if there are any ideas... since the viewing angle is quite narrow with this panel, it would suit my project better if I could rotate and mount it the other way up, 180 degrees rotated.
This means I would need to either flip both axis or to rotate 180 degrees for the panel to view correctly.
Could not see in the drivers how to manage this task, only options are portrait or landscape. Any ideas?
Well being that everything other than characters can be seen upside-down, the print function provided in the UTFT library allows you to rotate the word(s).
print(String st, int x, int y, int deg) //0 - 359 degrees
Now the only thing I can see that you might have trouble with is the X and Y coordinates, and if so, you just need to subtract the correct screen values.
newX = (239 - X) , newY = (319 - Y)
newX = (319 - X) , newY = (239 - Y)
And if you knew how to make/modify the library in C++, you can make inverting the screen into a new function.
"void UTFT::InitLCD(byte orientation, byte invert)" //if invert = true, screen gets inverted 180 degrees, else screen is regular orientation
Thanks for the suggestion!
It had crossed my mind to calculate the alternative coords, didn't realise about the font rotation so that's useful. But also all RAW backgrounds will have to be pre-inverted as well as the icons... so, it can work but bit untidy.
I bet there is a much easier way to do it deeper down, as you pointed out also. I had a quick look at the code and currently it manages things differently for LANDSCAPE / PORTRAIT , so I really just want a new orientation option added, a modified LANDSCAPE which manages an X and Y flip.
Need to go through the code more and understand it, not familiar enough with it to have a crack just yet...
Had a play with the source earlier, particularly I wondered if there was some register on the LCD controller (SD1289) that might do it. Tried changing the ID and AM registers and it did sort of reverse things, like y-flipping each char in a text but not the order of the words....
Well worth a try but a non driver specific method would be better.
I tried re-setting up with the text rotated 180 degrees , and converting the coordinates, which did work but not without a new issue.
Looks like the time involved in rotating text is pretty high, so actually printing a screen full of stuff takes a lot longer with rotation.
My test app main loop was polling sub 1 second previously, and with the text rotation it was now polling every 4 seconds. Yikes!
Had to revert to the original code since its unworkable for text that is going to get regularly updated.
Hello, sorry for resurrecting this really old thread...! i have a sainsmart LCD 4.3, it's working perfectly and so is the touch and SD on it, so the project is successful and almost finished, but now i need to change the guts of it, and to make for less crucial space i have to rotate the LCD by 180degrees using it as landscape in UTFT...due to the SD card being on top and eating 2extra cm from the box. So the question remains, i mostly work with images loaded from SD, do i have to invert coordinates and images, or did anyone find another way by modding the library? if i have to mod it, does the URTOUCH library follow or do i have to mod it too?
thanks for your time!
You just change MX, MY or SS, GS.
UTFT has no concept of hardware rotation. You just get Portrait in the way that you want. Then Landscape is calculated in software.
Life is easier if you said which controller you have.
i've been reading as many threads as i could find and i knew it should be a software solution, that's why i didn't mention the controller. for the record, it's SSD1963, and works with the "ITDB43" declaration in UTFT.
i'll have a go at the MX, MY as you mentioned and let you know
You change SS and GS on a SSD1963 to control the geometry directions. e.g.
LCD_Write_DATA(0x22 ^ 0x03); //invert both SS and GS to rotate 180 degrees
You change MY, MX for the write directions. e.g. drawing a bitmap with hardware.
what can i say, as always, you're MAGIC!! pure magic! i just changed that and it worked perfectly, drawing bitmaps and text and all is now at the right place i didn't even have to change any printing locations! now on to invert the touch input
Why not use MCUFRIEND_kbv for your SSD1963 target?
It defaults to 800x480 but you can change it to 480x272 if you want.
Since you are probably a 16-bit write-only, you need a "special" driver.
And remember to tft.begin(0x1963)
Hey i thought mcufriend_kbv was only made for mcufriend boards... but i'm already using urtouch and utftbuttons libraries, don't they depend on UTFT?
You can do anything with the Adafruit GFX methods that you can do with UTFT.
Even Buttons and Proportional Fonts.
Yes, mcufriend_kbv is designed for the Uno shields. It can read the ID and work with over 20 controllers.
When you have a write-only shield, you have to enable special drivers.
#define USE_SPECIAL //check for custom drivers
Edit any sketches to force the ID for your write-only shield:
uint16_t ID = tft.readID(); //
if (ID == 0xD3D3) ID = 0x1963; // write-only shield
Note that regular Uno Shields will still work on the Uno.
However a Mega or Due will only work with the 16-bit Mega Shield.
No, I don't encourage punters to use non-Uno shields. You can imagine the amount of grief that would be caused. (especially if they can't even distinguish between a Mega shield and Uno shield)
I suggest that you just try the graphictest_kbv sketch and see for yourself.
This old thread has to be resurrected once again, just for the sake of sharing the knowledge.
I had a 2.2" LCD display with ILI9225 controller and was using a UTFT library with it. Everything works great but the orientation. By digging the datasheet I've discovered how would one rotate the screen in hardware.
In initlcd.c file for the ili9225 display driver I found the line
LCD_Write_COM_DATA(ILI9225_ENTRY_MODE, 0x1030); // set GRAM write direction and BGR=1.
And substituted the value 0x1030 for 0x1000. This flips the landscape orientation of the display. If you want portrait, or rotated-portrait, use a 0x1028 or 0x1018 values.
That's that. Sorry for necroposting, but in 2 years I could very well be that guy who's going to be googling on how to rotate this screen. (If you're me from the future then hi, future me.)
Yes, that is how you set the orientation of an ILI9225 / ILI9320 class of controller.
UTFT is very easy to "get working" on a new controller.
You just issue commands to get a correct Portrait mode. Any subsequent rotations are done in software.
Note that all controllers can use their hardware for all four rotations. There is no software speed penalty at all. UTFT concentrates on Universal rather than speed or efficiency.
LCD_Write_COM(0x00,0x03); LCD_Write_DATA(0x10,0x30); // set GRAM write direction and BGR=1.
LCD_Write_COM(0x00,0x20); LCD_Write_DATA(0x00,0x00); // GRAM horizontal Address
LCD_Write_COM(0x00,0x21); LCD_Write_DATA(0x00,0x00); // GRAM Vertical Address
LCD_Write_COM(0x00,0x50); LCD_Write_DATA(0x01,0x3F); // // Horizontal GRAM Start Address
LCD_Write_COM(0x00,0x51); LCD_Write_DATA(0x00,0x00); // Horizontal GRAM End Address//319
LCD_Write_COM(0x00,0x52); LCD_Write_DATA(0x00,0xEF); // Vertical GRAM Start Address
LCD_Write_COM(0x00,0x53); LCD_Write_DATA(0x00,0x00); // Vertical GRAM Start Address//239
LCD_Write_COM(0x00,0x60); LCD_Write_DATA(0xA7,0x00); //Driver Output Control (R60h)
I Changed the x0060 even to 2700 i mean gs and ss i changed i am unable to switch to portrait mode
I have no idea what controller you have.
UTFT has no concept of identifying the controller.
UTFT relies on the truthfulness of repected suppliers like ColdTears or Itead.
When you deal with Ebay or AliExpress the vendors are either ignorant or just lie.
The commands look like an ILI9320 class of controller. The SS and GS bits are normally in reg(0x60)
i am using lgdp4532 which is almost same as ILI9325
its coming like image attached below
i want to know on which command to rotate the display to landscape
i have tried gs and ss but still the address pointer is incrementing in same direction and printing like show in image
please help me solve that
this is how it looks like
Ok, so you have a display that is rendering in PORTRAIT_REV mode.
It seems to be a regular Mcufriend Uno Shield.
A shield is designed to plug into an Arduino. All the male pins mate with corresponding female socckets.
And your code and font looks like UTFT. UTFT has no concept of using TFT hardware. You simply create a single Portrait and UTFT moves everything in software.
I suggest that you develop your mating skills.
HI DAVID THANKS FOR INPUT
I AM USING ANOTHER CONTROLLER MSP430 NOT ARDUINO SO I AM UNABLE TO ROTATE I AM NOT USING SETROTATION FUNCTION HERE AND ALSO I AM NOT USING UTFT LIBRARY
SO IS THERE ANY COMMAND I CAN ROTATE THE DISPLAY