Frank's Random Wanderings

SSD1289 Landscape Mode & TFT Screen Rotation

SSD1289 TFT Display

A lot of the SSD1289 based TFT displays commonly available ship by default in portrait mode. Which is to say, 240 pixels across by 320 pixels deep. When you read the SSD1289 datasheet it would appear the chip defaults to landscape mode, however the display manufacturer can configure it however they like, and portrait mode is a common default.

Switching it to landscape mode isn’t as simple as it might appear. I had to do that recently for a project, and searching google, and various forums, I found I wasn’t the only one wondering how to accomplish it. With a little reading, trial & error I did work it out.

Here’s some simple C code to show one way of performing screen rotation on the SSD1289.

The above code maintains a variable to keep track of whether it’s in portrait mode (is_orientation_landscape = 0) or landscape mode (is_orientation_landscape = 1). The above code also writes the “magic numbers” to the SSD2390 registers; read the SSD1289 datasheet to understand what those numbers mean. The macros TFT_CS_0 and TFT_CS_1 are simply for controlling the TFT ChipSelect line.

The reason for the is_orientation_landscape variable becomes clear in the code below.

The TFT_Set_Address() function is heavily used to set the corners of the “box” that subsequent pixels will be drawn into. When in landscape mode the X & Y positions must be transposed. Effectively, (X1, Y1, X2, Y2) in portrait mode becomes (Y1, X1, Y2, X2) in landscape mode. In landscape mode, as should be obvious, resolution is now 320 pixels across (X direction) by 240 pixels down (Y direction).

That’s it. With these changes, the SSD1289 can be easily flipped between portrait and landscape mode.

Leave a Reply

Your email address will not be published. Required fields are marked *