cancel
Showing results for 
Search instead for 
Did you mean: 

How to print a string on the display using wildcard in touchgfx?

kvkhekale
Associate II

Hello,

I am preparing a keypad project in touchgfx.

Basically I need to print integer and fraction values on LCD screen through keypad.

However, since touchgfx generates a wildcard as uint16_t, I am not able to put the value inside a buffer and giving it in the string form to snprintf, so as to print it on the screen.

How can I generate a wildcard variable in char* format, instead of uint16_t format?

1 ACCEPTED SOLUTION

Accepted Solutions
Unicode::strncpy(buffer, "helloworld", NR_OF_CHARS+1); //buffer belongs to textArea
textArea.resizeToCurrentText(); //resize if necessary
textArea.invalidate(); //invalidate to render new text

 Ensure that you have generated glyphs for "h", "e", "l", "o", "w", "d" by adding them to the wildcard list in your Texts settings in the designer.

View solution in original post

12 REPLIES 12
Jesper Ronnholm
Associate III

If you're only after printing integer wildcards, you could probably use the "itoa" function in the Unicode class (integer to ascii conversion). Then you just need to reference the wildcard buffer.

Just remember to invalidate the textArea widget when you want it to render a new value.

Martin KJELDSEN
Chief III

Hi @kvkhekale​,

You can use Unicode::strncopy() to copy a string (char*) to a Unicode::UnicodeChar* buffer.

Best regards,

Martin

Hey,

could you elaborate this please...I'm getting now every second character displayed and can't get this working properly. Thanks!

HHarj.1
Senior

Bump. I'm repeating the original question posted a year ago: How to print a string on the display using wildcard in touchgfx?

The answer was to use strncpy, but I have kept trying to use it but no success. I have Anyone who could show how to do it?

Unicode::strncpy(buffer, "helloworld", NR_OF_CHARS+1); //buffer belongs to textArea
textArea.resizeToCurrentText(); //resize if necessary
textArea.invalidate(); //invalidate to render new text

 Ensure that you have generated glyphs for "h", "e", "l", "o", "w", "d" by adding them to the wildcard list in your Texts settings in the designer.

Ok, thank you. I thought I couldn't do even that right, but there is something else then because...0690X00000DXXFWQA5.png I was still not getting it right, so instead of my char array I put test string "Fail" in there, and the display shows ?a?l

You're missing "F" and "i" in your text sheet as wildcards - TouchGFX does not know what to generate for you if its not a static text. Does that make sense? It's just trying to save you some flash space by only generating what you need. The reason you have "a", for instance, is because it appears in some other static text so its already generated.

I updated the answer with: " Ensure that you have generated glyphs for "h", "e", "l", "o", "r", "w", "d" by adding them to the wildcard list in your Texts settings in the designer."

Sigh...I had put the range a-z, A-Z in wildcard characters...not in the wildcard range where they are supposed to be. That's why I wasted last two debugging. Unfortunately, I had some static text so I managed to show every other character which led me to think it's about Unicode vs Char thing. Ended up doing some weird zero-padding functions with still same result ofc...lol:grinning_face_with_sweat:

Common mistake :D haha