LCD Menu Sample 2: Unterschied zwischen den Versionen

Aus ProjectWiki
Wechseln zu:Navigation, Suche
(Created page with "== Small Sample == === Menu structure === File:Menu_structure_simple.jpg === Menu data include file === <pre>$nocompile Const Lcd_width = 16 Const Lcd_bar_style = 1 Const L...")
 
K (Menu data include file)
 
(3 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
== Small Sample ==
+
This sample shows all functions of the menu.
=== Menu structure ===
+
It also uses the [[Universal Software Timer Main Page|software timer library]], but that's not necessary for the menu.
[[File:Menu_structure_simple.jpg]]
 
  
=== Menu data include file ===
+
== Menu structure ==
 +
[[File:Menu_structure_full.jpg]]
 +
 
 +
== Main file ==
 +
<pre>$regfile = "m32def.dat"
 +
$crystal = 16000000
 +
$baud = 57600
 +
 
 +
$hwstack = 64
 +
$swstack = 48
 +
$framesize = 64
 +
 
 +
 
 +
'###############################################################################
 +
'##      R O T A R Y  E N C O D E R                                          ##
 +
'###############################################################################
 +
Encoder_a Alias Pinb.1
 +
Encoder_switch Alias Pind.6
 +
Portb.1 = True                                              ' pullup encoder a,
 +
Portb.2 = True                                              ' encoder b,
 +
Portd.6 = True                                              ' and encoder switch
 +
Config Int2 = Falling                                      ' encoder b is the interrupt source
 +
On Int2 Encoder_isr
 +
Enable Int2
 +
Dim Encoder_switch_old As Bit
 +
Dim Encoder_turn_left As Byte , Encoder_turn_right As Byte
 +
 
 +
 
 +
'###############################################################################
 +
'##      T I M E R                                                            ##
 +
'###############################################################################
 +
Const Ticker_hwtimer = 0                                    ' Choose which hardware timer to use
 +
Const Ticker_frequency = 1000                              ' set the timer resolution
 +
Const Tickers = 2                                          ' # of software timers to use
 +
$include "tickers.inc"
 +
Const Timer_readswitches = 1
 +
Const Timer_valueupdate = 2
 +
 
 +
 
 +
'###############################################################################
 +
'##      L C D                                                                ##
 +
'###############################################################################
 +
Config Lcd = 16 * 2
 +
Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7 , E = Portc.2 , Rs = Portc.3
 +
Initlcd
 +
 
 +
 
 +
'###############################################################################
 +
'##      L C D  M E N U                                                      ##
 +
'###############################################################################
 +
Macro Menu_include_data
 +
  ' include the data file created with the menu designer
 +
  $include "menu_data_all.inc"
 +
End Macro
 +
$include "menu.inc"
 +
 
 +
 
 +
'###############################################################################
 +
'##      V A R I A B L E S                                                    ##
 +
'###############################################################################
 +
' Declare the variables associated with the menu values
 +
Dim Test_bit As Byte                                        ' bit values have to be declared as byte
 +
Dim Test_byte As Byte
 +
Dim Test_byte_counting 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        ' max string length is stored in a constant
 +
 
 +
Dim Tempbyte As Byte
 +
 
 +
 
 +
'###############################################################################
 +
'##      I N I T                                                              ##
 +
'###############################################################################
 +
Encoder_switch_old = Encoder_switch
 +
 
 +
Ticker_time(timer_readswitches) = 20                        ' 20 ms debounce
 +
Ticker_enabled(timer_readswitches) = True
 +
Ticker_time(timer_valueupdate) = 500                        ' 500 ms read-only value update
 +
Ticker_enabled(timer_valueupdate) = True
 +
 
 +
Menu_init
 +
 
 +
Enable Interrupts
 +
Gosub Draw_homescreen
 +
 
 +
 
 +
'###############################################################################
 +
'##      M A I N  L O O P                                                    ##
 +
'###############################################################################
 +
Do
 +
  ' one function to rule them all
 +
  Menu
 +
 
 +
  Select Case Ticker_get_interrupt()
 +
  Case Timer_readswitches:
 +
      ' encoder switch pressed?
 +
      If Encoder_switch = True And Encoder_switch_old = False Then
 +
        Tempbyte = Menu_enter()
 +
        Select Case Tempbyte
 +
        Case Menu_exit:                                    ' menu closed
 +
            Gosub Draw_homescreen
 +
 
 +
        Case 2:
 +
            ' function 2 execute
 +
            Cls                                            ' show something on the LCD
 +
            Locate 1 , 2
 +
            Lcd "Function call"
 +
            Locate 2 , 2
 +
            Lcd "demonstration"
 +
            Wait 2
 +
            Test_string = "Executed"                        ' assign the byte variable with a value
 +
            Menu_show 24                                    ' and display it throuth the read-only byte menu entry
 +
        End Select
 +
      End If
 +
      Encoder_switch_old = Encoder_switch
 +
 
 +
      ' encoder turns left
 +
      If 0 < Encoder_turn_left Then
 +
        Decr Encoder_turn_left
 +
        Menu_backward
 +
      End If
 +
 
 +
      ' encoder turns right
 +
      If 0 < Encoder_turn_right Then
 +
        Decr Encoder_turn_right
 +
        Menu_forward
 +
      End If
 +
 
 +
  Case Timer_valueupdate
 +
      ' force the read-only value currently displayed to update
 +
      Menu_check_update
 +
 
 +
      Incr Test_byte_counting                              ' changing value to demonstrate read-only values
 +
      If Test_byte_counting = 101 Then Test_byte_counting = 0
 +
  End Select
 +
Loop
 +
 
 +
 
 +
'###############################################################################
 +
'##      S U B R O U T I N E S                                                ##
 +
'###############################################################################
 +
Draw_homescreen:
 +
  Cls
 +
  Cursor Off
 +
  Locate 1 , 1
 +
  Lcd "  LCD MENU 1.5"
 +
  Locate 2 , 1
 +
  Lcd "    Sample 2"
 +
Return
 +
 
 +
Encoder_isr:
 +
  ' to use with a rotary encoder
 +
  If Encoder_a = False Then
 +
      Incr Encoder_turn_right
 +
  Else
 +
      Incr Encoder_turn_left
 +
  End If
 +
Return</pre>
 +
 
 +
== Menu data include file ==
 
<pre>$nocompile
 
<pre>$nocompile
  
Zeile 11: Zeile 174:
 
Const Lcd_bit_display_on = "On"
 
Const Lcd_bit_display_on = "On"
  
Const Menu_entries_count = 9
+
Const Menu_entries_count = 25
 
Const Menu_default_entry = 1
 
Const Menu_default_entry = 1
  
 
Const Menu_values_use = True
 
Const Menu_values_use = True
Const Menu_values_edit_use = False
+
Const Menu_values_edit_use = True
Const Menu_values_count = 1
+
Const Menu_eeprom_preserve_use = True
Const Menu_value_bit_count = 0
+
Const Menu_values_count = 18
Const Menu_value_byte_count = 0
+
Const Menu_value_bit_count = 2
Const Menu_value_word_count = 0
+
Const Menu_value_byte_count = 2
Const Menu_value_integer_count = 0
+
Const Menu_value_word_count = 2
Const Menu_value_dword_count = 0
+
Const Menu_value_integer_count = 2
Const Menu_value_long_count = 0
+
Const Menu_value_dword_count = 2
Const Menu_value_single_count = 0
+
Const Menu_value_long_count = 2
Const Menu_value_double_count = 0
+
Const Menu_value_single_count = 2
Const Menu_value_string_count = 1
+
Const Menu_value_double_count = 2
 +
Const Menu_value_string_count = 2
 +
 
 +
Const Menu_eeprom_checksum = 134
 +
Const Menu_eeprom_size = 17
  
 
Goto Menu_data_jumpover
 
Goto Menu_data_jumpover
Zeile 31: Zeile 198:
 
Menu_entries:
 
Menu_entries:
 
   ' Type, Text ID, Before, Next, Child
 
   ' Type, Text ID, Before, Next, Child
   Data Menu_link , 0 , 7 , 2 , 4                          ' 1, Submenu
+
   Data Menu_link , 0 , 5 , 2 , 24                          ' 1, Link
   Data Menu_value , 5 , 1 , 3 , 1                          ' 2, Another Entry
+
   Data Menu_link , 1 , 1 , 3 , 6                          ' 2, Editable
   Data Menu_link , 6 , 2 , 7 , 3                          ' 3, 3rd Entry
+
   Data Menu_link , 2 , 2 , 4 , 16                          ' 3, Read Only
   Data Menu_link , 1 , 6 , 5 , 2                           ' 4, Sub-Entry 1
+
   Data Menu_function , 3 , 3 , 5 , 2                       ' 4, Function
   Data Menu_link , 2 , 4 , 6 , 8                           ' 5, Submenu 2
+
   Data Menu_exit , 4 , 4 , 1 , 0                           ' 5, {127} Exit
   Data Menu_link , 4 , 5 , 4 , 1                          ' 6, {127} Back
+
  Data Menu_value , 5 , 15 , 7 , 1                        ' 6, Bit
   Data Menu_exit , 7 , 3 , 1 , 0                          ' 7, {127} Exit
+
  Data Menu_value , 6 , 6 , 8 , 2                         ' 7, Byte
   Data Menu_link , 3 , 9 , 9 , 4                          ' 8, Entry
+
   Data Menu_value , 7 , 7 , 9 , 3                          ' 8, Word
   Data Menu_link , 4 , 8 , 8 , 5                          ' 9, {127} Back
+
  Data Menu_value , 8 , 8 , 10 , 4                         ' 9, Integer
 +
  Data Menu_value , 9 , 9 , 11 , 5                         ' 10, DWord
 +
  Data Menu_value , 10 , 10 , 12 , 6                      ' 11, Long
 +
  Data Menu_value , 11 , 11 , 13 , 7                      ' 12, Single
 +
  Data Menu_value , 12 , 12 , 14 , 8                      ' 13, Double
 +
  Data Menu_value , 13 , 13 , 15 , 9                      ' 14, String
 +
  Data Menu_link , 14 , 14 , 6 , 2                        ' 15, {127} Back
 +
   Data Menu_value , 5 , 25 , 17 , 10                      ' 16, Bit, read only
 +
  Data Menu_value , 6 , 16 , 18 , 11                      ' 17, Byte, read only
 +
  Data Menu_value , 7 , 17 , 19 , 12                      ' 18, Word, read only
 +
   Data Menu_value , 8 , 18 , 20 , 13                      ' 19, Integer, read only
 +
  Data Menu_value , 9 , 19 , 21 , 14                      ' 20, DWord, read only
 +
  Data Menu_value , 10 , 20 , 22 , 15                      ' 21, Long, read only
 +
  Data Menu_value , 11 , 21 , 23 , 16                      ' 22, Single, read only
 +
  Data Menu_value , 12 , 22 , 24 , 17                      ' 23, Double, read only
 +
  Data Menu_value , 13 , 23 , 25 , 18                      ' 24, String, read only
 +
   Data Menu_link , 14 , 24 , 16 , 3                        ' 25, {127} Back
  
 
Menu_string_constants:
 
Menu_string_constants:
   Data "Submenu"                                           ' 0
+
   Data "Link"                                             ' 0
   Data "Sub-Entry 1"                                       ' 1
+
   Data "Editable"                                         ' 1
   Data "Submenu 2"                                        ' 2
+
   Data "Read Only"                                        ' 2
   Data "Entry"                                             ' 3
+
   Data "Function"                                         ' 3
   Data "{127} Back"                                        ' 4
+
   Data "{127} Exit"                                        ' 4
   Data "Another Entry"                                     ' 5
+
   Data "Bit"                                               ' 5
   Data "3rd Entry"                                         ' 6
+
   Data "Byte"                                             ' 6
   Data "{127} Exit"                                        ' 7
+
  Data "Word"                                              ' 7
 +
  Data "Integer"                                          ' 8
 +
  Data "DWord"                                            ' 9
 +
  Data "Long"                                              ' 10
 +
  Data "Single"                                            ' 11
 +
  Data "Double"                                            ' 12
 +
  Data "String"                                            ' 13
 +
   Data "{127} Back"                                        ' 14
  
 
Menu_values:
 
Menu_values:
 
   ' Type, Value Child, Step/ReadOnly (if 0), Min, Max, [Init value]
 
   ' Type, Value Child, Step/ReadOnly (if 0), Min, Max, [Init value]
   Data Menu_value_string , 1 , 0                          ' 1, Another Entry
+
  Data Menu_value_bit , 1 , True , False                  ' 1, Bit
 +
  Data Menu_value_byte + Menu_value_flag_eeprom_preserve , 1 , 2 , 0 , 100 , 50      ' 2, Byte
 +
  Data Menu_value_word , 1 , 64% , 0% , 1024% , 0%        ' 3, Word
 +
  Data Menu_value_integer + Menu_value_flag_eeprom_preserve , 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 + Menu_value_flag_eeprom_preserve , 1 , 1 , "Hello World"      ' 9, String
 +
  Data Menu_value_bit , 2 , True , False                  ' 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
 
Macro Menu_varpointers
   Menu_value_varpointer(1) = Varptr(test_string)          ' Another Entry, entry: 2, value: 1
+
   Menu_value_varpointer(1) = Varptr(test_bit)              ' Bit, entry: 6, value: 1
 +
  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_counting)  ' 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
 
