freetronics / FTOLED

Arduino software library to drive OLED display modules
http://www.freetronics.com/oled128
GNU General Public License v3.0
26 stars 18 forks source link

Negative values in drawString (X & Y) doesn't work #8

Open IAmOrion opened 4 years ago

IAmOrion commented 4 years ago

If I wanted to animate text into view by a loop - starting with text at a Negative value, or in my case, show dynamic strings that may have a space in front of them. By using the stringWidth function, I'm getting the width of the string and then setting the cursor position so that the text would be centered. When there text string (including the empty space at the beginning of the string) is wider than the 128 display, in order for the text to be centered I need it to start at X pos -3. However, if I use any negative value for X it doesn't work - nothing shows on screen.

This is also a method used to avoid the need for a clear screen call and thus less flickering etc (By providing a space before and after the string to ensure there's no "overlapping" of text from the previous draw)