Teensy 3.1 ILI9341_t3 lib questions

Status
Not open for further replies.

joey120373

Well-known member
First off, wonderfull library!

I have a teensy 3.2 and the Adafruit 2.8 Cap touch display, working great.

I have a couple of questions about displaying text on this screen,

1, Is there an elegant way of aligning or centering text on a fixed point, i.e. the top center of the screen.? Right now i am printing a float, in the top center of the screen, say its "99.99". As soon as i want to increase that to 100.00, i have to do all kinds if nasty looking code to reset the cursor location so that the text will stay centered. It would be awesome if i could get the text to just automatically center.

2, This also ties in with #1, Clearing text. I am sure anyone who has used this library quickly figures out that updating text on the screen without erasing the previous line of text leads to some alien looking text. I have used 2 solutions for this, one involves drawing a filled box the same color as the background, and sized appropriately to cover the "old" text, just before writing the "new" text.
The second is writing the "old" text using the same color font as the background, then changing the color back and printing the "new"text.

Now doing this is just ugly and complicated, especially when having to do both in tandem.

any sugestions?

Thanks, Joe
 
Thanks blackketter, I will give that a shot.

Off topic a little, I started playing around with the Embed IDE today, using a Nucleo xxx401re ( their part numbers are nowhere near as fun as teensy X.X...).
I found a library that included the ILI9431, wires it up and it works. I was interests ted to see if it exhibited the same behavior, as far as I can tell it does not. Updated text appears just as one would hope.
I doubt I will use this, it's still no where near as intuative to program as the teensy, nor is it as well documented, at least for a novice like me. I do like the drag and drop programming though, while its one more step compared to the arduino/teensy loader, being able to update firmware without having to install an IDE ( thinking end user here ) is pretty meet.
 
1, Is there an elegant way of aligning or centering text on a fixed point, i.e. the top center of the screen.? Right now i am printing a float, in the top center of the screen, say its "99.99". As soon as i want to increase that to 100.00, i have to do all kinds if nasty looking code to reset the cursor location so that the text will stay centered. It would be awesome if i could get the text to just automatically center.

Tried using sprintf() or snprintf() with a format spec for the float? Such as "The value is %5.2f" to get leading space. You may need a fixed width font like Courier to keep things from moving around.

see
http://www.cplusplus.com/reference/cstdio/printf/
http://www.codingunit.com/printf-format-specifiers-format-conversions-and-formatted-output
 
Just to add some comment to this. I am also using the ILI9341_t3 library. Highly recommended. I wasted a few minutes getting the clipping right, due to getting exciting. In order to fit a 24 Hour clock with Arial 96 Point on a 320x240 screen aligned, I needed to draw the two first numbers, then a colon, finally the last two digits. All starting at a fixed x,y position. Looks rather good at the moment.

So, apart from the elegant solution proposed by stevech, I just did it the hard way. Good luck.
 
Do you have any examples of how drawText() is used to eliminate flicker?
My version draws the background color and the foreground color for each character without drawing the same pixels twice. The old character drawing code only draws the foreground, so you'd need to clear the whole character to the background color and then draw the foreground color on top of that.
 
Status
Not open for further replies.
Back
Top