old text stuck in other frame buffer when updating text of textArea with wild card
- June 13, 2024
- 5 replies
- 2190 views
I'm updating a text field (textArea with wild card) every tick (only for testing, in practice it will be updated less, and only when invalidated when changed). It updates the field just fine, however the old value remains in the other frame buffer. So the value alternates between the new value and the old value. But only if new text is smaller than old text.
Here was my initial code:
void Screen1View::updatePowerState(const char* str)
{
touchgfx::Unicode::strncpy(textAreaPowerControlStateBuffer, str, TEXTAREAPOWERCONTROLSTATE_SIZE -1);
textAreaPowerControlState.resizeToCurrentText();
textAreaPowerControlState.invalidate()
}
But this code didn't work when increasing the size. So I tried to invalidate by rectangle instead:
void Screen1View::updatePowerState(const char* str)
{
Rect invalidatedArea = textAreaPowerControlState.getRect();
invalidatedArea.x=0; // convert to relative rect
invalidatedArea.y=0; // convert to relative rect
touchgfx::Unicode::strncpy(textAreaPowerControlStateBuffer, str, TEXTAREAPOWERCONTROLSTATE_SIZE -1);
textAreaPowerControlState.resizeToCurrentText();
Rect invalidatedArea2 = textAreaPowerControlState.getRect();
invalidatedArea2.x=0; // convert to relative rect
invalidatedArea2.y=0; // convert to relative rect
invalidatedArea.expandToFit(invalidatedArea2);
textAreaPowerControlState.invalidateRect(invalidatedArea);
}
Even invalidating a very large size doesn't work:
void Screen1View::updatePowerState(const char* str)
{
touchgfx::Unicode::strncpy(textAreaPowerControlStateBuffer, str, TEXTAREAPOWERCONTROLSTATE_SIZE -1);
textAreaPowerControlState.resizeToCurrentText();
//textAreaPowerControlState.invalidate();
Rect invalidatedArea;
invalidatedArea.width = 500;
invalidatedArea.height = 24;
invalidatedArea.x=0;
invalidatedArea.y=0;
textAreaPowerControlState.invalidateRect(invalidatedArea);
}
This does expand, but when shrinking the older text that was to the right of the newer text remains in the other frame buffer.
I invalidate the d-cache by address and use the address of the current frame buffer and the area that has changed. This works flawlessly with animations and clock widget etc. So I don't know why it is not working with a text field.
I was wondering if it is also possible to invalidate only the wildcard area without too much work? It seems pointless to invalidate the entire text when only the wildcard part is updated.
I'm using TouchGFX 4.23.2
I've attached a video.
