Simple LCD Menu Main Page

Aus ProjectWiki
Wechseln zu:Navigation, Suche

Overview

This is a menu system for standard alphanumerical LC-displays.

To navigate through the menu, only 3 buttons are needed: Forward, Backward and Menu/Enter (or a rotary encoder with push button).

You can make multiple nested sub-menus, hidden menus (not supported by the designer yet), function calls and display or edit different value types (Bit, Byte, Word, Integer, Single, String).

The menu structure and associated data is stored in arrays at runtime, the structure is made by connecting the right entries together (with their array indexes).

Numerical values are displayed both as value and as a bargraph showing the current position in the specified range.

Bit values can be set to On/Off (or another custom text), numerical values will be increased/decreased by the specified step size and string values can be edited using a custom set of characters (and two special characters for backspace/enter). Read-Only values just show the content of a variable.

To save program space, just the pieces of code you use are compiled. You get the smallest size if you just use Links and Function Calls, it will increase if you use values (read-only, editable or both) and for each data type used.


How to use it

Setup

Include the menu structure created with the designer and the menu functions:

Macro Menu_include_data
   $include "inc\menu_data.bas"
End Macro
$include "inc\menu.bas"

Dimension used Variables

Between the function include and the initialisation you have to dimension the variables used to display or edit in the menu:

Dim Test_bit As Byte
Dim Test_byte As Byte
Dim Test_word As Word
Dim Test_integer As Integer
Dim Test_dword As Dword
Dim Test_long As Long
Dim Test_single As Single
Dim Test_double As Double
Dim Test_string As String * Menu_value_string_width

Bit data types have to be defined as a byte. Note that a constant was created containing the maximum string size.

Initialisation

Menu_init

Main Loop

Do
   If Switch_minus = 1 Then Menu_backward()            ' back button pressed
   If Switch_plus = 1 Then Menu_forward()              ' forward button pressed
   If Switch_enter = 1 Then                            ' enter button pressed
      Select Case Menu_enter()
      Case Menu_exit:                                  ' Exit entry selected
         ...
      Case 2-255:                                      ' Function call
         ...
      End Select
   End If
   Menu                                                ' Main function
   ...
Loop


Interface description

Declare Sub Menu()
Declare Sub Menu_forward()
Declare Sub Menu_backward()
Declare Function Menu_enter() As Byte
Declare Sub Menu_show(byval Entry_id As Byte)
Declare Sub Menu_hide()
Macro Menu_init
Const Menu_default_entry
Const Menu_value_string_width


Sample

Menu structure overview

Menu data include file

Main file

Download