cancel
Showing results for 
Search instead for 
Did you mean: 

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

Seba
Associate II

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?

4 REPLIES 4
MM..1
Chief III

Try place get print after invalidate.

Seba
Associate II

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

Seba
Associate II

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
Chief III

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