Skip to main content
kvkhekale
Associate III
February 26, 2019
Solved

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

  • February 26, 2019
  • 12 replies
  • 5612 views

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?

This topic has been closed for replies.
Best answer by Martin KJELDSEN
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.

12 replies

Jesper Ronnholm
Associate III
February 28, 2019

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
Principal III
March 5, 2019

Hi @kvkhekale​,

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

Best regards,

Martin

HHarj.1
Associate III
February 27, 2020

Hey,

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

ABeck.1
Associate III
April 7, 2020

HI,

how u solved this problm, plz share with me, I am also getting second character displayed.

HHarj.1
Associate III
February 28, 2020

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?

Martin KJELDSEN
Martin KJELDSENBest answer
Principal III
February 28, 2020
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.

HHarj.1
Associate III
February 28, 2020

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