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
|
|
101 FONT_COLOR color_greenish ; set menu title font color
|
|
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
|
|
131 FONT_COLOR color_greenish ; set menu title font color
|
|
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
|
|
148 FONT_COLOR_MEMO ; select default color
|
|
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
|
|
271 movlw CCP1CON_VALUE ; load PWM setting
|
623
|
272 btfss divemode ; in dive mode?
|
604
|
273 movwf CCP1CON ; NO - power-on backlight
|
0
|
274
|
634
|
275 menu_vertical_loop:
|
|
276 movf selected_item,W ; get cursor position into WREG
|
|
277 rcall menu_read_menu_item_data ; read menu item data
|
|
278 movf item_funct_addr+0,W ; check if execute function call address is NULL
|
|
279 iorwf item_funct_addr+1,W ; ...
|
|
280 bz next_line_menu ; YES - not selectable, step cursor to next menu item
|
640
|
281 btfsc divemode ; NO - in dive mode?
|
|
282 bra menu_line_loop_pre1 ; YES - skip next
|
634
|
283 rcall menu_draw_cursor_surf ; NO - draw the cursor (main menu style)
|
640
|
284 btfss imprint_time_date ; - currently imprinting the current time & date?
|
634
|
285 bra menu_line_loop_pre1 ; NO - skip
|
640
|
286 btfss switch_right ; YES - right button pressed, i.e. time or date changed?
|
|
287 bra menu_line_loop_pre1 ; NO - skip
|
|
288 call TFT_imprint_time_date_fast ; YES - show a fast response on the screen (may momentarily show an illegal day/month combination)
|
|
289 call rtc_set_rtc ; - update time and date on RTC module (corrects illegal day/month combinations)
|
0
|
290
|
|
291 menu_line_loop_pre1:
|
623
|
292 bcf switch_right ; clear left-over right button event
|
|
293 bcf switch_left ; clear left-over left button event
|
0
|
294
|
634
|
295 menu_line_loop_pre2:
|
623
|
296 btfsc divemode ; in dive mode?
|
631
|
297 goto divemode_option_divemenu_return ; YES - return to it
|
634
|
298 call reset_timeout_surfmode ; NO - reset timeout
|
640
|
299 ;bra menu_line_loop ; - operate menu HMI
|
604
|
300
|
623
|
301 menu_line_loop:
|
640
|
302 call housekeeping ; handle data imprinting, screen dump request, timeout and entering dive mode
|
|
303 btfsc switch_right ; right button pressed?
|
|
304 bra do_line_menu ; YES - execute menu item function
|
|
305 btfss switch_left ; NO - left button pressed?
|
|
306 bra menu_line_loop ; NO - loop
|
|
307 next_line_menu: ; YES - step cursor to next menu item
|
|
308 bcf switch_left ; - clear button event
|
|
309 incf selected_item,F ; - increment cursor position to next item
|
|
310 movf selected_item,W ; - copy new item number to WREG
|
|
311 cpfseq menu_item_count ; - new item number beyond number of menu items?
|
|
312 bra menu_vertical_loop ; NO - redraw cursor
|
|
313 clrf selected_item ; YES - reset cursor position to first item
|
|
314 bra menu_vertical_loop ; - redraw cursor
|
604
|
315
|
0
|
316
|
634
|
317 ;-----------------------------------------------------------------------------
|
|
318 ; Execute Menu Item Function
|
|
319 ;
|
582
|
320 global do_line_menu
|
0
|
321 do_line_menu:
|
634
|
322 decf menu_pos_cur,W ; get selected menu item (0-5) into WREG
|
623
|
323 btfsc divemode ; in dive mode?
|
634
|
324 movwf selected_item ; YES - take selected menu item from dive mode
|
|
325 movf selected_item,W ; copy selected menu item to WREG
|
|
326 rcall menu_read_menu_item_data ; read menu item data
|
|
327 movf item_type,W ; switch on menu item type
|
|
328 bz menu_do_line_call ; -> 0: call (with dynamic title)
|
|
329 dcfsnz WREG ;
|
|
330 bra menu_do_line_call ; -> 1: call (with fixed title)
|
|
331 dcfsnz WREG ;
|
|
332 bra menu_do_line_option ; -> 2: option
|
|
333 bra menu_line_loop_pre2 ; else do nothing
|
|
334
|
|
335 menu_do_line_call:
|
|
336 rcall menu_call_item_function ; push current cursor position onto stack and call menu item function
|
|
337 rcall menu_processor_pop ; get back cursor position
|
|
338 bra menu_vertical ; re-draw the menu
|
|
339
|
|
340 menu_do_line_option:
|
|
341 movff option_addr+0,FSR0L ; get address of option definition data
|
|
342 movff option_addr+1,FSR0H ; ...
|
|
343 btfsc option_addr+1,4 ; shall stop at max value?
|
|
344 bsf option_stop_at_max ; YES - set flag
|
|
345 btfsc option_addr+1,6 ; is the selected option an option group member?
|
|
346 call option_adjust_group_member ; YES - adjust address to selected group member
|
|
347 btfss option_addr+1,5 ; shall increment?
|
|
348 call option_inc ; YES - increment option value
|
|
349 btfsc option_addr+1,5 ; shall decrement?
|
|
350 call option_dec ; YES - decrement option value
|
|
351 bcf option_stop_at_max ; revert to default (= wrap-around after max value)
|
|
352 bra menu_vertical ; re-draw the menu
|
|
353
|
|
354
|
|
355 ;-----------------------------------------------------------------------------
|
|
356 ; Draw all Menu Items
|
|
357 ;
|
|
358 menu_draw_menu_items:
|
|
359 btfss divemode ; in dive mode?
|
|
360 bra menu_draw_lines_surfmode ; NO
|
|
361 ;bra menu_draw_lines_divemode ; YES
|
|
362
|
|
363 global menu_draw_lines_divemode
|
|
364 menu_draw_lines_divemode:
|
640
|
365 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)
|
|
366
|
|
367 IFDEF _big_divemenu
|
|
368
|
|
369 btfss alt_layout_active ; big menu selected?
|
|
370 bra menu_draw_lines_divemode_small ; NO
|
|
371 ;bra menu_draw_lines_divemode_big ; YES
|
|
372
|
|
373 menu_draw_lines_divemode_big:
|
643
|
374 WIN_STD dm_menu_item1_column+.16,dm_menu_item1_row+.28
|
640
|
375 decf menu_pos_cur,W ; get selected item as 0..5 into WREG
|
|
376 movwf menu_item_start ; set first item to draw = selected item
|
|
377 bra menu_draw_menu_items_common ; continue with common part
|
|
378
|
|
379 ENDIF ; _big_divemenu
|
|
380
|
|
381 menu_draw_lines_divemode_small:
|
|
382 WIN_SMALL dm_menu_item1_column,dm_menu_item1_row
|
634
|
383 clrf menu_item_start ; set first item in menu block as first item to draw
|
|
384 bra menu_draw_menu_items_common ; continue with common part
|
|
385
|
|
386 menu_draw_lines_surfmode:
|
|
387 WIN_SMALL MENU_LEFT, 0 ; initialize start position and font
|
|
388 movff menu_vertical_start,win_top ; set vertical output position
|
|
389 clrf menu_item_start ; set first item in menu block as first item to draw
|
|
390
|
|
391 IFDEF scrolling_menu_enabled
|
|
392 ; does the menu have more than 7 item ?
|
|
393 movf menu_item_count,W ; get number of menu items
|
|
394 addlw -(MENU_LINES_MAX+1) ; more than 7 item?
|
640
|
395 bn menu_draw_menu_items_common ; NO - continue with common part
|
634
|
396 movf selected_item,W ; YES - compute first item to be drawn as current cursor position - 6
|
|
397 addlw -(MENU_LINES_MAX-1) ; - ...
|
|
398 btfsc STATUS,N ; - is this < 0 ?
|
|
399 clrf WREG ; YES - revert to starting from first item
|
|
400 movwf menu_item_start ; - set first item to be drawn
|
|
401 ENDIF ; scrolling_menu_enabled
|
|
402
|
|
403 menu_draw_menu_items_common:
|
|
404 movff menu_item_start,menu_item_curr ; initialize menu item counter
|
|
405
|
|
406 menu_draw_menu_items_loop:
|
640
|
407 FONT_COLOR_MEMO ; set default font color (may had been changed by a dynamic title)
|
|
408 REINIT_BUFFER ; initialize output buffer again
|
634
|
409 movf menu_item_curr,W ; get menu item to draw
|
|
410 rcall menu_read_menu_item_data ; read menu item data
|
|
411 movf item_type,W ; switch on menu item type:
|
640
|
412 bz menu_draw_menu_item_dynamic ; -> 0: call with dynamic title
|
634
|
413 dcfsnz WREG ;
|
|
414 bra menu_draw_menu_item_call ; -> 1: call with fixed title
|
|
415 dcfsnz WREG ;
|
|
416 bra menu_draw_menu_item_option ; -> 2: option increment
|
|
417 bra menu_draw_menu_item_print ; no output in case of illegal type
|
|
418
|
|
419 menu_draw_menu_item_dynamic:
|
|
420 movf item_title_addr+0,W ; check if call address is NULL
|
|
421 iorwf item_title_addr+1,W ; ...
|
|
422 btfsc STATUS,Z ; is null?
|
640
|
423 bra menu_draw_menu_item_after_print ; YES - no printing on this menu line
|
|
424 movff menu_item_curr,PRODL ; NO - pass menu item position to call function
|
634
|
425 rcall menu_text_call ; - call dynamic title function
|
|
426 bra menu_draw_menu_item_print ; - print menu item
|
|
427
|
|
428 menu_draw_menu_item_call:
|
|
429 movff item_title_addr+0,FSR1L ; point to multi-lingual text
|
|
430 movff item_title_addr+1,FSR1H ; ...
|
640
|
431 call strcat_text_FSR ; copy translated text to buffer
|
634
|
432 bra menu_draw_menu_item_print ; print menu item
|
|
433
|
|
434 menu_draw_menu_item_option:
|
|
435 movff item_title_addr+0,FSR1L ; point to multi-lingual text
|
|
436 movff item_title_addr+1,FSR1H ; ...
|
640
|
437 call strcat_text_FSR ; copy translated text to buffer
|
634
|
438 movff option_addr+0,FSR0L ; hand over address of option definition data
|
|
439 movff option_addr+1,FSR0H ; ...
|
|
440 btfsc option_addr+1,6 ; is the selected option an option group member?
|
|
441 call option_adjust_group_member ; YES - adjust address to selected group member
|
|
442 btfss block_option_value ; displaying of option value suspended?
|
|
443 call option_draw ; NO - draw option value
|
|
444 ;bra menu_draw_menu_item_print ; print menu item
|
0
|
445
|
634
|
446 menu_draw_menu_item_print:
|
|
447 movlw MAX_LINE_LENGTH_SURF ; load maximum length for a surface menu item
|
|
448 btfsc divemode ; in dive mode?
|
|
449 movlw MAX_LINE_LENGTH_DIVE ; YES - replace with maximum length for a dive mode menu item
|
|
450 call TFT_buffer_trim_length ; fill up or cut buffer to max length
|
|
451 PRINT ; print menu item to screen
|
640
|
452 ;bra menu_draw_menu_item_after_print ; continue with after-print actions
|
634
|
453
|
640
|
454 menu_draw_menu_item_after_print:
|
634
|
455 btfss divemode ; in dive mode?
|
640
|
456 bra menu_draw_menu_item_common ; NO
|
634
|
457 ;bra menu_draw_menu_item_divemode ; YES
|
|
458
|
|
459 menu_draw_menu_item_divemode:
|
640
|
460 IFDEF _big_divemenu
|
|
461 btfsc alt_layout_active ; big menu selected?
|
|
462 return ; YES - done
|
|
463 ENDIF
|
|
464
|
|
465 movlw .2 ; load a 2
|
|
466 cpfseq menu_item_curr ; just done menu item 2 (last item in left column) ?
|
634
|
467 bra menu_draw_menu_item_common ; NO - continue with common part
|
|
468 movlw dm_menu_item4_row ; YES - set vertical position for 2nd column
|
|
469 movff WREG,win_top ; - ...
|
|
470 movlw dm_menu_item4_column ; - set horizontal position for 2nd column
|
|
471 movff WREG,win_leftx2 ; - ...
|
640
|
472 bra menu_draw_menu_item_common_1 ; - continue in common part
|
634
|
473
|
640
|
474 menu_draw_menu_item_common:
|
|
475 movlw MENU_HEIGHT_SURF ; get menu items vertical spacing for surface mode
|
|
476 btfsc divemode ; in dive mode?
|
|
477 movlw MENU_HEIGHT_DIVE ; YES - replace with vertical spacing for dive mode
|
|
478 addwf win_top,F ; adjust vertical output position
|
|
479
|
|
480 menu_draw_menu_item_common_1:
|
|
481 incf menu_item_curr,F ; increment menu item number
|
|
482
|
634
|
483 IFDEF scrolling_menu_enabled
|
640
|
484 btfsc divemode ; in dive mode?
|
|
485 bra menu_draw_menu_item_common_2 ; YES - skip
|
|
486 movf menu_item_start,W ; NO - get the number of the menu item that menu drawing started with
|
|
487 subwf menu_item_curr,W ; - compute how many item have been drawn already
|
|
488 xorlw MENU_LINES_MAX ; - compare with how max item fit the screen
|
|
489 btfsc STATUS,Z ; - screen full?
|
|
490 return ; - YES - done
|
|
491 ;bra menu_draw_menu_item_common_2 ; NO - continue
|
634
|
492 ENDIF ; scrolling_menu_enabled
|
|
493
|
640
|
494 menu_draw_menu_item_common_2:
|
634
|
495 movf menu_item_curr,W ; get current menu item
|
|
496 xorwf menu_item_count,W ; compare with total number of menu items, more item to do?
|
|
497 bnz menu_draw_menu_items_loop ; YES - loop
|
|
498 return ; NO - done
|
|
499
|
|
500
|
|
501 ;-----------------------------------------------------------------------------
|
|
502 ; Helper Function - call Function for dynamic Title
|
|
503 ;
|
|
504 menu_text_call:
|
|
505 clrf PCLATU ; execute a computed goto
|
|
506 movff item_title_addr+1,PCLATH ; ...
|
|
507 movf item_title_addr+0,W ; ...
|
|
508 movwf PCL ; ...
|
|
509
|
0
|
510
|
634
|
511 ;-----------------------------------------------------------------------------
|
|
512 ; Draw the Cursor (Main Menu Style)
|
|
513 ;
|
|
514 menu_draw_cursor_surf:
|
640
|
515 WIN_LEFT MENU_LEFT-8 ; set horizontal start of cursor column
|
634
|
516 WIN_WIDTH .6 ; set width of cursor column
|
|
517 WIN_HEIGHT .223 ; set preliminary hight of cursor column
|
|
518
|
|
519 movf menu_vertical_start,W ; get vertical start of menu items
|
|
520 movwf win_top ; set vertical start of cursor column
|
|
521 subwf win_height,F ; final hight = prelim.height - vertical start
|
|
522
|
|
523 clrf WREG ; set color to black
|
|
524 BOX_COLOR ; clear cursor area
|
|
525
|
640
|
526 FONT_SIZE FT_SMALL ; set font size
|
|
527
|
634
|
528 movf menu_item_start,W ; get number of menu item that is on the first line
|
|
529 subwf selected_item,W ; compute line number of current menu item
|
|
530
|
|
531 mullw MENU_HEIGHT_SURF ; multiply line number with vertical menu items spacing
|
|
532 movf PRODL,W ; get computed vertical offset
|
|
533 addwf menu_vertical_start,W ; add offset to vertical start position
|
|
534 movwf win_top ; set final vertical position
|
640
|
535 bra menu_draw_cursor_common ; print cursor
|
634
|
536
|
|
537
|
|
538 ;-----------------------------------------------------------------------------
|
|
539 ; Draw the Cursor (Dive Mode Style)
|
|
540 ;
|
|
541 global menu_draw_cursor_dive
|
|
542 menu_draw_cursor_dive:
|
640
|
543 IFDEF _big_divemenu
|
|
544 btfss alt_layout_active ; big menu selected?
|
|
545 bra menu_draw_cursor_dive_small ; NO
|
|
546 ;bra menu_draw_cursor_dive_big ; YES
|
|
547
|
|
548 menu_draw_cursor_dive_big:
|
643
|
549 WIN_STD dm_menu_item1_column,dm_menu_item1_row+.26
|
640
|
550 bra menu_draw_cursor_common ; print cursor
|
|
551 ENDIF ; _big_divemenu
|
|
552
|
|
553 menu_draw_cursor_dive_small:
|
634
|
554 ; clear cursor areas
|
|
555 WIN_BOX_BLACK dm_menu_row+.1, dm_menu_lower-.1, dm_menu_item1_column-.8, dm_menu_item1_column-.1
|
|
556 WIN_BOX_BLACK dm_menu_row+.1, dm_menu_lower-.1, dm_menu_item4_column-.8, dm_menu_item4_column-.1
|
|
557
|
640
|
558 FONT_SIZE FT_SMALL ; set font size
|
|
559
|
634
|
560 movlw dm_menu_item1_column-.8 ; load position of left column
|
|
561 btfsc menu_pos_cur,2 ; cursor at menu item 4..6 ?
|
|
562 movlw dm_menu_item4_column-.8 ; YES - replace with position of right column
|
|
563 movwf win_leftx2 ; set horizontal position
|
|
564
|
|
565 decf menu_pos_cur,W ; get cursor position as 0..5 into WREG
|
|
566 btfsc menu_pos_cur,2 ; cursor at menu item 4..6 ?
|
|
567 addlw -.3 ; YES - subtract 3 to get line number in right column
|
|
568
|
640
|
569 mullw MENU_HEIGHT_DIVE ; multiply line number (0..2) with vertical menu items spacing
|
634
|
570 movf PRODL,W ; get computed vertical offset
|
|
571 addlw dm_menu_item1_row ; add offset to vertical start position
|
|
572 movwf win_top ; set final vertical position
|
640
|
573 ;bra menu_draw_cursor_common ; print cursor
|
634
|
574
|
|
575
|
|
576 ;-----------------------------------------------------------------------------
|
|
577 ; Helper Function - common Part of drawing the Cursor
|
|
578 ;
|
|
579 menu_draw_cursor_common:
|
640
|
580 FONT_COLOR_MEMO ; set font color (may have changed in-between)
|
634
|
581 STRCPY_PRINT "\xb7" ; print cursor
|
|
582 return ; done
|
0
|
583
|
|
584 ;-----------------------------------------------------------------------------
|
|
585
|
634
|
586 END
|