MenuLib

I already wrote a Menu Library whichwas mainly determined by its complicated structure and huge size in memory. Furthermore the library put its data out on its own.

This MenuLib is based upon a simple graph-based concept. The look can be configured by the user and the code is just about 250 lines long. As usual the lib can be easily ported to any architecture as long as there is a C-compiler at hand.

Include in project (compile):

  • menulib.c
  • string.c

Functions:

  • void init_menu(menudata * menu, uint8_t entries); – Initializes the statemachine with the supplied pointer menu onto the menu structure. entries is the amount of Menu entries.
  • void mGetText(char * txt, uint8_t lines, uint8_t linelen, uint8_t parents); – Supply a pointer to a memory-space of the size lines * (linelen +1) and the function will output the menu in lines 0-terminated strings.
  • void mStatemachine(uint8_t key);key is the keycode as defined in menulib.h

Defines (menulib.h):

  • #define cMenuLine 21 -Maximum (text) length of a menu entry
  • #define mCallbackWithParams 1 -Use callback functions with a (preshared) parameter. Comment to use Functions without params (saves storage space)

You can deactivate the features by commenting the following defines

  • #define mOffsetString “+” – A char (string) to display a father-> child relation
  • #define mOffsetShortenedString “#” – At some point the tree history must be shortened. Symbos for this. Undefine only in combination with mOffsetString
  • #define mMarkedString “>” – Char (string) to mark the selected item
  • #define mNotMarkedString “-“ – Char (string) to mark not selected item

Keycodes for statemachine controlling…

  • #define mKeyUp      8 – Keycode for “up”
  • #define mKeyDown    2 – Keycode for “down”
  • #define mKeyOK      6 – Keycode for “OK” (deeper)
  • #define mKeyBack    4 – Keycode for “back”

Downloads:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.