Skip to main content
kronikary
Associate II
February 13, 2021
Solved

Rendering multiple lines/boxes

  • February 13, 2021
  • 1 reply
  • 1471 views

Hi!

I am using TouchGFX in my application. In one of the pages I need to render unknown amount (depends on backend) of lines as well as boxes. What is best approach to this? Should I use TouchGFX MVP and send from backend information about width/color/position or maybe create my own function that will use DMA2D and render lines/boxes. If the first option is way to go, in TouchGFXDesigner I guess I would need to create one line and one box. How to change this line/box parameters (like position) without deleting previous rendered line/box? Since TouchGFX treats objects as rectangles it will overlay as rectangle. Is it even possible with TouchGFX engine?

TL:DR: How to use TouchGFX engine to render unlimited number of custom objects (linex/boxes)?

Thank you

This topic has been closed for replies.
Best answer by zzzzz

I see, back to your original question, You may create a low-level function to blend your data with TGFX LCD buffer data. but you cannot draw a thousand lines with only one line widget.

1000-2000 lines do take many resources, but may not very slow. We had a project which needs to draw dots (canvas widgets, similar to a line) on a graph. the information of dots is generated in the backend and its quantity is unknown, A global STL queue is used to hold all the dots. In view tick, check the queue, grab the data and redraw the graph. In my case, the quantity of dots is about 400-1000, internal RAM size is 320K. There has no noticeable delay.

Graph widget is added in TGFX 4.16, perhaps, do a simple test, add 2000 lines in a graph widget and test it on your board. Check the size of that screen (the size of this screen is how much memory TGFX needed) and the speed. If everything is acceptable, then use this mechanism. If not, then find another way to render the LCD.

1 reply

zzzzz
Senior
February 15, 2021

I would suggest use MVP or an RTOS queue to notify the frontend of the widgets to add.

In the frontend, add code to the custom screen class instead of the base class (TouchGFXDesigner). Based on the information from the backend, dynamically create (new widgets) the widgets (line, box) and add them to the screen. Use an STL container (vector should work) to hold these new widgets pointers and destroy (delete widgets) them in the teardown function.

kronikary
kronikaryAuthor
Associate II
February 17, 2021

Overall it seems like a good idea, but in my case I might need to create 1000-2000 lines, and storing them as widgets will take too much resources. Also using ModelTick to inform frontend about new widget will be too slow.

I don't need to store information about each widget. I need to render the frame, and invalidate after rendering process is done.

zzzzz
zzzzzBest answer
Senior
February 17, 2021

I see, back to your original question, You may create a low-level function to blend your data with TGFX LCD buffer data. but you cannot draw a thousand lines with only one line widget.

1000-2000 lines do take many resources, but may not very slow. We had a project which needs to draw dots (canvas widgets, similar to a line) on a graph. the information of dots is generated in the backend and its quantity is unknown, A global STL queue is used to hold all the dots. In view tick, check the queue, grab the data and redraw the graph. In my case, the quantity of dots is about 400-1000, internal RAM size is 320K. There has no noticeable delay.

Graph widget is added in TGFX 4.16, perhaps, do a simple test, add 2000 lines in a graph widget and test it on your board. Check the size of that screen (the size of this screen is how much memory TGFX needed) and the speed. If everything is acceptable, then use this mechanism. If not, then find another way to render the LCD.