Skip to content
Rui Azevedo edited this page Sep 29, 2017 · 14 revisions

Idling

When exiting from the main menu, either with '/' escape or by selecting an exit option if available. The menu enter an idle state. By default a blank screen doing nothing.

to return to menu again press select or '*' key

Often you want to enter other tasks on that state. There are multiple methods of doing so.

The efficient way

Just don't call the menu poll function, clear the screen and use it for whatever purpose you desire. This is efficient because the menu is not being polled and its completely inactive.

  • This method can be used at any time and is independent of the menu state.
  • The menu state is preserved
  • Just start calling the poll function again to resume.

The easy way

Check the menu state and do alternative tasks when menu exited. The alternative tasks are only executed when exiting from the main menu.

example:

void loop() {
  nav.poll();
  if (nav.sleepTask) {
    //do your update here...
  }
}

The hard way

provide a your idling function and do stuff inside it. This method is non blocking, if your function is non blocking and the alternative tasks are called when exiting from main menu.

start by pointing your alternative idle function

nav.idleTask=myFunct;//can do this on setup or when appropriate

myFunct will then be called when the menu is suspended/idling, and when exiting from main menu.

myFunct is of type idleFunct

result (*idleFunc)(menuOut& o,idleEvent);

your function will be called for each defined output device (passed it as first parameter) and with one of the following events as second parameter:

enum idleEvent {idleStart,idling,idleEnd};

Therefor it will be called at least 3 time per output device, one for each event. On some devices that require redraw the idling event might repeat for each poll until exit.

The preemptive way

call idleOn() to force menu into an idle state with the predefined idle function or idleOn(myFunct) for an alternative one.

call idleOff() to resume

Clone this wiki locally