cancel
Showing results for 
Search instead for 
Did you mean: 

snprintf on wildcard only once

Msolinas
Senior

Hi friends, I have this problem:

static uint16_t txt[10];

Unicode::snprintfFloat(txt,6U,"%0.2f",functionGetFloat());
Unicode::snprintf( TextIndicatorBuffer,TEXTINDICATOR_SIZE,"%s %s",TypedText(T_STATEPRODUCTMANAGERWC5).getText(),txt);
TextIndicator.setWildcard(TextIndicatorBuffer);
TextIndicator.invalidate();
 
this work only once, after calling this function the second once, nothing change... some hint? thanks..
 
 
16 REPLIES 16
JTP1
Lead

Hello

Basically this should work, if your 'functionGetFloat' is returning different number every time and returned value fits to 6 char wide buffer.

This is probably not needed:

TextIndicator.setWildcard(TextIndicatorBuffer);

But you can add resizing before invalidating if text area is not enough wide:

TextIndicator.resizeToCurrentText();

Br: J.T

Hi jpt1, thanks for answer.

I alternate in the same place calling text in memory like:

TextIndicator.setTypedText(TypedText(T_STATEPRODUCTMANAGERWC4));

I tried any form of solution in the hint list.

In first attempt the text change in right mode, but after the first call, it not appair over. In debug the function get called, but no showing changes on text on screen.

calling passages over 

TextIndicator.setTypedText(TypedText(T_STATEPRODUCTMANAGERWC4));

or

TextIndicator.setTypedText(TypedText(T_STATEPRODUCTMANAGERWC6));

change, but trough sprintf only once and stop... i tried your solution and more other but with no luck.

PS:

if I use 

TextIndicator.resizeToCurrentText();
It shift position losting central justified text position and do not resolve my problem, becose make the same issue.... appair only once and stop to work.

OK. What if you remove static from txt[10]- declaration ? (maybe optimization cause this issue)

I guess your TEXTINDICATOR -buffer is enough big ?

JTP1, thanks for your reply and your help.

The buffer is very big, I changed txt in NO static, nothing change, was in optimization O1, I changed to O0... nothing change, from text to text work, but snprintf only once. If I return in back to previous screen, it work once again, but only one change... after nothing. I think this is a touchgfx architecture or widjet problem... maybe... or I need to clear something before write back in wildcard buffer???!!

 

Which tgfx version you are using ? Actually I put you code to some test project in 4.21.4 and it worked fine. It should not be necessary to do any operations. What if you remove the typed text and snprint only one string (txt), how it then works ? 

I working on 4.21.4 like your. I tried with only snprintf and a simple string NO float... same proble.. I can be crazy now friend... thanks for your efforts

 

this is a screenshot of the point:

Msolinas_0-1689587346656.png

As you can see, is a state machine that change simply the string value in screen after 2 temporized situations...

 

PS: TEXTINDICATORSIZE is 150 char... and usually I use no more then 50 char.

JTP1
Lead

Weird, I test it now also in target, earlier just in simulator.. still works. Maybe you can share some code more ?

JTP1: Maybe you can share some code more ?

Is difficolt, is big project... but for explane, everyting work propely, is only this point and this feature...