How do I rotate text on inkyphat?

I’m working on a thermometer display project with my inkyphat and the last thing I’m missing is text. I can print text alright with the python libs but since the thermometer is displayed in a portrait orientation the text is always angled 90 degrees.

I have found that PIL can perform a rotate and that a possible way for this to work would be to create a temp image, write text to it, rotate and paste into the inkyphat image.

How do I do this? I’m relatively new to Python and programming in general and can’t figure out how to call PIL/Pillow so it allows me access to what the inkyphat library itself is already doing.

Can anyone advise how to maybe achieve this? I would love to see the inkyphat library extended to support this out of the box. Would make text display a lot more versatile.

Hi there R0ckarong,
Within the documentation for the Inkyphat hat ( it lists inkyphat.set_rotation(r) as being part of the default library. I’m afraid I don’t have an Inkyphat to test this with, so I haven’t a clue whether this will work, but it seems it should fulfill your needs?

This command rotates the full display (and thus everything on it) by 180 degrees to set off the mounting position (usb on top or bottom). Unfortunately, it does not allow rotating single “elements” that you wish to draw on the display.

1 Like

Ah, OK. Thank you for enlightening me.
I’m not too familiar with epaper displays (well, not at all), so I’m afraid I won’t be able to help much in this matter!
My apologies.

Are you proficient in Python? Unfortunately my understanding is not deep enough to figure out how to use modules from the PIL library directly to interact with the display. The current library uses PIL as a basis but I don’t know how to integrate other methods into it for testing.

If you’re looking to simply use the PIL modules, then it should be as simple as importing PIL and calling the required functions. For example;

from PIL import Image, ImageDraw
`im ="hopper.jpg")`
draw = ImageDraw.Draw(im)
draw.line((0, 0) + im.size, fill=128)
draw.line((0, im.size[1], im.size[0], 0), fill=128)
del draw
# write to stdout, "PNG")

Helpfully provided from
For any of the other modules, have a look at some of the other examples seen at
Hopefully helpful. :)
And I’m moderately proficient in Python, though I’d prefer to have an Inkyphat to help properly without constantly asking you whether it works! Though I’m still happy to help as much as I can as long as you can bare my questions.

I’ve tried this. The problem is that here I don’t know what to pass to “” to load the buffer that represents the inkyphat display. The PIL functions are pretty clear to me but without knowing how to write them to the buffer for the display I can’t really use it.

The closest thing I can find is the file contained within the library folder of the Inkyphat instillation. It seems to deal with both PIL and the display on their own, namely;

  • from . import il91874

  • _panel = il91874.IL91874(resolution=(HEIGHT, WIDTH), h_flip=False, v_flip=True)

  • def show():
    """Display the current buffy on Inky pHAT."""
    for y in range(WIDTH):
    for x in range(HEIGHT):
    _panel.set_pixel(x, y, _image.getpixel((y, x)))

These all seem to set up the display and end up writing to the display somehow, but I’m afraid I’m nearing the end of my knowledge of this sort of stuff…
I’ll try and do some research myself and see if I can turn up anything that might actually help with your specific situation!

1 Like

OK, I think I have something here:
Here is a link to a forum discussion about rotating text in PIL:
Stenci posted a piece of example code which should, in theory, allow you to rotate your text to the desired angle.
After that, all you should have to do is use the inkyphat.set_image() in order to update your screen frame with image1 every however-long-you’d-like-your-FPS-to-be and wallah!
This solution causes a lot of issues though, like how to preserve not only the text but the thermometer as well, and the ridiculous loop you would potentially need in order to update the text every time you get a new value.
Looking at how complex this is now, it’s probably why Gadgetoid didn’t include it in the original inkyphat.text() function!
Have a go at just producing some rotated text using PIL and see if you can get any progress.

I played around with this exact thread solution two days ago and managed to
get a blank box drawn on top of my display but I didn’t manage to remember
what I did to make that work.

You appear to have me at a loss…
I’ll certainly keep trying to figure out some way of getting this working (probably by getting an Inkyphat sometime soon), but I think your best bet now will be that someone with more experience from the Pimoroni team like @Gadgetoid will be able to help!
I’ll be sure to keep you up to date with any ideas I come up with in the near future, but I think it’ll take more than my average time span to reply.

Btw. I got a response on GitHub and will try as soon as I get my inky back.