2024-12-30 05:26 AM
Hello there,
i'm using touchgfx to show time data using
touchgfx::Unicode::snprintf(textArea1Buffer, TEXTAREA1_SIZE, "%d", sec);
but when I use invalidate() function to refresh the text area, the text disappear from my screen;
instead, the code getRootContainer().invalidate(); works well and make things correct.
by the way, the code using textArea1.invalidate(); can shown on TouchGFX simulator, it just doesn't work on my F411CEU6
here is my code:
uint16_t count = 0;
uint16_t sec = 0;
void Clock_screenView::handleTickEvent()
{
touchgfx::Rect Rect1;
if(count > 33)
{
touchgfx::Unicode::snprintf(textArea1Buffer, TEXTAREA1_SIZE, "%d", sec);
textArea1.invalidate();
//getRootContainer().invalidate();
count=0;
sec++;
}
else
{
count++;
}
}
Is there anyone, who can explain this phenomena?
Best regards
Rust
2024-12-30 08:21 AM
I think I found the reason...
I think the textArea1's rect struct can not be set correctly, after the setXY(), its rect still is {0, 0, 0, 0}
and its parent class Drawable's rect also is {0, 0, 0, 0};
getRootContainer().invalidate(); could work because it has rect indicates the whole screen.
these code generated by touchgfx automaticly.
Clock_screenViewBase::Clock_screenViewBase()
{
__background.setPosition(0, 0, 240, 135);
__background.setColor(touchgfx::Color::getColorFromRGB(0, 0, 0));
add(__background);
textArea1.setXY(77, 57);
textArea1.setColor(touchgfx::Color::getColorFromRGB(0, 255, 0));
textArea1.setLinespacing(0);
Unicode::snprintf(textArea1Buffer, TEXTAREA1_SIZE, "%s", touchgfx::TypedText(T___SINGLEUSE_HH39).getText());
textArea1.setWildcard(textArea1Buffer);
textArea1.resizeToCurrentText();
textArea1.setTypedText(touchgfx::TypedText(T___SINGLEUSE_U230));
add(textArea1);
}
It looks like a compilation optimization problem. but my compilation optimization is already set to None(-O0).
If you have any ideas about the question, please let me know, thanks.
Best regards
Rust