[Top] [Contents] [Index] [ ? ]

MEX - The Menu Executor

Abstract
This document describes version 1.0 of MEX, the Menu EXecutor. MEX is a generic interpreter for the binary menu format which is generated by MLC, the Menu Language Compiler. The current version of MEX is written in Ansi-C and compiles with icc11 (68HC11) or djgcc (Intel x86). Related information about ML (Menu Language), can be obtained in the following document: See section `Introduction' in A Menu-Language Introduction.

Copyright (C) 1997-2001 Hubert Hoegl Edition 0.9.1

Last change: April 7 2001

1. Document History  
2. Introduction  
3. Menu Navigation  
4. Line Navigation and Field Editing  
5. Keyboard Layouts  
6. Programming Interface  
7. Implementation Notes  


1. Document History

2004-05-24

Added this section. No entries so far.


2. Introduction

A typical user interface for embedded systems consists of a tiny keyboard and a LC-display. The M-Language was designed to comfortably describe menu-based user interaction with embedded system euqipped with these two I/O components. The menu description can be compiled into a binary menu format and linked with an embedded application. Control of the LCD and the keyboard is done by a function (or process in a multitasking environment) which interprets the binary menu data, called "Menu Executor" in the further context.

Typical LC-display sizes are 16x2, 16x4, 20x2 and 20x4. All these formats can be controlled with MEX. The following figure shows a 16x4 display.

 
column           column
  1                16
  v                v
  +----------------+
  |................|  <- row 1
  |................|
  |................|
  |................|  <- row 4
  +----------------+

The minimum requirement for the keyboard consists of 5 keys. These are the four cursor keys (left, right, up, down) and a tabulator key.


3. Menu Navigation

3.1 The LCD Layout  
3.2 Moving in the hierarchy  


3.1 The LCD Layout

MEX uses a fixed LCD layout. The top line of the display is called the status line and shows miscellaneous information about the current status of the user interface. Thus on a four line display there are three remaining lines which can be used for displaying menu data. On a two line display there will be only one menu-line below the status line.

A future version of MEX may also be able to display a footer line on a four line display. In this case two menu lines will be displayed.

 
    +----------------+
    |TTTTTTTTTTTTNLLK| <- Status line
    |C..............S| <- Menu line 1
    |C..............S| <- Menu line 2
    |C..............S| <- Menu line 3
    +----------------+

The display layout is divided into fields, which are denoted by characters in the above figure. The table below explains the fields:

`T'
In this field the `menu-title' is displayed. The menu-title is specified for each menu-table in the `menu-struct' section of the `.m' file. The menu-title is displayed left-aligned. On a 20 character per line display, there will be four more characters for this field.

`N'
This is a line-navigation character. It informs the user that the current cursor line contains writeable fields. If the cursor is positioned onto one of these writeable line components by the tabulator key, the N-field informs about the type of the line component (integer, counter, trigger, etc.). Currently the character is `*' when the line is completely `read-only', which means, that no entries can be done. The character switches to `:' when at least one of the line components is writeable.

`L'
The two-character L-field shows the line-number of the current cursor line. It ranges from 1 to 99.

`K'
The K-field contains either an empty character, `+' or `!'. The empty character is display when the current menu table contains not more than three menu lines on a four line display. If there are more than three lines in the menu-table, the character is `+'. The cursor can be moved downwards until the last line, which is signaled by a `!'.

`C'
The first character of all menu lines is reserved for the line cursor or also called "vertical" cursor.

`S'
The last character of all menu lines is reserved for the submenu indicator. This character is either `>' is the menu-line points to a submenu or `P' if the menu-line points to a submenu which has a password security access.

`.'
These characters are used for displaying menu data.


3.2 Moving in the hierarchy

By using the four cursor keys one can move freely within the hierarchical menu structure. The following figure shows how these four cursor keys should be mounted:

 
               KEY_UP

      KEY_LEFT       KEY_RIGHT

              KEY_DOWN

The keys KEY_UP and KEY_DOWN move the previous or next line in a menu-table. KEY_RIGHT steps into a submenu and KEY_LEFT jumps out of a submenu.

Accessing protected submenus: When a submenu is protected by a password (this is indicated by the rightmost line-character equal to P) then prior to entering the submenu a password has to be typed in the keyboard. The password is specified as the attribute `key' in the menu description file. The password consists of a string of integers, for example

 
(key   '401302')

