2023-05-05 01:14 AM
Hey,
I'm trying to add '%' as a wildcard character for a value that will passed through as, for example, 50%, for a battery level in a status bar container.
I have the value set up as a single use resource that uses a topology where the wildcard range/characters are set as 0-9/% respectively, and is written via a buffer with sprintf, as follows:
Unicode::snprintf(txtBatteryBuffer, TXTBATTERY_SIZE, "%d%%", chargeLevel);
txtBattery.invalidate();
I believe the % should be appended to my chargeLevel int in the formatting of the string here. Unfortunately I only see the numbers in GUI and no '%' still.
Any advice would be much appreciated, perhaps my appending of % is wrong?
Thanks,
Solved! Go to Solution.
2023-05-05 01:42 AM
Solved just after I posted! Had one too many '%' in the snprintf line apparently. '%d%' worked okay and +1 to the buffer size
2023-05-05 01:17 AM
Just for further information: I do not add the '%' in TouchGfx itself (i.e <value>%) to avoid a horrible looking blank value appearing when switching screens where a new status bar is created each time, although this is still under investigation
2023-05-05 01:42 AM
Solved just after I posted! Had one too many '%' in the snprintf line apparently. '%d%' worked okay and +1 to the buffer size