cancel
Showing results for 
Search instead for 
Did you mean: 

Canvas buffer generated by Designer

Luk35
Associate III

Hi,

I have allocated memory in external sdram and set buffer using CanvasWidgetRenderer::setupBuffer() method. Generated base class for my view is allocating memory in internal RAM and in constructor is passing it to setupBuffer mehod. How to avoid this behaviour? Can I tell somehow to Designer that memory is allocated already?

Definition:

static const uint16_t CANVAS_BUFFER_SIZE = 12000;
    uint8_t canvasBuffer[CANVAS_BUFFER_SIZE];

First line of view base class constructor:

CanvasWidgetRenderer::setupBuffer(canvasBuffer, CANVAS_BUFFER_SIZE);

5 REPLIES 5
Martin KJELDSEN
Chief III

Hi @Luk35​,

CanvasWidgetRenderer::setupBuffer(canvasBuffer, CANVAS_BUFFER_SIZE);

simply takes a pointer of size uint8_t to a place in memory. For the first code snippet in your post this just implies internal ram. You can use any addressable RAM, but when supplying a pointer to external memory you must make sure that this is reserved.

/Martin

Hi @Martin KJELDSEN​ It is not a case. I have reserved memory in external RAM. I have called in main

CanvasWidgetRenderer::setupBuffer(myCanvasBuffer, MY_CANVAS_BUFFER_SIZE);

but Touch GFX Designer allocates memory in interal RAM and sets own buffer (much smaller) in generated view base class constructor.

Hi @Luk35​,

Not sure i follow you here - You say that the designer allocates memory and sets its own buffer in some base class? Can you show me the code? The designer shouldn't have an opinion on where to allocate this buffer. Yes, the examples it provides always allocate in internal RAM for simplicity.

/Martin

Luk35
Associate III

Yes. Please check attached project (simulator). I have uncommented lines of code responsible for canvas buffer in main.cpp file.

It seems that circle and line widgets causes problem. I have opened text editor next to Designer and placing Circle or Line (or Circle Progress/Line progress) on the screen creates canvas buffer in Screen1ViewBase class.

JHarding
Senior

@Martin KJELDSEN​ I am having this exact same issue. Is there a way to tell TGFX Designer to stop adding the buffers to the auto generated base classes? I have manually setup my canvas buffer, when I enter a screen that changes that buffer and then go back into a screen that requires a larger buffer that I have setup manually, obvious issues arise.

I setup my canvaswidgetrenderer like @Martin KJELDSEN​ mentions in this post here, but the designer changes the size of the buffer on some of my screens (mainly ones that draw individual lines). I need to disable this functionality. Please provide some guidance here.