A typical situtation is shown in the figure below:

 
    +----------------+
    |Pwd:......      | 
    | Sensors...    >| 
    | Parameter...  >|
    |>System...     P| 
    +----------------+

On entering menu-line 3 ("System...") the status line changes to a password entry field. After the string "Pwd:" there are as many points as there are digits in the password (in our case six). On every subsequent keypress a `.' changes to a `*' character indicating how many password character already have been entered.

For entering the required numeric passord value, each key has also a fixed numerical value. Thus on a minimal five-key keyboard one can represent the numbers zero to four. Thus one may not choose numbers bigger than four in the key-attribute of the menu description file when using the minimal keyboard.

When all password characters have been chosen right, than immediately after pressing the last password character one enters the submenu. If the password was wrong, the attempt to enter the submenu is ignored. In either case the status line will again change to show the typical contents.


4. Line Navigation and Field Editing

The principle of navigation within a line ("horizontal navigation") is very simple. It is done solely with the tabulator key. If a menu-line contains no writeable line components, then pressing the tabulator key has no effect. If there is a writeable field (or also called `entry field') somewhere within the line (indicated by the line-navigation character in the status line), then subsequently pressing the tab-key will position the "horizontal" line cursor (blinking black box) on this field.

Now assume the cursor is positioned on the first character of an entry field. The way to change its value is dependant on the type of the entry field. When using the minimum keyboard layout (five keys), all field entry is done via the four cursor keys. Note that while the horizontal cursor is displayed (blinking), one can not navigate through the menu hierarchy!

When the cursor is positioned on the final line-component in a line then the next keypress on tabulator will make the horizontal cursor disappear. Then again the cursor-keys have their menu-navigation functionality.

There are nine different types of entry fields(1).

4.1 Counter entry field  
4.2 Date entry field  
4.3 Float entry field  
4.4 Integer entry field  
4.5 Option entry field  
4.6 String entry field  
4.7 Switchbox entry field  
4.8 Time entry field  
4.9 Trigger entry field  


4.1 Counter entry field

The counter field is similar to the integer field, except that the displayed field value can only be increased or decreased by a fixed stepsize. The from-, to-, and step-values can be described in the menu specification.

The counter entry field is controlled via KEY_UP and KEY_DOWN. On pressing KEY_UP the field is increased by one step and pressing KEY_DOWN decreases the value by one step. No action results when the counter value would result past the maximum or below the minimum value.


4.2 Date entry field

The date entry field exists in a long and a short variant. They differ in the length of the year-field. The long one uses four digit year numbers and the short one only two digits.

 
|......12/04/1961|   <- long date (day/month/year)
|........12/04/61|   <- short date

The tab-key move the horizontal cursor from day to month to year on successive keypresses. Thus the whole field behaves as if it were composed of three subfields. Each single field can be adjusted according to the rules given for counter entry fields.

Sub-components.

The `date' entry field consist of three sub-components. In the example above these are 12, 04 and 61 (in the short format).

In principle this is nothing more than three separate fields of type `dd' with string separators `:' and `.'. The only reason for introducing the compound types `date' and `time' was its better encapsulation. ML currently does not allow to specify how the different sub-components are handled, so MEX has to choose an appropriate field processing method. Currently all sub-components in `date' and `time' are of elementary type `counter'.


4.3 Float entry field

Currently there is no support for read-only or editable float components. If editable float fields should be used, then it is highly recommended to have a numerical keypad consisting of the keys zero to nine and a point.


4.4 Integer entry field

The current version of MEX has only limited support for `integer' line components. As read-only fields one can use the type attributes `dd', `sdd', `sddd' and `DDD' (See section `Integer' in A Menu-Language Introduction.).

Currently there is no support for editable integer components. This is due to the fact that the basic keyboard layout consisting only of five keys. Integers can best be input with a numerical keypad containing the numbers zero to nine.


4.5 Option entry field

In an option entry field one selects an individual option by pressing the KEY_LEFT or KEY_RIGHT keys subsequently. On pressing the KEY_TAB key the option field is left and the callback handler is called.


4.6 String entry field

Strings are currently only supported as read-only.


4.7 Switchbox entry field

