|
Post by jackroffel on Nov 21, 2015 18:30:28 GMT -8
Hi all,
It appears to me that assets loaded via LOAD_ASSETS() are loaded into video memory, and remain there for the duration of the sketch. These assets take significantly more GD2 RAM as opposed to what they take in flash memory.
My project uses several large png files, but these are never displayed on the same screen at the same time. Since I am using a Mega 2560, I have sufficient flash memory to include a gd2assets.h file containing all these png files, but when I add up the GD2 memory needed by the output returned from the asset converter, I clearly do not have enough GD2 memory to load them all at once.
I was going to use multiple .h files by editing them to create unique labels, and then load them as needed using a differently names LOAD_ASSETS() macro - but am reluctant to do what does not seem to be documented as even possible. Can I load different LOAD_ASSET() setups in the same sketch? How do I unload previous ones?
Jack
|
|
|
Post by jamesbowman on Nov 22, 2015 0:45:55 GMT -8
Right, if you manually edit the LOAD_ASSETS() macro in each file - e.g. to LOAD_ASSETS_1(), LOAD_ASSETS_2() etc. then you can load each set in turn using the appropriate macro.
Each set of assets will load at address 0, overwriting the previously loaded set.
If you're displaying existing assets and you load new assets, then the overwrite will be visible. This may not be what you want, so to prevent the glitching you can show a loading message:
GD.Clear() GD.cmd_text(240, 136, 31, OPT_CENTER, "Loading..."); GD.swap(); LOAD_ASSETS_1();
|
|
|
Post by jackroffel on Nov 22, 2015 10:44:05 GMT -8
James,
Thanks - I will try this. Looking at 2 individual asset.h files, I see that I will have a duplicate definition for #define ASSETS_END. I could not find it being used anywhere - can I comment this out?
Jack
|
|
|
Post by jamesbowman on Nov 22, 2015 16:03:30 GMT -8
Yes, ASSETS_END is not used, so it can be removed.
|
|