Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Menu system for monochrome graphical displays

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 asfdoc_common2_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 gfx_mono_menu 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)
 
More...
 
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
Value:
SYSFONT_LINESPACING) - 1)
#define GFX_MONO_LCD_HEIGHT
Definition: gfx_mono_null.h:59

Maximum number of menu elements on display.

Referenced by menu_draw().

#define GFX_MONO_MENU_EVENT_EXIT   0xFE

Exit.

User has pressed the back button.

Referenced by gfx_mono_menu_process_key().

#define GFX_MONO_MENU_EVENT_IDLE   0xFF

Idle.

Nothing to report.

Referenced by gfx_mono_menu_process_key().

void gfx_mono_menu_init ( struct gfx_mono_menu menu)

Initialize the menu handling. Clear screen and draw menu.

Parameters
[in]menumenu 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 gfx_mono_menu::title.

uint8_t gfx_mono_menu_process_key ( struct gfx_mono_menu menu,
uint8_t  keycode 
)

Update menu depending on input.

Parameters
[in]menumenu struct with menu options
[in]keycodekeycode to process
Return values
selectedmenu option or status code

References gfx_mono_menu::current_selection, GFX_MONO_MENU_EVENT_EXIT, GFX_MONO_MENU_EVENT_IDLE, menu_draw(), and gfx_mono_menu::num_elements.

PROGMEM_DECLARE ( gfx_mono_color_t  ,
arrow_right_data  [] 
)