puzrin
September 30, 2019, 8:12am
1
Description
I need simple list with 2-lines elements, controlled from keyboard. Now use page + [cont + 2 labels]*N.
Memory consumption is 2K per every 5 additional items. That’s too much. Is there any method to reduce?
What MCU/Processor/Board and compiler are you using?
Now - PIO+SDL2+Ubuntu
Target - stm32f072cbt6 (128k flash + 16k ram)
What do you want to achieve?
Less memory consumption for list
What have you tried so far?
Dropped everything. Every list item is just cont, not button
No themes. Created 3 global styles and apply those everywhere
Code to reproduce
#ifndef __DOSES__
#define __DOSES__
typedef struct {
float volume; // Volume to dispense, in mm³
const char * desc; // Description
char title[16]; // Title (volume + " mm³", in text form)
} dose_t;
dose_t doses[] = {
{ .volume = 0.041, .desc = "chip 0402" },
{ .volume = 0.053, .desc = "SOT-23" },
{ .volume = 0.085, .desc = "chip 0603" },
{ .volume = 0.17, .desc = "chip 0805" },
{ .volume = 0.35, .desc = "chip 1206" },
{ .volume = 0 } // Mark end of list
};
#endif
Open project, change list content as you wish and run sdl2 build. It prints mem stat to console.
Screenshot and/or video
See above.
It’s 2kB for 15 element (1 cont + 2 label) * 5). So 2kB / 15 = 136 byte / object. It seems correct.
I was thinking about implementing a special list which needs
item height
an array of custom structs (descriptors) e.g. with some texts and icons
and a callback to draw an item to a given place based on a given descriptor
This way no objects are created at all and even very long lists could be created very effectively.
However, it’s still just a plan…
2 Likes
puzrin
October 1, 2019, 3:08pm
3
Hm… the most problematic list has const strings and all sizes fixed. I could create container only and draw texts manually. Is that possible? If yes, where to read about? 3x mem reduce is enouth for my case.
A minor suggestion: draw at least the containers (or buttons) and add only the texts manually. You can assign the texts as user_data to the containers.
To draw the texts manually you need to overwrite the design function of lv_cont.
Take look at this article .
3 Likes
puzrin
October 2, 2019, 7:58am
5
That’s exactly what i needed. Thanks!
1 Like
hi @puzrin ,
How did you implement this list? Can you share it?
Best regard
Lucas
Old post but wondering if this was ever completed?