I am working on another project and I need some advice on using menus. I need to find a best way to create a LCD menu/submenu which doesn't use too much memory. Memory is my main problem right now because I need enough free RAM.
Any better ways? I think that menu library is proabably the best way to do it because it is easy and as far as I understand it should use much of memory or prog space.
Whatever way you decide to create the menu, to use the least amount of memory for the strings, structure your menu to use words which are used multiple times, then only create a string for that word, and when you print it, index on that string. In other words, if you use a word or word part multiple times in your menus, then only store that singular form, and code you menu structure in such a way as to refer to those string parts to create the menu.
For example, if you had the following menu structure:
1. Main Menu
A. User Menu
i. List Users
ii. Add User
iii. Remove User
iv. Goto Main Menu
B. Program Menu
i. List Program
ii. Add Program
iii. Remove Program
iv. Goto Main Menu
2. Start Program
3. Stop Program
The strings you would code for would be:
Main
Menu
User
List
Add
Remove
Goto
Program
Start
Stop
Which represent far fewer bytes than the complete menu shown earlier. You might be able to reduce it further, but at a certain point you'll have a case of diminishing returns. For such an optimization to work best, though, you should have the entire menu for your project planned out in advance, so you can know where and how you can apply your optimizations.
Yes that is one way to reduce memory size. Using progmem as I am is also another way.
Does any one have a finished code that uses menus/submenus? Because writing a menu system that uses submenus isn't as easy as I thought. It is not hard either but why create something when there is an already working version available .
I know I just said it in a strange way. And for now I don't have any problems with too little progmem but if I started using too many strings I would fill up the RAM realy fast.
... but if I started using too many strings I would fill up the RAM realy fast.
No, the whole point of putting your strings into PROGMEM is so that they stay there and don't fill up your RAM. You just need to make sure your strings are really there and not just the table pointing to your strings while the strings are still in RAM.
And since I don't have much experience with pointers I need a way to use PROGMEM with this library. I now that you can do it with pointers but I don't know how.