A switchbox is similar to an array of switches. Each of the switches can be in `off' or `on' position. When the horizontal cursor is initially positioned in a switchbox, the cursor is blinking on the leftmost switch. By pressing either KEY_LEFT or KEY_RIGHT, the blinking cursor can be moved within the switchbox. A switch can be turned on by pressing KEY_UP. KEY_DOWN turns the switch in the off state.


4.8 Time entry field

For explanation see the date entry field above. The time entry field is similar to the date entry field composed of three (long) or two (short) sub-components.

 
|........12:04.59|   <- long time (hour:minute.second) 
|...........12:04|   <- short time (hour:minute) 


4.9 Trigger entry field

The trigger entry field is shown as a single predefined character (currently the outline of a box). When the horizontal cursor is positioned on a trigger, then pressing any of the cursor keys results in jumping into the callback handler for this field.

Note the difference to the callback behaviour of the other entry types: With the other entry fields the callback function is always called when the entry field is finished by pressing the tabulator key. This behaviour is not satisfactory for the trigger field because stepping over a trigger field by pressing tab should not activate the callback.


5. Keyboard Layouts


5.1 Mandatory keys

Keys that must be available:

`KEY_LEFT'
Cursor left

`KEY_RIGHT'
Cursor right

`KEY_UP'
Cursor up

`KEY_DOWN'
Cursor down

`KEY_RTAB'
Right tabulator key.

Suggested floorplan for the minimal keyboad

 
----------------------------------
             UP
        LEFT     RIGHT       TAB
             DN                  
----------------------------------


5.2 Optional keys

Keys that optionally can be available:

`KEY_0 to KEY_9, KEY_POINT'
Extra numerical keypad.

`KEY_Fx'
Any number of function keys

Suggested floorplan for the extended keyboad

 
----------------------------------------------------

                                       7  8  9
                                       4  5  6
             UP                        1  2  3 
        LEFT     RIGHT       TAB       0     .
             DN                  
               
----------------------------------------------------


6. Programming Interface

META: Needs to be written.

6.1 Initialization  
6.2 Menu variable access  
6.3 Installing callbacks  
6.4 The ticker interface  
6.5 Display refreshing  


6.1 Initialization

Library Function: uchar mex_init (uchar* menu, uchar bootmode);

menu points to the beginning of a binary menu image. bootmode is one of COLD_BOOT or WARM_BOOT.


6.2 Menu variable access

META: ...


6.3 Installing callbacks

Library Function: fcncbp handler (fcncbp* fa, fcncbp f)

Function `handler' installs function f at the location pointed to by fa. The return value contains the previous installed callback handler.


6.4 The ticker interface

META: ...


6.5 Display refreshing

META: ...


7. Implementation Notes

MEX has been written in Ansi-C. The prototype compiles with icc11 3.5 (68HC11) and gcc 2.7.2.1 (Unix, DOS). The program was mainly tested on a 68HC11 based embedded controller with small keyboard (23 keys) and 16x4 LC-display. The program size on the HC11 is about 14 kbytes. When all currently unimplemented features will be implemented, then the code-size is expected to be about 18 to 20 kbytes.

Porting MEX to another target/compiler in principle involves only an additional `#define' for the new compiler in `include/types.h' and some typedefs, also in `types.h'.


[Top] [Contents] [Index] [ ? ]

Footnotes

(1)

There is one line component which is not editable. This is the `hfill' component.


[Top] [Contents] [Index] [ ? ]

Table of Contents


[Top] [Contents] [Index] [ ? ]

Short Table of Contents

1. Document History
2. Introduction
3. Menu Navigation
4. Line Navigation and Field Editing
5. Keyboard Layouts
6. Programming Interface
7. Implementation Notes

[Top] [Contents] [Index] [ ? ]

About this document

This document was generated by Hubert Hoegl on May, 24 2004 using texi2html

The buttons in the navigation panels have the following meaning:

Button Name Go to From 1.2.3 go to
[ < ] Back previous section in reading order 1.2.2
[ > ] Forward next section in reading order 1.2.4
[ << ] FastBack previous or up-and-previous section 1.1
[ Up ] Up up section 1.2
[ >> ] FastForward next or up-and-next section 1.3
[Top] Top cover (top) of document  
[Contents] Contents table of contents  
[Index] Index concept index  
[ ? ] About this page  

where the Example assumes that the current position is at Subsubsection One-Two-Three of a document of the following structure:

This document was generated by Hubert Hoegl on May, 24 2004 using texi2html