Display corruption issue when direct drawing to framebuffer in custom widget
I'm following this guide to creating a custom widget. Instead of any qr code logic, all I'm starting with is just drawing a solid color to the invalidated widget.
void MyWidget::draw(const touchgfx::Rect& invalidatedArea) const {
touchgfx::Rect absolute = getAbsoluteRect();
uint16_t* framebuffer = touchgfx::HAL::getInstance()->lockFrameBuffer();
for (int y = invalidatedArea.y; y < invalidatedArea.bottom(); y++)
{
for (int x = invalidatedArea.x; x < invalidatedArea.right(); x++)
{
framebuffer[absolute.x + x + (absolute.y + y) * touchgfx::HAL::DISPLAY_WIDTH] = 0xFFFF;
}
}
touchgfx::HAL::getInstance()->unlockFrameBuffer();
}When I download and run the program, the area in which the widget is supposed to reside does not update when I enter the screen, instead it holds the image of the last screen. I also see three white boxes of interleaving white in a different part of the screen altogether.
As an experiment, I attempted to draw a white 800px line at the top of the screen, and discovered the white line only went 2/3 of the way across. I reason this is because the framebuffer is a 16 bit pointer, and my pixel format is 24 bits.
- If this is the case, in my opinion this should be clearly indicated in the linked touchgfx documentation page.
- Is there a pixel-format independent way to draw pixels to the framebuffer? As it stands I would have to work out the byte offsets for every x/y pixel, and write 24 bits of data into two adjacent 16 bit cells
- Does the STM32F769i support 16 bit pixel format?
Thanks.
