cancel
Showing results for 
Search instead for 
Did you mean: 

How do I display ASCII extended characters in TouchGFX? I create a character string in main.c and it displays good in TouchGFX. I use Unicode::strncpy to convert the character string for the wildcard buffer in TouchGFX.

MLync.1
Associate II

I am trying to display a temperature value and would like to include the degree symbol °. I have included this symbol in the typographies as a wildcard character. TouchGFX displays the string, but it inserts the fallback character and then the wildcard character. (72 ?°) Why is the fallback character being inserted?

4 REPLIES 4
Romain DIELEMAN
ST Employee

Hi,

If you put the symbol "°" (or any other) in wildcard character, you can display it by displaying an UnicodeChar array. You need to implement the correct ASCII code: in this case, ° = 0x00B0.

With the settings and the code below you will display the following message : The temperature is 28 °.

Watch out: you need have a text area large enough to display the message, so removing auto size and increasing the width could be a good idea (in the Text Area tab on the right side of the Designer tool).

0693W000001qDinQAE.png

Screen1View::Screen1View()  //replace with name of your screen
{
    Unicode::UnicodeChar a[] = {0x00B0,0};
    uint16_t degree = 28;
    Unicode::snprintf(textArea1Buffer, TEXTAREA1_SIZE, "%d %s", degree, a);
    textArea1.invalidate();
}

Otherwise the symbol "°" is already supported 😊, you don't have to do the above process . In the the documentation on text and fonts, this section's example tries to display a temperature, and sets the symbol "°" directly in the text section of the Text Area configuration tab.

/Romain

It took me a while to figure out how get the degree symbol be placed in the Designer. Maybe I am missing it, but the "this section's example" doesn't give a very good explanation on how to actually get the symbol in the designer. For anyone wanting to do this, hold down the Alt key and type the code 0176--This HAS to be done on the number key pad (with Num Lock on).

You are right to point out that solution, I didnt think that people would not have access to the degree symbol on their keyboard (french keyboards have the degree symbol).

You can also just copy/paste the ° symbol from anywhere to designer as well using the ctrl c and ctrl v shortcuts.

Thanks a lot for pointing that out, this is one of those solutions/shortcuts we forgot to explicitly write down, like pressing f5 to directly run the simulator.

wired
Senior III

On a Windows laptop with no numeric keypad or way to simulate it, such as my Dell Precision, the easiest way I found is to bring up the Character Map application, found in the Windows Accessories folder. You can Copy/Paste your symbol directly into Designer from it. No need to mess with Unicode characters in the C code.

From Resources:

0693W00000HpWapQAF.png