Jomelo / LCDMenuLib2

Create a tree menu. Use it with different lcd types / console output / ssh console.
MIT License
249 stars 47 forks source link

Problem with hidden elements and menu update #43

Closed snoerenberg closed 5 years ago

snoerenberg commented 5 years ago

Hi,

thanks for your great library. I use it in a personal project and got the following problem:

1st problem: Once I started a program I do not get back to the "Stop Program/Back" screen even I Used "LCDML.FUNC_goBackToMenu(1);" which should get me not to the root.

2nd problem: Once I started a program and stopped it again, the reload takes place and I see all 4 programs which I could start, but I can only select between "Program 1" and "Program 2". It seems that the update of the menu does not take care of the hidden elements changed and therefor only the prior present 2 can be selected (prior the screen update only "Stop Program" and "Back" have been present)

I would really like to get there a solution. I could not figure it out, even with a manual work around:

// LCDML.OTHER_setCursorToID(2); // fix for hidden element // http://forum.arduino.cc/index.php?topic=73816.msg3610953#msg3610953

I attach a working sample for the serial monitor here. LCDML_000_serialMonitor_Prob_Hidden.zip

Thanks a lot Stephan

Jomelo commented 5 years ago

Hello, i can reproduce the problem and try to find a fix. Its a bug in the lib.

snoerenberg commented 5 years ago

Hi @Jomelo is there anything I can help you with? I've not yet compiled the library on my own with debug enabled.

Jomelo commented 5 years ago

Hello, i am working on it, but it is not so easy.

For example what is correct for the next cursor position

Example 2:

I can program it so, that it worked with your example, but other peaple have the same problem with other menu structures. At the moment the menu goes to the next stable state. A stable state is to set the menu to the root position.

A possible solution could be to add new function to control the "goBack" handling like this:

With this function the user can decide how the handling is correct. When the next visible element is not found. The menu goes to the layer above and search the next visible element.

At the moment i test this method.

Jomelo commented 5 years ago

Another solution is to work with LCDML.OTHER_setCursorToID(...) and set the cursor on the defined position.

I think it is the easiest way to solve it fastly.

Jomelo commented 5 years ago

I have edit your example to select the correct cursor position after stopping the programn.

// void mFunc_startProcess(uint8_t param) // { if (LCDML.FUNC_setup()) // ** SETUP ***** { _currentProgram = param; LCDML.OTHER_setCursorToID(15);

//LCDML.OTHER_setCursorToID(2);
// fix for hidden element
// http://forum.arduino.cc/index.php?topic=73816.msg3610953#msg3610953

}

if (LCDML.FUNC_loop()) // ** LOOP ***** {

}

if (LCDML.FUNC_close()) // ** STABLE END ***** { // you can here reset some global vars or do nothing
} }

// void mFunc_stopProcess(uint8_t param) // { if (LCDML.FUNC_setup()) // ** SETUP *** { *uint8_t cursor_element_id = 3 + ((_currentProgram - 1) 3);

_currentProgram = 0;

LCDML.OTHER_setCursorToID(cursor_element_id);

}

if (LCDML.FUNC_loop()) // ** LOOP ***** {

}

if (LCDML.FUNC_close()) // ** STABLE END ***** { } }

snoerenberg commented 5 years ago

Hi @Jomelo, perfect - the workaround works :) also in my CrystalLCD project where I use it