comparison src/menu_processor.asm @ 623:c40025d8e750

3.03 beta released
author heinrichsweikamp
date Mon, 03 Jun 2019 14:01:48 +0200
parents e76a87e087ef
children 185ba2f91f59
comparison
equal deleted inserted replaced
622:02d1386429a6 623:c40025d8e750
1 ;============================================================================= 1 ;=============================================================================
2 ; 2 ;
3 ; File menu_processor.asm REFACTORED VERSION V2.99d 3 ; File menu_processor.asm combined next generation V3.03.2
4 ; 4 ;
5 ; Routines to handle all hwOS graphic/text menus. 5 ; Routines to handle all hwOS graphic/text menus.
6 ; 6 ;
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
8 ;============================================================================= 8 ;=============================================================================
13 #include "hwos.inc" 13 #include "hwos.inc"
14 #include "convert.inc" 14 #include "convert.inc"
15 #include "strings.inc" 15 #include "strings.inc"
16 #include "tft.inc" 16 #include "tft.inc"
17 #include "varargs.inc" 17 #include "varargs.inc"
18 #include "wait.inc"
19 #include "start.inc" 18 #include "start.inc"
20 #include "surfmode.inc" 19 #include "surfmode.inc"
21 #include "divemode.inc" 20 #include "divemode.inc"
22 #include "tft_outputs.inc" 21 #include "tft_outputs.inc"
23 #include "eeprom_rs232.inc" 22 #include "eeprom_rs232.inc"
24 #include "adc_lightsensor.inc" 23 #include "adc_lightsensor.inc"
25 #include "i2c.inc" 24 #include "i2c.inc"
25 #include "rtc.inc"
26 #include "wait.inc"
26 27
27 28
28 ; NOTE: needs to be identical in .inc and .asm ! 29 ; NOTE: needs to be identical in .inc and .asm !
29 #define MENU_LINES_MAX .7 ; number of lines per screen? 30 #define MENU_LINES_MAX .7 ; maximum number of lines per screen
30 #define MENU_TITLE_FONT WIN_STD ; font needs to contain lower and UPPER chars 31 #define MENU_TITLE_FONT WIN_STD ; font needs to contain lower and UPPER chars
31 #define MENU_LINE_FONT WIN_SMALL ; font needs to contain lower and UPPER chars 32 #define MENU_LINE_FONT WIN_SMALL ; font needs to contain lower and UPPER chars
32 #define MENU_LEFT .20 ; position of first menu item 33 #define MENU_LEFT .20 ; position of first menu item
33 #define MENU_HEIGHT .27 ; spacing between menu lines 34 #define MENU_HEIGHT .27 ; spacing between menu lines
34 #define MENU_VCENTER .125 ; position on screen 35 #define MENU_VCENTER .125 ; position on screen
35 #define MENU_LINE_MAX_LENGTH .20 ; length in characters 36 #define MENU_LINE_MAX_LENGTH .20 ; length in characters
36 #define option_item proc_item 37 #define option_item proc_item
37 38
38 ; Other needed references 39
39 extern aa_wordprocessor 40 extern aa_wordprocessor
40 extern option_inc 41 extern option_inc
41 extern option_draw 42 extern option_draw
42 extern comm_mode
43 extern TFT_clear_divemode_menu 43 extern TFT_clear_divemode_menu
44 extern TFT_divemask_color 44 extern TFT_divemask_color
45 extern rtc_set_rtc 45 extern rtc_set_rtc
46 extern divemode_option0_return 46 extern divemode_option0_return
47 extern TFT_fillup_with_spaces 47 extern TFT_fillup_with_spaces
48 48
49 49
50 menu_proc CODE 50 menu_proc CODE
51 51
52 ;============================================================================= 52 ;=============================================================================
53 ; menu handler. 53 ; menu handler
54 ; 54 ;
55 ; Input: TBLPTR = addr of menu block. 55 ; Input: TBLPTR = addr of menu block
56
56 global menu_processor 57 global menu_processor
57 menu_processor: 58 menu_processor:
58 banksel common ; bank 1 59 ; btfss divemode ; in dive mode?
59 btfss divemode ; in divemode? 60 ; call request_speed_fastest ; NO - request CPU speed change to fastest speed
60 call speed_fastest ; NO - make it quick
61 ;---- Read menu block ------------------------------------------------ 61 ;---- Read menu block ------------------------------------------------
62 VARARGS_BEGIN ; read inline PROM data 62 VARARGS_BEGIN ; read inline PROM data
63 clrf STKPTR ; never return from here 63 clrf STKPTR ; never return from here
64 VARARGS_GET8 item_max ; get number of items 64 VARARGS_GET8 item_max ; get number of items
65 VARARGS_GET8 menu_flags ; get flags 65 VARARGS_GET8 menu_flags ; get flags
66 VARARGS_GET24 menu_title ; get pointer to menu title 66 VARARGS_GET24 menu_title ; get pointer to menu title
67 VARARGS_GET8 menu_center ; vertical position 67 VARARGS_GET8 menu_center ; vertical position
68 movff TBLPTRL, menu_block+0 ; save base address for menu_read_item 68 movff TBLPTRL, menu_block+0 ; save base address for menu_read_item
69 movff TBLPTRH, menu_block+1 69 movff TBLPTRH, menu_block+1 ; ...
70 movff TBLPTRU, menu_block+2 70 movff TBLPTRU, menu_block+2 ; ...
71 btfss divemode ; in divemode? 71 btfss divemode ; in dive mode?
72 bra menu_processor0 ; NO 72 bra menu_processor0 ; NO
73
73 ; Required for menus with less entries than the calling menu but not so nice when setting up gas 6.... mH 74 ; Required for menus with less entries than the calling menu but not so nice when setting up gas 6.... mH
74 movlw .1 75 movlw .1
75 cpfsgt menupos1 ; only if menupos1 = 1... 76 cpfsgt menu_pos_cur ; only if menu_pos_cur = 1...
76 call TFT_clear_divemode_menu ; ... clear the menu! 77 call TFT_clear_divemode_menu ; ... clear the menu!
77 ; Draw one frame around the divemode menu 78 ; Draw one frame around the dive mode menu
78 call TFT_divemask_color 79 call TFT_divemask_color
79 WIN_FRAME_COLOR16 dm_menu_row, dm_menu_lower, dm_menu_left ,dm_menu_right ; top, bottom, left, right 80 WIN_FRAME_COLOR16 dm_menu_row, dm_menu_lower, dm_menu_left ,dm_menu_right ; top, bottom, left, right
80 call TFT_standard_color 81 call TFT_standard_color
81 82
82 bra menu_processor1 ; skip next code segment in divemode 83 bra menu_processor1 ; skip next code segment in dive mode
83 84
84 menu_processor0: 85 menu_processor0:
85 ;---- draw menu title ------------------------------------------------ 86 ;---- draw menu title ------------------------------------------------
86 clrf CCP1CON ; stop PWM 87 clrf CCP1CON ; stop PWM
87 bcf PORTC,2 ; pull PWM out to GND 88 bcf PORTC,2 ; pull PWM out to GND
88 call TFT_ClearScreen 89 call TFT_ClearScreen
89 rcall menu_processor_title 90 rcall menu_processor_title
90 rcall menu_processor_bottom_line 91 rcall menu_processor_bottom_line
91 92
92 menu_processor1: 93 menu_processor1:
93 movlw FT_SMALL 94 WIN_FONT FT_SMALL
94 movff WREG, win_font
95 95
96 ;---- Select menu type ----------------------------------------------- 96 ;---- Select menu type -----------------------------------------------
97 bra menu_vertical 97 bra menu_vertical
98 98
99 99
100 ;============================================================================= 100 ;=============================================================================
101 ; draw menu bottom line 101 ; draw menu bottom line
102 ; 102 ;
103 global menu_processor_bottom_line,menu_processor_bottom_line_comm
104 menu_processor_bottom_line: 103 menu_processor_bottom_line:
105 ;---- Draw bottom line ----------------------------------------------- 104 ;---- Draw bottom line -----------------------------------------------
106 TEXT_TINY .5, .240-.16, tNext 105 TEXT_TINY .5, .240-.16, tNext
107 TEXT_TINY .160-.6*.6, .240-.16, tEnter 106 TEXT_TINY .160-.6*.6, .240-.16, tEnter
108 WIN_COLOR color_greenish 107 goto TFT_standard_color ; ...and return
109 menu_processor_bottom_line_comm:
110 ; Serial Number and Firmware Version
111 WIN_TINY .40,.240-.16
112 STRCPY "#"
113 call TFT_cat_serial
114 STRCAT " v"
115 call TFT_cat_firmware
116 STRCAT " "
117 call TFT_cat_beta_release
118 STRCAT_PRINT ""
119 call TFT_standard_color
120 bcf win_invert
121 return
122 108
123 ;============================================================================= 109 ;=============================================================================
124 ; (re-)draw menu title 110 ; (re-)draw menu title
125 ; 111 ;
126 menu_processor_title: 112 menu_processor_title:
163 ;============================================================================= 149 ;=============================================================================
164 ; Restart with first icon/line selected 150 ; Restart with first icon/line selected
165 ; 151 ;
166 global menu_processor_reset 152 global menu_processor_reset
167 menu_processor_reset: 153 menu_processor_reset:
168 banksel menustack 154 clrf menustack ; clear first stack position
169 lfsr FSR2,menustack 155 clrf menustack_pointer ; set stack pointer to first stack position
170 clrf POSTINC2 156 clrf selected_item ; set last menu item to first item
171 clrf POSTINC2
172 clrf POSTINC2
173 clrf POSTINC2
174 clrf POSTINC2
175 banksel common
176 clrf selected_item
177 return 157 return
178 158
159
160 global menu_processor_double_pop
179 global menu_processor_pop 161 global menu_processor_pop
162 menu_processor_double_pop:
163 decf menustack_pointer,F ; decrement stack pointer
180 menu_processor_pop: 164 menu_processor_pop:
181 movff menustack+0,selected_item 165 decf menustack_pointer,F ; decrement stack pointer
182 movff menustack+1,menustack+0 166 btfsc menustack_pointer,7 ; did the stack pointer under-run?
183 movff menustack+2,menustack+1 167 clrf menustack_pointer ; YES - reset stack pointer to first stack position
184 movff menustack+3,menustack+2 168 movf menustack_pointer,W ; load stack pointer into WREG
185 movff menustack+4,menustack+3 169 lfsr FSR2,menustack ; load base address of menu stack
186 return 170 movff PLUSW2,selected_item ; retrieve menu item from stack
187 171 return ; done
188 global menu_processor_double_pop 172
189 menu_processor_double_pop:
190 movff menustack+1,selected_item
191 movff menustack+2,menustack+0
192 movff menustack+3,menustack+1
193 movff menustack+4,menustack+2
194 return
195 173
196 menu_processor_push: 174 menu_processor_push:
197 movff menustack+3,menustack+4 175 lfsr FSR2,menustack ; load base address of menu stack
198 movff menustack+2,menustack+3 176 movf menustack_pointer,W ; load stack pointer into WREG
199 movff menustack+1,menustack+2 177 movff selected_item,PLUSW2 ; save menu item to stack
200 movff menustack+0,menustack+1 178 incf menustack_pointer,W ; increment stack pointer, park result in WREG
201 movff selected_item,menustack+0 179 btfss WREG,3 ; result < 8 ?
202 clrf selected_item 180 movwf menustack_pointer ; YES - update stack pointer
203 return 181 clrf selected_item ; set to first item in new menu
182 return ; done
183
204 184
205 ;---- Execute menu selection ------------------------------------------------- 185 ;---- Execute menu selection -------------------------------------------------
206 do_menu_item: 186 do_menu_item:
207 bcf switch_right ; avoid loops 187 bcf switch_right ; clear left-over button event
208 call speed_normal ; back to normal speed
209 movf selected_item,W ; reread proc address from table 188 movf selected_item,W ; reread proc address from table
210 rcall menu_read_item ; (destroys PROD) 189 rcall menu_read_item ; (destroys PROD)
211 movff selected_item,PRODL ; pass along selected line 190 movff selected_item,PRODL ; pass along selected line
212 rcall menu_processor_push ; remember where we got from (clears selected_item) 191 rcall menu_processor_push ; remember where we got from (clears selected_item)
213 movff proc_item+2,PCLATU ; then execute computed goto 192 movff proc_item+2,PCLATU ; then execute computed goto
245 ; Vertical menu - set of line/value to choose from, 224 ; Vertical menu - set of line/value to choose from,
246 ; entry point to update lines already shown 225 ; entry point to update lines already shown
247 ; 226 ;
248 global menu_vertical 227 global menu_vertical
249 menu_vertical: 228 menu_vertical:
250 btfss divemode ; in divemode?
251 clrf timeout_counter2 ; NO - reset timeout
252
253 menu_vertical_2:
254 rcall menu_draw_lines ; always re-draw whole menu 229 rcall menu_draw_lines ; always re-draw whole menu
255 movlw CCP1CON_VALUE ; see hwos.inc 230 movlw CCP1CON_VALUE ; see hwos.inc
256 btfss divemode ; in divemode? 231 btfss divemode ; in dive mode?
257 movwf CCP1CON ; NO - power-on backlight 232 movwf CCP1CON ; NO - power-on backlight
258 233
259 menu_vertical_1: 234 menu_vertical_1:
260 movf selected_item,W ; get current item data 235 movf selected_item,W ; copy current menu item selection to WREG
261 rcall menu_read_item 236 rcall menu_read_item ; get current menu item data
262 movf proc_item+0,W ; check if proc address is NULL 237 movf proc_item+0,W ; check if proc address is NULL
263 iorwf proc_item+1,W 238 iorwf proc_item+1,W
264 bz next_line_menu ; YES - not selectable 239 bz next_line_menu ; YES - not selectable
265 btfss divemode ; in divemode? 240 btfss divemode ; in dive mode?
266 rcall menu_draw_selected_line ; NO 241 rcall menu_draw_selected_line ; NO
267 btfsc in_color_menu ; in the color scheme menu? 242 btfss imprint_time_date ; currently imprinting the current time & date?
243 bra menu_line_loop_pre1 ; NO
244 btfss switch_right ; YES - right button pressed, i.e. time or date changed?
245 bra menu_line_loop_pre1 ; NO
246 call TFT_show_time_date_menu_fast ; YES - show a fast response on the screen (may momentarily show an illegal day/month combination)
247 call rtc_set_rtc ; - update time and date on RTC module (corrects illegal day/month combinations)
248
249 menu_line_loop_pre1:
250 btfsc imprint_color_schemes ; in the color scheme menu?
268 call TFT_show_color_schemes ; YES - update the color schemes 251 call TFT_show_color_schemes ; YES - update the color schemes
269 btfss settime_setdate ; in the set time or set date menu?
270 bra menu_line_loop_pre2 ; NO - skip all following
271 movff month,lo ; new month
272 dcfsnz lo,F
273 movlw .31
274 dcfsnz lo,F
275 movlw .28
276 dcfsnz lo,F
277 movlw .31
278 dcfsnz lo,F
279 movlw .30
280 dcfsnz lo,F
281 movlw .31
282 dcfsnz lo,F
283 movlw .30
284 dcfsnz lo,F
285 movlw .31
286 dcfsnz lo,F
287 movlw .31
288 dcfsnz lo,F
289 movlw .30
290 dcfsnz lo,F
291 movlw .31
292 dcfsnz lo,F
293 movlw .30
294 dcfsnz lo,F
295 movlw .31
296 cpfsgt day ; day ok?
297 bra menu_line_loop_pre1 ; YES
298 movlw .1 ; NO - set to 1st
299 movwf day
300
301 menu_line_loop_pre1:
302 btfsc switch_right ; enter pressed?
303 call rtc_set_rtc ; YES - update mins,sec,hours,day,month and year to RTC module
304 call TFT_show_time_date_menu ; update clock
305 252
306 menu_line_loop_pre2: 253 menu_line_loop_pre2:
307 bcf switch_right 254 bcf switch_right ; clear left-over right button event
308 bcf switch_left 255 bcf switch_left ; clear left-over left button event
309 btfss divemode ; in divemode?
310 call speed_normal ; NO
311 256
312 menu_line_loop_pre3: 257 menu_line_loop_pre3:
313 btfsc divemode ; in divemode? 258 btfsc divemode ; in dive mode?
314 goto divemode_option0_return ; Yes - return to it 259 goto divemode_option0_return ; YES - return to it
315 260 ;bra menu_line_loop_surface ; - proceed to surface mode dispatcher
261
262 ; dispatcher for surface mode menus
263 menu_line_loop_surface:
264 call reset_timeout_surfmode ; reset timeout
316 menu_line_loop: 265 menu_line_loop:
317 btfsc switch_right 266 call housekeeping ; handle data imprinting, screen dump request, timeout and entering dive mode
318 bra do_line_menu ; type dependent 267 btfsc switch_right ; right button pressed?
319 btfsc switch_left 268 bra do_line_menu ; YES - type dependent
320 bra next_line_menu 269 btfsc switch_left ; left button pressed?
321 btfss quarter_second_update ; 1/4 second? 270 bra next_line_menu ; YES - goto next item
322 bra menu_line_loop1 ; NO - not yet... 271 bra menu_line_loop ; NO to both - loop
323 btfsc menu_update_sensor_mv ; in the "Calibrate" menu?
324 call TFT_menu_calibrate ; YES - update mV data
325 bcf quarter_second_update ; clear flag
326
327 menu_line_loop1:
328 btfss onesecupdate ; new second?
329 bra menu_line_loop2 ; NO - not yet...
330
331 IFDEF _rx_functions
332 btfsc FLAG_tr_enabled ; TR functions enabled?
333 call I2C_get_tankdata ; YES - get new tank data
334 btfsc menu_update_tank_pres ; in tank setup menu?
335 call TFT_menu_tank_pres ; YES - update tank press
336 ENDIF
337
338 call timeout_surfmode ; timeout on timeout_counter2
339 call set_dive_modes ; check if divemode must be entered
340 call get_battery_voltage ; gets battery voltage
341 btfsc settime_setdate ; in the set time or set date menu?
342 call TFT_show_time_date_menu ; YES - update clock
343 bcf onesecupdate ; one second updates done
344
345 menu_line_loop2:
346 btfsc sleepmode ; timeout?
347 goto restart ; YES - back to surfacemode
348 btfsc divemode
349 goto restart ; enter divemode if required
350
351 IFDEF _screendump
352 btfsc enable_screen_dumps ; screendump enabled?
353 call TFT_dump_screen_check ; YES - check if requested and do it
354 ELSE
355 btfsc disable_comm_mode ; COMM mode disabled (happens during new battery procedure)?
356 bra menu_line_loop ; YES - loop
357 ENDIF
358 btfsc enable_screen_dumps ; screendump enabled?
359 bra menu_line_loop ; loop and skip the COMM mode
360
361 btfsc vusb_in ; USB plugged in?
362 call comm_mode ; YES - start COMM mode
363
364 bra menu_line_loop ; loop
365 272
366 273
367 ;---- Move to menu's next line 274 ;---- Move to menu's next line
368 next_line_menu: 275 next_line_menu:
369 btfss divemode ; not in divemode 276 bcf switch_left ; clear button event
370 call speed_fastest
371 bcf switch_left ; avoid looping
372 incf selected_item,F ; select next item 277 incf selected_item,F ; select next item
373 movf selected_item,W ; index == max ? 278 movf selected_item,W ; copy item number to WREG
374 cpfseq item_max 279 cpfseq item_max ; item number == max ?
375 bra menu_vertical_1 ; NO - redraw cursor 280 bra menu_vertical_1 ; NO - redraw cursor
376 clrf selected_item ; YES - restart for item 0 281 clrf selected_item ; YES - wrap-around to first item
377 bra menu_vertical_1 ; then redraw cursor 282 bra menu_vertical_1 ; then redraw cursor
378 283
379 global do_line_menu 284 global do_line_menu
380 do_line_menu: 285 do_line_menu:
381 btfss divemode ; in divemode? 286 decf menu_pos_cur,W ; menu_processor needs 0-5
382 call speed_fastest ; NO 287 btfsc divemode ; in dive mode?
383 ; bcf switch_right ; avoid looping 288 movwf selected_item ; YES - set selected item from WREG
384 decf menupos1,W ; menu_processor needs 0-5
385 btfsc divemode ; only in divemode
386 movwf selected_item
387 movf selected_item,W ; read selected descriptor 289 movf selected_item,W ; read selected descriptor
388 rcall menu_read_item 290 rcall menu_read_item
389 movf value_type,W ; switch on data type 291 movf value_type,W ; switch on data type
390 bz menu_do_line_call ; CALL 292 bz menu_do_line_call ; CALL
391 dcfsnz WREG 293 dcfsnz WREG
405 ;---- Call option specific increment subroutine 307 ;---- Call option specific increment subroutine
406 menu_do_line_option: 308 menu_do_line_option:
407 movff option_item+0,FSR0L ; get option handle 309 movff option_item+0,FSR0L ; get option handle
408 movff option_item+1,FSR0H 310 movff option_item+1,FSR0H
409 call option_inc ; increment 311 call option_inc ; increment
410 movff selected_item,PRODL ; pass selection to callback. 312 movff selected_item,PRODL ; pass selection to callback
411 rcall menu_text_call 313 rcall menu_text_call
412 bra menu_vertical_2 ; redraw all lines 314 bra menu_vertical ; redraw all lines
413 315
414 ;----------------------------------------------------------------------------- 316 ;-----------------------------------------------------------------------------
415 317
318 global menu_draw_lines_divemode ; entry point for re-drawing of the menu to update color-coding of gases
416 menu_draw_lines_divemode: 319 menu_draw_lines_divemode:
417 movlw dm_menu_item1_row 320 movlw dm_menu_item1_row
418 movff WREG,win_top 321 movff WREG,win_top
419 movlw dm_menu_item1_column 322 movlw dm_menu_item1_column
420 movff WREG,win_leftx2 323 movff WREG,win_leftx2
421 clrf start_item 324 clrf start_item
422 movff item_max,menupos4 ; copy item_max for divemode cursor routine 325 movff item_max,menu_pos_max ; copy item_max for dive mode cursor routine
423 bra menu_draw_lines_2 326 bra menu_draw_lines_2
424 327
425 menu_draw_lines: 328 menu_draw_lines:
426 btfsc divemode ; in divemode? 329 btfsc divemode ; in dive mode?
427 bra menu_draw_lines_divemode ; YES 330 bra menu_draw_lines_divemode ; YES
428 btfsc menu_flags,0 ; Dynamic title? 331 btfsc menu_flags,0 ; Dynamic title?
429 rcall menu_processor_title ; YES - redraw it then 332 rcall menu_processor_title ; YES - redraw it then
430 MENU_LINE_FONT MENU_LEFT, 0 ; init start position/font 333 MENU_LINE_FONT MENU_LEFT, 0 ; initialize start position/font
431 movff menu_center,win_top ; computed in menu block. 334 movff menu_center,win_top ; computed in menu block.
432 335
433 ; Does the menu have more than 6 lines ? 336 ; Does the menu have more than 6 lines ?
434 movf item_max,W 337 movf item_max,W
435 addlw -(MENU_LINES_MAX+1) ; (max - 7) 338 addlw -(MENU_LINES_MAX+1) ;
436 bnn menu_draw_long_menu ; bra if (max >= 7) 339 bnn menu_draw_long_menu ; bra if >= 7
437 clrf start_item 340 clrf start_item
438 bra menu_draw_lines_2 341 bra menu_draw_lines_2
439 342
440 menu_draw_long_menu: 343 menu_draw_long_menu:
441 movf selected_item,W ; start at selected-6 344 movf selected_item,W ; start at selected-6
444 clrf WREG ; YES - start from top instead 347 clrf WREG ; YES - start from top instead
445 movwf start_item 348 movwf start_item
446 349
447 menu_draw_lines_2: 350 menu_draw_lines_2:
448 movff start_item, menu_item 351 movff start_item, menu_item
352 WIN_FONT FT_SMALL ; set font size
449 353
450 menu_draw_lines_1: 354 menu_draw_lines_1:
451 call TFT_standard_color ; restore color after disabled lines 355 call TFT_standard_color ; set default text color
452 movf menu_item,W 356 movf menu_item,W
453 rcall menu_read_item 357 rcall menu_read_item
454 movf value_type,W ; switch on data type 358 movf value_type,W ; switch on data type
455 bz menu_draw_line_call 359 bz menu_draw_line_call
456 dcfsnz WREG 360 dcfsnz WREG
477 movff text_item+0,FSR1L ; read string from PROM 381 movff text_item+0,FSR1L ; read string from PROM
478 movff text_item+1,FSR1H 382 movff text_item+1,FSR1H
479 call strcpy_text ; copy in buffer 383 call strcpy_text ; copy in buffer
480 movff option_item+0,FSR0L ; retrieve option handle 384 movff option_item+0,FSR0L ; retrieve option handle
481 movff option_item+1,FSR0H 385 movff option_item+1,FSR0H
482 btfss settime_setdate ; not in Time/Date menu 386 btfss block_option_value ; display of option value suspended?
483 call option_draw 387 call option_draw ; NO - draw option (do not do it when setting time or date)
484 bra menu_draw_line_none 388 bra menu_draw_line_none
485 389
486 menu_draw_line_dynamic: 390 menu_draw_line_dynamic:
487 lfsr FSR2,buffer 391 lfsr FSR2,buffer
488 movff menu_item,PRODL ; pass item to callback 392 movff menu_item,PRODL ; pass item to callback
500 movff dynamic_item+1,PCLATH 404 movff dynamic_item+1,PCLATH
501 movf dynamic_item+0,W 405 movf dynamic_item+0,W
502 movwf PCL ; ...and jump 406 movwf PCL ; ...and jump
503 407
504 menu_draw_line_none: 408 menu_draw_line_none:
505 btfsc divemode ; in divemode? 409 btfsc divemode ; in dive mode?
506 bra menu_draw_line_none_divemode ; YES 410 bra menu_draw_line_none_divemode ; YES
507 movlw MENU_LINE_MAX_LENGTH 411 movlw MENU_LINE_MAX_LENGTH
508 call TFT_fillup_with_spaces ; fill up FSR2 with spaces (Total string length in #WREG) 412 call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
509 clrf WREG 413 clrf WREG
510 movff WREG,buffer+MENU_LINE_MAX_LENGTH ; NO - make sure won't be longer than MENU_LINE_MAX_LENGTH ch 414 movff WREG,buffer+MENU_LINE_MAX_LENGTH ; NO - make sure won't be longer than MENU_LINE_MAX_LENGTH ch
511 call aa_wordprocessor 415 call aa_wordprocessor
512 bcf win_invert ; clear flag for inverted output by default 416 bcf win_invert ; clear flag for inverted output by default
513 movlw MENU_HEIGHT ; NO - move to next line 417 movlw MENU_HEIGHT ; NO - move to next line
514 addwf win_top,F 418 addwf win_top,F
515 incf menu_item,F ; inc loop counter 419 incf menu_item,F ; inc loop counter
516 movf start_item,W ; first line (scrolled) 420 movf start_item,W ; first line (scrolled)
517 subwf menu_item,W ; current - first 421 subwf menu_item,W ; current - first
518 xorlw MENU_LINES_MAX ; already done 6 lines? 422 xorlw MENU_LINES_MAX ; get max number of lines
519 btfsc STATUS,Z 423 btfsc STATUS,Z ; already done max number of lines?
520 return ; YES 424 return ; YES
521 menu_draw_line_none2: 425 menu_draw_line_none2:
522 movf menu_item,W ; done item_max lines? 426 movf menu_item,W ; done item_max lines?
523 xorwf item_max,W 427 xorwf item_max,W
524 btfss STATUS,Z 428 btfss STATUS,Z
525 bra menu_draw_lines_1 ; NO - loop... 429 bra menu_draw_lines_1 ; NO - loop...
526 return 430 return
527 431
528 menu_draw_line_none_divemode: 432 menu_draw_line_none_divemode:
529 movlw .10 433 movlw .10
530 call TFT_fillup_with_spaces ; fill up FSR2 with spaces (Total string length in #WREG) 434 call TFT_fillup_with_spaces ; fill up FSR2 with spaces (total string length in #WREG)
531 clrf WREG 435 clrf WREG
532 movff WREG,buffer+.10 436 movff WREG,buffer+.10
533 call aa_wordprocessor ; draw the line 437 call aa_wordprocessor ; draw the line
534 banksel common
535 bcf win_invert ; reset invert flag 438 bcf win_invert ; reset invert flag
536 banksel win_top 439 movlw .24 ; dive mode menu spacing
537 movlw .24 ; divemode menu spacing
538 addwf win_top,F 440 addwf win_top,F
539 incf menu_item,F ; inc loop counter 441 incf menu_item,F ; inc loop counter
540 movlw .3 442 movlw .3
541 cpfseq menu_item ; at pos 4? 443 cpfseq menu_item ; at position 4?
542 bra menu_draw_line_none2 ; NO 444 bra menu_draw_line_none2 ; NO
543 movlw dm_menu_item4_row 445 movlw dm_menu_item4_row
544 movff WREG,win_top ; reset row 446 movff WREG,win_top ; reset row
545 movlw dm_menu_item4_column 447 movlw dm_menu_item4_column
546 movff WREG,win_leftx2 ; new column 448 movff WREG,win_leftx2 ; new column
547 bra menu_draw_line_none2 ; done 449 bra menu_draw_line_none2 ; done
548 450
549 ;----------------------------------------------------------------------------- 451 ;-----------------------------------------------------------------------------
550 ; Put a mark in front of the current line 452 ; draw cursor
551 menu_draw_selected_line: 453 menu_draw_selected_line:
552 clrf timeout_counter2 ; reset timeout
553 WIN_BOX_BLACK .34,.221,MENU_LEFT-8,MENU_LEFT-2 ; clear left column 454 WIN_BOX_BLACK .34,.221,MENU_LEFT-8,MENU_LEFT-2 ; clear left column
554 call TFT_standard_color 455 call TFT_standard_color
555 WIN_SMALL MENU_LEFT-8, 0 ; arrow symbol only in small font 456 WIN_SMALL MENU_LEFT-8, 0 ; arrow symbol only in small font
556 movf start_item,W ; first line (scrolled) 457 movf start_item,W ; first line (scrolled)
557 subwf selected_item,W ; selected - first 458 subwf selected_item,W ; selected - first
558 mullw MENU_HEIGHT ; 30 pixel by line 459 mullw MENU_HEIGHT ; 30 pixel by line
559 movf PRODL,W ; result 460 movf PRODL,W ; result
560 addwf menu_center,W ; added to first line 461 addwf menu_center,W ; added to first line
561 movwf win_top ; and stored to pos. 462 movwf win_top ; and stored to position
562 STRCPY_PRINT "\xb7" ; print cursor 463 STRCPY_PRINT "\xb7" ; print cursor
563 return 464 return
564 465
565 END 466 END