cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGfx - Adding '%' as a Wildcard Character

TakenTheBacon
Associate III

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,

1 ACCEPTED SOLUTION

Accepted Solutions
TakenTheBacon
Associate III

Solved just after I posted! Had one too many '%' in the snprintf line apparently. '%d%' worked okay and +1 to the buffer size

View solution in original post

2 REPLIES 2
TakenTheBacon
Associate III

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

TakenTheBacon
Associate III

Solved just after I posted! Had one too many '%' in the snprintf line apparently. '%d%' worked okay and +1 to the buffer size