Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Menu by
MenuItem.h@10:2b6ddf53b05e, 2015-03-16 (annotated)
- Committer:
- charly
- Date:
- Mon Mar 16 21:05:37 2015 +0000
- Revision:
- 10:2b6ddf53b05e
- Parent:
- 9:c9df0b33d176
- Child:
- 11:6814cbc83ae0
First version of a Yes/No Question with UserInterface and result.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| charly | 9:c9df0b33d176 | 1 | #ifndef MENUITEM_H |
| charly | 9:c9df0b33d176 | 2 | #define MENUITEM_H |
| charly | 9:c9df0b33d176 | 3 | |
| charly | 9:c9df0b33d176 | 4 | #include "Menu.h" |
| charly | 9:c9df0b33d176 | 5 | |
| charly | 9:c9df0b33d176 | 6 | class Menu; |
| charly | 9:c9df0b33d176 | 7 | |
| charly | 9:c9df0b33d176 | 8 | /** MenuItem is a menu-item of menu |
| charly | 9:c9df0b33d176 | 9 | */ |
| charly | 9:c9df0b33d176 | 10 | class MenuItem { |
| charly | 9:c9df0b33d176 | 11 | private: |
| charly | 9:c9df0b33d176 | 12 | |
| charly | 9:c9df0b33d176 | 13 | public: |
| charly | 10:2b6ddf53b05e | 14 | /** modes of MenuItems |
| charly | 10:2b6ddf53b05e | 15 | */ |
| charly | 10:2b6ddf53b05e | 16 | enum mode{ |
| charly | 10:2b6ddf53b05e | 17 | /** default mode: just display the Menu-Text an perform user_action |
| charly | 10:2b6ddf53b05e | 18 | */ |
| charly | 10:2b6ddf53b05e | 19 | mode_default = 0, |
| charly | 10:2b6ddf53b05e | 20 | /** wait_select: Call user_action and then only accept a select |
| charly | 10:2b6ddf53b05e | 21 | * use for displaying text, values,... |
| charly | 10:2b6ddf53b05e | 22 | * the menu is paused until select is pressed |
| charly | 10:2b6ddf53b05e | 23 | */ |
| charly | 10:2b6ddf53b05e | 24 | mode_wait_select = 1, |
| charly | 10:2b6ddf53b05e | 25 | /** mode_yes_no: show text and ask user for yes/no |
| charly | 10:2b6ddf53b05e | 26 | * |
| charly | 10:2b6ddf53b05e | 27 | */ |
| charly | 10:2b6ddf53b05e | 28 | mode_yes_no = 2 |
| charly | 10:2b6ddf53b05e | 29 | }; |
| charly | 10:2b6ddf53b05e | 30 | |
| charly | 10:2b6ddf53b05e | 31 | /** structure to pass data to menu and back |
| charly | 10:2b6ddf53b05e | 32 | */ |
| charly | 10:2b6ddf53b05e | 33 | struct menu_data{ |
| charly | 10:2b6ddf53b05e | 34 | // Longer text to display. |
| charly | 10:2b6ddf53b05e | 35 | // For Yes/No-Question |
| charly | 10:2b6ddf53b05e | 36 | char * text; |
| charly | 10:2b6ddf53b05e | 37 | //Yes/No Value In and Out |
| charly | 10:2b6ddf53b05e | 38 | bool yes_no; |
| charly | 10:2b6ddf53b05e | 39 | }; |
| charly | 10:2b6ddf53b05e | 40 | |
| charly | 9:c9df0b33d176 | 41 | /** pointer to user-action to execute when menu item is selected |
| charly | 9:c9df0b33d176 | 42 | */ |
| charly | 9:c9df0b33d176 | 43 | void (*userAction)(); |
| charly | 9:c9df0b33d176 | 44 | /** Text of Menue-Item to display |
| charly | 9:c9df0b33d176 | 45 | */ |
| charly | 9:c9df0b33d176 | 46 | char* selText; |
| charly | 9:c9df0b33d176 | 47 | /** position of menuitem in menu |
| charly | 9:c9df0b33d176 | 48 | */ |
| charly | 9:c9df0b33d176 | 49 | int pos; |
| charly | 9:c9df0b33d176 | 50 | /** Pointer to child-menue |
| charly | 9:c9df0b33d176 | 51 | */ |
| charly | 9:c9df0b33d176 | 52 | Menu *childMenu; |
| charly | 10:2b6ddf53b05e | 53 | /** itemMode |
| charly | 10:2b6ddf53b05e | 54 | */ |
| charly | 10:2b6ddf53b05e | 55 | uint8_t itemMode; |
| charly | 10:2b6ddf53b05e | 56 | |
| charly | 10:2b6ddf53b05e | 57 | menu_data * menu_parameter; |
| charly | 9:c9df0b33d176 | 58 | |
| charly | 9:c9df0b33d176 | 59 | /** a sub-menu |
| charly | 9:c9df0b33d176 | 60 | */ |
| charly | 10:2b6ddf53b05e | 61 | MenuItem(void (*)(), int, Menu *, char *, uint8_t = mode_default, menu_data * = NULL); |
| charly | 9:c9df0b33d176 | 62 | |
| charly | 9:c9df0b33d176 | 63 | }; |
| charly | 9:c9df0b33d176 | 64 | |
| charly | 9:c9df0b33d176 | 65 | #endif |
