2024-05-06 07:19 AM
I'm using TouchGfx 4.21.3 for designing LCD screens for my project with ST Microcontroller. I have a requirement to have 4000 of value to use for scroll list and each element in scroll list is container. Can I make scroll list with 4000 items in it (scrollList1.setNumberOfItems(4000);)?
How much is the maximum value that scroll list can expand?
Solved! Go to Solution.
2024-05-06 07:39 AM - edited 2024-05-06 07:49 AM
Hello @BhavyaSri and welcome to the TouchGFX community!
Setting the number of elements of a scroll list to 4000 in Designer doesn't seem to create any problem.
Indeed, in the documentation, on the API class of ScrollList (documentation_scroll_list), you can see that the get item method uses an int16 which is the limit of items you can create:
However, your MCU might probably not have enough memory to store 4000 custom containers containing each multiple widgets.
In that case, the solution is to only create a few widgets and as soon as the widgets gets out of view, display them again at the bottom. This way you have a limited number of items that can fit in your MCU's memory.
If this comment answer your question, I invite you to select it as "best answer".
Regards,
2024-05-06 07:39 AM - edited 2024-05-06 07:49 AM
Hello @BhavyaSri and welcome to the TouchGFX community!
Setting the number of elements of a scroll list to 4000 in Designer doesn't seem to create any problem.
Indeed, in the documentation, on the API class of ScrollList (documentation_scroll_list), you can see that the get item method uses an int16 which is the limit of items you can create:
However, your MCU might probably not have enough memory to store 4000 custom containers containing each multiple widgets.
In that case, the solution is to only create a few widgets and as soon as the widgets gets out of view, display them again at the bottom. This way you have a limited number of items that can fit in your MCU's memory.
If this comment answer your question, I invite you to select it as "best answer".
Regards,
2024-05-06 08:16 AM - edited 2024-05-06 08:55 AM
Thanks for quick response, will try with 4000.
But how to do below part of your solution ?
"In that case, the solution is to only create a few widgets and as soon as the widgets gets out of view, display them again at the bottom. This way you have a limited number of items that can fit in your MCU's memory."
2024-05-06 08:54 AM - edited 2024-05-06 08:56 AM
Is there a parameter in touchgfx designer to set this ?
2024-05-06 08:56 AM
This is exactly what this user is trying to do : https://community.st.com/t5/user/viewprofilepage/user-id/76084
Basically, you have to know how many of the widgets you can see in your scroll list.
For instance this can look something like that :
In that case, you can see a maximum of 4 elements.
I would use a scollable container because it has more useleful functions that allows to do what you want.
You can track how much the user have scrolled the container with the method getScrolledY().
You can get the index of the element that should be displayed the highest by doing : getScrolledY() / (widgetHeight + paddingY) (you have to round down with the function floor).
In the case the user have scrolled enought so that the first element is not visible anymore, then the index is getScrolledY() / (widgetHeight + paddingY) = 1.
Here is what it would look like:
Now that you know that the user have scrolled enough, you can modify the content of the first widget in your scrollable container. it means that you should keep the information stored somewhere. You could use a text file, this would take significantly less space than storing each 4000 widget.
Once you have updated the content of your widget, you have to position it at the right position which is the number of scrollable widgets + the index, in that case : 5.
You can do that with the method setY knowing that the position is 5, the coordinates would be (index - 1) * (widgetHeight + paddingY).
You would also have to make sure that it works when scrolling upwards instead of downwards.
This is a challenging and rewarding task but it is necessary when working on embedded devices with limited memories.
Regards,
2024-05-06 09:27 AM
Thanks for the reply. I'll try this option and will back to you with the update.
2024-05-07 05:33 AM
Isn't that the way, ScrollLists are working in TouchGFX by design? If you look in the generated base class of the view, you see there are only [visible list elements on screen +1] number of items in the object array.
2024-05-08 01:23 AM
Hello @BhavyaSri ,
I am glad I was able to help you.
I will be happy to help you on any issues that is TouchGFX related.
In the meantime, I invite you to check our online resources:
- documentation : support.touchgfx.com/
- tutorials : support.touchgfx.com/docs/category/tutorials
- technical videos : youtube.com/TechnicalVideosTouchGFX
Regards,