cancel
Showing results for 
Search instead for 
Did you mean: 

CanvasWidgetRenderer setup buffer

Du1
Senior

I read the 4.10.0 User Manual on CanvasWidgetRenderer.

I was unsure what it means by "CanvasWidget will not allocate memory dynamically, but will use memory from the buffer kept in CanvasWidget -Renderer."

I see the commented line in main.cpp:

//static uint8_t canvasBuffer[CANVAS_BUFFER_SIZE];
    //CanvasWidgetRenderer::setupBuffer(canvasBuffer, CANVAS_BUFFER_SIZE);

When I create screens with lineprogressbar the generated files all have :

static const uint16_t CANVAS_BUFFER_SIZE = 4800;
uint8_t canvasBuffer[CANVAS_BUFFER_SIZE];
 
CanvasWidgetRenderer::setupBuffer(canvasBuffer, CANVAS_BUFFER_SIZE);

Is it better to have one function (CanvasWidgetRenderer::setupBuffer(canvasBuffer, CANVAS_BUFFER_SIZE);) called in main.cpp or have multiple screen call (CanvasWidgetRenderer::setupBuffer(canvasBuffer, CANVAS_BUFFER_SIZE);) ?

The application is running fine with multiple calls, but I was just afraid this will create memory problem if the buffer isn't returned during teardown.

Thanks for the help!

1 ACCEPTED SOLUTION

Accepted Solutions
Martin KJELDSEN
Chief III

Hi @Du​,

If you want different buffer sizes for individual screens its fine to do it in each screen. Only one screen (View+Presenter) can be active at any point in time. A new screen will get placement newed into the memory of the old one (statically allocated for worst case pair).

But it's also fine to just define one buffer size for all if that seems appropriate for your application.

Best regards,

Martin

View solution in original post

3 REPLIES 3
Martin KJELDSEN
Chief III

Hi @Du​,

If you want different buffer sizes for individual screens its fine to do it in each screen. Only one screen (View+Presenter) can be active at any point in time. A new screen will get placement newed into the memory of the old one (statically allocated for worst case pair).

But it's also fine to just define one buffer size for all if that seems appropriate for your application.

Best regards,

Martin

Du1
Senior

Thanks for detailed explanation @Martin KJELDSEN​ !

You're welcome!