2020-04-29 11:55 AM
2020-04-29 02:35 PM
I need way more information than that :) thanks
2020-04-30 03:06 AM
What are you trying to achieve? Generally, adding as many widgets as possible to a root container of a view is not always the best option. Try bundling some lines together in a container. Maybe you really don't need a canvas line with antialiasing but can create a custom widget that implements ::draw() and writes pixels directly into the farmebuffer.
/Martin
2020-05-01 03:12 AM
thank you for replying. I like your idea "create a custom widget that implements ::draw() and writes pixels directly into the farmebuffer", but I don't know how to do that. Can you help me ?
2020-05-01 04:25 AM
Sure! The best thing you can do is maybe take a look at the "Custom Widget Example" UI template from the designer.
There's nothing noteworthy on the canvas because the example is based around the Lens widget (Lens.cpp under gui/src/common/) which has no elements and draws directly into the framebuffer through draw().
/Martin
2020-05-01 04:27 AM
Generally, you would declare your widget like:
#include <touchgfx/widgets/Widget.hpp>
class MyWidget : public touchgfx::Widget
{
And implement a custom draw-function to become part of the TouchGFX render chain.
void MyWidget::draw(const touchgfx::Rect& invalidatedArea) const
{
//lock FB - Get pointer to start of framebuffer
uint16_t* fb = touchgfx::HAL::getInstance()->lockFrameBuffer();
//Start writing something!
//Unlock FB
touchgfx::HAL::getInstance()->unlockFrameBuffer();
}
2020-05-01 05:09 AM
thank you so much! I'll try
2020-05-01 06:55 AM
For example, I want to draw a rectangle with 5x5 pixels, how do I do it?