# Portrait Orientation

**URL:** <http://forum.squareline.io/t/portrait-orientation/1637>\
**Category:** How to\
**Created:** [August 10, 2023, 3:26pm UTC](http://forum.squareline.io/t/portrait-orientation/1637 "2023-08-10T15:26:11Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![bcuervo](http://forum.squareline.io/user_avatar/forum.squareline.io/bcuervo/32/772_2.png) [@bcuervo](http://forum.squareline.io/u/bcuervo)\
**Post date:** [August 10, 2023, 3:26pm UTC](http://forum.squareline.io/t/portrait-orientation/1637/1 "2023-08-10T15:26:11Z")

</div>

I’m trying to rotate my display image from landscape to portrait. When this is done in the SLS project settings it works fine in the user interface but has no effect on the actual display. When I change the orientation in the Arduino code, ui.ino, using the tft.setRotation( ) function, the image rotates but becomes scrambled as shown below.  
Does anyone know how to get a portrait image on their display?

 ![Orientation](http://forum.squareline.io/uploads/default/original/1X/b92bab756fd003ba6c0e100eb99f8bdd694ac8fd.jpeg)

---

<div class="post-metadata">

**Author:** ![bcuervo](http://forum.squareline.io/user_avatar/forum.squareline.io/bcuervo/32/772_2.png) [@bcuervo](http://forum.squareline.io/u/bcuervo)\
**Post date:** [August 15, 2023, 4:49pm UTC](http://forum.squareline.io/t/portrait-orientation/1637/2 "2023-08-15T16:49:42Z")

</div>

I got a new display, tried to rotate the image from landscape to portrait and still have the same problem with the image being distorted.  
I’m sure someone at SLS or in the community has run into this problem or knows a solution.  
Any help?

Thanks,  
Bryan

 ![Picture1](http://forum.squareline.io/uploads/default/original/1X/4ca6af2977f55f0d6107c09709fdf65ae6ef0cfc.jpeg)

---

<div class="post-metadata">

**Author:** ![Marian\_M](http://forum.squareline.io/letter_avatar_proxy/v4/letter/m/4af34b/32.png) [@Marian\_M](http://forum.squareline.io/u/Marian_M)\
**Post date:** [August 15, 2023, 5:42pm UTC](http://forum.squareline.io/t/portrait-orientation/1637/3 "2023-08-15T17:42:13Z")

</div>

Squareline now support only one orientation resp. too 180 flip for rectangle displays.  
All orientation is possible on square or round displays with same width and height.

But if your plan is only portrait you can use it, but need more steps as set orientation.

---

<div class="post-metadata">

**Author:** ![bcuervo](http://forum.squareline.io/user_avatar/forum.squareline.io/bcuervo/32/772_2.png) [@bcuervo](http://forum.squareline.io/u/bcuervo)\
**Post date:** [August 15, 2023, 6:10pm UTC](http://forum.squareline.io/t/portrait-orientation/1637/4 "2023-08-15T18:10:51Z")

</div>

Thanks Marian.

Does anybody know that steps to take to change the physical display orientation from landscape to portrait?

---

<div class="post-metadata">

**Author:** ![Marian\_M](http://forum.squareline.io/letter_avatar_proxy/v4/letter/m/4af34b/32.png) [@Marian\_M](http://forum.squareline.io/u/Marian_M)\
**Post date:** [August 15, 2023, 6:19pm UTC](http://forum.squareline.io/t/portrait-orientation/1637/5 "2023-08-15T18:19:18Z")

</div>

Your images dont show what you plan. For example your project is now configured  
320x240.

1. 320x240 hw driver for display in config driver and SQUARELINE project
2. 320x240 sw driver config in ino setup part and flush
3. set orientation maybe 0 for hw

If you change only 3 result is as you see.  
If you change 2 and 3 to 240 x 320 then image will ok but cut part because design is landscape.  
Then for ok you need complete 123 change to 240 x 320 and orientation 3

---

<div class="post-metadata">

**Author:** ![bcuervo](http://forum.squareline.io/user_avatar/forum.squareline.io/bcuervo/32/772_2.png) [@bcuervo](http://forum.squareline.io/u/bcuervo)\
**Post date:** [August 15, 2023, 8:43pm UTC](http://forum.squareline.io/t/portrait-orientation/1637/6 "2023-08-15T20:43:59Z")

</div>

With your help I got there 😀

Here is a quick explanation for others working in the Arduino environment…

**Changing orientation from landscape to portrait:**

Leaving the screen and width settings as shown.  
static const uint16\_t screenWidth = 320;  
static const uint16\_t screenHeight = 240;

But changing tft.setRotation () to tft.setRotation (3) or tft.setRotation (1) gives you landscape or the landscape flipped 180 deg. Changing to (0), (2) or (4) rotates the screen to portrait but the image is scrambled as shown in the previous post.

Switching the screen and width settings as shown.  
static const uint16\_t screenWidth = 240;  
static const uint16\_t screenHeight = 320;

And changing tft.setRotation () to tft.setRotation (2)

Gets me the portrait view I was looking for.  
 ![Portrait](http://forum.squareline.io/uploads/default/original/1X/c0e5b4f3dc11fd80fdc09abb6a5f4d31b0bff240.jpeg)

FYI, if I change the rotation 90 degrees (to give me a portrait view) in SLS, the SLS display rotates to portrait view but has no effect on the physical display.

 ![SLS rotate](http://forum.squareline.io/uploads/default/original/1X/c198a8d170c12c9e32c5f961a19d19060c49c0e2.jpeg)

---

<div class="post-metadata">

**Author:** ![Marian\_M](http://forum.squareline.io/letter_avatar_proxy/v4/letter/m/4af34b/32.png) [@Marian\_M](http://forum.squareline.io/u/Marian_M)\
**Post date:** [August 16, 2023, 5:15am UTC](http://forum.squareline.io/t/portrait-orientation/1637/7 "2023-08-16T05:15:27Z")

</div>

Yes this is only for WYSIWYG.

---

<div class="post-metadata">

**Author:** ![MarkTecWiz](http://forum.squareline.io/letter_avatar_proxy/v4/letter/m/ad7895/32.png) [@MarkTecWiz](http://forum.squareline.io/u/MarkTecWiz)\
**Post date:** [April 3, 2024, 1:43pm UTC](http://forum.squareline.io/t/portrait-orientation/1637/8 "2024-04-03T13:43:53Z")

</div>

I am using an Elecrow esp32 and the gfx driver  
This worked for me

```auto
disp_drv.drawbuf = 1; //added lines below here
disp_drv.sw_rotate - 1;
disp_drv.rotate = LV_DISP_ROT_90;
lv_disp_drv_register(&disp_drv); //added lines above here 

```

---

<div class="post-metadata">

**Author:** ![makershed](http://forum.squareline.io/letter_avatar_proxy/v4/letter/m/87869e/32.png) [@makershed](http://forum.squareline.io/u/makershed)\
**Post date:** [July 3, 2024, 6:36am UTC](http://forum.squareline.io/t/portrait-orientation/1637/9 "2024-07-03T06:36:56Z")

</div>

@MarkTecWiz is almost correct.

Here is the correct syntax:

```auto
    /*Initialize the display*/
    static lv_disp_drv_t disp_drv;
    lv_disp_drv_init(&disp_drv);
    disp_drv.hor_res = screenWidth;
    disp_drv.ver_res = screenHeight;
    disp_drv.flush_cb = my_disp_flush;
    disp_drv.draw_buf = &draw_buf;
    disp_drv.sw_rotate = 1; // If you turn on software rotation, Do not update or replace LVGL
    disp_drv.rotated = LV_DISP_ROT_90;
    disp_drv.full_refresh = 1; // full_refresh must be 1
    lv_disp_drv_register(&disp_drv);

```

Hope this helps!  
Yash

---

<div class="post-metadata">

**Author:** ![Hermit](http://forum.squareline.io/user_avatar/forum.squareline.io/hermit/32/971_2.png) [@Hermit](http://forum.squareline.io/u/Hermit)\
**Post date:** [July 3, 2024, 10:55am UTC](http://forum.squareline.io/t/portrait-orientation/1637/10 "2024-07-03T10:55:17Z")

</div>

The screen rotation must be set in the display driver in order to drive a portrait display instead of landscape one.

---

<div class="post-metadata">

**Author:** ![rettired\_badger](http://forum.squareline.io/user_avatar/forum.squareline.io/rettired_badger/32/1788_2.png) [@rettired\_badger](http://forum.squareline.io/u/rettired_badger)\
**Post date:** [April 15, 2025, 3:29am UTC](http://forum.squareline.io/t/portrait-orientation/1637/11 "2025-04-15T03:29:25Z")

</div>

I’ve tried for hours to get the portrait rotation figured out. Did everything I could do in the app, but it still was incorrectly rotated. Glad I signed up! This is exactly what I needed.
