This module provides a simple menu system for monochrome graphical displays.
Typical flow of an application using the menu system:
1) Define menu structure.
2) Call gfx_mono_menu_init.
3) Get user input.
4) Update menu with user input using function gfx_mono_menu_process_key.
5) Interpret gfx_mono_menu_process_key return value.
6) Go to 3.
The menu is declared using the Menu system for monochrome graphical displays struct.
To start the menu system, call the gfx_mono_menu_init function. This function will clear the display and draw the menu.
Before the menu can be updated, you need input from the user. Methods for getting input is not part of the menu module.
As soon as input is received, inform the menu system using the gfx_mono_menu_process_key function. This function will then return a status code and act depending on the given keycode:
MENU_KEYCODE_DOWN : Change selection to next menu item (or first if at bottom). Returns MENU_EVENT_IDLE.
MENU_KEYCODE_UP : Change selection to previous menu item (or last if at top). Returns MENU_EVENT_IDLE.
MENU_KEYCODE_ENTER : Nothing changes in menu. Returns the line selected.
MENU_KEYCODE_BACK : Nothing changes in menu. Returns MENU_EVENT_EXIT.
The value of the keycodes used are defined in conf_menu.h. These value can be changed if needed.
The graphical indicator used to indicate menu selection is defined in conf_menu.h. This indicator can be changed if needed.
Data Structures | |
struct | gfx_mono_menu |
Menu struct. More... | |
Macros | |
#define | GFX_MONO_MENU_ELEMENTS_PER_SCREEN |
Maximum number of menu elements on display. More... | |
Functions | |
void | gfx_mono_menu_init (struct gfx_mono_menu *menu) |
uint8_t | gfx_mono_menu_process_key (struct gfx_mono_menu *menu, uint8_t keycode) |
Update menu depending on input. More... | |
PROGMEM_DECLARE (gfx_mono_color_t, arrow_right_data[]) | |
Menu events definitions | |
#define | GFX_MONO_MENU_EVENT_IDLE 0xFF |
Idle. More... | |
#define | GFX_MONO_MENU_EVENT_EXIT 0xFE |
Exit. More... | |
#define GFX_MONO_MENU_ELEMENTS_PER_SCREEN |
Maximum number of menu elements on display.
Referenced by menu_draw(), run_menu_init_test(), and run_menu_page_change_test().
#define GFX_MONO_MENU_EVENT_EXIT 0xFE |
Exit.
User has pressed the back button.
Referenced by gfx_mono_menu_process_key(), and run_menu_navigation_test().
#define GFX_MONO_MENU_EVENT_IDLE 0xFF |
void gfx_mono_menu_init | ( | struct gfx_mono_menu * | menu | ) |
Initialize the menu handling. Clear screen and draw menu.
menu | menu struct with menu options |
References gfx_mono_draw_filled_rect, gfx_mono_draw_progmem_string(), GFX_MONO_LCD_HEIGHT, GFX_MONO_LCD_WIDTH, GFX_PIXEL_CLR, menu_draw(), PROGMEM_PTR_T, sysfont, and title.
Referenced by run_menu_init_test(), run_menu_navigation_test(), run_menu_page_change_test(), run_menu_wrap_first_test(), and run_menu_wrap_last_test().
uint8_t gfx_mono_menu_process_key | ( | struct gfx_mono_menu * | menu, |
uint8_t | keycode | ||
) |
Update menu depending on input.
menu | menu struct with menu options |
keycode | keycode to process |
selected | menu option or status code |
References current_selection, GFX_MONO_MENU_EVENT_EXIT, GFX_MONO_MENU_EVENT_IDLE, GFX_MONO_MENU_KEYCODE_BACK, GFX_MONO_MENU_KEYCODE_DOWN, GFX_MONO_MENU_KEYCODE_ENTER, GFX_MONO_MENU_KEYCODE_UP, menu_draw(), and num_elements.
Referenced by run_menu_navigation_test(), run_menu_page_change_test(), run_menu_wrap_first_test(), and run_menu_wrap_last_test().
PROGMEM_DECLARE | ( | gfx_mono_color_t | , |
arrow_right_data | [] | ||
) |