APM:Libraries
|
Class defining and handling one menu tree. More...
#include <AP_Menu.h>
Classes | |
struct | arg |
struct | command |
Public Member Functions | |
FUNCTOR_TYPEDEF (func, int8_t, uint8_t, const struct arg *) | |
FUNCTOR_TYPEDEF (preprompt, bool) | |
Menu (const char *prompt, const struct command *commands, uint8_t entries, preprompt ppfunc=0) | |
void | set_limits (uint8_t commandline_max, uint8_t args_max) |
set command line length limit More... | |
void | run (void) |
menu runner More... | |
bool | check_input (void) |
Static Public Member Functions | |
static void | set_port (AP_HAL::BetterStream *port) |
Private Member Functions | |
void | _help (void) |
implements the 'help' command More... | |
int8_t | _call (uint8_t n, uint8_t argc) |
void | _allocate_buffers (void) |
bool | _check_for_input (void) |
bool | _run_command (bool prompt_on_enter) |
void | _display_prompt () |
Private Attributes | |
const char * | _prompt |
prompt to display More... | |
const command * | _commands |
array of commands More... | |
const uint8_t | _entries |
size of the menu More... | |
const preprompt | _ppfunc |
optional pre-prompt action More... | |
uint8_t | _commandline_max |
uint8_t | _args_max |
uint8_t | _input_len |
Static Private Attributes | |
static char * | _inbuf |
input buffer More... | |
static arg * | _argv |
arguments More... | |
static AP_HAL::BetterStream * | _port |
Menu::Menu | ( | const char * | prompt, |
const struct command * | commands, | ||
uint8_t | entries, | ||
preprompt | ppfunc = 0 |
||
) |
constructor
Note that you should normally not call the constructor directly. Use the MENU and MENU2 macros defined below.
prompt | The prompt to be displayed with this menu. |
commands | An array of ::command structures in program memory. |
entries | The number of entries in the menu. |
Definition at line 21 of file AP_Menu.cpp.
|
private |
Definition at line 260 of file AP_Menu.cpp.
Referenced by check_input(), and run().
|
private |
calls the function for the n'th menu item
n | Index for the menu item to call |
argc | Number of arguments prepared for the menu item |
Definition at line 235 of file AP_Menu.cpp.
Referenced by _run_command().
|
private |
check for another input byte on the port and accumulate return true if we have a full line ready to process
Definition at line 40 of file AP_Menu.cpp.
Referenced by check_input(), and run().
|
private |
Definition at line 80 of file AP_Menu.cpp.
Referenced by _run_command(), and run().
|
private |
implements the 'help' command
Implements the default 'help' command.
Definition at line 222 of file AP_Menu.cpp.
Referenced by _run_command().
|
private |
Definition at line 87 of file AP_Menu.cpp.
Referenced by check_input(), and run().
bool Menu::check_input | ( | void | ) |
check for new input on the port. Can be used to allow for the menu to operate asynchronously this will return true if the user asked to exit the menu
Definition at line 204 of file AP_Menu.cpp.
Menu::FUNCTOR_TYPEDEF | ( | func | , |
int8_t | , | ||
uint8_t | , | ||
const struct arg * | |||
) |
menu command function
Functions called by menu array entries are expected to be of this type.
argc | The number of valid arguments, including the name of the command in argv[0]. Will never be more than MENU_ARGS_MAX. |
argv | Pointer to an array of Menu::arg structures detailing any optional arguments given to the command. argv[0] is always the name of the command, so that the same function can be used to handle more than one command. |
Referenced by set_port().
Menu::FUNCTOR_TYPEDEF | ( | preprompt | , |
bool | |||
) |
menu pre-prompt function
Called immediately before waiting for the user to type a command; can be used to display help text or status, for example.
If this function returns false, the menu exits.
void Menu::run | ( | void | ) |
void Menu::set_limits | ( | uint8_t | commandline_max, |
uint8_t | args_max | ||
) |
set command line length limit
set limits on max args and command line length
Definition at line 244 of file AP_Menu.cpp.
|
inlinestatic |
|
private |
Definition at line 134 of file AP_Menu.h.
Referenced by _allocate_buffers(), _run_command(), and set_limits().
|
staticprivate |
arguments
Definition at line 131 of file AP_Menu.h.
Referenced by _allocate_buffers(), _call(), _run_command(), Menu(), and set_limits().
|
private |
Definition at line 133 of file AP_Menu.h.
Referenced by _allocate_buffers(), _check_for_input(), and set_limits().
|
private |
array of commands
Definition at line 126 of file AP_Menu.h.
Referenced by _call(), _help(), and _run_command().
|
private |
size of the menu
Definition at line 127 of file AP_Menu.h.
Referenced by _help(), and _run_command().
|
staticprivate |
input buffer
Definition at line 130 of file AP_Menu.h.
Referenced by _allocate_buffers(), _check_for_input(), _run_command(), Menu(), and set_limits().
|
private |
Definition at line 140 of file AP_Menu.h.
Referenced by _check_for_input(), _run_command(), and run().
|
staticprivate |
Definition at line 152 of file AP_Menu.h.
Referenced by _check_for_input(), _display_prompt(), _help(), _run_command(), check_input(), run(), and set_port().
|
private |
|
private |