Skip to main content
Seba
Associate
October 26, 2022
Question

getTextWidth() function returns wrong values only on target PCB.

  • October 26, 2022
  • 4 replies
  • 2791 views

A simple screen with one TextArea and one wildcard:

0693W00000VO9fPQAT.pngBelow is the code that updates the field in the wildcard and displays the total width of the text on the terminal.

The problem is that in the simulator the getTextWidth() function works correctly, while on the target PCB (STM32L4P5) the data is read incorrectly. Below is a screenshot from the terminal and the PCB.

void Screen1View::tick()
{
	counter++;
	if (counter > 10)
	{
		counter = 0;
		param++;
 
		Unicode::snprintf(textArea1Buffer, TEXTAREA1_SIZE, "%d", param);
 
#ifdef SIMULATOR
	touchgfx_printf("param: %d, getTextWidth: %u\n", param, textArea1.getTextWidth());
#else
	TRACE("param: %d, getTextWidth: %u\r", param, textArea1.getTextWidth());
#endif
 
		textArea1.invalidate();
	}
}

0693W00000VO9iFQAT.png0693W00000VO9jgQAD.pngAnyone had a similar problem? What could be the reason for this behavior?

This topic has been closed for replies.

4 replies

MM..1
Super User
October 26, 2022

Try place get print after invalidate.

Seba
SebaAuthor
Associate
October 26, 2022

I try invalidate() before and after getTextWidth() and the result is the same.

Seba
SebaAuthor
Associate
October 26, 2022

I found the reason why the getTextWidth() function is not working properly.

If I put the FontFlashSection in the external SPI FLASH memory then the getTextWidth() function returns wrong values:

 FontFlashSection :
 {
 *(FontFlashSection FontFlashSection.*)
 *(.gnu.linkonce.r.*)
 . = ALIGN(0x4);
 } >NOR_FLASH

If I put the FontFlashSection in the internal FLASH memory then the getTextWidth() function works fine:

 FontFlashSection :
 {
 *(FontFlashSection FontFlashSection.*)
 *(.gnu.linkonce.r.*)
 . = ALIGN(0x4);
 } >FLASH

Images placed in the external SPI FLASH memory (ExtFlashSection section) work correctly.

What could be the cause of this behavior?

MM..1
Super User
October 27, 2022

Simply bug, try write version used for ST Emp info.