Skip to main content
Msolinas
Senior
July 16, 2023
Question

snprintf on wildcard only once

  • July 16, 2023
  • 5 replies
  • 3486 views

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..
 
 
This topic has been closed for replies.

5 replies

Graduate II
July 17, 2023

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

Msolinas
MsolinasAuthor
Senior
July 17, 2023

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.
Graduate II
July 17, 2023

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

I guess your TEXTINDICATOR -buffer is enough big ?

Graduate II
July 17, 2023

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

Msolinas
MsolinasAuthor
Senior
July 17, 2023

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... 

Graduate II
July 17, 2023

Okey,i think you must have

TextIndicator.setWildcard(TextIndicatorBuffer);

since in some machine states use setTypedText funtion. Place this setWildcard in the states you use wildcard buffer.

Msolinas
MsolinasAuthor
Senior
July 17, 2023

I tried, but not work, if you see, was in the first comment in the start. Everyting seems work in first attempt I call the machine, but from the second one not work... 

this work very well..

Msolinas_1-1689589853338.png

 

I considering to open a touchgfx ticket... really strange issue.

Graduate II
July 17, 2023

Sorry my brains are in holiday:grinning_face_with_sweat:

If you use setTypedText()- function in some machine state, you must return it also to the original single use id. Like this:

 

TextIndicator.setTypedText(touchgfx::TypedText(T___SINGLEUSE_IGD9));

 

Open your view-base.cpp and check singleuse ID there.

Maybe easier is to not use setTypedText, but do like this

 

Unicode::snprintf( TextIndicatorBuffer,TEXTINDICATOR_SIZE,"%s",TypedText(T_STATEPRODUCTMANAGERWC1).getText());

 

in the TIMING_ANSWER_HOLD, then the correct single-use ID stays.

Graduate II
July 17, 2023
Msolinas
MsolinasAuthor
Senior
July 17, 2023

Dear JTP1, I tried to change all lines in snprintf not using TextIndicator.setTypedText(blabla)... not work nothing at all! seems that if I use for this wildcard snprintf, after work once, it not will work over on this buffer.

if you look at the TIMING_ANSWER_HOLD, you can see the same for productSelectorCounter... and this work... 

Msolinas_0-1689593223800.png

 

It work onli the first called routine in this sequence... after stop .

 

Msolinas
MsolinasAuthor
Senior
July 24, 2023

hi JTP1, I not solved the problem, I don't know why but this not work in my code. for time restrict in the work, by now I changed all in a simple retTypedText