annotate src/menu_processor.asm @ 639:0ff82370991d

minor
author heinrichsweikamp
date Mon, 10 Aug 2020 15:34:38 +0200
parents 4050675965ea
children 8c1f1f334275
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
3 ; File menu_processor.asm * combined next generation V3.09.5
0
heinrichsweikamp
parents:
diff changeset
4 ;
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 229
diff changeset
5 ; Routines to handle all hwOS graphic/text menus.
0
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 229
diff changeset
10 ; 2012-11-02 : [jDG] Cleanup for hwOS: removed icons. Added scrolling.
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
11 ; But need a font with lower/upper alpha chars...
0
heinrichsweikamp
parents:
diff changeset
12
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
13 #include "hwos.inc"
0
heinrichsweikamp
parents:
diff changeset
14 #include "convert.inc"
heinrichsweikamp
parents:
diff changeset
15 #include "strings.inc"
heinrichsweikamp
parents:
diff changeset
16 #include "tft.inc"
heinrichsweikamp
parents:
diff changeset
17 #include "varargs.inc"
heinrichsweikamp
parents:
diff changeset
18 #include "start.inc"
heinrichsweikamp
parents:
diff changeset
19 #include "surfmode.inc"
heinrichsweikamp
parents:
diff changeset
20 #include "divemode.inc"
heinrichsweikamp
parents:
diff changeset
21 #include "tft_outputs.inc"
heinrichsweikamp
parents:
diff changeset
22 #include "eeprom_rs232.inc"
62
e7c7c7eeea58 show battery voltage in info menu
heinrichsweikamp
parents: 50
diff changeset
23 #include "adc_lightsensor.inc"
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
24 #include "i2c.inc"
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
25 #include "rtc.inc"
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
26 #include "wait.inc"
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
27 #include "colorschemes.inc"
229
e1e5876bd777 minor cleanup
mh@mh-THINK
parents: 189
diff changeset
28
0
heinrichsweikamp
parents:
diff changeset
29
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
30 ; NOTE: needs to be identical in .inc and .asm !
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
31 ;
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
32 #define MENU_LINES_MAX .7 ; maximum number of lines per screen
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
33 #define MENU_LEFT .20 ; position of first menu item
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
34 #define MENU_HEIGHT_SURF .27 ; spacing between menu item in surface mode (pixel)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
35 #define MENU_HEIGHT_DIVE .24 ; spacing between menu item in surface mode (pixel)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
36 #define MENU_VCENTER .125 ; position on screen
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
37 #define MAX_LINE_LENGTH_TITLE .17 ; max menu title length (characters)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
38 #define MAX_LINE_LENGTH_SURF .20 ; max menu item length in surface menu (characters)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
39 #define MAX_LINE_LENGTH_DIVE .10 ; max menu item length in dive mode menu (characters)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
40 #define MENU_ITEM_DATA_SIZE .4 ; size of a menu item data block
0
heinrichsweikamp
parents:
diff changeset
41
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
42 ; Alias for easier code reading
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
43 #define option_addr item_funct_addr
0
heinrichsweikamp
parents:
diff changeset
44
heinrichsweikamp
parents:
diff changeset
45
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
46 extern option_adjust_group_member
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
47 extern option_inc
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
48 extern option_dec
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
49 extern option_draw
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
50
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
51 extern rtc_set_rtc
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
52 extern divemode_option_divemenu_return
0
heinrichsweikamp
parents:
diff changeset
53
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
54
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
55 ;=============================================================================
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
56 menu_proc CODE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
57 ;=============================================================================
0
heinrichsweikamp
parents:
diff changeset
58
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
59
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
60 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
61 ; Entry Point for Menu Processor, called by MENU_BEGIN Macros
0
heinrichsweikamp
parents:
diff changeset
62 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
63 global menu_processor
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
64 menu_processor:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
65 ; read menu header
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
66 VARARGS_BEGIN ; load TBLPTR with start address of the menu header data
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
67 clrf STKPTR ; never return from here
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
68
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
69 VARARGS_GET8 menu_item_count ; get number of items
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
70 VARARGS_GET8 menu_vertical_start ; get vertical start position of 1st menu item
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
71
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
72 movf menu_vertical_start,W ; excite flags
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
73 bz menu_processor_no_title ; no menu title text -> skip reading menu title text address
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
74
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
75 VARARGS_GET16 menu_title_addr ; get address of menu title text
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
76
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
77 menu_processor_no_title:
0
heinrichsweikamp
parents:
diff changeset
78
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
79 movff TBLPTRL, menu_item_data_start+0 ; store base address for menu_read_menu_item_data
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
80 movff TBLPTRH, menu_item_data_start+1 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
81 movff TBLPTRU, menu_item_data_start+2 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
82
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
83 btfss divemode ; in dive mode?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
84 bra menu_processor_menu_title ; NO - no frame in surface mode menu
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
85
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
86 ; required for menus with less entries than the calling menu but not so nice when setting up gas 6.... mH
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
87 movlw .1 ; menu_pos_cur = 1 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
88 cpfsgt menu_pos_cur ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
89 call TFT_clear_divemode_menu ; YES - clear the menu
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
90
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
91 ; draw a frame around the dive mode menu
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
92 movf pallet_color_mask,W ; get mask color into WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
93 WIN_FRAME_COLOR dm_menu_row, dm_menu_lower, dm_menu_left ,dm_menu_right ; top, bottom, left, right
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
94 bra menu_processor_menu_body ; the dive mode menu has no menu title and footer
0
heinrichsweikamp
parents:
diff changeset
95
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
96 menu_processor_menu_title:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
97 ; prepare screen
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
98 clrf CCP1CON ; stop PWM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
99 bcf PORTC,2 ; fade out backlight
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
100 call TFT_ClearScreen ; clear screen
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
101
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
102 ; draw menu title
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
103 WIN_BOX_BLACK .2,.23,.0,.159 ; clear menu title area
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
104 WIN_STD .0, .2 ; set menu title font and position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
105 FONT_COLOR color_greenish ; set menu title font color
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
106 movff menu_title_addr+0,FSR1L ; point to multi-lingual menu title text
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
107 movff menu_title_addr+1,FSR1H ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
108 call strcpy_text_FSR ; copy translated text into the buffer
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
109 movf FSR2L,W ; get title text length
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
110 mullw .9 ; compute title length in pixels_x2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
111 bcf STATUS,C ; divide by 2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
112 rrcf PRODL ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
113 movf PRODL,W ; get result into WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
114 sublw .80 ; compute 80 (screen center position) - half title width in pixel_x2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
115 movwf win_leftx2 ; set result as horizontal start position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
116 movlw MAX_LINE_LENGTH_TITLE ; load max allowed length of a menu title
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
117 movwf FSR2L ; set buffer pointer to end of max length
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
118 clrf INDF2 ; terminate string at max length
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
119 PRINT ; output menu title
0
heinrichsweikamp
parents:
diff changeset
120
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
121 ; draw footer line
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
122 FONT_COLOR_MEMO ; select default color
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
123 WIN_TINY .5, .224 ; tiny font, left position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
124 STRCPY_TEXT_PRINT tNext ; print "Next"
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
125 WIN_TINY .124, .224 ; tiny font, righ position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
126 STRCPY_TEXT_PRINT tEnter ; print "Enter"
0
heinrichsweikamp
parents:
diff changeset
127
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
128 menu_processor_menu_body:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
129 FONT_SIZE FT_SMALL ; select font size
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
130 bra menu_vertical ; draw the menu items
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
131
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
132
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
133 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
134 ; Helper Function - call Callback-Function to draw the Menu Item Title
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
135 ;
0
heinrichsweikamp
parents:
diff changeset
136 menu_processor_call_title:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
137 movff menu_title_addr+2,PCLATU ; execute computed goto
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
138 movff menu_title_addr+1,PCLATH ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
139 movf menu_title_addr+0,W ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
140 movwf PCL ; ...
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
141
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
142
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
143 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
144 ; Clear all memorized Menu Item Selections and restart with Cursor on first Item
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
145 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
146 global menu_processor_reset
0
heinrichsweikamp
parents:
diff changeset
147 menu_processor_reset:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
148 clrf menustack ; clear first stack position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
149 clrf menustack_pointer ; set stack pointer to first stack position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
150 clrf selected_item ; set cursor position to first menu item
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
151 return ; done
0
heinrichsweikamp
parents:
diff changeset
152
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
153
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
154 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
155 ; Pull / Double-Pull Cursor Position from Stack
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
156 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
157 global menu_processor_double_pop
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
158 global menu_processor_pop
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
159 menu_processor_double_pop:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
160 decf menustack_pointer,F ; decrement stack pointer
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
161 menu_processor_pop:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
162 decf menustack_pointer,F ; decrement stack pointer
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
163 btfsc menustack_pointer,7 ; did the stack pointer under-run?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
164 clrf menustack_pointer ; YES - reset stack pointer to first stack position
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
165 movf menustack_pointer,W ; load stack pointer into WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
166 lfsr FSR2,menustack ; load base address of menu stack
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
167 movff PLUSW2,selected_item ; retrieve cursor position from stack
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
168 return ; done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
169
0
heinrichsweikamp
parents:
diff changeset
170
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
171 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
172 ; Push Cursor Position onto Stack
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
173 ;
0
heinrichsweikamp
parents:
diff changeset
174 menu_processor_push:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
175 lfsr FSR2,menustack ; load base address of menu stack
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
176 movf menustack_pointer,W ; load stack pointer into WREG
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
177 movff selected_item,PLUSW2 ; save cursor position to stack
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
178 incf menustack_pointer,W ; increment stack pointer, park result in WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
179 btfss WREG,3 ; result < 8 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
180 movwf menustack_pointer ; YES - update stack pointer
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
181 clrf selected_item ; set cursor to first item in new menu
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
182 return ; done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
183
0
heinrichsweikamp
parents:
diff changeset
184
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
185 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
186 ; Helper Function - call Menu Item Function
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
187 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
188 menu_call_item_function:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
189 bcf switch_right ; clear button event
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
190 movf selected_item,W ; copy current cursor position to WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
191 rcall menu_read_menu_item_data ; read item function address
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
192 movff selected_item,PRODL ; pass cursor position (menu item number) to call function
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
193 rcall menu_processor_push ; push current cursor position onto stack
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
194 clrf PCLATU ; execute computed goto
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
195 movff item_funct_addr+1,PCLATH ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
196 movf item_funct_addr+0,W ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
197 movwf PCL ; ...
0
heinrichsweikamp
parents:
diff changeset
198
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
199
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
200 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
201 ; Read Menu Item Data
0
heinrichsweikamp
parents:
diff changeset
202 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
203 menu_read_menu_item_data:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
204 cpfsgt menu_item_count ; selected menu item valid? || * Safety Check * to prevent any computed
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
205 clrf WREG ; NO - change selection to first item || goto to an illegal random target address
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
206
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
207 mullw MENU_ITEM_DATA_SIZE ; compute menu item data offset
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
208 movf PRODL,W ; add offset to base address of menu data block and set up TBLPTR
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
209 addwf menu_item_data_start+0,W ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
210 movwf TBLPTRL ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
211 movf PRODH,W ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
212 addwfc menu_item_data_start+1,W ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
213 movwf TBLPTRH ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
214 movlw 0 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
215 addwfc menu_item_data_start+2,W ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
216 movwf TBLPTRU ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
217
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
218 VARARGS_GET16 item_title_addr ; read address of item title function or title text | with embedded
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
219 VARARGS_GET16 item_funct_addr ; read address of item call function or option definition data | menu item type
0
heinrichsweikamp
parents:
diff changeset
220
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
221 movlw .2 ; probe for menu item type = OPTION
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
222 btfsc item_funct_addr,0 ; is type OPTION?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
223 bra menu_read_menu_item_data_1 ; YES
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
224
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
225 movlw .1 ; probe for menu item type = MENU_CALL
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
226 btfsc item_title_addr,0 ; is type MENU_CALL?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
227 bra menu_read_menu_item_data_1 ; YES
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
228
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
229 movlw .0 ; must be MENU_DYNAMIC
0
heinrichsweikamp
parents:
diff changeset
230
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
231 menu_read_menu_item_data_1:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
232 movwf item_type ; store menu item type
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
233 bcf item_title_addr+0,0 ; strip menu item type encoding from addresses (reset to even addresses)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
234 bcf item_funct_addr+0,0 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
235
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
236 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
237
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
238
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
239 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
240 ; Menu HMI Operation
0
heinrichsweikamp
parents:
diff changeset
241 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
242 global menu_vertical
0
heinrichsweikamp
parents:
diff changeset
243 menu_vertical:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
244 rcall menu_draw_menu_items ; draw all menu items
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
245 movlw CCP1CON_VALUE ; load PWM setting
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
246 btfss divemode ; in dive mode?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
247 movwf CCP1CON ; NO - power-on backlight
0
heinrichsweikamp
parents:
diff changeset
248
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
249 menu_vertical_loop:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
250 movf selected_item,W ; get cursor position into WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
251 rcall menu_read_menu_item_data ; read menu item data
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
252 movf item_funct_addr+0,W ; check if execute function call address is NULL
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
253 iorwf item_funct_addr+1,W ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
254 bz next_line_menu ; YES - not selectable, step cursor to next menu item
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
255 btfss divemode ; NO - in dive mode?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
256 rcall menu_draw_cursor_surf ; NO - draw the cursor (main menu style)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
257 btfss imprint_time_date ; - currently imprinting the current time & date?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
258 bra menu_line_loop_pre1 ; NO - skip
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
259 btfss switch_right ; YES - right button pressed, i.e. time or date changed?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
260 bra menu_line_loop_pre1 ; NO - skip
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
261 call TFT_imprint_time_date_fast ; YES - show a fast response on the screen (may momentarily show an illegal day/month combination)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
262 call rtc_set_rtc ; - update time and date on RTC module (corrects illegal day/month combinations)
0
heinrichsweikamp
parents:
diff changeset
263
heinrichsweikamp
parents:
diff changeset
264 menu_line_loop_pre1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
265 bcf switch_right ; clear left-over right button event
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
266 bcf switch_left ; clear left-over left button event
0
heinrichsweikamp
parents:
diff changeset
267
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
268 menu_line_loop_pre2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
269 btfsc divemode ; in dive mode?
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 623
diff changeset
270 goto divemode_option_divemenu_return ; YES - return to it
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
271 call reset_timeout_surfmode ; NO - reset timeout
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
272
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
273 menu_line_loop:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
274 call housekeeping ; - handle data imprinting, screen dump request, timeout and entering dive mode
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
275 btfsc switch_right ; - right button pressed?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
276 bra do_line_menu ; YES - execute menu item function
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
277 btfss switch_left ; NO - left button pressed?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
278 bra menu_line_loop ; NO - loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
279 next_line_menu: ; YES - step cursor to next menu item
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
280 bcf switch_left ; - clear button event
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
281 incf selected_item,F ; - increment cursor position to next item
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
282 movf selected_item,W ; - copy new item number to WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
283 cpfseq menu_item_count ; - new item number beyond number of menu items?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
284 bra menu_vertical_loop ; NO - redraw cursor
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
285 clrf selected_item ; YES - reset cursor position to first item
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
286 bra menu_vertical_loop ; - redraw cursor
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
287
0
heinrichsweikamp
parents:
diff changeset
288
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
289 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
290 ; Execute Menu Item Function
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
291 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
292 global do_line_menu
0
heinrichsweikamp
parents:
diff changeset
293 do_line_menu:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
294 decf menu_pos_cur,W ; get selected menu item (0-5) into WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 619
diff changeset
295 btfsc divemode ; in dive mode?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
296 movwf selected_item ; YES - take selected menu item from dive mode
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
297 movf selected_item,W ; copy selected menu item to WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
298 rcall menu_read_menu_item_data ; read menu item data
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
299 movf item_type,W ; switch on menu item type
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
300 bz menu_do_line_call ; -> 0: call (with dynamic title)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
301 dcfsnz WREG ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
302 bra menu_do_line_call ; -> 1: call (with fixed title)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
303 dcfsnz WREG ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
304 bra menu_do_line_option ; -> 2: option
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
305 bra menu_line_loop_pre2 ; else do nothing
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
306
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
307 menu_do_line_call:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
308 rcall menu_call_item_function ; push current cursor position onto stack and call menu item function
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
309 rcall menu_processor_pop ; get back cursor position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
310 bra menu_vertical ; re-draw the menu
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
311
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
312 menu_do_line_option:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
313 movff option_addr+0,FSR0L ; get address of option definition data
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
314 movff option_addr+1,FSR0H ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
315 btfsc option_addr+1,4 ; shall stop at max value?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
316 bsf option_stop_at_max ; YES - set flag
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
317 btfsc option_addr+1,6 ; is the selected option an option group member?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
318 call option_adjust_group_member ; YES - adjust address to selected group member
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
319 btfss option_addr+1,5 ; shall increment?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
320 call option_inc ; YES - increment option value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
321 btfsc option_addr+1,5 ; shall decrement?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
322 call option_dec ; YES - decrement option value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
323 bcf option_stop_at_max ; revert to default (= wrap-around after max value)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
324 bra menu_vertical ; re-draw the menu
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
325
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
326
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
327 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
328 ; Draw all Menu Items
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
329 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
330 menu_draw_menu_items:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
331 btfss divemode ; in dive mode?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
332 bra menu_draw_lines_surfmode ; NO
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
333 ;bra menu_draw_lines_divemode ; YES
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
334
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
335 global menu_draw_lines_divemode
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
336 menu_draw_lines_divemode:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
337 movlw dm_menu_item1_row ; get row position for 1st item
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
338 movwf win_top ; set vertical output position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
339 movlw dm_menu_item1_column ; get column position for 1st item
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
340 movwf win_leftx2 ; set horizontal output position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
341 clrf menu_item_start ; set first item in menu block as first item to draw
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
342 movff menu_item_count,menu_pos_max ; copy number of item in menu block to menu_pos_max
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
343 bra menu_draw_menu_items_common ; continue with common part
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
344
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
345 menu_draw_lines_surfmode:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
346 WIN_SMALL MENU_LEFT, 0 ; initialize start position and font
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
347 movff menu_vertical_start,win_top ; set vertical output position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
348 clrf menu_item_start ; set first item in menu block as first item to draw
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
349
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
350 IFDEF scrolling_menu_enabled
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
351 ; does the menu have more than 7 item ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
352 movf menu_item_count,W ; get number of menu items
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
353 addlw -(MENU_LINES_MAX+1) ; more than 7 item?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
354 bn menu_draw_menu_items_common ; NO - continue with common part
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
355 movf selected_item,W ; YES - compute first item to be drawn as current cursor position - 6
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
356 addlw -(MENU_LINES_MAX-1) ; - ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
357 btfsc STATUS,N ; - is this < 0 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
358 clrf WREG ; YES - revert to starting from first item
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
359 movwf menu_item_start ; - set first item to be drawn
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
360 ENDIF ; scrolling_menu_enabled
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
361
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
362 menu_draw_menu_items_common:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
363 movff menu_item_start,menu_item_curr ; initialize menu item counter
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
364 FONT_SIZE FT_SMALL ; set font size
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
365
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
366 menu_draw_menu_items_loop:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
367 FONT_COLOR_MEMO ; set default font color (may be changed by dynamic titles)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
368 movf menu_item_curr,W ; get menu item to draw
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
369 rcall menu_read_menu_item_data ; read menu item data
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
370 movf item_type,W ; switch on menu item type:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
371 bz menu_draw_menu_item_dynamic ; -> 0: call with dynamic title
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
372 dcfsnz WREG ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
373 bra menu_draw_menu_item_call ; -> 1: call with fixed title
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
374 dcfsnz WREG ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
375 bra menu_draw_menu_item_option ; -> 2: option increment
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
376 bra menu_draw_menu_item_print ; no output in case of illegal type
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
377
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
378 menu_draw_menu_item_dynamic:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
379
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
380 movf item_title_addr+0,W ; check if call address is NULL
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
381 iorwf item_title_addr+1,W ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
382 btfsc STATUS,Z ; is null?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
383 bra menu_draw_menu_item_no_print ; YES - no printing on this menu line
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
384 INIT_BUFFER ; NO - initialize buffer
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
385 movff menu_item_curr,PRODL ; - pass menu item position to call function
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
386 rcall menu_text_call ; - call dynamic title function
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
387 bra menu_draw_menu_item_print ; - print menu item
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
388
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
389 menu_draw_menu_item_call:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
390 movff item_title_addr+0,FSR1L ; point to multi-lingual text
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
391 movff item_title_addr+1,FSR1H ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
392 call strcpy_text_FSR ; copy translated text to buffer
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
393 bra menu_draw_menu_item_print ; print menu item
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
394
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
395 menu_draw_menu_item_option:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
396 movff item_title_addr+0,FSR1L ; point to multi-lingual text
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
397 movff item_title_addr+1,FSR1H ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
398 call strcpy_text_FSR ; copy translated text to buffer
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
399 movff option_addr+0,FSR0L ; hand over address of option definition data
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
400 movff option_addr+1,FSR0H ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
401 btfsc option_addr+1,6 ; is the selected option an option group member?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
402 call option_adjust_group_member ; YES - adjust address to selected group member
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
403 btfss block_option_value ; displaying of option value suspended?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
404 call option_draw ; NO - draw option value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
405 ;bra menu_draw_menu_item_print ; print menu item
0
heinrichsweikamp
parents:
diff changeset
406
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
407 menu_draw_menu_item_print:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
408 movlw MAX_LINE_LENGTH_SURF ; load maximum length for a surface menu item
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
409 btfsc divemode ; in dive mode?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
410 movlw MAX_LINE_LENGTH_DIVE ; YES - replace with maximum length for a dive mode menu item
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
411 call TFT_buffer_trim_length ; fill up or cut buffer to max length
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
412 PRINT ; print menu item to screen
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
413 ;bra menu_draw_menu_item_no_print ; continue with after-print actions
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
414
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
415 menu_draw_menu_item_no_print:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
416 movlw MENU_HEIGHT_SURF ; get menu items vertical spacing for surface mode
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
417 btfsc divemode ; in dive mode?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
418 movlw MENU_HEIGHT_DIVE ; YES - replace with vertical spacing for dive mode
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
419
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
420 addwf win_top,F ; adjust vertical output position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
421 incf menu_item_curr,F ; go to next menu item
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
422
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
423 btfss divemode ; in dive mode?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
424 bra menu_draw_menu_item_surfmode ; NO
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
425 ;bra menu_draw_menu_item_divemode ; YES
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
426
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
427 menu_draw_menu_item_divemode:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
428 movlw .3 ; load a 3
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
429 cpfseq menu_item_curr ; just done menu item 3 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
430 bra menu_draw_menu_item_common ; NO - continue with common part
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
431 movlw dm_menu_item4_row ; YES - set vertical position for 2nd column
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
432 movff WREG,win_top ; - ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
433 movlw dm_menu_item4_column ; - set horizontal position for 2nd column
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
434 movff WREG,win_leftx2 ; - ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
435 bra menu_draw_menu_item_common ; - continue with common part
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
436
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
437 menu_draw_menu_item_surfmode:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
438 IFDEF scrolling_menu_enabled
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
439 movf menu_item_start,W ; get the number of the menu item that menu drawing started with
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
440 subwf menu_item_curr,W ; compute how many item have been drawn already
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
441 xorlw MENU_LINES_MAX ; compare with how max item fit the screen
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
442 btfsc STATUS,Z ; screen full?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
443 return ; YES - done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
444 ;bra menu_draw_menu_item_common ; NO - continue with common part
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
445 ENDIF ; scrolling_menu_enabled
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
446
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
447 menu_draw_menu_item_common:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
448 movf menu_item_curr,W ; get current menu item
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
449 xorwf menu_item_count,W ; compare with total number of menu items, more item to do?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
450 bnz menu_draw_menu_items_loop ; YES - loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
451 return ; NO - done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
452
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
453
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
454 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
455 ; Helper Function - call Function for dynamic Title
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
456 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
457 menu_text_call:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
458 clrf PCLATU ; execute a computed goto
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
459 movff item_title_addr+1,PCLATH ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
460 movf item_title_addr+0,W ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
461 movwf PCL ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
462
0
heinrichsweikamp
parents:
diff changeset
463
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
464 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
465 ; Draw the Cursor (Main Menu Style)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
466 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
467 menu_draw_cursor_surf:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
468 WIN_LEFT MENU_LEFT-8 ; set horizontal start of cursor column
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
469 WIN_WIDTH .6 ; set width of cursor column
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
470 WIN_HEIGHT .223 ; set preliminary hight of cursor column
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
471
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
472 movf menu_vertical_start,W ; get vertical start of menu items
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
473 movwf win_top ; set vertical start of cursor column
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
474 subwf win_height,F ; final hight = prelim.height - vertical start
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
475
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
476 clrf WREG ; set color to black
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
477 BOX_COLOR ; clear cursor area
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
478
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
479 movf menu_item_start,W ; get number of menu item that is on the first line
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
480 subwf selected_item,W ; compute line number of current menu item
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
481
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
482 mullw MENU_HEIGHT_SURF ; multiply line number with vertical menu items spacing
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
483 movf PRODL,W ; get computed vertical offset
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
484 addwf menu_vertical_start,W ; add offset to vertical start position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
485 movwf win_top ; set final vertical position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
486 bra menu_draw_cursor_common ; print cursor and return
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
487
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
488
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
489 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
490 ; Draw the Cursor (Dive Mode Style)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
491 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
492 global menu_draw_cursor_dive
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
493 menu_draw_cursor_dive:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
494 ; clear cursor areas
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
495 WIN_BOX_BLACK dm_menu_row+.1, dm_menu_lower-.1, dm_menu_item1_column-.8, dm_menu_item1_column-.1
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
496 WIN_BOX_BLACK dm_menu_row+.1, dm_menu_lower-.1, dm_menu_item4_column-.8, dm_menu_item4_column-.1
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
497
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
498 movlw dm_menu_item1_column-.8 ; load position of left column
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
499 btfsc menu_pos_cur,2 ; cursor at menu item 4..6 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
500 movlw dm_menu_item4_column-.8 ; YES - replace with position of right column
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
501 movwf win_leftx2 ; set horizontal position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
502
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
503 decf menu_pos_cur,W ; get cursor position as 0..5 into WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
504 btfsc menu_pos_cur,2 ; cursor at menu item 4..6 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
505 addlw -.3 ; YES - subtract 3 to get line number in right column
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
506
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
507 mullw MENU_HEIGHT_DIVE ; multiply line number with vertical menu items spacing
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
508 movf PRODL,W ; get computed vertical offset
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
509 addlw dm_menu_item1_row ; add offset to vertical start position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
510 movwf win_top ; set final vertical position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
511 ;bra menu_draw_cursor_common ; print cursor and return
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
512
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
513
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
514 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
515 ; Helper Function - common Part of drawing the Cursor
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
516 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
517 menu_draw_cursor_common:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
518 FONT_COLOR_MEMO ; set font color
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
519 FONT_SIZE FT_SMALL ; set font size
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
520 STRCPY_PRINT "\xb7" ; print cursor
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
521 return ; done
0
heinrichsweikamp
parents:
diff changeset
522
heinrichsweikamp
parents:
diff changeset
523 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
524
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
525 END