Skip to content
Brian Alano edited this page Feb 13, 2019 · 6 revisions

Full automated input

Input is normally done by reading a stream, like the Serial input. Menu input drivers are almost all built around the stream functionality, they all have a read and available functions like Serial. So anything that you can transform into a stream can be an input driver, provided that it uses the defined navigation characters.

The library also provides the chainStream utility to concatenate multiple input streams into a single stream. In this case the next device is only read after the current input is exhausted. With this utility we can have multiple inputs in parallel.

Constructing a chain of streams:

chainStream<N> name(menuIn** chain)

where:

N number of streams to concatenate

name object name

chain and array of menuIn pointers

example:

encoderIn<encA,encB> encoder;//simple quad encoder driver
encoderInStream<encA,encB> encStream(encoder,4);// simple quad encoder fake Stream

//a keyboard with only one key as the encoder button
keyMap encBtn_map[]={{-encBtn,options->getCmdChar(enterCmd)}};//negative pin numbers use internal pull-up, on = low
keyIn<1> encButton(encBtn_map);//1 is the number of keys

serialIn serial(Serial);

//input from the encoder + encoder button + serial
menuIn* inputsList[]={&encStream,&encButton,&serial};
chainStream<3> in(inputsList);//3 is the number of inputs

this construction can be automated by the MENU_INPUTS macro

MENU_INPUTS(name[,&menuIn]);

where:

name is the new stream name followed by a list of streams

example:

MENU_INPUTS(in,&encStream,&encButton,&serial);

You can also use the chainStream utility to generate a NULL stream if you plan to use the system without stream input.

chainStream<0> in(NULL);//<-- this creates a NULL stream

The null stream (never has input) might be useful for programmatic menu drive.

Programmatic drive

Parsed drive

You can drive the menu system by calling the navRoot::doInput function with a navigation character. This is the easy way.

API driven

Menu system can also be driven by calling navRoot::doCmd function with a navCmd structure. See details on Navigation -> navRoot object