cancel
Showing results for 
Search instead for 
Did you mean: 

Mistake in Custom Widget example

PWagn.1
Associate II

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

1 REPLY 1
Osman SOYKURT
ST Employee

Hello PWagn.1,

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

Thanks for your contribution :)

/Osman

Osman SOYKURT
ST Software Developer | TouchGFX