New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduction of memory usage? #35
Comments
probably yes #6 |
yeah I have read that and I have read a couple tutorials to use PROGMEN but I am not able to get this infos into my sketch. Could you give an example? |
not yet, it was just an idea |
I've send updates for some navigation bugs, support for looping menus, and U8glib support, guess i will read something about progmem |
I guess a good start would be to use the F ( ) Macro like in lcd.print(F("Hallo")); or here https://www.arduino.cc/en/Reference/PROGMEM :) just as an idea. I am pretty much a hobby programmer so I am dependent on your grace ^^ |
ok I guess it will be nessasary to work with string as all the other Menu's out the, as I startet my project I had no idea why they using them, but now it's clear, it saves memory. Insteard of putting the "Text" in a Field there should be a const char mainMenuSTRING_ID_0 [] PROGMEM = "Aquarium" MENU(mainMenu, mainMenuSTRING_ID_0, And then the libary need the read the PROGMEN with pgm_read_word_near(mainMenuSTRING_ID_0); And there my knowlege stop's, cause I don't fully understand the MACROS of the lib... |
I pointed out this example and discussion on Arduino forum, http://forum.arduino.cc/index.php?topic=110307.0, maybe this can help you to implement PROGMEM text var. |
I've done some checkings, by moving strings and menus data (list of options) to PROGMEM and it is not a big saving.. still checking pratical compile measures --------------------------- structures sizeof ---------------------------------- rough estimates ===================================== menu struct: strings ------------------------------------------ test menu struct size ---------------------------- even moving text and data to flash, the remainder of menu structure is bigger than the moved part to make bigger savings all menu structure would have to be revised by separating things that can be constant and status variables, in some cases with worst results. A simple prompt can be all in progmem except for the enabled status var, spliting the class between memory types will result in more memory usage. things for version 3 i guess |
Each time I had used F() macro on String I never noticed big savings on memory usage. |
I my project I have a lot blank space character to format the print. I guess other users do that too, so I thought, and I am actullay not sure if blank space character getting saved in strings, it could be good to implement a Format class so that just the nessasary characters will be saved. |
yes, datatypes are important and in some cases we can exchange data by code... |
and yes, blank space is stored, you can use tabs, but your driver must understand tabs |
here's a small code that uses no macros if you want to play with PROGMEM bool ledOn() {return false;}//returning true here makes the menu exit after
bool ledOff() {return false;}
prompt sub1("LED ON",ledOn);
prompt sub2("LED OFF",ledOff);
prompt* const subMenuData[]={&sub1,&sub2};
menu subMenu("Sub-menu",2,subMenuData);
prompt empty("Empty");
prompt* mainMenuData[]={&subMenu,&empty};
menu mainMenu("Main menu",2,mainMenuData); |
Just sent update with text strings and menu data stored in PROGMEM |
Hey,
I got my Menu quiet finished and now it takes up to 30% of program storage space and about 50% of dynamic memory on an UNO. Is it possible to reduce the footprint?
The text was updated successfully, but these errors were encountered: