2021-02-13 09:35 AM
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
Solved! Go to Solution.
2021-02-17 10:28 AM
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.
2021-02-15 10:23 AM
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.
2021-02-17 09:41 AM
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.
2021-02-17 10:28 AM
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.
2021-02-18 04:16 AM
I have been rendering linex/boxes with my own functions which worked pretty well. I hoped I could use TouchGFX engine to do the same in easy and efficent way (with built into anti-ailiasing). As you said it is not possible to use one widget so it is unfortunate since I will need to use 2 graphic engines - one for GUI and one for my custom rendering stuff. I hope in future development few features will be added to TouchGFX so it wouldn't be just GUI development app.
The things you said about graph widget are very interesting. I could possibly use it to render what I need, but I am left with 50kB of free RAM and application is not done yet. Although I will keep that in mind.
Thank you =)