Does anyone know how to set the orientation on the screen has to have the color palette on the bottom of the screen. In the header file is says "void setOrientation(unsigned int HV). I have no clue what HV means.
At a guess HV might stand for Horizontal or Vertical try 0 or 1 values?
Hi,
how this Tft.setOrientation feature should be used in practise? I have tried with 0 and 1 without any change for orientation.
I have Arduino 1280 and Seeedstudio 2.8" TFT with touch. I’m using TFT.h ver 1.1 library and all examples are working fine. The shield is connected directly to board.
Regards,
-Teme
Tried the same thing and nothing worked, but this is what’s wrote in the cpp file.
void TFT::setOrientation(unsigned int HV)//horizontal or vertical
{
sendCommand(0x03);
if(HV==1)//vertical
{
if(IC_CODE == 0x5408) { sendData(0x1038); }
else { sendData(0x5038); }
}
else//horizontal
{
if(IC_CODE == 0x5408) { sendData(0x1030); }
else { sendData(0x5030); }
}
sendCommand(0x0022); //Start to write to display RAM
}
You will need to look at the controller IC data (ST7781) and see if the commands are correct. I had a quick look but there is no obvious reference to orientation. There will be an option somewhere to
dictate how you right the GRAM.
Dale
setOrientation doesn’t work in draw character, or draw-fill rectangle because in that code they are hard banged into
setOrientation (1) == vertical Horizontal lines and Vertical lines are the same way.
No mater what you set orientation to, when they run they go vertical.
Shouldn’t HV be declared as a variable on the way in so that when you setorientation all else goes with it –
characters rotate – lines and boxes rotate?
if not why is the code checking “if(HV==1)//vertical”
void TFT::setOrientation(unsigned int HV)//horizontal or vertical
{
sendCommand(0x03);
if(HV==1)//vertical
{
if(IC_CODE == 0x5408) { sendData(0x1038); }
else { sendData(0x5038); }
}
else//horizontal
{
if(IC_CODE == 0x5408) { sendData(0x1030); }
else { sendData(0x5030); }
}
sendCommand(0x0022); //Start to write to display RAM
}
Its probably just a bad library implementation. You maybe better of with one of these http://www.4dsystems.com.au/prod.php?id=133 and if you are patient, our
forthcoming shield to make things a bit easier http://gorillabuilderz.com.au/shop/lcd-shield/.
We will also be releasing our own LCD module with a very flexible library specifically for Arduino/chipKit Uno
users.
I am also stumped on changing the screen orientation.
I commented out the conditional statements and tried each of the four options one at a time and it did not make any change whatsoever.
I question whether the line
sendCommand(0x03);
is correct, since all of the other commands in the library have four-digit commands. I tried replacing it with 0x0003 with no effect though.
I took a look at the data sheet for the ST7781R (orientation is on page 93), but my kung fu is not strong enough to really decipher it.
It looks like the command, data, and write values in the library make sense though:
Entry Mode (R03h)
RS WRX RDX D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
1 ↑ 1 TRI DFM 0 BGR 0 0 HWM 0 ORG 0 I/D1 I/D0 AM 0 0 0
Default value 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0
AM: Sets the DRAM Update Direction
When AM = “0”, set the horizontal writing direction.
When AM = “1”, set the vertical writing direction.
When a window area is set by registers R50h ~R53h, only the addressed DRAM area is updated based
on I/D [1:0] and AM bits setting.
The difference between the 0x1030 and 0x1038 (orientation values in the library) in binary is that 4th bit (which is AM). But the TFT.init() function seems to set it to 1030, which strikes me that it should be horizontal by default. My display comes up in vertical by default.
I have no idea if I am reading any of this correctly. Does any of it make any sense?
Is there a way to confirm that the display driver is actually an ST7781R?
I created a quick program that I thought might read out the values written to the registers in question and it seems to work.
Below is my sketch:
[code]#include <stdint.h>
#include <TFT.h>
void setup()
{
Tft.init(); //init TFT library
Tft.setOrientation(1); // not that it does any good
unsigned int IC= Tft.readRegister(0); // Register 0x00, the IC_CODE
unsigned int OR= Tft.readRegister(3);// Register 0x03, Entry Mode
Serial.begin(9600);
Serial.println(IC, HEX); // display each as hex and binary
Serial.println(IC, BIN);
Serial.println(OR, HEX);
Serial.println(OR, BIN);
}
void loop()
{
Tft.drawString(“Done.”,0,0,2,WHITE);
}
[/code]
Below is the serial output from my display, purchased yesterday from Radio Shack:
7783
111011110000011
5038
101000000111000
By changing the Tft.setOrientation integer to 0 I see that the program is indeed writing 0x5030 to register 0x0003. I am not making any more sense out of the unit’s behavior now, but I hope that someone more knowledgeable than I can look at this info and help find a solution.
Thank you very much.
The Tft.setOrientation(1) should be -1 or 3 to make it landscape. Some items like buttons will be broken however
I have a similar problem, and I do not know how to solve it, I also purchased another TFT touch screen,
it is STONE 3.5 inch screen,
it can set the rotation of the screen at the very beginning of the creation of a new project, I think it is very convenient.