Skip to main content
PWagn.1
Associate II
January 6, 2022
Question

Mistake in Custom Widget example

  • January 6, 2022
  • 1 reply
  • 571 views

In Custom Widget example in documentation, there is a mistake in draw method.

The example suggest to use touchgfx::HAL::DISPLAY_WIDTH to calculate position in framebuffer.

framebuffer[absolute.x + x + (absolute.y + y) * touchgfx::HAL::DISPLAY_WIDTH] = data->at(x / scale, y / scale) ? 0x0000 : 0xffff;

This is not correct, because the framebuffer is not always allocated for entire line of display, but only invalidated section, so to get position of another line the Y coordinate must be multiplied by FRAME_BUFFER_WIDTH instead:

framebuffer[absolute.x + x + (absolute.y + y) * touchgfx::HAL::FRAME_BUFFER_WIDTH] = data->at(x / scale, y / scale) ? 0x0000 : 0xffff;

I believe, the same issue appears in the linked source examples.

Petr

This topic has been closed for replies.

1 reply

Osman SOYKURT
Technical Moderator
February 24, 2022

Hello PWagn.1,

Yes, you're right. We will fix that soon.

Thanks for your contribution :)

/Osman

Osman SOYKURTST Software Developer | TouchGFX