annotate src/menu_processor.asm @ 584:d63dec562d50

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