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