End Macro
  
Zeile 74: Zeile 298:
 
'(
 
'(
 
###DESIGNER###
 
###DESIGNER###
1f8b0800000000000400ecbd07601c499625262f6dca7b7f4af54ad7e074a10880601324d8904010
+
1f8b08000000000004009d95cd4ee33010c7ef91f20e957a268a9d8fb647ba6df92a748102bb7b41
ecc188cde692ec1d69472329ab2a81ca6556655d661640cced9dbcf7de7befbdf7de7befbdf7ba3b
+
6963aa08cb91da4480104fb6877da47d05ec193bd82988aa529b8c6792df8cc7f36ffffffd4752df
9d4e27f7dfff3f5c6664016cf6ce4adac99e2180aac81f3f7e7c1f3f22fec7bff71fdcfdf4374e76
+
23be7738fc311a4f8e8e4f4ecfa6e717b39f9757d7f39bdbbb5fbfff744242a338497bfd81efcd84
7fe3e4f8c9c9d3d3679f7ffbec3bbfd7f32f5e7cf9f2275ebd7ef3d54f7ef7f7fe7d7e2addd9ddbb
+
fc3e3cc02b215ccf99a8a78578f43dbcd21822d48e8cf3a2ca169cf95e0ac1c80e5eb12cefcc047f
b77fffd307070f7fe3e4cb25fdfffc9c5fd9e17fbfc897ebe7c5f2ed6f9cbc5e4f16f4c76f9cecf3
+
91380cc7189ed4625915a5ccf861517820c107c6cf45e57baf84f6de3a6863e214c3b719af65caa1
17fb9defb64f976d7d9dd2377bfcfdfdc8bb297d75c05f1df8dff29b0c91be7928df3cc9a6f4cd2f
+
0a800dd624e31bd6dce66c53dd2f2c3f0142cf25bc54cc20c04c649ef9ba6ede07a706a8ae845807
dedd7bf04b52f9fd3e83fd74e86bc1784fbefec9ac5ce734ea65d5cef33ad50ef8d3d76d5d2c2fb8
+
7efa0eebae5ce79a8566e8d6f2044e9ba51a9ac6d034491b38b41351b1155b6b60b372cb2b8c5b53
f19bbc697fff46ff7e53e30d8172cfc7ee5e3d3300eef1b70fe4dbd377456b5090dfe9bb1ffff11f
+
0f12e82081465395c2618eac12479fd6986f1709b80471c4c14d4bb1d234345b300ece2d568a2cea
3ffdf219fdfb1b27
+
b0ae0bb1e2e628cca2c5db68b7d92c0d5459ea12063481a355e0c8dd73592f1ab059b477addd061c
 +
