Skip to main content
ALuiz.1
Associate II
November 28, 2022
Question

Pass string to a function

  • November 28, 2022
  • 2 replies
  • 1119 views

I need to pass a 6 characters string to a function in a custom container, but the string is cut to 4 characters.

The function is called in the screen where the container is, like this: container.function(str). 

If I pass a string smaller than 5 characters it works ok, but greater not. I'm sure at this moment the 6 characters string is complete.

In the custom container the string and the function are defined as follows:

 Unicode::UnicodeChar str[7];

 function (Unicode::unicodechar * str);

Is there a limitation to pass strings greater than 4 characters in TouchGFX? How could I solve it?

Thanks.

This topic has been closed for replies.

2 replies

Osman SOYKURT
ST Technical Moderator
December 1, 2022

Hello ALuiz.1,

I've tested to show logs with a function in a container with a string given by my main screen. I don't reproduce the error you describe. You'll find attached an example of how I get a string with my container.

Do want to use it on a text Area in your container? If yes, what did you put as your buffer size in your wildcard ?

/Osman

ST Software Developer | TouchGFX
ALuiz.1
ALuiz.1Author
Associate II
December 5, 2022

Thanks for the answer.

I solved the problem changing the type of the variable passed.

In screen I created an uint8_t buffer and I used the commands:

Unicode::toUTF8(str, buffer, 7);
container.function((char *)buffer);

In custom container I did:

function(char * str)
{
 Unicode::fromUTF8((uint8_t *)str, localBuffer, 7);
   ...
}