\section{menu Struct Reference}
\label{structmenu}\index{menu@{menu}}
{\tt \#include $<$menu.h$>$}

\subsection*{Data Fields}
\begin{CompactItemize}
\item 
uint8\_\-t {\bf type}
\item 
void $\ast$ {\bf data}
\end{CompactItemize}


\subsection{Detailed Description}
This is the documentation of the \doxyref{menu}{p.}{structmenu} module.

RESUME ======

The aim of this module is to provide some simple functions to use a tree-based \doxyref{menu}{p.}{structmenu} in a program. The displaying of the \doxyref{menu}{p.}{structmenu} can be done in several ways: uart, lcd, ... This module tries to be independant of the way it is displayed.

MAIN FUNCTIONS ==============

The main functions that can be used are : \doxyref{menu\_\-left()}{p.}{menu_8c_181625db1ec09e267a4756644ae538dd}, \doxyref{menu\_\-right()}{p.}{menu_8c_33fb8db3ebecfbab3900a5e0d39fccf8}, \doxyref{menu\_\-up()}{p.}{menu_8c_cb3303048b2d6514e77a3f4fd05c1c98} and \doxyref{menu\_\-down()}{p.}{menu_8c_0da12eec795a34a3313415d4803cc67c}. they are used to browse the \doxyref{menu}{p.}{structmenu}. Each of these functions take a pointer to a \doxyref{menu}{p.}{structmenu} as an argument and return another one. The directions correspond to (one of) the natural representation of a tree.

root ----- submenu1 ----- leaf1 $|$ $|$ $|$ $|$--- leaf2 $|$ $|$ $|$ $|$--- submenu2 ----- leaf3 $|$ $|$ $|$ $|$--- leaf4 $|$ ---- leaf5

Left goes to the parent. Right goes to the first son Up goes to the \doxyref{menu}{p.}{structmenu} before, on the same level. Down goes to the \doxyref{menu}{p.}{structmenu} after, on the same level.

These functions try to be tolerant : for example, doing a \doxyref{menu\_\-left()}{p.}{menu_8c_181625db1ec09e267a4756644ae538dd} on the root \doxyref{menu}{p.}{structmenu} return the root \doxyref{menu}{p.}{structmenu}. Doing a \doxyref{menu\_\-down()}{p.}{menu_8c_0da12eec795a34a3313415d4803cc67c} on the last \doxyref{menu}{p.}{structmenu} of a level returns the first \doxyref{menu}{p.}{structmenu} on the same level.

The module provide one function for displaying a \doxyref{menu}{p.}{structmenu} and another to do an action depending on a character. These functions can be reimplemented by the user to be more adapted to his application.

The default display function clear the screen, print the parent of the \doxyref{menu}{p.}{structmenu}, then all other menus on the same level, highlighting the \doxyref{menu}{p.}{structmenu} given in parameter.

The default menu\_\-update() function takes a character as parameter.\begin{itemize}
\item 'n' (next) is equivalent to menu\_\-right.\item 'p' (previous) is equivalent to menu\_\-left.\item 'f' (forward) is equivalent to menu\_\-down.\item 'b' (backward) is equivalent to menu\_\-up.\item '0', '1', ..., '9' selects the \doxyref{menu}{p.}{structmenu} n on the same level.\end{itemize}


IMPLEMENTATION ==============

A \doxyref{menu}{p.}{structmenu} is a static table of a \doxyref{menu}{p.}{structmenu} element. Each \doxyref{menu}{p.}{structmenu} element is a struct \doxyref{menu}{p.}{structmenu} :

struct \doxyref{menu}{p.}{structmenu} \{ uint8\_\-t type; void $\ast$ data; \}

An element type can be : MENU\_\-TYPE\_\-ROOT if the element is the root of the \doxyref{menu}{p.}{structmenu}, MENU\_\-TYPE\_\-MENU if it is a submenu under the root, MENU\_\-TYPE\_\-FCT\_\-HDR, MENU\_\-TYPE\_\-FCT\_\-PTR, MENU\_\-TYPE\_\-FCT\_\-DATA, to declare a leaf that executes a function, or MENU\_\-TYPE\_\-END to mark the end of a submenu or the end of the root \doxyref{menu}{p.}{structmenu}.

For each of these types, the data field points to different things : MENU\_\-TYPE\_\-ROOT data -$>$ (char $\ast$) title of the \doxyref{menu}{p.}{structmenu} MENU\_\-TYPE\_\-MENU data -$>$ (char $\ast$) title of the \doxyref{menu}{p.}{structmenu} MENU\_\-TYPE\_\-FCT\_\-HDR data -$>$ (char $\ast$) title of the \doxyref{menu}{p.}{structmenu} MENU\_\-TYPE\_\-FCT\_\-PTR data -$>$ void ($\ast$f)(void $\ast$) function that will be called MENU\_\-TYPE\_\-FCT\_\-DATA data -$>$ (void $\ast$) parameter of this function MENU\_\-TYPE\_\-END data -$>$ NULL

Here is an exemple :

root ----- submenu1 ----- leaf1 $|$ $|$ $|$ $|$--- leaf2 $|$ $|$ $|$ $|$--- submenu2 ----- leaf3 $|$ $|$ $|$ $|$--- leaf4 $|$ ---- leaf5

will be represented as :

MENU\_\-TYPE\_\-ROOT, \char`\"{}root\char`\"{} MENU\_\-TYPE\_\-MENU, \char`\"{}submenu1\char`\"{} MENU\_\-TYPE\_\-FCT\_\-HDR, \char`\"{}leaf1\char`\"{} MENU\_\-TYPE\_\-FCT\_\-PTR, fct\_\-leaf1 MENU\_\-TYPE\_\-FCT\_\-DATA, leaf1\_\-data MENU\_\-TYPE\_\-FCT\_\-HDR, \char`\"{}leaf2\char`\"{} MENU\_\-TYPE\_\-FCT\_\-PTR, fct\_\-leaf2 MENU\_\-TYPE\_\-FCT\_\-DATA, leaf2\_\-data MENU\_\-TYPE\_\-MENU, \char`\"{}submenu2\char`\"{} MENU\_\-TYPE\_\-FCT\_\-HDR, \char`\"{}leaf3\char`\"{} MENU\_\-TYPE\_\-FCT\_\-PTR, fct\_\-leaf3 MENU\_\-TYPE\_\-FCT\_\-DATA, leaf3\_\-data MENU\_\-TYPE\_\-FCT\_\-HDR, \char`\"{}leaf4\char`\"{} MENU\_\-TYPE\_\-FCT\_\-PTR, fct\_\-leaf4 MENU\_\-TYPE\_\-FCT\_\-DATA, leaf4\_\-data MENU\_\-TYPE\_\-END, NULL MENU\_\-TYPE\_\-END, NULL MENU\_\-TYPE\_\-FCT\_\-HDR, \char`\"{}leaf5\char`\"{} MENU\_\-TYPE\_\-FCT\_\-PTR, fct\_\-leaf5 MENU\_\-TYPE\_\-FCT\_\-DATA, leaf5\_\-data MENU\_\-TYPE\_\-END, NULL

For AVR version, all is stored in program memory. (TODO : store the \doxyref{menu}{p.}{structmenu} table in program memory, currently only text is stored there) The structure that defines a \doxyref{menu}{p.}{structmenu} element. A \doxyref{menu}{p.}{structmenu} is composed of several struct a this type, see the documentation for more informations 

Definition at line 156 of file menu.h.

\subsection{Field Documentation}
\index{menu@{menu}!type@{type}}
\index{type@{type}!menu@{menu}}
\subsubsection[type]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t {\bf menu::type}}\label{structmenu_ae1fcff216beb7d9efea368541ea77ff}




Definition at line 157 of file menu.h.

Referenced by menu\_\-call\_\-fct(), menu\_\-default\_\-update(), menu\_\-get\_\-name(), menu\_\-get\_\-next(), menu\_\-get\_\-parent(), menu\_\-get\_\-previous(), and menu\_\-get\_\-type().\index{menu@{menu}!data@{data}}
\index{data@{data}!menu@{menu}}
\subsubsection[data]{\setlength{\rightskip}{0pt plus 5cm}void$\ast$ {\bf menu::data}}\label{structmenu_0f989fd744677f0e506c9b991c08c128}




Definition at line 158 of file menu.h.

Referenced by menu\_\-get\_\-name().

The documentation for this struct was generated from the following file:\begin{CompactItemize}
\item 
aversive\_\-10-03-12/modules/ihm/menu/{\bf menu.h}\end{CompactItemize}
