inkypHAT multi-line text

I have been very much taken with the inkypHAT from Pimoroni and was really excited when I got mine back in January 2018. For only £22 you get a full 212 x 104 three colour eInk display which produces great clear and crisp graphics and text.

There have been many projects I have wanted to make and my first was a name badge I wore to BETT back in January.

A second project I have been keen to make was a Bible verse a day display screen for my desk to give me encouraging verses during the day. I soon discovered that this wasn't going to be the easiest task as I needed a simple way of converting long strings to multi line text.

IMG_0728


If you would like a copy of the code it is available here on GitHub

This project can easily be used for other purposes and is very useful if you want to be able to display a long piece of text over the whole display at different font sizes. I have included a step which calculates the average character width for the current font so calculates automatically how many characters can fit onto one line and where to split the string into the correct line lengths.

Example 1: calculating the average character width and the number of characters which will fit on the display
Example 2: selecting a random verse from the list and splitting it into the correct length lines
Example 3: dealing with the ends of lines to ensure that split words have a dash

blog comments powered by Disqus