Simple LCD Menu Main Page: Unterschied zwischen den Versionen

Aus ProjectWiki
Wechseln zu:Navigation, Suche
K (→‎LCD Menu Designer)
 
(30 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 4: Zeile 4:
 
To navigate through the menu, only 3 buttons are needed: Forward, Backward and Menu/Enter (or a rotary encoder with push button).
 
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).
+
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, DWord, Long, Single, Double, 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).
 
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).
Zeile 12: Zeile 12:
 
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.
 
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.  
+
Editable values could be preserved in EEPROM by option, stored values are loaded automatically in the init routine.
  
 +
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.
 +
 +
== Video Demo ==
 +
Watch this [http://www.vimeo.com/25921689 video] to see it in action.
  
 
== How to use it ==
 
== How to use it ==
Zeile 68: Zeile 72:
 
<pre>Macro Menu_init</pre>
 
<pre>Macro Menu_init</pre>
 
loads the menu data
 
loads the menu data
 +
 +
 +
<pre>Macro Menu_check_update</pre>
 +
call this macro in the time interval you wish to update read-only values
  
  
Zeile 92: Zeile 100:
 
<pre>Declare Sub Menu_hide()</pre>
 
<pre>Declare Sub Menu_hide()</pre>
 
hides the menu
 
hides the menu
−
== LCD Menu Designer ==
 
−
[[File:Menu_designer_settings.jpg|thumb|Global menu settings]]
 
  
−
== Small Sample ==
 
−
=== Menu structure overview ===
 
−
[[File:Menu_structure_simple.jpg]]
 
  
−
=== Menu data include file ===
+
<pre>Const Menu_eeprom_start = 1</pre>
−
<pre>$nocompile
+
Optional parameter for the EEPROM start address, default value is 1. To use another adress set the constant before the include directive:
 +
<pre>...
 +
Const Menu_eeprom_start = 123
 +
#include "menu.inc"
 +
...</pre>
  
−
Const Lcd_width = 16
 
−
Const Lcd_bar_style = 1
 
−
Const Lcd_bit_display_off = "Off"
 
−
Const Lcd_bit_display_on = "On"
 
  
−
Const Menu_entries_count = 9
+
<pre>Const Menu_eeprom_size = xxx</pre>
−
Const Menu_default_entry = 1
+
The size in bytes the menu uses in EEPROM to preserve values. This constant is defined in the menu data file.
  
−
Const Menu_values_use = True
 
−
Const Menu_values_edit_use = False
 
−
Const Menu_values_count = 1
 
−
Const Menu_value_bit_count = 0
 
−
Const Menu_value_byte_count = 0
 
−
Const Menu_value_word_count = 0
 
−
Const Menu_value_integer_count = 0
 
−
Const Menu_value_dword_count = 0
 
−
Const Menu_value_long_count = 0
 
−
Const Menu_value_single_count = 0
 
−
Const Menu_value_double_count = 0
 
−
Const Menu_value_string_count = 1
 
  
−
Goto Menu_data_jumpover
+
<pre>Const Menu_eeprom_end = xxx</pre>
 +
Points to the first unused memory location after the menu data in EEPROM (defined in menu.inc).
  
−
Menu_entries:
+
== LCD Menu Designer ==
−
  ' Type, Text ID, Before, Next, Child
+
=== Global Settings ===
−
  Data Menu_link , 0 , 7 , 2 , 4                          ' 1, Submenu
+
[[File:Menu_designer_settings.jpg|Global menu settings]]
−
  Data Menu_value , 5 , 1 , 3 , 1                          ' 2, Another Entry
 
−
  Data Menu_link , 6 , 2 , 7 , 3                          ' 3, 3rd Entry
 
−
  Data Menu_link , 1 , 6 , 5 , 2                          ' 4, Sub-Entry 1
 
−
  Data Menu_link , 2 , 4 , 6 , 8                          ' 5, Submenu 2
 
−
  Data Menu_link , 4 , 5 , 4 , 1                          ' 6, {127} Back
 
−
  Data Menu_exit , 7 , 3 , 1 , 0                          ' 7, {127} Exit
 
−
  Data Menu_link , 3 , 9 , 9 , 4                          ' 8, Entry
 
−
  Data Menu_link , 4 , 8 , 8 , 5                          ' 9, {127} Back
 
  
−
Menu_string_constants:
+
When the first entry in the menu tree is selected, the global settings are visible. Here you can select the LCD character width, the visual style for the [[LCD Bargraph with different styles|bargraph]], edit the character table used in string edit mode and choose the texts to display for bit values (Default is On/Off, you can set it for example to Yes/No or High/Low etc.).
−
  Data "Submenu"                                          ' 0
 
−
  Data "Sub-Entry 1"                                      ' 1
 
−
  Data "Submenu 2"                                        ' 2
 
−
  Data "Entry"                                            ' 3
 
−
  Data "{127} Back"                                        ' 4
 
−
  Data "Another Entry"                                    ' 5
 
−
  Data "3rd Entry"                                        ' 6
 
−
  Data "{127} Exit"                                        ' 7
 
  
−
Menu_values:
+
=== Link ===
−
  ' Type, Value Child, Step/ReadOnly (if 0), Min, Max, [Init value]
+
[[File:Menu_designer_link.jpg|Entry is a link, select the target]]
−
  Data Menu_value_string , 1 , 0                          ' 1, Another Entry
 
  
−
Macro Menu_varpointers
+
With links you can jump to another entry in the menu, just select it in the right menu tree.
−
  Menu_value_varpointer(1) = Varptr(test_string)          ' Another Entry, entry: 2, value: 1
+
Submenu- and Back entries are also links, but the target is created automatically.
−
End Macro
 
  
−
Menu_string_characters:
+
=== Value ===
−
  ' Table of characters used in string editing
+
[[File:Menu_designer_value.jpg|Value settings]]
−
  Data 254                                                ' start of table, needed
 
  
−
  Data "ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789"
+
Select the variable type (all Bascom types are supported) and choose if the value should be editable or read-only.
 +
In the "Associated variable" field enter the Variable name you declared in your code.
 +
Then set the range of the value (lowest and highest possible value).
 +
If the value is editable, you further have to set its initial value (will be set in Menu_init) and, if its a numerical value, the step size (positive, > 0).
 +
Editable values could also be preserved in EEPROM. On startup, values stored in EEPROM are loaded to the linked variables. If no values have been saved before/data is not valid (ex. the menu structure changes), they will be set to the initial value. When exiting the edit mode, the updated value is stored in EEPROM for the next startup.
  
−
  ' special characters with function, these are needed
+
=== Function ===
−
  Data Menu_character_backspace                            ' backspace
+
[[File:Menu_designer_function.jpg|Function ID select]]
−
  Data Menu_character_finish                              ' finish string editing
 
−
  Data 254                                                ' end of table
 
  
−
Menu_data_jumpover:
+
Select a function ID between 2 and 255. When this entry is selected, the menu hides and the Menu()-function returns the ID.
  
−
'(
+
=== Tool: Character Table ===
−
###DESIGNER###
+
[[File:Menu_designer_character_table.jpg|Tool: interactive LCD character table]]
−
1f8b0800000000000400ecbd07601c499625262f6dca7b7f4af54ad7e074a10880601324d8904010
 
−
ecc188cde692ec1d69472329ab2a81ca6556655d661640cced9dbcf7de7befbdf7de7befbdf7ba3b
 
−
9d4e27f7dfff3f5c6664016cf6ce4adac99e2180aac81f3f7e7c1f3f22fec7bff71fdcfdf4374e76
 
−
7fe3e4f8c9c9d3d3679f7ffbec3bbfd7f32f5e7cf9f2275ebd7ef3d54f7ef7f7fe7d7e2addd9ddbb
 
−
b77fffd307070f7fe3e4cb25fdfffc9c5fd9e17fbfc897ebe7c5f2ed6f9cbc5e4f16f4c76f9cecf3
 
−
17fb9defb64f976d7d9dd2377bfcfdfdc8bb297d75c05f1df8dff29b0c91be7928df3cc9a6f4cd2f
 
−
dedd7bf04b52f9fd3e83fd74e86bc1784fbefec9ac5ce734ea65d5cef33ad50ef8d3d76d5d2c2fb8
 
−
f19bbc697fff46ff7e53e30d8172cfc7ee5e3d3300eef1b70fe4dbd377456b5090dfe9bb1ffff11f
 
−
3ffdf219fdfb1b27
 
−
###DESIGNER_END###
 
−
')</pre>
 
  
−
=== Main file ===
+
With this little tool it is easy to get the corresponding code for characters supported by alphanumerical LCDs.
 +
Click on the desired character, the calculated code, formatted ready to use in Bascom strings, appears in the text field below.
  
−
== Full Sample ==
+
== Samples ==
 +
=== Sample 1: Small menu ===
 +
Bare sample with minimal functions
 +
[[LCD Menu Sample 1]]
  
−
=== Menu structure ===
+
=== Sample 2: All functions ===
−
[file:Menu_structure_full.jpg]]
+
Complete sample demonstrating all functions of the menu
 +
