Pages: 1 [2] 3 4   Go Down
Author Topic: MenuBackend, new menu managment library  (Read 44093 times)
0 Members and 1 Guest are viewing this topic.
Norway@Oslo
Offline Offline
Edison Member
*
Karma: 13
Posts: 2033
loveArduino(true);
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

http://pastebin.org/221107

The bug in 1.2 got introduced by my being stupid.
When elements are added I use a set method, and that takes a position parameter (above,right etc), but for version 1.2 I also added the constants MenuItem::ABOVE/RIGHT etc for checking against the hasChildren. I had to change the names of my internal representation of the directions in order to avoid naming conflicts, but forgot to change the identifying names in my switch/case in the set method.
Stupid, but easily fixable.

Could you test if this works:

if (menu.getCurrent().hasChildren() & (MenuItem::ABOVE | MenuItem::BELOW))
{
  Serial.println("The current item has either an element below or above");
}



Thank you for your contribution with this library!

Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 125
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I made a test last nite, and added some serial navigation (using 1.0).
So far I like it a lot.  I will try to re-test with your latest tonite.

I did confirm to myself that jumping to the root, or top menus would be helpful.  You definitely get a feel for this with the serial nav.   Going down 4 steps, and seeing that to return you have to go up 4 steps.

Thanks.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I figured that was the case with the bug.  I had compared the new and old code and saw that there was a difference is some of the internal variables.

Anyways, when I test what you asked I get this.
Code:
ERROR:
In function 'void loop()':
error: 'ABOVE' is not a member of 'MenuItem'

Thanks
Logged

Brno@Czech Republic
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nice library, I will definitely test more and give you some feedback.
Logged

Norway@Oslo
Offline Offline
Edison Member
*
Karma: 13
Posts: 2033
loveArduino(true);
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Feedback is awesome! I am insanely busy these days, but I regulary check this forum, and will try to make suggested changes when I have time.
Last two weeks of my bachelor degree study... one 50 page dissertation and some exams. smiley
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 125
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Get busy and graduate you lug !

Then we have work for you to do!

Seriously, congrats on getting out of school.
Logged

Brno@Czech Republic
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I agree, finishing school and getting diploma is priority. Got one myself smiley.
I have some problems with the menubackend,  but it might be me, I'm arduino noob. I will test it later today ...
Logged

Brno@Czech Republic
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello again,

tested your menu, and it is working just fine. Used a rotary encoder, buttons and LCD for navigation. Well I must say I was getting some misbehavior, before I understood that the menu is made that way. That it is made for four cursor keys.

Here come my question, would it be hard to change the menubackend to work with buttons like left, right, select and exit. It would be very convenient to use it with rotary encoder left-right. Push button on rotary as select and one other button as exit.

Also a suggestion for your code to include exit of current level of menu   on any item not just on top one.

Adam
Logged

Norway@Oslo
Offline Offline
Edison Member
*
Karma: 13
Posts: 2033
loveArduino(true);
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You can try to use moveBack(); if you want to exit a level.

You can inmplement what you ask yourself, actually.
If you only add menu items to the left or to the right, you end up with a horizontal structure, witch you can navigate with moveLeft(); and moveRight(); and select with use();.
smiley
Logged

Brno@Czech Republic
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello again,

tried your advice.  moveBack(); just move back one step in menu. But the rest is working just fine.

Can you maybe show me how to implement menuExit routine in your C. Which will do the following, but without showing it all on menu?

Code:
while ((menu.getCurrent().hasChildren() & MenuItem::LEFT) == 0){
  menu.moveUp();
  }
menu.moveLeft();

Logged

Norway@Oslo
Offline Offline
Edison Member
*
Karma: 13
Posts: 2033
loveArduino(true);
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What exactly do you want a menuExit(); to do?  smiley
Logged

Brno@Czech Republic
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, the same as the code I posted.  smiley Only not to show it all through  menuChangeEvent on LCD. That is menu.moveLeft(); but not only on most top one menu but on any item in same up-down level.
Logged

Norway@Oslo
Offline Offline
Edison Member
*
Karma: 13
Posts: 2033
loveArduino(true);
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Th code you posted looks to be a bit specific to what you want. Care to explain the principle so I might make it something that could be useful for more users? smiley
Logged

Brno@Czech Republic
Offline Offline
Newbie
*
Karma: 0
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Not exactly sure what do you mean. As I explained before in this thread, I'm tying to put simple menu on LCD. Menu that can be managed by a rotary with push button on it as select, and one extra button as exit. Your menubackend is working fine for this, but I'm not C programmer. Tried some liked lists and pointers but not able to achieve same efficiency as your code. So I'm lost how to put this while statement without showing the progress on LCD.
Logged

Norway@Oslo
Offline Offline
Edison Member
*
Karma: 13
Posts: 2033
loveArduino(true);
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So then my question is: Exit to where?
smiley
Logged

Pages: 1 [2] 3 4   Go Up
Jump to: