Is there a command to concatenate a string. If not, is there some way to find the length of a string or where it'll end. Hoping there is a way to do it so I don't have to hard code the set cursor command after every word or variable. Thanks.

You can use the command getFontWidth() to return the current font width, then calculate the length of your string, and multiply them to get the total width. Then compare with getLCDWidth() to check if the string fit on the LCD width. Below is the example. Hope this helps.

User mini profile

JP,
Is your code example correct? I did a test with the 5 x 7 font and found that getFontWidth() returns 5, which doesn't account for the extra pixel space between characters. At least for the 5 x 7 font, I think you have to multiply the string length by (uView.getFontWidth() + 1).

In the actual font file, there is no extra pixel space, so getFontWidth() returning 5 is technically correct.

Depending on how a user wish to display the text, if user is using print() then adding 1 to the getFontWidth() will get the desired result, if the user wish to drawChar() manually without extra pixel space, then getFontWidth() without adding 1 will be correct.

So it all depends on the situation. My example only serves as a basis for the explanation.