# New programmer, display writing is not showing horizontal

**URL:** <https://forums.pimoroni.com/t/new-programmer-display-writing-is-not-showing-horizontal/20277>\
**Category:** Raspberry Pi\
**Created:** [September 12, 2022, 3:05pm UTC](https://forums.pimoroni.com/t/new-programmer-display-writing-is-not-showing-horizontal/20277 "2022-09-12T15:05:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![VortigernWolf](https://avatars.discourse-cdn.com/v4/letter/v/7993a0/32.png) [@VortigernWolf](https://forums.pimoroni.com/u/VortigernWolf)\
**Post date:** [September 12, 2022, 3:05pm UTC](https://forums.pimoroni.com/t/new-programmer-display-writing-is-not-showing-horizontal/20277/1 "2022-09-12T15:05:48Z")

</div>

Hi

I am completely new to this :).

I have a Pico W with the Display pack. I have put together a code that displays the Balls and Rainbow program. The problem I have is that the display writing is showing vertical but not horizontal along the length. Is anyone able to help me turn the writing around please?

import time  
import random

from picographics import PicoGraphics, DISPLAY\_PICO\_DISPLAY, PEN\_P8, PEN\_RGB565  
from pimoroni import RGBLED

display = PicoGraphics(display=DISPLAY\_PICO\_DISPLAY, pen\_type=PEN\_RGB565)

led = RGBLED(6, 7, 8)  
BLACK = display.create\_pen(0, 0, 0)

display.set\_backlight(1.0)

WIDTH, HEIGHT = display.get\_bounds()

# From CPython Lib/colorsys.py

def hsv\_to\_rgb(h, s, v):  
if s == 0.0:  
return v, v, v  
i = int(h \* 6.0)  
f = (h \* 6.0) - i  
p = v \* (1.0 - s)  
q = v \* (1.0 - s \* f)  
t = v \* (1.0 - s \* (1.0 - f))  
i = i % 6  
if i == 0:  
return v, t, p  
if i == 1:  
return q, v, p  
if i == 2:  
return p, v, t  
if i == 3:  
return p, q, v  
if i == 4:  
return t, p, v  
if i == 5:  
return v, p, q

h = 0

class Ball:  
def **init** (self, x, y, r, dx, dy, pen):  
self.x = x  
self.y = y  
self.r = r  
self.dx = dx  
self.dy = dy  
self.pen = pen

while True:

# initialise shapes

```
balls = []
for i in range(0, 50):
    r = random.randint(0, 10) + 3
    balls.append(
        Ball(
            random.randint(r, r + (WIDTH - 2 * r)),
            random.randint(r, r + (HEIGHT - 2 * r)),
            r,
            (14 - r) / 2,
            (14 - r) / 2,
            display.create_pen(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)),
    )
)
    
BG = display.create_pen(40, 40, 40)

for i in range(0, 100): #set how long balls bounce for
    display.set_pen (BG) #background colour for balls
    display.clear()

    for ball in balls:
        ball.x += ball.dx
        ball.y += ball.dy

        xmax = WIDTH - ball.r
        xmin = ball.r
        ymax = HEIGHT - ball.r
        ymin = ball.r

        if ball.x < xmin or ball.x > xmax:
            ball.dx *= -1

        if ball.y < ymin or ball.y > ymax:
            ball.dy *= -1

        display.set_pen(ball.pen)
        display.circle(int(ball.x), int(ball.y), int(ball.r))

    display.update()
    time.sleep(0.01)

for i in range(0, 300): #set how long Baloo displays for
    h += 1
    r, g, b = [int(255 * c) for c in hsv_to_rgb(h / 360.0, 1.0, 1.0)] # rainbow magic
    led.set_rgb(r, g, b) # Set LED to a converted HSV value
    RAINBOW = display.create_pen(r, g, b) # Set pen to a converted HSV value
    display.set_pen(RAINBOW)
    display.clear() # Fill the screen with the colour
    display.set_pen(BLACK) # Set pen to black
    display.text("Not displaying horizontal", 10, 10, 240, 3) # Add some text
    display.update() # Update the display
    time.sleep(1 / 500)

```

# initialise shapes

```
balls = []
for i in range(0, 50):
    r = random.randint(0, 10) + 3
    balls.append(
        Ball(
            random.randint(r, r + (WIDTH - 2 * r)),
            random.randint(r, r + (HEIGHT - 2 * r)),
            r,
            (14 - r) / 2,
            (14 - r) / 2,
            display.create_pen(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)),
    )
)

for i in range(0, 50): #set how long balls bounce for
    display.set_pen (BG) #background colour for balls
    display.clear()

    for ball in balls:
        ball.x += ball.dx
        ball.y += ball.dy

        xmax = WIDTH - ball.r
        xmin = ball.r
        ymax = HEIGHT - ball.r
        ymin = ball.r

        if ball.x < xmin or ball.x > xmax:
            ball.dx *= -1

        if ball.y < ymin or ball.y > ymax:
            ball.dy *= -1

        display.set_pen(ball.pen)
        display.circle(int(ball.x), int(ball.y), int(ball.r))

    display.update()
    time.sleep(0.01)
for i in range(0, 300): #set how long Baloo displays for
    h += 1
    r, g, b = [int(255 * c) for c in hsv_to_rgb(h / 360.0, 1.0, 1.0)] # rainbow magic
    led.set_rgb(r, g, b) # Set LED to a converted HSV value
    RAINBOW = display.create_pen(r, g, b) # Set pen to a converted HSV value
    display.set_pen(RAINBOW)
    display.clear() # Fill the screen with the colour
    display.set_pen(BLACK) # Set pen to black
    display.text("how do I ", 10, 20, 240, 5) # Add some text
    display.text("get it horizontal?", 10, 90, 240, 7)
    display.update() # Update the display
    time.sleep(1 / 500)

```

Any advice gratefully recieved. Thank you in advance.

Vortigern

---

<div class="post-metadata">

**Author:** ![hel](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/hel/32/6075_2.png) [@hel](https://forums.pimoroni.com/u/hel)\
**Post date:** [September 12, 2022, 3:21pm UTC](https://forums.pimoroni.com/t/new-programmer-display-writing-is-not-showing-horizontal/20277/2 "2022-09-12T15:21:59Z")

</div>

You can add a sneaky `rotate=90 (or 180, or 270).`to the line when you set up your display to rotate it:

`display = PicoGraphics(display=DISPLAY_PICO_DISPLAY, pen_type=PEN_RGB565, rotate=90)`

You could also rotate the text if you don’t want to rotate the whole display - details in the `picographics` [docs](https://github.com/pimoroni/pimoroni-pico/tree/main/micropython/modules/picographics#drawing-text)!

---

<div class="post-metadata">

**Author:** ![VortigernWolf](https://avatars.discourse-cdn.com/v4/letter/v/7993a0/32.png) [@VortigernWolf](https://forums.pimoroni.com/u/VortigernWolf)\
**Post date:** [September 12, 2022, 3:32pm UTC](https://forums.pimoroni.com/t/new-programmer-display-writing-is-not-showing-horizontal/20277/3 "2022-09-12T15:32:22Z")

</div>

Thank you very much. That was the command I needed.
