Custom Widget - Draw function "interrupted"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-02-17 5:13 AM
I followed the Tutorial for the QR Code. It works when you draw just one custom widget. But when i add the same custom widget serveral times in the same Screen or in a custom Container, the code is not able to draw all the custom widgets, it seems that the draw function is interrupted and my QR Code it's not complete.
Maybe something about the HAL? Any suggestion?
I add my example project in 4.16.
Thanks!
Solved! Go to Solution.
- Labels:
-
TouchGFX
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-03-02 4:23 AM
Hello @Alexandre RENOUX, @Romain DIELEMAN ,
Many thanks for asking.
Yes, there were some errors in the code and for sure the library it's not perfect (https://github.com/nayuki/QR-Code-generator/tree/master/cpp), but at the end i made it work changing the suggested draw code for the next one:
void QrCodeWidget::draw(const touchgfx::Rect& invalidatedArea) const
{
if (!code) {
return;
}
bool result = true;
for(int yPos = 0; yPos < code->getSize(); yPos++) {
for(int xPos = 0; xPos < code->getSize(); xPos++) {
result = code->getModule(xPos, yPos);
Rect rect(xPos*scale, yPos*scale, scale, scale);
translateRectToAbsolute(rect);
HAL::lcd().fillRect(rect, result ? 0x00000000 : 0xffffffff, 255);
}
}
}
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-02-22 5:16 AM
@Romain DIELEMAN @Martin KJELDSEN @Alexandre RENOUX any hint about this problem with a QR Code in a Custom Widget?
The custom widget doesn't work in combination with other widgets.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-02-22 6:12 AM
Hi,
Yes I tried and faced the same issue. I didn't investigate further into this but it must come from the QR widget in itself since we write directly into the framebuffer, it needs to be dissected and tested :downcast_face_with_sweat:.
/Romain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-03-02 1:42 AM
Hello @GPa.1 ,
I cannot see your project anymore and neither the image (if I remember well).
After some investigation, I believe the issue comes from the QR Code lib used which is not a TouchGFX or ST product.
I see in the lib that some vector class is used which involves dynamic allocation. We try to avoid that and only declare statically allocated variables. This might be a good start to see what is exactly the problem.
/Alexandre
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-03-02 4:23 AM
Hello @Alexandre RENOUX, @Romain DIELEMAN ,
Many thanks for asking.
Yes, there were some errors in the code and for sure the library it's not perfect (https://github.com/nayuki/QR-Code-generator/tree/master/cpp), but at the end i made it work changing the suggested draw code for the next one:
void QrCodeWidget::draw(const touchgfx::Rect& invalidatedArea) const
{
if (!code) {
return;
}
bool result = true;
for(int yPos = 0; yPos < code->getSize(); yPos++) {
for(int xPos = 0; xPos < code->getSize(); xPos++) {
result = code->getModule(xPos, yPos);
Rect rect(xPos*scale, yPos*scale, scale, scale);
translateRectToAbsolute(rect);
HAL::lcd().fillRect(rect, result ? 0x00000000 : 0xffffffff, 255);
}
}
}
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-03-02 6:13 AM
Great to hear that :thumbs_up:
And thanks for sharing the solution.
/Romain