912026893c8f0f232068f43147ec165fad8ba6156671cc382f3bb2cb3c77ce6ca3e33ad900817aee
 +
87d9f2d1cc3dda14c683ec35f89895a02cc93793dfea899afcfb65598b0aaa4594514088b3a0a8fb
 +
68c082e9df14a2b7b9ab066c662302c46a0d8438094a5a7b8ac0aa126f5aa9fb88608b95206b1711
 +
045fc8406fd75201ce89e2eea28136d7a84073b74510e21045f84ff0ddfc7f329466f4f55cf691f5
 +
e5e8cb60b7db1dcf26f2ea7beff13bf4bfd1060000
 
###DESIGNER_END###
 
###DESIGNER_END###
 
')</pre>
 
')</pre>
 
=== Main file ===
 

Aktuelle Version vom 21. November 2017, 18:44 Uhr

This sample shows all functions of the menu. It also uses the software timer library, but that's not necessary for the menu.

Menu structure

Menu structure full.jpg

Main file

$regfile = "m32def.dat"
$crystal = 16000000
$baud = 57600

$hwstack = 64
$swstack = 48
$framesize = 64


'###############################################################################
'##      R O T A R Y   E N C O D E R                                          ##
'###############################################################################
Encoder_a Alias Pinb.1
Encoder_switch Alias Pind.6
Portb.1 = True                                              ' pullup encoder a,
Portb.2 = True                                              ' encoder b,
Portd.6 = True                                              ' and encoder switch
Config Int2 = Falling                                       ' encoder b is the interrupt source
On Int2 Encoder_isr
Enable Int2
Dim Encoder_switch_old As Bit
Dim Encoder_turn_left As Byte , Encoder_turn_right As Byte


