2.4 GFX Menu System
This module provides a simple menu system for monochrome graphical displays.
Typical flow of an application using the menu system:
- Define menu structure.
- Call gfx_mono_menu_init.
- Get user input.
- Update menu with user input using function gfx_mono_menu_process_key.
- Interpret gfx_mono_menu_process_key return value.
- 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 key-code:
- 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 key-codes used are defined in conf_menu.h. These values 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.
The menu system functions are listed below, implemented in gfx_mono_menu.h/c.
Functions | Description |
---|---|
gfx_mono_menu_init() | Initialize the menu handling. Clear screen and draw menu. |
gfx_mono_menu_process_key() | Update menu depending on input |