comparison src/menu_processor.asm @ 604:ca4556fb60b9

bump to 2.99beta, work on 3.00 stable
author heinrichsweikamp
date Thu, 22 Nov 2018 19:47:26 +0100
parents b455b31ce022
children c5151a490d88
comparison
equal deleted inserted replaced
603:00b24fb4324d 604:ca4556fb60b9
1 ;============================================================================= 1 ;=============================================================================
2 ; 2 ;
3 ; File menu_processor.asm REFACTORED VERSION V2.98 3 ; File menu_processor.asm REFACTORED VERSION V2.99d
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 ;=============================================================================
9 ; HISTORY 9 ; HISTORY
10 ; 2012-11-02 : [jDG] Cleanup for hwOS: removed icons. Added scrolling. 10 ; 2012-11-02 : [jDG] Cleanup for hwOS: removed icons. Added scrolling.
11 ; But need a font with lower/upper alpha chars... 11 ; But need a font with lower/upper alpha chars...
12 12
13 #include "hwos.inc"
13 #include "convert.inc" 14 #include "convert.inc"
14 #include "hwos.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" 18 #include "wait.inc"
19 #include "start.inc" 19 #include "start.inc"
20 #include "surfmode.inc" 20 #include "surfmode.inc"
21 #include "divemode.inc" 21 #include "divemode.inc"
22 #include "tft_outputs.inc" 22 #include "tft_outputs.inc"
23 #include "eeprom_rs232.inc" 23 #include "eeprom_rs232.inc"
24 #include "adc_lightsensor.inc" 24 #include "adc_lightsensor.inc"
25 25 #include "i2c.inc"
26 26
27 ;NOTE: should be identical in .inc and .asm ! 27
28 #define MENU_LINES_MAX .7 ; Number of lines per screen? 28 ; NOTE: needs to be identical in .inc and .asm !
29 #define MENU_TITLE_FONT WIN_STD ; Font should contains lower/UPPER alpha 29 #define MENU_LINES_MAX .7 ; number of lines per screen?
30 #define MENU_LINE_FONT WIN_SMALL ; Font should contains lower/UPPER alpha 30 #define MENU_TITLE_FONT WIN_STD ; font needs to contain lower and UPPER chars
31 #define MENU_LEFT .20 ; Position of first menu item 31 #define MENU_LINE_FONT WIN_SMALL ; font needs to contain lower and UPPER chars
32 #define MENU_HEIGHT .27 ; Spacing between menu lines. 32 #define MENU_LEFT .20 ; position of first menu item
33 #define MENU_VCENTER .125 ; Position on screen. 33 #define MENU_HEIGHT .27 ; spacing between menu lines
34 #define MENU_LINE_MAX_LENGTH .20 ; Length in characters 34 #define MENU_VCENTER .125 ; position on screen
35 #define MENU_LINE_MAX_LENGTH .20 ; length in characters
35 #define option_item proc_item 36 #define option_item proc_item
36 37
37 ; Other needed references 38 ; Other needed references
38 extern aa_wordprocessor 39 extern aa_wordprocessor
39 extern option_inc 40 extern option_inc
44 extern rtc_set_rtc 45 extern rtc_set_rtc
45 extern divemode_option0_return 46 extern divemode_option0_return
46 extern TFT_fillup_with_spaces 47 extern TFT_fillup_with_spaces
47 48
48 49
49 basic CODE 50 menu_proc CODE
50 51
51 ;============================================================================= 52 ;=============================================================================
52 ; menu handler. 53 ; menu handler.
53 ; 54 ;
54 ; Input: TBLPTR = addr of menu block. 55 ; Input: TBLPTR = addr of menu block.
55 global menu_processor 56 global menu_processor
56 menu_processor: 57 menu_processor:
57 banksel common ; Bank1 58 banksel common ; bank 1
58 btfss divemode ; Not in divemode 59 btfss divemode ; in divemode?
59 call speed_fastest ; Make it quick ! 60 call speed_fastest ; NO - make it quick
60 ;---- Read menu block ------------------------------------------------ 61 ;---- Read menu block ------------------------------------------------
61 VARARGS_BEGIN ; Read inline PROM data 62 VARARGS_BEGIN ; read inline PROM data
62 clrf STKPTR ; Never return, anyway... 63 clrf STKPTR ; never return from here
63 VARARGS_GET8 item_max ; Get number of items 64 VARARGS_GET8 item_max ; get number of items
64 VARARGS_GET8 menu_flags ; Get flags 65 VARARGS_GET8 menu_flags ; get flags
65 VARARGS_GET24 menu_title ; Get pointer to menu title 66 VARARGS_GET24 menu_title ; get pointer to menu title
66 VARARGS_GET8 menu_center ; Vertical position 67 VARARGS_GET8 menu_center ; vertical position
67 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
68 movff TBLPTRH, menu_block+1 69 movff TBLPTRH, menu_block+1
69 movff TBLPTRU, menu_block+2 70 movff TBLPTRU, menu_block+2
70 btfss divemode ; In divemode? 71 btfss divemode ; in divemode?
71 bra menu_processor0 ; No 72 bra menu_processor0 ; NO
72 ; Required for menus with less entries then the calling menu but not so nice when setting up gas 6.... mH 73 ; Required for menus with less entries than the calling menu but not so nice when setting up gas 6.... mH
73 movlw .1 74 movlw .1
74 cpfsgt menupos1 ; only if menupos1 = 1... 75 cpfsgt menupos1 ; only if menupos1 = 1...
75 call TFT_clear_divemode_menu ; ... Clear the menu! 76 call TFT_clear_divemode_menu ; ... clear the menu!
76 ; Draw one frame around the divemode menu 77 ; Draw one frame around the divemode menu
77 call TFT_divemask_color 78 call TFT_divemask_color
78 WIN_FRAME_COLOR16 dm_menu_row, dm_menu_lower, dm_menu_left ,dm_menu_right ; top, bottom, left, right 79 WIN_FRAME_COLOR16 dm_menu_row, dm_menu_lower, dm_menu_left ,dm_menu_right ; top, bottom, left, right
79 call TFT_standard_color 80 call TFT_standard_color
80 81
81 bra menu_processor1 ; Yes, skip some lines here 82 bra menu_processor1 ; skip next code segment in divemode
82 83
83 menu_processor0: 84 menu_processor0:
84 ;---- draw menu title ------------------------------------------------ 85 ;---- draw menu title ------------------------------------------------
85 clrf CCP1CON ; stop PWM 86 clrf CCP1CON ; stop PWM
86 bcf PORTC,2 ; Pull PWM out to GND 87 bcf PORTC,2 ; pull PWM out to GND
87 call TFT_ClearScreen 88 call TFT_ClearScreen
88 rcall menu_processor_title 89 rcall menu_processor_title
89 rcall menu_processor_bottom_line 90 rcall menu_processor_bottom_line
90 91
91 menu_processor1: 92 menu_processor1:
93 movff WREG, win_font 94 movff WREG, win_font
94 95
95 ;---- Select menu type ----------------------------------------------- 96 ;---- Select menu type -----------------------------------------------
96 bra menu_vertical 97 bra menu_vertical
97 98
98 global menu_processor_bottom_line 99
100 ;=============================================================================
101 ; draw menu bottom line
102 ;
103 global menu_processor_bottom_line,menu_processor_bottom_line_comm
99 menu_processor_bottom_line: 104 menu_processor_bottom_line:
100 ;---- Draw bottom line ----------------------------------------------- 105 ;---- Draw bottom line -----------------------------------------------
101 TEXT_TINY .5, .240-.16, tNext 106 TEXT_TINY .5, .240-.16, tNext
102 TEXT_TINY .160-.6*.6, .240-.16, tEnter 107 TEXT_TINY .160-.6*.6, .240-.16, tEnter
103 WIN_COLOR color_greenish 108 WIN_COLOR color_greenish
104 ; Serial and Firmware Version 109 menu_processor_bottom_line_comm:
105 WIN_TINY .57,.240-.16 110 ; Serial Number and Firmware Version
111 WIN_TINY .32,.240-.16
106 STRCPY "#" 112 STRCPY "#"
107 call TFT_cat_serial 113 call TFT_cat_serial
108 STRCAT " v" 114 STRCAT " v"
109 call TFT_cat_firmware 115 call TFT_cat_firmware
116 STRCAT " "
117 call TFT_cat_beta_release
110 STRCAT_PRINT "" 118 STRCAT_PRINT ""
111 call TFT_standard_color 119 call TFT_standard_color
112 bcf win_invert 120 bcf win_invert
113 return 121 return
114 122
115 ;============================================================================= 123 ;=============================================================================
116 ; (re-)draw menu title. 124 ; (re-)draw menu title
117 ; 125 ;
118 menu_processor_title: 126 menu_processor_title:
119 WIN_BOX_BLACK .2,.23,.0,.159 ; Clear Menu title 127 WIN_BOX_BLACK .2,.23,.0,.159 ; clear menu title
120 MENU_TITLE_FONT .0, .2 ; Menu title positioning 128 MENU_TITLE_FONT .0, .2 ; menu title positioning
121 btfss menu_flags,0 ; Static or dynamic title ? 129 btfss menu_flags,0 ; static or dynamic title?
122 bra menu_processor_static_title 130 bra menu_processor_static_title ; static title
123 rcall menu_processor_call_title ; add gas, detail and color. 131 rcall menu_processor_call_title ; dynamic title - add gas, detail and color
124 bra menu_processor_title_1 132 bra menu_processor_title_1
125 133
126 menu_processor_static_title: 134 menu_processor_static_title:
127 movff menu_title+0,FSR1L ; Just copy string. 135 movff menu_title+0,FSR1L ; just copy string
128 movff menu_title+1,FSR1H 136 movff menu_title+1,FSR1H
129 call strcpy_text 137 call strcpy_text
130 138
131 menu_processor_title_1: 139 menu_processor_title_1:
132 WIN_COLOR color_greenish 140 WIN_COLOR color_greenish
133 movf FSR2L,W ; Get title length 141 movf FSR2L,W ; get title length
134 mullw .9 ; Convert to half pixels 142 mullw .9 ; convert to half pixels
135 bcf STATUS,C ; Clear carry 143 bcf STATUS,C ; clear carry
136 rrcf PRODL ; /2 144 rrcf PRODL ; /2
137 movf PRODL,W ; Back to WREG 145 movf PRODL,W ; back to WREG
138 sublw .80 ; 80 - width 146 sublw .80 ; 80 - width
139 movwf win_leftx2 ; Aligned to center. 147 movwf win_leftx2 ; aligned to center
140 movlw .0 148 movlw .0 ; string termination code
141 movff WREG,buffer+.17 ; limit to 17chars (Std font max.) 149 movff WREG,buffer+.17 ; limit to 17 chars (std font max.)
142 call aa_wordprocessor 150 call aa_wordprocessor
143 call TFT_standard_color 151 call TFT_standard_color
144 return 152 return
145 153
146 ;============================================================================= 154 ;=============================================================================
147 ; Call dynamic proc for menu title: 155 ; Call dynamic proc for menu title:
148 156
149 menu_processor_call_title: 157 menu_processor_call_title:
150 movff menu_title+2,PCLATU ; Just execute computed goto. 158 movff menu_title+2,PCLATU ; execute computed goto
151 movff menu_title+1,PCLATH 159 movff menu_title+1,PCLATH
152 movf menu_title+0,W 160 movf menu_title+0,W
153 movwf PCL 161 movwf PCL
154 162
155 ;============================================================================= 163 ;=============================================================================
156 ; Restart with first icon/line selected. 164 ; Restart with first icon/line selected
165 ;
157 global menu_processor_reset 166 global menu_processor_reset
158 menu_processor_reset: 167 menu_processor_reset:
159 banksel menustack 168 banksel menustack
160 lfsr FSR2,menustack 169 lfsr FSR2,menustack
161 clrf POSTINC2 170 clrf POSTINC2
193 clrf selected_item 202 clrf selected_item
194 return 203 return
195 204
196 ;---- Execute menu selection ------------------------------------------------- 205 ;---- Execute menu selection -------------------------------------------------
197 do_menu_item: 206 do_menu_item:
198 bcf switch_right ; Avoid loops. 207 bcf switch_right ; avoid loops
199 call speed_normal ; Back to normal speed. 208 call speed_normal ; back to normal speed
200 movf selected_item,W ; Reread proc address from table. 209 movf selected_item,W ; reread proc address from table
201 rcall menu_read_item ; (destroy PROD) 210 rcall menu_read_item ; (destroys PROD)
202 movff selected_item,PRODL ; Pass along selected line 211 movff selected_item,PRODL ; pass along selected line
203 rcall menu_processor_push ; Remember where we get from. (clears selected_item) 212 rcall menu_processor_push ; remember where we got from (clears selected_item)
204 movff proc_item+2,PCLATU ; Then execute computed goto. 213 movff proc_item+2,PCLATU ; then execute computed goto
205 movff proc_item+1,PCLATH 214 movff proc_item+1,PCLATH
206 movf proc_item+0,W 215 movf proc_item+0,W
207 movwf PCL 216 movwf PCL
208 217
209 ;============================================================================= 218 ;=============================================================================
210 ; Get current item from table. 219 ; Get current item from table.
211 ; 220 ;
212 ; Input : Item number in WREG, menu_block. 221 ; Input : Item number in WREG, menu_block.
213 ; 222 ; Output : icon_large, text_item, proc_item 16bits pointers.
214 ; Output: icon_large, text_item, proc_item 16bits pointers.
215 ;
216 ; Trashed: PROD, WREG 223 ; Trashed: PROD, WREG
224 ;
217 menu_read_item: 225 menu_read_item:
218 mullw .10 ; 10 bytes per item. 226 mullw .10 ; 10 bytes per item
219 movf PRODL,W ; Then do a 24bits add 227 movf PRODL,W ; then do a 24 bits add
220 addwf menu_block+0,W ; with menu_block, and 228 addwf menu_block+0,W ; with menu_block, and
221 movwf TBLPTRL ; setup TBLPTR 229 movwf TBLPTRL ; setup TBLPTR
222 movf PRODH,W 230 movf PRODH,W
223 addwfc menu_block+1,W 231 addwfc menu_block+1,W
224 movwf TBLPTRH 232 movwf TBLPTRH
225 movlw 0 233 movlw 0
226 addwfc menu_block+2,W 234 addwfc menu_block+2,W
227 movwf TBLPTRU 235 movwf TBLPTRU
228 VARARGS_GET8 value_type ; Read 10 bytes of item data 236 VARARGS_GET8 value_type ; read 10 bytes of item data
229 VARARGS_GET24 dynamic_item 237 VARARGS_GET24 dynamic_item
230 VARARGS_GET24 proc_item 238 VARARGS_GET24 proc_item
231 VARARGS_GET8 WREG ; Skip dummy byte 239 VARARGS_GET8 WREG ; skip dummy byte
232 VARARGS_GET16 text_item 240 VARARGS_GET16 text_item
233 241
234 return 242 return
235 243
236 ;============================================================================= 244 ;=============================================================================
237 ; Vertical menu : set of line/value to choose from. 245 ; Vertical menu - set of line/value to choose from,
238 ; Entry point to update lines already shown. 246 ; entry point to update lines already shown
239 ; 247 ;
240 global menu_vertical 248 global menu_vertical
241 menu_vertical: 249 menu_vertical:
242 btfss divemode ; Not in divemode 250 btfss divemode ; in divemode?
243 clrf timeout_counter2 ; Reset timeout 251 clrf timeout_counter2 ; NO - reset timeout
244 252
245 menu_vertical_2: 253 menu_vertical_2:
246 rcall menu_draw_lines ; Always re-draw whole menu 254 rcall menu_draw_lines ; always re-draw whole menu
247 movlw CCP1CON_VALUE ; See hwos.inc 255 movlw CCP1CON_VALUE ; see hwos.inc
248 btfss divemode ; Not in divemode 256 btfss divemode ; in divemode?
249 movwf CCP1CON ; Power-on backlight 257 movwf CCP1CON ; NO - power-on backlight
250 258
251 menu_vertical_1: 259 menu_vertical_1:
252 movf selected_item,W ; Get current item data 260 movf selected_item,W ; get current item data
253 rcall menu_read_item 261 rcall menu_read_item
254 movf proc_item+0,W ; Check if pro address is NULL ? 262 movf proc_item+0,W ; check if proc address is NULL
255 iorwf proc_item+1,W 263 iorwf proc_item+1,W
256 bz next_line_menu ; YES: not selectable ! 264 bz next_line_menu ; YES - not selectable
257 btfss divemode ; Not in divemode 265 btfss divemode ; in divemode?
258 rcall menu_draw_selected_line 266 rcall menu_draw_selected_line ; NO
259 btfsc in_color_menu ; =1: In the color scheme menu 267 btfsc in_color_menu ; in the color scheme menu?
260 call TFT_show_color_schemes ; Yes, update the color schemes 268 call TFT_show_color_schemes ; YES - update the color schemes
261 btfss settime_setdate ; In the Set Time or Set Date menu? 269 btfss settime_setdate ; in the set time or set date menu?
262 bra menu_line_loop_pre2 ; no, skip all following 270 bra menu_line_loop_pre2 ; NO - skip all following
263 movff month,lo ; new month 271 movff month,lo ; new month
264 dcfsnz lo,F 272 dcfsnz lo,F
265 movlw .31 273 movlw .31
266 dcfsnz lo,F 274 dcfsnz lo,F
267 movlw .28 275 movlw .28
284 dcfsnz lo,F 292 dcfsnz lo,F
285 movlw .30 293 movlw .30
286 dcfsnz lo,F 294 dcfsnz lo,F
287 movlw .31 295 movlw .31
288 cpfsgt day ; day ok? 296 cpfsgt day ; day ok?
289 bra menu_line_loop_pre1 ; OK! 297 bra menu_line_loop_pre1 ; YES
290 movlw .1 ; not OK, set to 1st 298 movlw .1 ; NO - set to 1st
291 movwf day 299 movwf day
292 300
293 menu_line_loop_pre1: 301 menu_line_loop_pre1:
294 btfsc switch_right ; Enter pressed? 302 btfsc switch_right ; enter pressed?
295 call rtc_set_rtc ; Yes, update mins,sec,hours,day,month and year to RTC module 303 call rtc_set_rtc ; YES - update mins,sec,hours,day,month and year to RTC module
296 call TFT_show_time_date_menu ; Update clock 304 call TFT_show_time_date_menu ; update clock
297 305
298 menu_line_loop_pre2: 306 menu_line_loop_pre2:
299 bcf switch_right 307 bcf switch_right
300 bcf switch_left 308 bcf switch_left
301 btfss divemode ; Not in divemode 309 btfss divemode ; in divemode?
302 call speed_normal 310 call speed_normal ; NO
303 311
304 menu_line_loop_pre3: 312 menu_line_loop_pre3:
305 btfsc divemode ; In divemode? 313 btfsc divemode ; in divemode?
306 goto divemode_option0_return ; Yes, return to it 314 goto divemode_option0_return ; Yes - return to it
307 315
308 menu_line_loop: 316 menu_line_loop:
309 btfsc switch_right 317 btfsc switch_right
310 bra do_line_menu ; Type dependent 318 bra do_line_menu ; type dependent
311 btfsc switch_left 319 btfsc switch_left
312 bra next_line_menu 320 bra next_line_menu
313 btfss quarter_second_update ; 1/4 second? 321 btfss quarter_second_update ; 1/4 second?
314 bra menu_line_loop1 ; Not yet... 322 bra menu_line_loop1 ; NO - not yet...
315 btfsc menu_show_sensors2 ; In the "Calibrate" menu? 323 btfsc menu_update_sensor_mv ; in the "Calibrate" menu?
316 call TFT_menu_calibrate ; Yes, update mV data 324 call TFT_menu_calibrate ; YES - update mV data
317 bcf quarter_second_update ; Clear flag 325 bcf quarter_second_update ; clear flag
318 326
319 menu_line_loop1: 327 menu_line_loop1:
320 btfss onesecupdate ; New second 328 btfss onesecupdate ; new second?
321 bra menu_line_loop2 ; not yet... 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
322 call timeout_surfmode ; timeout on timeout_counter2 338 call timeout_surfmode ; timeout on timeout_counter2
323 call set_dive_modes ; check, if divemode must be entered 339 call set_dive_modes ; check if divemode must be entered
324 call get_battery_voltage ; gets battery voltage 340 call get_battery_voltage ; gets battery voltage
325 btfsc settime_setdate ; In the Set Time or Set Date menu? 341 btfsc settime_setdate ; in the set time or set date menu?
326 call TFT_show_time_date_menu ; Yes, update clock 342 call TFT_show_time_date_menu ; YES - update clock
327 bcf onesecupdate ; one second updates done 343 bcf onesecupdate ; one second updates done
328 344
329 menu_line_loop2: 345 menu_line_loop2:
330 btfsc sleepmode ; Timeout? 346 btfsc sleepmode ; timeout?
331 goto restart ; Yes, back to surfacemode 347 goto restart ; YES - back to surfacemode
332 btfsc divemode 348 btfsc divemode
333 goto restart ; Enter divemode if required 349 goto restart ; enter divemode if required
334 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump) 350
335 bra menu_line_loop3 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
336 btfsc vusb_in ; USB plugged in? 359 btfsc vusb_in ; USB plugged in?
337 call comm_mode ; Start COMM mode 360 call comm_mode ; YES - start COMM mode
338 bra menu_line_loop4 361
339 menu_line_loop3: 362 bra menu_line_loop ; loop
340 btfss vusb_in ; USB (still) plugged in? 363
341 bcf enable_screen_dumps ; No, clear flag
342 call rs232_get_byte
343 btfsc rs232_receive_overflow
344 bra menu_line_loop4
345 movlw "l"
346 cpfseq RCREG1
347 bra menu_line_loop4
348 call TFT_dump_screen ; Dump the screen contents
349 menu_line_loop4:
350 bra menu_line_loop
351 364
352 ;---- Move to menu's next line 365 ;---- Move to menu's next line
353 next_line_menu: 366 next_line_menu:
354 btfss divemode ; not in divemode 367 btfss divemode ; not in divemode
355 call speed_fastest 368 call speed_fastest
356 bcf switch_left ; Avoid looping. 369 bcf switch_left ; avoid looping
357 incf selected_item,F ; Select next item. 370 incf selected_item,F ; select next item
358 movf selected_item,W ; Index == max ? 371 movf selected_item,W ; index == max ?
359 cpfseq item_max 372 cpfseq item_max
360 bra menu_vertical_1 ; NO: redraw cursor. 373 bra menu_vertical_1 ; NO - redraw cursor
361 clrf selected_item ; YES: restart for item 0. 374 clrf selected_item ; YES - restart for item 0
362 bra menu_vertical_1 ; Then redraw cursor. 375 bra menu_vertical_1 ; then redraw cursor
363 376
364 global do_line_menu 377 global do_line_menu
365 do_line_menu: 378 do_line_menu:
366 btfss divemode ; not in divemode 379 btfss divemode ; in divemode?
367 call speed_fastest 380 call speed_fastest ; NO
368 ; bcf switch_right ; Avoid looping. 381 ; bcf switch_right ; avoid looping
369 decf menupos1,W ; menu_processor needs 0-5... 382 decf menupos1,W ; menu_processor needs 0-5
370 btfsc divemode ; only in divemode 383 btfsc divemode ; only in divemode
371 movwf selected_item 384 movwf selected_item
372 movf selected_item,W ; Read selected descriptor 385 movf selected_item,W ; read selected descriptor
373 rcall menu_read_item 386 rcall menu_read_item
374 movf value_type,W ; Switch on data type 387 movf value_type,W ; switch on data type
375 bz menu_do_line_call ; CALL 388 bz menu_do_line_call ; CALL
376 dcfsnz WREG 389 dcfsnz WREG
377 bra menu_do_line_call ; STRING: do as call 390 bra menu_do_line_call ; STRING: do as call
378 dcfsnz WREG 391 dcfsnz WREG
379 bra menu_do_line_option ; OPTION 392 bra menu_do_line_option ; OPTION
380 dcfsnz WREG 393 dcfsnz WREG
381 bra menu_do_line_call ; DYNAMIC: do as call 394 bra menu_do_line_call ; DYNAMIC: do as call
382 bra menu_line_loop_pre3 ; else do nothing... 395 bra menu_line_loop_pre3 ; else do nothing
383 396
384 ;---- CALL 397 ;---- CALL
385 menu_do_line_call: 398 menu_do_line_call:
386 rcall do_menu_item ; Same as icon menu: calculated goto. 399 rcall do_menu_item ; same as icon menu: calculated goto
387 rcall menu_processor_pop ; Back to same line, 400 rcall menu_processor_pop ; back to same line,
388 bra menu_vertical ; Then continue into menu... 401 bra menu_vertical ; then continue into menu...
389 402
390 ;---- Call option specific increment subroutine 403 ;---- Call option specific increment subroutine
391 menu_do_line_option: 404 menu_do_line_option:
392 movff option_item+0,FSR0L ; Get option handle 405 movff option_item+0,FSR0L ; get option handle
393 movff option_item+1,FSR0H 406 movff option_item+1,FSR0H
394 call option_inc ; increment 407 call option_inc ; increment
395 movff selected_item,PRODL ; Pass selection to callback. 408 movff selected_item,PRODL ; pass selection to callback.
396 rcall menu_text_call 409 rcall menu_text_call
397 bra menu_vertical_2 ; redraw all lines... 410 bra menu_vertical_2 ; redraw all lines
398 411
399 ;----------------------------------------------------------------------------- 412 ;-----------------------------------------------------------------------------
400 413
401 menu_draw_lines_divemode: 414 menu_draw_lines_divemode:
402 movlw dm_menu_item1_row 415 movlw dm_menu_item1_row
403 movff WREG,win_top 416 movff WREG,win_top
404 movlw dm_menu_item1_column 417 movlw dm_menu_item1_column
405 movff WREG,win_leftx2 418 movff WREG,win_leftx2
406 clrf start_item 419 clrf start_item
407 movff item_max,menupos4 ; Copy item_max for divemode cursor routine 420 movff item_max,menupos4 ; copy item_max for divemode cursor routine
408 bra menu_draw_lines_2 421 bra menu_draw_lines_2
409 422
410 menu_draw_lines: 423 menu_draw_lines:
411 btfsc divemode ; in divemode? 424 btfsc divemode ; in divemode?
412 bra menu_draw_lines_divemode ; Yes 425 bra menu_draw_lines_divemode ; YES
413 btfsc menu_flags,0 ; Dynamic title ? 426 btfsc menu_flags,0 ; Dynamic title?
414 rcall menu_processor_title ; YES: redraw it then. 427 rcall menu_processor_title ; YES - redraw it then
415 MENU_LINE_FONT MENU_LEFT, 0 ; Init start position/font 428 MENU_LINE_FONT MENU_LEFT, 0 ; init start position/font
416 movff menu_center,win_top ; computed in menu block. 429 movff menu_center,win_top ; computed in menu block.
417 430
418 ; Does the menu have more than 6 lines ? 431 ; Does the menu have more than 6 lines ?
419 movf item_max,W 432 movf item_max,W
420 addlw -(MENU_LINES_MAX+1) ; (max - 7) 433 addlw -(MENU_LINES_MAX+1) ; (max - 7)
421 bnn menu_draw_long_menu ; bra if (max >= 7) 434 bnn menu_draw_long_menu ; bra if (max >= 7)
422 clrf start_item 435 clrf start_item
423 bra menu_draw_lines_2 436 bra menu_draw_lines_2
424 437
425 menu_draw_long_menu: 438 menu_draw_long_menu:
426 movf selected_item,W ; Start at selected-6 439 movf selected_item,W ; start at selected-6
427 addlw -(MENU_LINES_MAX-1) 440 addlw -(MENU_LINES_MAX-1)
428 btfsc STATUS,N ; This is <0 ? 441 btfsc STATUS,N ; is this < 0 ?
429 clrf WREG ; YES: start from top instead. 442 clrf WREG ; YES - start from top instead
430 movwf start_item 443 movwf start_item
431 444
432 menu_draw_lines_2: 445 menu_draw_lines_2:
433 movff start_item, menu_item 446 movff start_item, menu_item
434 447
435 menu_draw_lines_1: 448 menu_draw_lines_1:
436 call TFT_standard_color ; Restore color after disabled lines. 449 call TFT_standard_color ; restore color after disabled lines
437 movf menu_item,W 450 movf menu_item,W
438 rcall menu_read_item 451 rcall menu_read_item
439 movf value_type,W ; Switch on data type 452 movf value_type,W ; switch on data type
440 bz menu_draw_line_call 453 bz menu_draw_line_call
441 dcfsnz WREG 454 dcfsnz WREG
442 bra menu_draw_line_string 455 bra menu_draw_line_string
443 dcfsnz WREG 456 dcfsnz WREG
444 bra menu_draw_line_option 457 bra menu_draw_line_option
445 dcfsnz WREG 458 dcfsnz WREG
446 bra menu_draw_line_dynamic 459 bra menu_draw_line_dynamic
447 bra menu_draw_line_none 460 bra menu_draw_line_none
448 461
449 menu_draw_line_string: 462 menu_draw_line_string:
450 movff text_item+0,TBLPTRL ; Read not-translated string from PROM. 463 movff text_item+0,TBLPTRL ; read not-translated string from PROM
451 movff text_item+1,TBLPTRH 464 movff text_item+1,TBLPTRH
452 call strcpy_prom ; Copy in buffer 465 call strcpy_prom ; copy in buffer
453 bra menu_draw_line_none 466 bra menu_draw_line_none
454 467
455 menu_draw_line_call: 468 menu_draw_line_call:
456 movff text_item+0,FSR1L ; Read string from PROM. 469 movff text_item+0,FSR1L ; read string from PROM
457 movff text_item+1,FSR1H 470 movff text_item+1,FSR1H
458 call strcpy_text ; Copy in buffer 471 call strcpy_text ; copy in buffer
459 bra menu_draw_line_none 472 bra menu_draw_line_none
460 473
461 menu_draw_line_option: 474 menu_draw_line_option:
462 movff text_item+0,FSR1L ; Read string from PROM. 475 movff text_item+0,FSR1L ; read string from PROM
463 movff text_item+1,FSR1H 476 movff text_item+1,FSR1H
464 call strcpy_text ; Copy in buffer 477 call strcpy_text ; copy in buffer
465 movff option_item+0,FSR0L ; Retrieve option handle. 478 movff option_item+0,FSR0L ; retrieve option handle
466 movff option_item+1,FSR0H 479 movff option_item+1,FSR0H
467 btfss settime_setdate ; Not in Time/Date menu... 480 btfss settime_setdate ; not in Time/Date menu
468 call option_draw 481 call option_draw
469 bra menu_draw_line_none 482 bra menu_draw_line_none
470 483
471 menu_draw_line_dynamic: 484 menu_draw_line_dynamic:
472 lfsr FSR2,buffer 485 lfsr FSR2,buffer
473 movff menu_item,PRODL ; Pass item to callback. 486 movff menu_item,PRODL ; pass item to callback
474 rcall menu_text_call ; Push return address. 487 rcall menu_text_call ; push return address
475 bra menu_draw_line_none 488 bra menu_draw_line_none
476 489
477 ; Computed goto to pointer inside dynamic_item: 490 ; Computed goto to pointer inside dynamic_item:
478 menu_text_call: 491 menu_text_call:
479 movf dynamic_item+0,W ; Check if callback is NULL 492 movf dynamic_item+0,W ; check if callback is NULL
480 iorwf dynamic_item+1,W 493 iorwf dynamic_item+1,W
481 iorwf dynamic_item+2,W 494 iorwf dynamic_item+2,W
482 btfsc STATUS,Z 495 btfsc STATUS,Z
483 return ; YES: don't call it. 496 return ; YES - don't call it
484 movff dynamic_item+2,PCLATU ; Prepare... 497 movff dynamic_item+2,PCLATU ; prepare...
485 movff dynamic_item+1,PCLATH 498 movff dynamic_item+1,PCLATH
486 movf dynamic_item+0,W 499 movf dynamic_item+0,W
487 movwf PCL ; And jump ! 500 movwf PCL ; ...and jump
488 501
489 menu_draw_line_none: 502 menu_draw_line_none:
490 btfsc divemode ; In divemode? 503 btfsc divemode ; in divemode?
491 bra menu_draw_line_none_divemode ; Yes 504 bra menu_draw_line_none_divemode ; YES
492 movlw MENU_LINE_MAX_LENGTH 505 movlw MENU_LINE_MAX_LENGTH
493 call TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) 506 call TFT_fillup_with_spaces ; fill up FSR2 with spaces (Total string length in #WREG)
494 clrf WREG 507 clrf WREG
495 movff WREG,buffer+MENU_LINE_MAX_LENGTH ; No - make sure won't be longer than MENU_LINE_MAX_LENGTH ch 508 movff WREG,buffer+MENU_LINE_MAX_LENGTH ; NO - make sure won't be longer than MENU_LINE_MAX_LENGTH ch
496 call aa_wordprocessor 509 call aa_wordprocessor
497 movlw MENU_HEIGHT ; No, Move to next line 510 bcf win_invert ; clear flag for inverted output by default
511 movlw MENU_HEIGHT ; NO - move to next line
498 addwf win_top,F 512 addwf win_top,F
499 incf menu_item,F ; inc loop counter 513 incf menu_item,F ; inc loop counter
500 movf start_item,W ; First line (scrolled) 514 movf start_item,W ; first line (scrolled)
501 subwf menu_item,W ; current - first 515 subwf menu_item,W ; current - first
502 xorlw MENU_LINES_MAX ; Already done 6 lines ? 516 xorlw MENU_LINES_MAX ; already done 6 lines?
503 btfsc STATUS,Z 517 btfsc STATUS,Z
504 return ; YES 518 return ; YES
505 menu_draw_line_none2: 519 menu_draw_line_none2:
506 movf menu_item,W ; Done item_max lines ? 520 movf menu_item,W ; done item_max lines?
507 xorwf item_max,W 521 xorwf item_max,W
508 btfss STATUS,Z 522 btfss STATUS,Z
509 bra menu_draw_lines_1 ; No: loop... 523 bra menu_draw_lines_1 ; NO - loop...
510 return 524 return
511 525
512 menu_draw_line_none_divemode: 526 menu_draw_line_none_divemode:
513 movlw .10 527 movlw .10
514 call TFT_fillup_with_spaces ; Fill up FSR2 with spaces (Total string length in #WREG) 528 call TFT_fillup_with_spaces ; fill up FSR2 with spaces (Total string length in #WREG)
515 clrf WREG 529 clrf WREG
516 movff WREG,buffer+.10 530 movff WREG,buffer+.10
517 call aa_wordprocessor ; Draw the line! 531 call aa_wordprocessor ; draw the line
518 banksel common 532 banksel common
519 bcf win_invert ; Reset invert flag 533 bcf win_invert ; reset invert flag
520 banksel win_top 534 banksel win_top
521 movlw .24 ; divemode menu spacing 535 movlw .24 ; divemode menu spacing
522 addwf win_top,F 536 addwf win_top,F
523 incf menu_item,F ; inc loop counter 537 incf menu_item,F ; inc loop counter
524 movlw .3 538 movlw .3
525 cpfseq menu_item ; At pos 4? 539 cpfseq menu_item ; at pos 4?
526 bra menu_draw_line_none2 ; No 540 bra menu_draw_line_none2 ; NO
527 movlw dm_menu_item4_row 541 movlw dm_menu_item4_row
528 movff WREG,win_top ; Reset row 542 movff WREG,win_top ; reset row
529 movlw dm_menu_item4_column 543 movlw dm_menu_item4_column
530 movff WREG,win_leftx2 ; New column 544 movff WREG,win_leftx2 ; new column
531 bra menu_draw_line_none2 ; Done. 545 bra menu_draw_line_none2 ; done
532 546
533 ;----------------------------------------------------------------------------- 547 ;-----------------------------------------------------------------------------
534 ; Put a mark in front of the current line 548 ; Put a mark in front of the current line
535 menu_draw_selected_line: 549 menu_draw_selected_line:
536 clrf timeout_counter2 ; Reset timeout 550 clrf timeout_counter2 ; reset timeout
537 WIN_BOX_BLACK .34,.221,MENU_LEFT-8,MENU_LEFT-2 ; Clear left column 551 WIN_BOX_BLACK .34,.221,MENU_LEFT-8,MENU_LEFT-2 ; clear left column
538 call TFT_standard_color 552 call TFT_standard_color
539 WIN_SMALL MENU_LEFT-8, 0 ; Arrow symbol only in small font 553 WIN_SMALL MENU_LEFT-8, 0 ; arrow symbol only in small font
540 movf start_item,W ; First line (scrolled) 554 movf start_item,W ; first line (scrolled)
541 subwf selected_item,W ; selected - first 555 subwf selected_item,W ; selected - first
542 mullw MENU_HEIGHT ; 30 pixel by line 556 mullw MENU_HEIGHT ; 30 pixel by line
543 movf PRODL,W ; result 557 movf PRODL,W ; result
544 addwf menu_center,W ; added to first line 558 addwf menu_center,W ; added to first line
545 movwf win_top ; and stored to pos. 559 movwf win_top ; and stored to pos.