'###############################################################################
'##      T I M E R                                                            ##
'###############################################################################
Const Ticker_hwtimer = 0                                    ' Choose which hardware timer to use
Const Ticker_frequency = 1000                               ' set the timer resolution
Const Tickers = 2                                           ' # of software timers to use
$include "tickers.inc"
Const Timer_readswitches = 1
Const Timer_valueupdate = 2


'###############################################################################
'##      L C D                                                                ##
'###############################################################################
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7 , E = Portc.2 , Rs = Portc.3
Initlcd


'###############################################################################
'##      L C D   M E N U                                                      ##
'###############################################################################
Macro Menu_include_data
   ' include the data file created with the menu designer
   $include "menu_data_all.inc"
End Macro
$include "menu.inc"


'###############################################################################
'##      V A R I A B L E S                                                    ##
'###############################################################################
' Declare the variables associated with the menu values
Dim Test_bit As Byte                                        ' bit values have to be declared as byte
Dim Test_byte As Byte
Dim Test_byte_counting 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         ' max string length is stored in a constant

Dim Tempbyte As Byte


'###############################################################################
'##      I N I T                                                              ##
'###############################################################################
Encoder_switch_old = Encoder_switch

Ticker_time(timer_readswitches) = 20                        ' 20 ms debounce
Ticker_enabled(timer_readswitches) = True
Ticker_time(timer_valueupdate) = 500                        ' 500 ms read-only value update
Ticker_enabled(timer_valueupdate) = True

Menu_init

Enable Interrupts
Gosub Draw_homescreen


'###############################################################################
'##      M A I N   L O O P                                                    ##
'###############################################################################
Do
   ' one function to rule them all
   Menu

   Select Case Ticker_get_interrupt()
   Case Timer_readswitches:
      ' encoder switch pressed?
      If Encoder_switch = True And Encoder_switch_old = False Then
         Tempbyte = Menu_enter()
         Select Case Tempbyte
         Case Menu_exit:                                    ' menu closed
            Gosub Draw_homescreen

         Case 2:
            ' function 2 execute
            Cls                                             ' show something on the LCD
            Locate 1 , 2
            Lcd "Function call"
            Locate 2 , 2
            Lcd "demonstration"
            Wait 2
            Test_string = "Executed"                        ' assign the byte variable with a value
            Menu_show 24                                    ' and display it throuth the read-only byte menu entry
         End Select
      End If
      Encoder_switch_old = Encoder_switch

      ' encoder turns left
      If 0 < Encoder_turn_left Then
         Decr Encoder_turn_left
         Menu_backward
      End If

      ' encoder turns right
      If 0 < Encoder_turn_right Then
         Decr Encoder_turn_right
         Menu_forward
      End If

   Case Timer_valueupdate
      ' force the read-only value currently displayed to update
      Menu_check_update

      Incr Test_byte_counting                               ' changing value to demonstrate read-only values
      If Test_byte_counting = 101 Then Test_byte_counting = 0
   End Select
