Gentlemen good night!
I started playing with Arduino just a few weeks (as a hobby) and I'm loving it! Well, let my doubt. I found this library to create menus in the Playground LCD,GitHub - DavidAndrews/Arduino_LCD_Menu: This library creates menu systems primarily useful for 16x2 or 16x4 LCD displays. (which by the way I thought fantastic!) But I'm getting a strange behavior.
Since the whole program itself works fine, I'll just post the code to create the menu.
This is the menu structure that works 100%. Without "redrawn" behavior:
The menu tree is:
Light Sensors
- On
- Off
- Back
Lights
- Balcony Lights
- On
- Off
- Back
Temperature
Code:
void setupMenus()
{
g_menuLCD.MenuLCDSetup();
MenuEntry * p_menuEntryRoot;
p_menuEntryRoot = new MenuEntry("Sensores Luz", NULL, NULL);
g_menuManager.addMenuRoot( p_menuEntryRoot );
g_menuManager.addChild( new MenuEntry("Ligar", (void *) (&sensorLuz), MenuEntry_BoolTrueCallbackFunc ) );
g_menuManager.addChild( new MenuEntry("Desligar", (void *) (&sensorLuz), MenuEntry_BoolFalseCallbackFunc ) );
g_menuManager.addChild( new MenuEntry("Voltar", (void *) &g_menuManager, MenuEntry_BackCallbackFunc) );
//Crio o menu Luzes
g_menuManager.addSibling( new MenuEntry("Luzes", NULL, NULL ) );
g_menuManager.MenuDown(); //Vou "para baixo" do menu luzes
//Adiciono o filho do menu luzes
g_menuManager.addChild( new MenuEntry("Luz da Varanda", NULL, NULL ) );
g_menuManager.MenuDown(); //Vou pra baixo do item luz da varanda
g_menuManager.MenuSelect(); //seleciono o menu
//adiciono os filhos
g_menuManager.addChild( new MenuEntry("Ligar", (void *) (&luzVaranda), MenuEntry_BoolTrueCallbackFunc ) );
g_menuManager.addChild( new MenuEntry("Desligar", (void *) (&luzVaranda), MenuEntry_BoolFalseCallbackFunc ) );
g_menuManager.addChild( new MenuEntry("Voltar", (void *) &g_menuManager, MenuEntry_BackCallbackFunc) );
//Volto para o menu principal para adicionar mais filhos
g_menuManager.SelectRoot();
//adiciono o menu filho para verificar a temperatura
g_menuManager.addSibling( new MenuEntry("Temperatura", (void *) (&mostraTemp), MenuEntry_BoolTrueCallbackFunc));
g_menuManager.DrawMenu();
}
Now, this is the menu structure that causes the "redrawn" behavior. I only added one more subitem for menu:
Menu tree:
Light Sensors
- On
- Off
- Back
Lights
- Balcony Lights
- On
- Off
- Back
- Garage Lights <---- The new subitem with childrens
- On
- Off
- Back
Temperature
void setupMenus()
{
g_menuLCD.MenuLCDSetup();
MenuEntry * p_menuEntryRoot;
p_menuEntryRoot = new MenuEntry("Sensores Luz", NULL, NULL);
g_menuManager.addMenuRoot( p_menuEntryRoot );
g_menuManager.addChild( new MenuEntry("Ligar", (void *) (&sensorLuz), MenuEntry_BoolTrueCallbackFunc ) );
g_menuManager.addChild( new MenuEntry("Desligar", (void *) (&sensorLuz), MenuEntry_BoolFalseCallbackFunc ) );
g_menuManager.addChild( new MenuEntry("Voltar", (void *) &g_menuManager, MenuEntry_BackCallbackFunc) );
//Crio o menu Luzes
g_menuManager.addSibling( new MenuEntry("Luzes", NULL, NULL ) );
g_menuManager.MenuDown(); //Vou "para baixo" do menu luzes
//Adiciono o filho do menu luzes
g_menuManager.addChild( new MenuEntry("Luz da Varanda", NULL, NULL ) );
g_menuManager.MenuDown(); //Vou pra baixo do item luz da varanda
g_menuManager.MenuSelect(); //seleciono o menu
//adiciono os filhos
g_menuManager.addChild( new MenuEntry("Ligar", (void *) (&luzVaranda), MenuEntry_BoolTrueCallbackFunc ) );
g_menuManager.addChild( new MenuEntry("Desligar", (void *) (&luzVaranda), MenuEntry_BoolFalseCallbackFunc ) );
g_menuManager.addChild( new MenuEntry("Voltar", (void *) &g_menuManager, MenuEntry_BackCallbackFunc) );
// Here the new subiten withe their children
//Adiciono novo item de menu abaixo de luzes
g_menuManager.addSibling( new MenuEntry("Luz Garagem", NULL, NULL ) );
g_menuManager.MenuDown(); //Vou pra baixo do item luz da varanda
g_menuManager.MenuSelect(); //seleciono o menu
//adiciono os filhos
g_menuManager.addChild( new MenuEntry("Ligar", (void *) (&luzGaragem), MenuEntry_BoolTrueCallbackFunc ) );
g_menuManager.addChild( new MenuEntry("Desligar", (void *) (&luzGaragem), MenuEntry_BoolFalseCallbackFunc ) );
g_menuManager.addChild( new MenuEntry("Voltar", (void *) &g_menuManager, MenuEntry_BackCallbackFunc) );
// Finish of the problematic subitem
//Volto para o menu principal para adicionar mais filhos
g_menuManager.SelectRoot();
//adiciono o menu filho para verificar a temperatura
g_menuManager.addSibling( new MenuEntry("Temperatura", (void *) (&mostraTemp), MenuEntry_BoolTrueCallbackFunc));
g_menuManager.DrawMenu();
}
What am I doing wrong? Has anyone used this library?
Note: Just remember that regardless of this behavior, the two menu code works perfectly.
Note2: Sorry bad english... it's rusty...
Note3: I made this little video in order to show the problem: - YouTube
Note4: For this post is not only questions (my first!), I made this little application to help create custom characters for LCD. I hope it's useful! It's hosted in my domain. http://danielcordeiro.eti.br/index.php/downloads/arduino-char/