MenuDesigner
This project provides a complete GUI system for systems with limited resources.
Sourceforge start page
Download
Description
The
project consists of two parts. The MenuInterpreter and the MenuEditor.
The MenuEditor is a graphical editor, written in Pascal/Lazarus (tested
with Linux and Windows), where you can build your menu system. The
MenuEditor then will compile the menu into a compact bytecode. The
MenuInterpreter, written in platform independent C, draws screens
according to the bytecode. The MenuInterpreter is optimized to use very
small resources.
For example, the MenuInterpreter can run on a small 8 bit
microcontroller like an AVR ATmega32 (32KB flash, 2KB RAM) with a
128x64 black/white LCD and some keys connected. An example menu which
uses ASCII characters as display and runs on an ATmega8 (8KB flash, 1KB
RAM) is provided.
Features
- Independent from the used LCD controller
- The interpreter needs about 5KB program space
- Very low permanent RAM usage
- The generated menu system can be stored on any random access readable memory
- Using 16 or 24 bit addresses, the menu may have a size of up to 24MB or up to 64KB if 16 bit addresses are used
- Navigation is optimized for use with few keys. The minimum is two, but four would be more comfortable
- The following GUI elements are supported:
- Window: Can contain objects
- SubWindow: Good for pop-up messages, has all abilities of a normal window
- Box: Draws a box either white or black
- Label: Draws text on the screen
- Button: A button for actions or text with a border
- Graphic: Black and white pixel images, supports basic compression
- List: Shows multiple lines of text and a scrollbar if needed
- Checkbox
- Radiobutton
- Shortcut: Invisible, supports direct actions and window changes
- Global shortcut: Like a shortcut, but once defined, its valid within all windows
- Static text and graphics can be stored directly within the bytecode, changing text and graphics can be stored in the RAM
- Support for multiple fonts
- Renderer and data for 5x7 font included
- Renderer for 8x16 font included (3rd party)
- Tool for converting system fonts into a proper 8x16 or 5x7 data array provided
- Partial support for mice and touch screens (support for list element is incomplete)
- Support to select a different languages during run-time
- No need for special hardware like timers or similar
- The editor automatically configures the source code to either use
32 or 16 bit address size and switches between 8 and 16 bit types for
the display coordinates. This reduces the code size and improves speed
- The editor can optimizes the size of the byte code by finding and re-using duplicate text and graphics
- The editor detects which GUI elements are really used and
configures the source code of the interpreter so that unused code is
optimized out. As example, if neither lists, nor images are used, the
needed program space is reduced from 5KB to 3,5KB. And if you need
nothing more than labels and buttons, the space for the interpreter is
reduced to 2,8KB.
Limits
- GUI elements can not be moved to an other position during run-time
- Labels can use one of 256 possible fonts, all other elements only support one of 16 possible fonts
- Animations are difficult to realize
- There is a maximum of 256 different checkboxes
- There is a maximum of 256 different lists
- There is a maximum of 16 different groups of groupbuttons with 16 different selections in each group
- Lists are limited to ~10000 lines
- The screen may have a resolution of up to 4096x4096
- Only one Window and one SubWindow can be shown at the same time
- There is a maximum of 254 different languages
What is needed to use the code
Generally the code should work on any platform, supported by gcc or a similar C compiler.
Normally you have to implemented five functions for yourself:
Implement unsigned char menu_byte_get(MENUADDR addr)
The access to the binary menu structure. Like RAM, Flash or EEPROM
read. Its best to make sure 'addr' is below the MENU_DATASIZE
definition.
Implement void menu_screen_set(SCREENPOS x, SCREENPOS y, unsigned char color)
This function gets called while the screen is redrawn. Please note that
x and y can be outside of the defined screen size. You must catch this
in order to prevent memory corruption.
Depending on your selected screen resolution, SCREENPOS is a 8 or 16 bit unsigned integer.
Implement void menu_screen_flush(void)
This function gets called once, when redrawing has completed. Use this
to draw the values set by the function above to the screen.
Implement void menu_screen_clear(void)
Gets called on every screen switch. Simply provided, because there are
often faster methods for clearing a screen than drawing every single
pixel.
Implement unsigned char menu_action(unsigned short action)
This function gets called so you can react on the user inputs of the
screen, return 1 if you want a redraw, 0 if not. If a screen change
occurs, a redraw is made anyway.
Call void menu_keypress(unsigned char key)
You should call this function in order to initiate screen changes or let the menu react on other key inputs.
Call void menu_redraw(void)
If you have dynamic data (text, graphics) on the screen you should call void menu_redraw(void) in order
to init a redraw.
(Since version 1.4) If compiled with mouse/touch support,
call, void menu_mouse(SCREENPOS x, SCREENPOS y, unsigned char key)
to run the menu_keypress(unsigned char key) function for the element on the given screen position.
Note: This behaviour is currently not sufficient for comfortable using with the list element.
(Since version 1.5) If compiled with multi-language support,
call void menu_language_set(unsigned char id)
To set the language to display. You may need to call menu_redraw(void)
afterward in order for displaying the menu in the new selected language.
To exchange dynamic data with the GUI, like text which is modified
during run-time or read out the state of a checkbox, global variables
(the five arrays in the graphic) are used. They are used in favor of
getter and setter functions in order to reduce the program size. To
find the correct index in the array, the editor generates some #define
with user configurable names.
Additional resources
I wrote a wiki article over the menu system (in German) some time ago http://www.mikrocontroller.net/articles/MenuDesigner
and posted the source code to a forum http://www.mikrocontroller.net/topic/140369
Contact
You used the MenuDesigner?
Write me your opinion m DOT talk AT marwedels DOT de
Last changed: 23.05.2012