Loop


'###############################################################################
'##      S U B R O U T I N E S                                                ##
'###############################################################################
Draw_homescreen:
   Cls
   Cursor Off
   Locate 1 , 1
   Lcd "  LCD MENU 1.5"
   Locate 2 , 1
   Lcd "    Sample 2"
Return

Encoder_isr:
   ' to use with a rotary encoder
   If Encoder_a = False Then
      Incr Encoder_turn_right
   Else
      Incr Encoder_turn_left
   End If
Return

Menu data include file

$nocompile

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 = 25
Const Menu_default_entry = 1

Const Menu_values_use = True
Const Menu_values_edit_use = True
Const Menu_eeprom_preserve_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

Const Menu_eeprom_checksum = 134
Const Menu_eeprom_size = 17

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 , 2 , 2 , 4 , 16                          ' 3, Read Only
   Data Menu_function , 3 , 3 , 5 , 2                       ' 4, Function
   Data Menu_exit , 4 , 4 , 1 , 0                           ' 5, {127} Exit
   Data Menu_value , 5 , 15 , 7 , 1                         ' 6, Bit
   Data Menu_value , 6 , 6 , 8 , 2                          ' 7, Byte
   Data Menu_value , 7 , 7 , 9 , 3                          ' 8, Word
   Data Menu_value , 8 , 8 , 10 , 4                         ' 9, Integer
   Data Menu_value , 9 , 9 , 11 , 5                         ' 10, DWord
   Data Menu_value , 10 , 10 , 12 , 6                       ' 11, Long
   Data Menu_value , 11 , 11 , 13 , 7                       ' 12, Single
   Data Menu_value , 12 , 12 , 14 , 8                       ' 13, Double
   Data Menu_value , 13 , 13 , 15 , 9                       ' 14, String
   Data Menu_link , 14 , 14 , 6 , 2                         ' 15, {127} Back
   Data Menu_value , 5 , 25 , 17 , 10                       ' 16, Bit, read only
   Data Menu_value , 6 , 16 , 18 , 11                       ' 17, Byte, read only
   Data Menu_value , 7 , 17 , 19 , 12                       ' 18, Word, read only
   Data Menu_value , 8 , 18 , 20 , 13                       ' 19, Integer, read only
   Data Menu_value , 9 , 19 , 21 , 14                       ' 20, DWord, read only
   Data Menu_value , 10 , 20 , 22 , 15                      ' 21, Long, read only
   Data Menu_value , 11 , 21 , 23 , 16                      ' 22, Single, read only
   Data Menu_value , 12 , 22 , 24 , 17                      ' 23, Double, read only
   Data Menu_value , 13 , 23 , 25 , 18                      ' 24, String, read only
   Data Menu_link , 14 , 24 , 16 , 3                        ' 25, {127} Back