[[LCD Menu Sample 2]]
  
−
=== Menu data include file ===
+
=== Sample 3: All functions, simulation ===
−
<pre>$nocompile
+
Uses the same menu as in [[LCD Menu Sample 2]], but is optimized for use in the simulator, button events are generated using the serial connection.
  
−
Const Lcd_width = 16
+
=== Sample 4: All functions, Arduino M2560 + LCD Keyboard Shield ===
−
Const Lcd_bar_style = 1
+
Uses the same menu as in [[LCD Menu Sample 2]], runs on off-the-shelf hardware Arduino M2560 and the LCD Keyboard shield.
−
Const Lcd_bit_display_off = "Off"
 
−
Const Lcd_bit_display_on = "On"
 
  
−
Const Menu_entries_count = 25
+
== Download ==
−
Const Menu_default_entry = 1
+
* [http://www.braunecker.at/downloads/lcd_menu/setup_lcd_menu_1_5.exe LCD Menu Version 1.5]
−
 
 
−
Const Menu_values_use = True
 
−
Const Menu_values_edit_use = True
 
−
Const Menu_values_count = 18
 
−
Const Menu_value_bit_count = 2
 
−
Const Menu_value_byte_count = 2
 
−
Const Menu_value_word_count = 2
 
−
Const Menu_value_integer_count = 2
 
−
Const Menu_value_dword_count = 2
 
−
Const Menu_value_long_count = 2
 
−
Const Menu_value_single_count = 2
 
−
Const Menu_value_double_count = 2
 
−
Const Menu_value_string_count = 2
 
−
 
 
−
Goto Menu_data_jumpover
 
−
 
 
−
Menu_entries:
 
−
  ' Type, Text ID, Before, Next, Child
 
−
  Data Menu_link , 0 , 5 , 2 , 24                          ' 1, Link
 
−
  Data Menu_link , 1 , 1 , 3 , 6                          ' 2, Editable
 
−
  Data Menu_link , 12 , 2 , 4 , 16                        ' 3, Read Only
 
−
  Data Menu_function , 13 , 3 , 5 , 2                      ' 4, Function
 
−
  Data Menu_exit , 14 , 4 , 1 , 0                          ' 5, {127} Exit
 
−
  Data Menu_value , 2 , 15 , 7 , 1                        ' 6, Bit
 
−
  Data Menu_value , 3 , 6 , 8 , 2                          ' 7, Byte
 
−
  Data Menu_value , 4 , 7 , 9 , 3                          ' 8, Word
 
−
  Data Menu_value , 5 , 8 , 10 , 4                        ' 9, Integer
 
−
  Data Menu_value , 6 , 9 , 11 , 5                         ' 10, DWord
 
−
  Data Menu_value , 7 , 10 , 12 , 6                        ' 11, Long
 
−
  Data Menu_value , 8 , 11 , 13 , 7                        ' 12, Single
 
−
  Data Menu_value , 9 , 12 , 14 , 8                        ' 13, Double
 
−
  Data Menu_value , 10 , 13 , 15 , 9                      ' 14, String
 
−
  Data Menu_link , 11 , 14 , 6 , 2                        ' 15, {127} Back
 
−
  Data Menu_value , 2 , 25 , 17 , 10                      ' 16, Bit, read only
 
−
  Data Menu_value , 3 , 16 , 18 , 11                      ' 17, Byte, read only
 
−
  Data Menu_value , 4 , 17 , 19 , 12                      ' 18, Word, read only
 
−
  Data Menu_value , 5 , 18 , 20 , 13                      ' 19, Integer, read only
 
−
  Data Menu_value , 6 , 19 , 21 , 14                      ' 20, DWord, read only
 
−
  Data Menu_value , 7 , 20 , 22 , 15                      ' 21, Long, read only
 
−
  Data Menu_value , 8 , 21 , 23 , 16                      ' 22, Single, read only
 
−
  Data Menu_value , 9 , 22 , 24 , 17                      ' 23, Double, read only
 
−
  Data Menu_value , 10 , 23 , 25 , 18                      ' 24, String, read only
 
−
  Data Menu_link , 11 , 24 , 16 , 3                        ' 25, {127} Back
 
  
−
Menu_string_constants:
+
To install the Menu Designer, run setup_lcd_menu_*_*.exe with administrator privileges.
−
  Data "Link"                                              ' 0
 
−
  Data "Editable"                                          ' 1
 
−
  Data "Bit"                                              ' 2
 
−
  Data "Byte"                                              ' 3
 
−
  Data "Word"                                              ' 4
 
−
  Data "Integer"                                          ' 5
 
−
  Data "DWord"                                            ' 6
 
−
  Data "Long"                                              ' 7
 
−
  Data "Single"                                            ' 8
 
−
  Data "Double"                                            ' 9
 
−
  Data "String"                                            ' 10
 
−
  Data "{127} Back"                                        ' 11
 
−
  Data "Read Only"                                        ' 12
 
−
  Data "Function"                                          ' 13
 
−
  Data "{127} Exit"                                        ' 14
 
  
−
Menu_values:
 
−
  ' Type, Value Child, Step/ReadOnly (if 0), Min, Max, [Init value]
 
−
  Data Menu_value_bit , 1 , 1 , False                      ' 1, Bit
 
−
  Data Menu_value_byte , 1 , 2 , 0 , 100 , 50              ' 2, Byte
 
−
  Data Menu_value_word , 1 , 64% , 0% , 1024% , 0%        ' 3, Word
 
−
  Data Menu_value_integer , 1 , 1% , -5% , 5% , 0%        ' 4, Integer
 
−
  Data Menu_value_dword , 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 10 , 0 , 0 , 0 , 0 , 0 , 0 , 0      ' 5, DWord
 
−
  Data Menu_value_long , 1 , 1& , 0& , 10& , 0&            ' 6, Long
 
−
  Data Menu_value_single , 1 , 0.25! , -2.5! , 2.5! , 0!  ' 7, Single
 
−
  Data Menu_value_double , 1 , 3.14159# , -31.4159# , 31.4159# , 0#      ' 8, Double
 
−
  Data Menu_value_string , 1 , 1 , "Hello World"          ' 9, String
 
−
  Data Menu_value_bit , 2 , 0                              ' 10, Bit, read only
 
−
  Data Menu_value_byte , 2 , 0 , 0 , 100                  ' 11, Byte, read only
 
−
  Data Menu_value_word , 2 , 0% , 0% , 1024%              ' 12, Word, read only
 
−
  Data Menu_value_integer , 2 , 0% , -5% , 5%              ' 13, Integer, read only
 
−
  Data Menu_value_dword , 2 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 10 , 0 , 0 , 0      ' 14, DWord, read only
 
−
  Data Menu_value_long , 2 , 0& , 0& , 10&                ' 15, Long, read only
 
−
  Data Menu_value_single , 2 , 0! , -2.5! , 2.5!          ' 16, Single, read only
 
−
  Data Menu_value_double , 2 , 0# , -31.4159# , 31.4159#  ' 17, Double, read only
 
−
  Data Menu_value_string , 2 , 0                          ' 18, String, read only
 
  
−
Macro Menu_varpointers
+
old Versions:
−
  Menu_value_varpointer(1) = Varptr(test_bit)              ' Bit, entry: 6, value: 1
+
* [http://www.braunecker.at/downloads/lcd_menu/setup_lcd_menu_1_4.exe LCD Menu Version 1.4]
−
  Menu_value_varpointer(2) = Varptr(test_byte)            ' Byte, entry: 7, value: 1
 
−
  Menu_value_varpointer(3) = Varptr(test_word)            ' Word, entry: 8, value: 1
 
−
  Menu_value_varpointer(4) = Varptr(test_integer)          ' Integer, entry: 9, value: 1
 
−
  Menu_value_varpointer(5) = Varptr(test_dword)            ' DWord, entry: 10, value: 1
 
−
  Menu_value_varpointer(6) = Varptr(test_long)            ' Long, entry: 11, value: 1
 
−
  Menu_value_varpointer(7) = Varptr(test_single)          ' Single, entry: 12, value: 1
 
−
  Menu_value_varpointer(8) = Varptr(test_double)          ' Double, entry: 13, value: 1
 
−
  Menu_value_varpointer(9) = Varptr(test_string)          ' String, entry: 14, value: 1
 
−
  Menu_value_varpointer(10) = Varptr(test_bit)            ' Bit, entry: 16, value: 2
 
−
  Menu_value_varpointer(11) = Varptr(test_byte)            ' Byte, entry: 17, value: 2
 
−
  Menu_value_varpointer(12) = Varptr(test_word)            ' Word, entry: 18, value: 2
 
−
  Menu_value_varpointer(13) = Varptr(test_integer)        ' Integer, entry: 19, value: 2
 
−
  Menu_value_varpointer(14) = Varptr(test_dword)          ' DWord, entry: 20, value: 2
 
−
  Menu_value_varpointer(15) = Varptr(test_long)            ' Long, entry: 21, value: 2
 
−
  Menu_value_varpointer(16) = Varptr(test_single)          ' Single, entry: 22, value: 2
 
−
  Menu_value_varpointer(17) = Varptr(test_double)          ' Double, entry: 23, value: 2
 
−
  Menu_value_varpointer(18) = Varptr(test_string)          ' String, entry: 24, value: 2
 
−
End Macro
 
  
−
Menu_string_characters:
+
== Changelog ==
−
  ' Table of characters used in string editing
+
=== Version 1.5 (21.11.2017) ===
−
  Data 254                                                ' start of table, needed
+
Enhancements:
 +
* Added option to preserve editable values in EEPROM
 +
* Changed file extensions from .bas to .inc
 +
* Added menu entry move up/down buttons
 +
Bug fixes:
 +
* Exported wrong count of values of type Long
 +
* Exported wrong data for Dword data types
 +
* Minor bug fixes
  
−
  Data "ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789"
+
=== Version 1.4 (21.05.2014) ===
 +
Enhancements:
 +
* Menu Tree Drag and Drop function
 +
* Automatic Check & File copy of Bascom sources in the data file location
 +
* Toolbar button to locate the Bascom source files
 +
Bug fixes:
 +
* Save function stopped saving the embedded Menu Designer data
 +
* Update Component was broken, so you have to manually download & install V.1.4, sorry for that
 +
* It was possible to enter longer strings than the max string length, following memory was overwritten
 +
* R23 is used in the timer ISR, but was not saved
  
−
  ' special characters with function, these are needed
+
=== Version 1.3 (11.08.2013) ===
−
  Data Menu_character_backspace                            ' backspace
+
* in some constellations, the designer gave false child IDs to value entries.
−
  Data Menu_character_finish                              ' finish string editing
+
* the read-only state of bit variables was taken from their start value
−
  Data 254                                                ' end of table
+
* minor bug fixes
  
−
Menu_data_jumpover:
+
=== Version 1.2 (07.12.2011) ===
−
 
+
* fixed a major bug when using Function-entries
−
'(
+
* LCD width was set to 0 if the default value was changed
−
###DESIGNER###
+
* new setup routine
−
1f8b0800000000000400ecbd07601c499625262f6dca7b7f4af54ad7e074a10880601324d8904010
+
* automatic updates (searches on startup, shows a notification if a new version is available and installs it)
−
ecc188cde692ec1d69472329ab2a81ca6556655d661640cced9dbcf7de7befbdf7de7befbdf7ba3b
 
−
9d4e27f7dfff3f5c6664016cf6ce4adac99e2180aac81f3f7e7c1f3f22fec7bff71fdcfdf4374e76
 
−
7fe3e4f8c9c9d3d3679f7ffbec3bbfd7f32f5e7cf9f2275ebd7ef3d54f7ef7f7fe7d7e2addd9ddbb
 
−
b77fffd307070f7fe3e4cb25fdfffc9c5fd9e17fbfc897ebe7c5f2ed6f9cc8bf7bfbfccd9effcde9
 
−
ac68b34999ffc6c9a7fccda7f2e54f66e59a3e7b52b4bf71c2bff36fcfb2b2a14fdfe44dfbfb4fbc
 
−
0f76f9d507e1abd76d6edee55fefef9837f94f7d1598ee0852f2bf8300ca77ab7aa650e45703e48a
 
−
fff28160749fd2ffef3198870198b3659b5fe4b542b27f196085f940e16ddf27747958fb0c6c7727
 
−
80f6d4c34a7f3790667dbc18ce7d81a393a2709e57cb0b0523bf1a2825ffd5032233b4abf3a7405e
 
−
17cb0b4c1fff69fe30801afddb8c6b6f0c44f0cfce78ef3e4f1920de0b8757ad2716a2f9c30e50ff
 
−
3610efed8ef777ef13b5dd2fe35df9e54080ef87e8b67561476dfef8765e96554a942c670671fd46
 
−
bb7928a0ee0ba827d99438f717efee3df825a9fcbec708ea3084b15fe5d92cfd72595ed37b9ff277
 
−
bbefc7db6f6ab4da15b8bb373077c8dbf2aa616dfcdc1528efc5dc6f1c14955c4c3dc07c3de616ac
 
−
94b701ed9e08cbfb32b7373af9a142f75eccdd03725f80dc86b9c75df6d69179dc6d277def36bc6d
 
−
011aee56807de606e00702f8167cedf394e16865ab0301727f88a3ef715fdac7b3f572da16152978
 
−
f79bb0bcbe7ffa0e1c2befcbeff4dd8ffff88f9f7ef98cfefd8d
 
−
###DESIGNER_END###
 
−
')</pre>
 
−
 
 
−
== Download ==
 
−
* [http://www.braunecker.at/ LCD Menu Version 1.1]
 

Aktuelle Version vom 17. Februar 2019, 11:56 Uhr

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, DWord, Long, Single, Double, 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.

Editable values could be preserved in EEPROM by option, stored values are loaded automatically in the init routine.

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.

Video Demo

Watch this video to see it in action.

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

Const Menu_default_entry

ID of the default entry


Const Menu_value_string_width

size for strings used to display


Macro Menu_init

loads the menu data


Macro Menu_check_update

call this macro in the time interval you wish to update read-only values


Declare Sub Menu()

Main function, called in Main Loop


Declare Sub Menu_forward()

Goes one step forward in the menu or while in edit mode, bit values are set to true, numerical values are increased by the step size and for strings, the following character in the table will be selected.


Declare Sub Menu_backward()

Goes one step backward in the menu or while in edit mode, bit values are set to false, numerical values are decreased by the step size and for strings, the preceeding character in the table will be selected.


Declare Function Menu_enter() As Byte

Shows the menu if inactive, follows a link, enters/exits the edit mode, adds a character in string edit mode or selects a function


Declare Sub Menu_show(byval Entry_id As Byte)

Displays the menu with the provided entry id, if 0, the default entry is selected


Declare Sub Menu_hide()

hides the menu


Const Menu_eeprom_start = 1

Optional parameter for the EEPROM start address, default value is 1. To use another adress set the constant before the include directive:

...
Const Menu_eeprom_start = 123
#include "menu.inc"
...


Const Menu_eeprom_size = xxx

The size in bytes the menu uses in EEPROM to preserve values. This constant is defined in the menu data file.


Const Menu_eeprom_end = xxx

Points to the first unused memory location after the menu data in EEPROM (defined in menu.inc).

LCD Menu Designer

Global Settings

Global menu settings

When the first entry in the menu tree is selected, the global settings are visible. Here you can select the LCD character width, the visual style for the bargraph, edit the character table used in string edit mode and choose the texts to display for bit values (Default is On/Off, you can set it for example to Yes/No or High/Low etc.).

Link

Entry is a link, select the target

With links you can jump to another entry in the menu, just select it in the right menu tree. Submenu- and Back entries are also links, but the target is created automatically.

Value

Value settings

Select the variable type (all Bascom types are supported) and choose if the value should be editable or read-only. In the "Associated variable" field enter the Variable name you declared in your code. Then set the range of the value (lowest and highest possible value). If the value is editable, you further have to set its initial value (will be set in Menu_init) and, if its a numerical value, the step size (positive, > 0). Editable values could also be preserved in EEPROM. On startup, values stored in EEPROM are loaded to the linked variables. If no values have been saved before/data is not valid (ex. the menu structure changes), they will be set to the initial value. When exiting the edit mode, the updated value is stored in EEPROM for the next startup.

Function

Function ID select

Select a function ID between 2 and 255. When this entry is selected, the menu hides and the Menu()-function returns the ID.

Tool: Character Table

Tool: interactive LCD character table

With this little tool it is easy to get the corresponding code for characters supported by alphanumerical LCDs. Click on the desired character, the calculated code, formatted ready to use in Bascom strings, appears in the text field below.

Samples

Sample 1: Small menu

Bare sample with minimal functions LCD Menu Sample 1

Sample 2: All functions

Complete sample demonstrating all functions of the menu LCD Menu Sample 2

Sample 3: All functions, simulation

Uses the same menu as in LCD Menu Sample 2, but is optimized for use in the simulator, button events are generated using the serial connection.

Sample 4: All functions, Arduino M2560 + LCD Keyboard Shield

Uses the same menu as in LCD Menu Sample 2, runs on off-the-shelf hardware Arduino M2560 and the LCD Keyboard shield.

Download

To install the Menu Designer, run setup_lcd_menu_*_*.exe with administrator privileges.


old Versions:

Changelog

Version 1.5 (21.11.2017)

Enhancements:

  • Added option to preserve editable values in EEPROM
  • Changed file extensions from .bas to .inc
  • Added menu entry move up/down buttons

Bug fixes:

  • Exported wrong count of values of type Long
  • Exported wrong data for Dword data types
  • Minor bug fixes

Version 1.4 (21.05.2014)

Enhancements:

  • Menu Tree Drag and Drop function
  • Automatic Check & File copy of Bascom sources in the data file location
  • Toolbar button to locate the Bascom source files

Bug fixes:

  • Save function stopped saving the embedded Menu Designer data
  • Update Component was broken, so you have to manually download & install V.1.4, sorry for that
  • It was possible to enter longer strings than the max string length, following memory was overwritten
  • R23 is used in the timer ISR, but was not saved

Version 1.3 (11.08.2013)

  • in some constellations, the designer gave false child IDs to value entries.
  • the read-only state of bit variables was taken from their start value
  • minor bug fixes

Version 1.2 (07.12.2011)

  • fixed a major bug when using Function-entries
  • LCD width was set to 0 if the default value was changed
  • new setup routine
  • automatic updates (searches on startup, shows a notification if a new version is available and installs it)