cancel
Showing results for 
Search instead for 
Did you mean: 

Text with wildcard not working, help!

alanoatwork
Associate II

This is one of those problems where I spent more hours than I care to explain.

I've got a text box configured with a wildcard:

alanoatwork_0-1763053165324.png

In Designer, I've got a typography set to Voltage, 20px:

alanoatwork_1-1763053256250.png

Here's the typographies:

alanoatwork_2-1763053294492.png

Screen1ViewBase.cpp entry looks like this:

 

 
    textCellVoltage.setPosition(191, 0, 67, 24);
    textCellVoltage.setColor(touchgfx::Color::getColorFromRGB(255, 255, 255));
    textCellVoltage.setLinespacing(0);
    Unicode::snprintf(textCellVoltageBuffer, TEXTCELLVOLTAGE_SIZE, "%s", touchgfx::TypedText(T___SINGLEUSE_B9IA).getText());
    textCellVoltage.setWildcard(textCellVoltageBuffer);
    textCellVoltage.setTypedText(touchgfx::TypedText(T___SINGLEUSE_F28R));
    textCellVoltage.setVisible(false);
    ImplantData.add(textCellVoltage);

 

Screen1View.cpp looks like this:

void Screen1View::enableScreenElementsAfterInterrogation() {
	tab2.setAlpha(255);
	tab2.invalidate();

	textCellVoltage.invalidate();
	Unicode::snprintf(textCellVoltageBuffer, 20, "%s", "123");
	textCellVoltage.setWildcard(textCellVoltageBuffer);
	textCellVoltage.resizeToCurrentTextWithAlignment();
//	textCellVoltage.resizeToCurrentText()
	textCellVoltage.setVisible(true);
	textCellVoltage.invalidate();
}
 

However, when enableScreenElementsAfterInterrogation is called, I see ?3?.  I've tried using resizeToCurrentTextWithAlignment, but that gives the same result.

I must be doing something ridiculous, as this is slightly more difficult than printing "Hello world!".

Any help would be appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
ferro
Lead

Hi @alanoatwork 

Try to add 'u' prefix to the string as printf expects unicode

Unicode::snprintf(textCellVoltageBuffer, 20, "%s", u"123");

 

touchgfx\framework\include\touchgfx\Unicode.hpp

ferro_0-1763056353996.png

 

View solution in original post

3 REPLIES 3
ferro
Lead

Hi @alanoatwork 

Try to add 'u' prefix to the string as printf expects unicode

Unicode::snprintf(textCellVoltageBuffer, 20, "%s", u"123");

 

touchgfx\framework\include\touchgfx\Unicode.hpp

ferro_0-1763056353996.png

 

Yes, that works!  Thanks.  

Programming can sometimes be very frustrating and rewarding at the same time.

 

I know, it's a jungle !