Menu_string_constants:
   Data "Link"                                              ' 0
   Data "Editable"                                          ' 1
   Data "Read Only"                                         ' 2
   Data "Function"                                          ' 3
   Data "{127} Exit"                                        ' 4
   Data "Bit"                                               ' 5
   Data "Byte"                                              ' 6
   Data "Word"                                              ' 7
   Data "Integer"                                           ' 8
   Data "DWord"                                             ' 9
   Data "Long"                                              ' 10
   Data "Single"                                            ' 11
   Data "Double"                                            ' 12
   Data "String"                                            ' 13
   Data "{127} Back"                                        ' 14

Menu_values:
   ' Type, Value Child, Step/ReadOnly (if 0), Min, Max, [Init value]
   Data Menu_value_bit , 1 , True , False                   ' 1, Bit
   Data Menu_value_byte + Menu_value_flag_eeprom_preserve , 1 , 2 , 0 , 100 , 50       ' 2, Byte
   Data Menu_value_word , 1 , 64% , 0% , 1024% , 0%         ' 3, Word
   Data Menu_value_integer + Menu_value_flag_eeprom_preserve , 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 + Menu_value_flag_eeprom_preserve , 1 , 1 , "Hello World"       ' 9, String
   Data Menu_value_bit , 2 , True , False                   ' 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
   Menu_value_varpointer(1) = Varptr(test_bit)              ' Bit, entry: 6, value: 1
   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_counting)   ' 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:
   ' Table of characters used in string editing
   Data 254                                                 ' start of table, needed

   Data "ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789"

   ' special characters with function, these are needed
   Data Menu_character_backspace                            ' backspace
   Data Menu_character_finish                               ' finish string editing
   Data 254                                                 ' end of table

Menu_data_jumpover:

'(
###DESIGNER###
1f8b08000000000004009d95cd4ee33010c7ef91f20e957a268a9d8fb647ba6df92a748102bb7b41
6963aa08cb91da4480104fb6877da47d05ec193bd82988aa529b8c6792df8cc7f36ffffffd4752df
23be7738fc311a4f8e8e4f4ecfa6e717b39f9757d7f39bdbbb5fbfff744242a338497bfd81efcd84
fc3e3cc02b215ccf99a8a78578f43dbcd21822d48e8cf3a2ca169cf95e0ac1c80e5eb12cefcc047f
91380cc7189ed4625915a5ccf861517820c107c6cf45e57baf84f6de3a6863e214c3b719af65caa1
0a800dd624e31bd6dce66c53dd2f2c3f0142cf25bc54cc20c04c649ef9ba6ede07a706a8ae845807
7efa0eebae5ce79a8566e8d6f2044e9ba51a9ac6d034491b38b41351b1155b6b60b372cb2b8c5b53
0f12e82081465395c2618eac12479fd6986f1709b80471c4c14d4bb1d234345b300ece2d568a2cea
b0ae0bb1e2e628cca2c5db68b7d92c0d5459ea12063481a355e0c8dd73592f1ab059b477addd061c
912026893c8f0f232068f43147ec165fad8ba6156671cc382f3bb2cb3c77ce6ca3e33ad900817aee
87d9f2d1cc3dda14c683ec35f89895a02cc93793dfea899afcfb65598b0aaa4594514088b3a0a8fb
68c082e9df14a2b7b9ab066c662302c46a0d8438094a5a7b8ac0aa126f5aa9fb88608b95206b1711
045fc8406fd75201ce89e2eea28136d7a84073b74510e21045f84ff0ddfc7f329466f4f55cf691f5
e5e8cb60b7db1dcf26f2ea7beff13bf4bfd1060000
###DESIGNER_END###
')