2023-02-17 06:30 AM
I am trying to pass text into the wildcard of a text:
---
// Container definition
DatenpunktFeldWert datenpunktFeldWertSchweissZeitSoll;
---
datenpunktFeldWertSchweissZeitSoll.setWertStr((touchgfx::Unicode::UnicodeChar*)L"23.4 s");
---
/*
* Wildcard Buffers
*/
static const uint16_t WERT_SIZE = 15;
touchgfx::Unicode::UnicodeChar WertBuffer[WERT_SIZE];
---
void DatenpunktFeldWert::setWertStr(touchgfx::Unicode::UnicodeChar* wertStr)
{
touchgfx::Unicode::snprintf(WertBuffer, WERT_SIZE, "%s", wertStr);
Wert.invalidate();
}
---
In Simulator this works perfectly:
However, only the 1st character is always shown on the display of the target.
What am I doing wrong?
Solved! Go to Solution.
2024-04-29 03:06 AM
Hello all,
Update :
An easier way is to use Unicode::strncpy instead to print string:
touchgfx::Unicode::strncpy(textAreaBuffer, "string", TEXTAREA_SIZE);
textArea.resizeToCurrentText(); // optional, will resize the box to fit the text if it's too small
textArea.invalidate();
Regards,
2023-02-17 06:44 AM
Hello @Roger.ch,
That is a behavior we are aware of.
To explain quickly there is some end of line code between every character composing your string. TouchGFX framework code reads your string, sees this special code, and then thinks that your string is over and only composed of this single character. We are discussing this problem internally and we'll try to improve the code to avoid those issues.
But for the moment you have 2 solutions:
You can either display your string as several char (with a for-loop for example), or you can use a float variable if you wanna display numbers in a wildcard, like :
touchgfx::Unicode::snprintf(WertBuffer, WERT_SIZE, "%f", wertStr);
Wert.invalidate();
I'd recommend the second option because it is easier to implement and more readable.
/Yoann
2023-02-17 07:12 AM
Hello Yoann
Thank you very much for your quick and competent help.
Best regards,
Roger
2024-04-23 02:08 AM
We're encountering the same issue where the simulator output appears correct, but only the first character is printed on the target.
We would greatly appreciate it if this problem could be addressed soon.
2024-04-29 03:06 AM
Hello all,
Update :
An easier way is to use Unicode::strncpy instead to print string:
touchgfx::Unicode::strncpy(textAreaBuffer, "string", TEXTAREA_SIZE);
textArea.resizeToCurrentText(); // optional, will resize the box to fit the text if it's too small
textArea.invalidate();
Regards,