Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/divemode_menu.asm @ 109:6e635bf5b7a7
fixed double-effect of ENTER button in divemode
author | heinrichsweikamp |
---|---|
date | Tue, 21 Dec 2010 09:39:23 +0100 |
parents | a2b9eca1f396 |
children | ed7826c740a0 |
rev | line source |
---|---|
0 | 1 ; OSTC - diving computer code |
2 ; Copyright (C) 2008 HeinrichsWeikamp GbR | |
3 | |
4 ; This program is free software: you can redistribute it and/or modify | |
5 ; it under the terms of the GNU General Public License as published by | |
6 ; the Free Software Foundation, either version 3 of the License, or | |
7 ; (at your option) any later version. | |
8 | |
9 ; This program is distributed in the hope that it will be useful, | |
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 ; GNU General Public License for more details. | |
13 | |
14 ; You should have received a copy of the GNU General Public License | |
15 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | |
17 | |
18 ; Underwater Menu (Set Gas, Decoplan, etc.) | |
19 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com | |
20 ; written: 11/11/05 | |
21 ; last updated: 090305 | |
22 ; known bugs: | |
23 ; ToDo: | |
24 | |
25 | |
26 test_switches_divemode: | |
27 ; checks switches in divemode | |
28 btfsc switch_left | |
29 bra test_switches_divemode2 | |
30 | |
31 btfss switch_right | |
32 return | |
33 | |
34 bcf switch_left ; Left button pressed! | |
35 bcf switch_right | |
36 | |
37 bcf select_bailoutgas ; Clear Flag for Bailout list | |
38 bsf premenu ; Set Flag for premenu | |
39 bcf menubit | |
40 clrf timeout_counter3 ; timeout_divemenu | |
41 | |
42 btfsc FLAG_apnoe_mode ; In Apnoe mode? | |
43 bra test_switches_divemode1 ; Yes! | |
44 | |
45 test_switches_divemode0: | |
46 WIN_INVERT .1 | |
47 DISPLAYTEXT .4 ;Menu? | |
48 WIN_INVERT .0 | |
49 return | |
50 | |
51 test_switches_divemode1: | |
52 DISPLAYTEXT .141 ;Quit? | |
53 return | |
54 | |
55 test_switches_divemode2: | |
56 bcf switch_left ; Also reactivate left button if there was a right press without prior left press | |
57 bcf switch_right ; enable right button again | |
58 | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
59 btfsc premenu |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
60 bra test_switches_divemode2_2 |
109
6e635bf5b7a7
fixed double-effect of ENTER button in divemode
heinrichsweikamp
parents:
107
diff
changeset
|
61 btfsc menubit |
6e635bf5b7a7
fixed double-effect of ENTER button in divemode
heinrichsweikamp
parents:
107
diff
changeset
|
62 bra test_switches_divemode2_2 ; Not in Premenu or Menu... |
0 | 63 |
107 | 64 bsf toggle_customview ; Toggle customview (Cleared in customview.asm) |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
65 btfsc standalone_simulator ; Standalone Simualtor active? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
66 bra divemode_menu_simulator ; Yes, Show simulator menu! |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
67 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
68 test_switches_divemode2_2: |
0 | 69 btfss FLAG_apnoe_mode ; In Apnoe mode? |
70 bra test_switches_divemode2a; No! | |
71 | |
72 ; Yes, so quit Apnoe mode at once... | |
73 bcf divemode ; Clear Divemode flag... | |
74 bcf premenu ; clear premenu flag | |
75 return | |
76 | |
77 test_switches_divemode2a: | |
78 bsf menubit ; Enter Divemode-Menu! | |
79 bcf premenu ; clear premenu flag | |
80 call PLED_clear_divemode_menu ; Clear dive mode menu area | |
81 call PLED_divemode_menu_mask_first ; Write Divemode menu1 mask | |
82 bcf display_set_simulator ; Clear Simulator-Menu flag | |
83 movlw d'1' | |
84 movwf menupos ; reset cursor in divemode menu | |
85 call PLED_divemenu_cursor ; show cursor | |
86 bcf switch_right | |
87 bcf switch_left ; Left button pressed! | |
88 return | |
89 | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
90 reset_stopwatch: |
71
6beb680a6130
1.72beta - color-coded gaslist, small fix with stopwatch
heinrichsweikamp
parents:
68
diff
changeset
|
91 btfsc lock_stopwatch_reset ; Reset locked? |
6beb680a6130
1.72beta - color-coded gaslist, small fix with stopwatch
heinrichsweikamp
parents:
68
diff
changeset
|
92 return ; Yes, do not reset (now)... |
0 | 93 ; Maker Set, also reset average Depth.... |
94 clrf average_depth_hold+0 | |
95 clrf average_depth_hold+1 | |
96 clrf average_depth_hold+2 | |
97 clrf average_depth_hold+3 ; Clear average depth register | |
98 movlw d'2' | |
99 movwf average_divesecs+0 | |
100 clrf average_divesecs+1 | |
101 call calc_average_depth | |
102 return | |
103 | |
104 test_switches_divemode_menu: | |
105 btfsc switch_left | |
106 bra test_switches_divemode_menu3 | |
107 btfss switch_right | |
108 return | |
109 | |
110 btfsc display_see_deco ; Is the Decoplan displayed? | |
111 bra divemenu_see_decoplan2 ; Yes, exit menu on left button press | |
112 | |
113 bcf switch_right ; Left button pressed | |
114 clrf timeout_counter3 ; timout_divemenu! | |
115 incf menupos,F | |
116 | |
117 ; Following routine configures the number of menu entries for the different modes | |
118 movlw d'6' ; number of available gases+1, ; number of menu options+1 | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
119 btfsc display_set_gas ; Are we in the "Gaslist" menu? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
120 movlw d'7' ; Yes, Number of entries for this menu+1 = 7 |
0 | 121 btfsc display_set_setpoint ; In SetPoint Menu? |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
122 movlw d'5' ; Number of entries for this menu+1 = 5 |
0 | 123 cpfseq menupos ; =limit? |
124 bra test_switches_divemode_menu1; No! | |
125 movlw d'1' ; Yes, reset to position 1! | |
126 movwf menupos | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
127 |
0 | 128 test_switches_divemode_menu1: |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
129 ; Finally, check if menuposition 3 should be skipped (No customview with function displayed) |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
130 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
131 btfsc display_set_gas ; Are we in the "Gaslist" or "SetPoint" menu? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
132 bra test_switches_divemode_menu1a ; Skip test for sub menus |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
133 btfsc display_set_xgas ; Are we in the "Gaslist" or "SetPoint" menu? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
134 bra test_switches_divemode_menu1a ; Skip test for sub menus |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
135 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
136 movlw d'3' |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
137 cpfseq menupos ; At position 3? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
138 bra test_switches_divemode_menu1a; No |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
139 btfss menu3_active ; Menu position 3 has functionality? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
140 incf menupos,F ; No, +1, skip to menuos=4 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
141 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
142 test_switches_divemode_menu1a: |
0 | 143 call PLED_divemenu_cursor ; update cursor |
144 return | |
145 | |
146 test_switches_divemode_menu3: | |
147 bcf switch_left | |
148 bcf switch_right | |
149 bsf menubit ; Enter Divemode-Menu! | |
150 bcf premenu ; clear premenu flag | |
151 clrf timeout_counter3 | |
152 | |
153 btfsc display_set_gas ; Are we in the "Gaslist" or "SetPoint" menu? | |
154 bra divemenu_set_gas2 ; Yes, so set gas and exit menu | |
155 | |
156 btfsc display_see_deco ; Is the Decoplan displayed? | |
157 bra divemenu_see_decoplan2 ; Yes, exit menu on right button press | |
158 | |
159 btfsc display_set_xgas ; Are we in the "Set Gas" menu? | |
160 bra divemenu_set_xgas2 ; Yes, so configure gas or set menu and exit menu | |
161 | |
162 btfsc display_set_simulator ; Are we in the Divemode Simulator menu? | |
163 goto divemode_menu_simulator2 ; Yes, so adjust depth or set and exit | |
164 | |
165 ; Options for Menu 1 | |
166 dcfsnz menupos,F | |
73
2227459e8ef2
Exchanged Decoplan and Gaslist in dive mode menu
heinrichsweikamp
parents:
71
diff
changeset
|
167 bra divemenu_set_gas ; Set gas sub-menu |
2227459e8ef2
Exchanged Decoplan and Gaslist in dive mode menu
heinrichsweikamp
parents:
71
diff
changeset
|
168 dcfsnz menupos,F |
0 | 169 bra divemenu_see_decoplan ; display the full decoplan |
170 dcfsnz menupos,F | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
171 bra divemode_menu3 ; Customview-function |
0 | 172 dcfsnz menupos,F |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
173 bra divemode_toggle_brightness ; Toggle OLED-Brightness |
0 | 174 dcfsnz menupos,F |
175 bra timeout_divemenu2 ; Quit divemode menu | |
176 return | |
177 | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
178 divemode_menu3: |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
179 movff menupos3,temp1 ; copy |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
180 dcfsnz temp1,F |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
181 bra toggle_stopwatch ; Toggle Stopwatch/Average register |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
182 dcfsnz temp1,F |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
183 bra set_marker ; Set Marker |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
184 dcfsnz temp1,F |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
185 bra divemode_menu3_nothing ; clock... |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
186 dcfsnz temp1,F |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
187 bra divemode_menu3_nothing ; leading tissue... |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
188 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
189 divemode_menu3_nothing: |
0 | 190 bra timeout_divemenu2 ; Quit divemode menu |
191 return | |
192 | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
193 set_marker: |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
194 movlw d'6' ; Type of Alarm (Manual Marker) |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
195 movwf AlarmType ; Copy to Alarm Register |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
196 bsf event_occured ; Set Event Flag |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
197 bra timeout_divemenu2 ; quit menu! |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
198 |
0 | 199 toggle_stopwatch: |
200 btg stopwatch_active ; Toggle Flag | |
201 | |
202 btfss stopwatch_active ; Show Stopwatch? | |
203 bra toggle_stopwatch2 ; No, remove outputs | |
204 | |
205 clrf average_depth_hold+0 | |
206 clrf average_depth_hold+1 | |
207 clrf average_depth_hold+2 | |
208 clrf average_depth_hold+3 ; Clear average depth register | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
209 movlw d'3' |
0 | 210 movwf average_divesecs+0 |
211 clrf average_divesecs+1 | |
212 call calc_average_depth | |
213 bra timeout_divemenu2 ; quit menu! | |
214 | |
215 toggle_stopwatch2: | |
87 | 216 call PLED_clear_customview_divemode ; Remove Stopwatch Outputs |
0 | 217 bra timeout_divemenu2 ; quit menu! |
218 | |
219 divemode_toggle_brightness: | |
220 read_int_eeprom d'90' ; Brightness offset? (Dim>0, Normal = 0) | |
221 tstfsz EEDATA ; Was dimmed? | |
222 bra divemode_toggle_brightness1 ; Yes... | |
223 | |
224 call PLED_brightness_low | |
225 movlw d'1' | |
226 movwf EEDATA ; Copy to EEDATA | |
227 write_int_eeprom d'90' ; Brightness offset? (Dim=1, Normal = 0) | |
228 bra divemode_toggle_brightness3 | |
229 | |
230 divemode_toggle_brightness1: | |
231 call PLED_brightness_full | |
232 movlw d'0' | |
233 movwf EEDATA ; Copy to EEDATA | |
234 write_int_eeprom d'90' ; Brightness offset? (Dim=1, Normal = 0) | |
235 | |
236 divemode_toggle_brightness3: | |
237 ; Now, redraw all outputs (All modes) | |
238 call PLED_active_gas_divemode ; Display gas, if required | |
239 call PLED_temp_divemode ; Displays temperature | |
240 call PLED_depth ; Displays new depth... | |
241 call PLED_max_pressure ; ...and max. depth | |
242 | |
243 btfsc FLAG_apnoe_mode ; Ignore in Apnoe mode | |
244 bra timeout_divemenu2 ; quit menu! | |
245 btfsc gauge_mode ; Ignore in Gauge mode | |
246 bra timeout_divemenu2 ; quit menu! | |
247 | |
248 ; Redraw Outputs in Deco modes | |
249 btfsc dekostop_active | |
250 call PLED_display_deko_mask ; clear nostop time, display decodata | |
251 btfss dekostop_active | |
252 call PLED_display_ndl_mask ; Clear deco data, display nostop time | |
253 bra timeout_divemenu2 ; quit menu! | |
254 | |
255 divemode_set_xgas: ; Set the extra gas... | |
256 bsf display_set_xgas ; Set Flag | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
257 bcf display_set_gas ; Clear Flag |
0 | 258 call PLED_clear_divemode_menu ; Clear Menu |
259 | |
260 movff char_I_O2_ratio, EEDATA ; Reset Gas6 to current gas | |
261 write_int_eeprom d'24' | |
262 movff char_I_He_ratio, EEDATA | |
263 write_int_eeprom d'25' | |
264 | |
265 call PLED_divemode_set_xgas ; Show mask | |
266 | |
267 movlw d'1' | |
268 movwf menupos ; reset cursor | |
269 call PLED_divemenu_cursor ; update cursor | |
270 return | |
271 | |
272 divemode_menu_simulator: | |
273 bsf menubit ; Enter Divemode-Menu! | |
274 bcf premenu ; clear premenu flag | |
275 bcf switch_right | |
276 bcf switch_left ; Left button pressed! | |
104 | 277 bsf display_set_simulator ; Set Flag |
278 bsf menu3_active ; So "+1" is accessible at all times | |
0 | 279 call PLED_clear_divemode_menu ; Clear Menu |
280 call PLED_divemode_simulator_mask; Show mask | |
281 movlw d'1' | |
282 movwf menupos ; reset cursor | |
283 call PLED_divemenu_cursor ; update cursor | |
284 return | |
285 | |
286 divemode_menu_simulator2: | |
287 dcfsnz menupos,F | |
288 bra timeout_divemenu2 ; quit underwater menu! | |
289 dcfsnz menupos,F | |
290 bra divemode_menu_simulator_p1 ; Adjust +1m | |
291 dcfsnz menupos,F | |
292 bra divemode_menu_simulator_m1 ; Adjust -1m | |
293 dcfsnz menupos,F | |
294 bra divemode_menu_simulator_p10 ; Adjust +10m | |
295 dcfsnz menupos,F | |
296 bra divemode_menu_simulator_m10 ; Adjust -10m | |
297 bra timeout_divemenu2 ; quit underwater menu! | |
298 | |
299 divemode_menu_simulator_common: | |
300 call PLED_divemode_simulator_mask ; Redraw Simualtor mask | |
301 | |
302 ; Check limits (140m and 0m) | |
303 movlw LOW d'15000' | |
304 movwf sub_a+0 | |
305 movlw HIGH d'15000' | |
306 movwf sub_a+1 | |
307 movff sim_pressure+0,sub_b+0 | |
308 movff sim_pressure+1,sub_b+1 | |
309 call sub16 ; sub_c = sub_a - sub_b | |
310 btfss neg_flag | |
311 bra divemode_menu_simulator_common2 | |
312 ; Too deep, limit to 140m | |
313 movlw LOW d'15000' | |
314 movwf sim_pressure+0 | |
315 movlw HIGH d'15000' | |
316 movwf sim_pressure+1 | |
317 return | |
318 | |
319 divemode_menu_simulator_common2: | |
320 movlw LOW d'1000' | |
321 movwf sub_a+0 | |
322 movlw HIGH d'1000' | |
323 movwf sub_a+1 | |
324 movff sim_pressure+0,sub_b+0 | |
325 movff sim_pressure+1,sub_b+1 | |
326 call sub16 ; sub_c = sub_a - sub_b | |
327 btfsc neg_flag | |
328 return | |
329 ; Too shallow, limit to 1m | |
330 movlw LOW d'1000' | |
331 movwf sim_pressure+0 | |
332 movlw HIGH d'1000' | |
333 movwf sim_pressure+1 | |
334 return | |
335 | |
336 divemode_menu_simulator_m10: | |
337 movlw LOW d'1000' | |
338 subwf sim_pressure+0,F | |
339 movlw HIGH d'1000' | |
340 subwfb sim_pressure+1,F | |
341 movlw d'5' | |
342 movwf menupos ; reset cursor | |
343 bra divemode_menu_simulator_common | |
344 | |
345 divemode_menu_simulator_p10: | |
346 movlw LOW d'1000' | |
347 addwf sim_pressure+0,F | |
348 movlw HIGH d'1000' | |
349 addwfc sim_pressure+1,F | |
350 movlw d'4' | |
351 movwf menupos ; reset cursor | |
352 bra divemode_menu_simulator_common | |
353 | |
354 divemode_menu_simulator_p1: | |
355 movlw d'100' | |
356 addwf sim_pressure+0,F | |
357 movlw d'0' | |
358 addwfc sim_pressure+1,F | |
359 movlw d'2' | |
360 movwf menupos ; reset cursor | |
361 bra divemode_menu_simulator_common | |
362 | |
363 divemode_menu_simulator_m1: | |
364 movlw d'100' | |
365 subwf sim_pressure+0,F | |
366 movlw d'0' | |
367 subwfb sim_pressure+1,F | |
368 movlw d'3' | |
369 movwf menupos ; reset cursor | |
370 bra divemode_menu_simulator_common | |
371 | |
372 divemenu_see_decoplan: | |
373 bsf display_see_deco ; set flag | |
64 | 374 call PLED_clear_divemode_menu ; Clear Menu |
0 | 375 |
376 read_int_eeprom d'34' | |
377 movlw d'3' | |
378 cpfsgt EEDATA ; in multi-gf mode? Z16 GF OC=4 and Z16 GF CC=5 | |
68 | 379 bra divemenu_see_decoplan1 ; No, standard ZH-L16 |
0 | 380 |
381 bsf multi_gf_display ; Yes, display the multi-gf table screen | |
64 | 382 bcf last_ceiling_gf_shown ; Clear flag |
0 | 383 |
64 | 384 call PLED_decoplan_gf_page1 ; Display the new screen |
0 | 385 return |
386 | |
387 divemenu_see_decoplan1: | |
388 | |
389 movff char_O_deco_status,deco_status ; | |
390 tstfsz deco_status ; deco_status=0 if decompression calculation done | |
391 return ; calculation not yet finished! | |
392 | |
393 call PLED_decoplan ; display the Decoplan | |
394 return | |
395 | |
396 divemenu_see_decoplan2: | |
64 | 397 btfsc multi_gf_display ; Next Page in Multi-GF Screen? |
398 bra divemenu_see_decoplan2_nextgf ; Yes! | |
399 ; No, remove outputs! | |
400 divemenu_see_decoplan2_0: | |
0 | 401 bcf display_see_deco ; clear flag |
402 bra timeout_divemenu2 ; quit menu! | |
403 | |
64 | 404 divemenu_see_decoplan2_nextgf: |
405 incf temp8,F | |
406 btfsc last_ceiling_gf_shown ; last ceiling shown? | |
407 bra divemenu_see_decoplan2_0 ; All done, clear and return | |
408 | |
409 clrf timeout_counter3 ; Clear timeout Divemode menu | |
68 | 410 bra timeout_divemenu3x ; Display next page |
64 | 411 |
0 | 412 divemenu_set_xgas2: |
413 dcfsnz menupos,F | |
414 bra divemenu_set_xgas2_exit ; Use the gas6 configured and exit | |
415 dcfsnz menupos,F | |
416 bra divemenu_set_xgas2_o2plus ; Adjust O2+ | |
417 dcfsnz menupos,F | |
418 bra divemenu_set_xgas2_o2minus ; Adjust O2- | |
419 dcfsnz menupos,F | |
420 bra divemenu_set_xgas2_heplus ; Adjust He+ | |
421 dcfsnz menupos,F | |
422 bra divemenu_set_xgas2_heminus ; Adjust He- | |
423 return | |
424 | |
425 divemenu_set_xgas2_heminus: | |
426 read_int_eeprom d'25' ; He value | |
427 movff EEDATA,lo | |
428 decf lo,F ; decrease He | |
429 movlw d'255' | |
430 cpfseq lo | |
431 bra divemenu_set_xgas2_heminus2 | |
432 incf lo,F ; limit to min=0 | |
433 divemenu_set_xgas2_heminus2: | |
434 movff lo, EEDATA | |
435 write_int_eeprom d'25' ; He Value | |
436 | |
437 call PLED_divemode_set_xgas ; Redraw menu | |
438 movlw d'5' | |
439 movwf menupos ; reset cursor | |
440 return | |
441 | |
442 divemenu_set_xgas2_heplus: | |
443 read_int_eeprom d'25' ; He value | |
444 movff EEDATA,lo | |
445 incf lo,F ; increase He | |
446 movlw d'101' | |
447 cpfseq lo | |
448 bra divemenu_set_xgas2_heplus2 | |
449 movlw d'4' ; O2 Limit | |
450 movwf lo | |
451 divemenu_set_xgas2_heplus2: ; test if O2+He>100... | |
452 read_int_eeprom d'24' ; O2 value | |
453 movf EEDATA,W | |
454 addwf lo,W ; add He value | |
455 movwf hi ; store in temp | |
456 movlw d'101' | |
457 cpfseq hi ; O2 and He > 100? | |
458 bra divemenu_set_xgas2_heplus3 ; No! | |
459 decf lo,F ; reduce He again = unchanged after operation | |
460 divemenu_set_xgas2_heplus3: ; save current value | |
461 movff lo, EEDATA | |
462 write_int_eeprom d'25' ; He Value | |
463 | |
464 call PLED_divemode_set_xgas ; Redraw menu | |
465 movlw d'4' | |
466 movwf menupos ; reset cursor | |
467 return | |
468 | |
469 divemenu_set_xgas2_o2minus: | |
470 read_int_eeprom d'24' ; O2 value | |
471 movff EEDATA,lo | |
472 decf lo,F ; decrease O2 | |
473 movlw d'3' ; Limit-1 | |
474 cpfseq lo | |
475 bra divemenu_set_xgas2_o2minus2 | |
476 incf lo,F ; limit to min=9 | |
477 divemenu_set_xgas2_o2minus2: | |
478 movff lo, EEDATA | |
479 write_int_eeprom d'24' ; O2 Value | |
480 | |
481 call PLED_divemode_set_xgas ; Redraw menu | |
482 movlw d'3' | |
483 movwf menupos ; reset cursor | |
484 return | |
485 | |
486 divemenu_set_xgas2_o2plus: | |
487 read_int_eeprom d'24' ; O2 value | |
488 movff EEDATA,lo | |
489 incf lo,F ; increase O2 | |
490 movlw d'101' | |
491 cpfseq lo | |
492 bra divemenu_set_xgas2_o2plus2 | |
493 movlw d'5' ; O2 limit | |
494 movwf lo | |
495 divemenu_set_xgas2_o2plus2: ; test if O2+He>100... | |
496 read_int_eeprom d'25' ; He value | |
497 movf EEDATA,W | |
498 addwf lo,W ; add O2 value | |
499 movwf hi ; store in temp | |
500 movlw d'101' | |
501 cpfseq hi ; O2 and He > 100? | |
502 bra divemenu_set_xgas2_o2plus3 ; No! | |
503 decf lo,F ; reduce O2 again = unchanged after operation | |
504 divemenu_set_xgas2_o2plus3: ; save current value | |
505 movff lo, EEDATA | |
506 write_int_eeprom d'24' ; O2 Value | |
507 | |
508 call PLED_divemode_set_xgas ; Redraw menu | |
509 movlw d'2' | |
510 movwf menupos ; reset cursor | |
511 return | |
512 | |
513 divemenu_set_xgas2_exit: | |
514 read_int_eeprom d'25' ; Read He ratio | |
515 movff EEDATA,char_I_He_ratio ; And copy into hold register | |
516 | |
517 read_int_eeprom d'24' ; Read O2 ratio | |
518 movff EEDATA, char_I_O2_ratio ; O2 ratio | |
519 movff char_I_He_ratio, wait_temp ; copy into bank1 register | |
520 bsf STATUS,C ; | |
521 movlw d'100' ; 100% | |
522 subfwb wait_temp,W ; minus He | |
523 subfwb EEDATA,F ; minus O2 | |
524 movff EEDATA, char_I_N2_ratio ; = N2! | |
525 bsf manual_gas_changed ; set event flag | |
526 bsf event_occured ; set global event flag | |
99 | 527 bsf is_bailout ;=1: CC mode, but bailout active! |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
528 clrf lo ; clear Setpoint, PLED_const_ppO2_value now displayes "Bail" |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
529 movff lo,char_I_const_ppO2 |
0 | 530 bra timeout_divemenu2 ; quit underwater menu! |
531 | |
532 divemenu_set_gas: | |
533 btfsc FLAG_const_ppO2_mode ; in ppO2 mode? | |
17 | 534 bra divemenu_set_setpoint ; Yes, display SetPoint list |
0 | 535 |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
536 divemenu_set_gas_2: |
0 | 537 bsf display_set_gas ; set flag |
538 call PLED_clear_divemode_menu ; Clear Menu | |
539 call PLED_gas_list ; Display all 5 gases | |
540 movlw d'1' | |
541 movwf menupos ; reset cursor | |
542 call PLED_divemenu_cursor ; update cursor | |
543 return | |
544 | |
545 divemenu_set_setpoint: | |
546 bsf display_set_setpoint ; set flag | |
547 bsf display_set_gas ; set flag | |
548 | |
549 call PLED_clear_divemode_menu ; Clear Menu | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
550 call PLED_splist_start ; Display SetPoints |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
551 DISPLAYTEXT d'137' ; Bailout (as a sub-menu) |
0 | 552 movlw d'1' |
553 movwf menupos ; reset cursor | |
554 call PLED_divemenu_cursor ; update cursor | |
555 return | |
556 | |
557 | |
558 divemenu_set_gas2: | |
559 btfsc select_bailoutgas ; Are we in the Bailout list? | |
560 bra divemenu_set_gas2a ; Yes, choose gas | |
561 | |
562 btfss FLAG_const_ppO2_mode ; are we in ppO2 mode? | |
563 bra divemenu_set_gas2a ; no, choose gas | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
564 ; Yes, so select SP 1-3 |
3 | 565 bcf is_bailout ;=1: CC mode, but bailout active! |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
566 call PLED_show_ppO2_clear ; Clear ppO2 value |
3 | 567 |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
568 divemenu_set_gas1: |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
569 movlw d'4' |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
570 cpfseq menupos ; At the "Bailout" position? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
571 bra divemenu_set_gas1b ; No, select SetPoint 1-3 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
572 bsf select_bailoutgas ; Set Flag |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
573 bcf display_set_setpoint ; Clear Flag |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
574 bra divemenu_set_gas_2 ; Configure the extra gas / Select Bailout |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
575 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
576 divemenu_set_gas1b: |
0 | 577 movlw d'35' ; offset in memory |
578 addwf menupos,W ; add SP number 0-2 | |
579 movwf EEADR | |
580 call read_eeprom ; Read SetPoint | |
581 movff EEDATA, char_I_const_ppO2 ; Use SetPoint | |
4 | 582 movff EEDATA, ppO2_setpoint_store ; Store also in this byte... |
0 | 583 |
584 divemenu_set_gas1a: | |
585 bcf display_set_setpoint ; Clear Display Flag | |
586 bsf stored_gas_changed ; set event flag | |
587 bsf event_occured ; set global event flag | |
588 bra timeout_divemenu2 ; quit menu! | |
589 | |
590 divemenu_set_gas2a: | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
591 movlw d'6' |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
592 cpfseq menupos ; At the "Gas 6.." position? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
593 bra divemenu_set_gas2b ; No, select Gas1-5 (Stored in Menupos) |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
594 bra divemode_set_xgas ; Configure the extra gas |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
595 divemenu_set_gas2b: |
3 | 596 bsf is_bailout ;=1: CC mode, but bailout active! |
0 | 597 clrf lo ; clear Setpoint, PLED_const_ppO2_value now displayes "Bail" |
598 movff lo,char_I_const_ppO2 | |
599 | |
600 bcf display_set_gas ; clear flag | |
601 movff menupos,active_gas ; copy into active gas register | |
602 decf menupos,W ; # of selected gas (0-4) | |
603 mullw d'4' ; times 4... | |
604 movf PRODL,W ; | |
605 addlw d'7' ; +7 = address for He ratio | |
606 movwf EEADR | |
607 call read_eeprom ; Read He ratio | |
608 movff EEDATA,char_I_He_ratio ; And copy into hold register | |
609 | |
610 decf menupos,W ; # of selected gas (0-4) | |
611 mullw d'4' ; times 4... | |
612 movf PRODL,W ; | |
613 addlw d'6' ; +6 = address for O2 ratio | |
614 movwf EEADR | |
615 call read_eeprom ; Read O2 ratio | |
616 movff EEDATA, char_I_O2_ratio ; O2 ratio | |
617 movff char_I_He_ratio, wait_temp ; copy into bank1 register | |
618 bsf STATUS,C ; | |
619 movlw d'100' ; 100% | |
620 subfwb wait_temp,W ; minus He | |
621 subfwb EEDATA,F ; minus O2 | |
622 movff EEDATA, char_I_N2_ratio ; = N2! | |
623 bsf stored_gas_changed ; set event flag | |
624 bsf event_occured ; set global event flag | |
625 bra timeout_divemenu2 ; quit menu! | |
626 | |
627 timeout_divemenu: | |
628 btfss menubit ; is the Dive mode menu displayed? | |
629 return ; No | |
630 | |
631 | |
632 btfsc display_set_simulator ; Is the Simulator Mask active? | |
633 bra timeout_divemenu6 ; Yes, update Simulator mask | |
634 | |
635 btfss display_see_deco ; Is the decoplan active? | |
636 bra timeout_divemenu1 ; No, skip updating the decoplan | |
637 | |
638 btfsc multi_gf_display ; display the multi-gf table screen? | |
639 bra timeout_divemenu3 ; Yes... | |
640 | |
641 movff char_O_deco_status,deco_status ; | |
66 | 642 tstfsz deco_status ; deco_status=0 if decompression calculation done |
643 bra timeout_divemenu1 ; No, skip updating the decoplan | |
0 | 644 |
66 | 645 call PLED_decoplan ; update the Decoplan |
0 | 646 |
647 timeout_divemenu1: | |
648 incf timeout_counter3,F ; increase timeout_counter3 | |
649 GETCUSTOM8 d'10' ; loads timeout_divemenu into WREG | |
650 cpfsgt timeout_counter3 ; ... longer then timeout_divemenu | |
651 return ; No! | |
652 timeout_divemenu2: ; quit divemode menu | |
66 | 653 btfss multi_gf_display ; Was the Multi-GF Table displayed? |
654 bra timeout_divemenu2a ; No, normal OLED rebuild | |
0 | 655 |
656 ; Restore some outputs | |
66 | 657 clrf temp8 ; Page 0-1 of deco list |
0 | 658 btfsc dekostop_active |
66 | 659 call PLED_display_deko_mask ; clear nostop time, display decodata |
0 | 660 btfss dekostop_active |
66 | 661 call PLED_display_ndl_mask ; Clear deco data, display nostop time |
0 | 662 |
663 timeout_divemenu2a: | |
66 | 664 bcf multi_gf_display ; Do not display the multi-gf table screen |
0 | 665 bcf menubit |
666 bcf premenu ; Yes, clear flags and menu, display dive time and mask again | |
66 | 667 call PLED_active_gas_divemode; Display gas, if required |
0 | 668 call PLED_clear_divemode_menu; Clear dive mode menu |
669 call PLED_divemode_mask ; Display mask | |
670 call PLED_divemins ; Display (new) divetime! | |
87 | 671 btfss dekostop_active |
672 call PLED_display_ndl_mask | |
673 btfsc dekostop_active | |
674 call PLED_display_deko_mask | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
675 call customview_mask ; Redraw current customview mask |
0 | 676 clrf timeout_counter3 ; Also clear timeout |
677 bcf display_see_deco ; clear all display flags | |
678 bcf display_set_gas | |
679 bcf display_set_xgas | |
680 bcf display_set_setpoint | |
681 bcf display_set_simulator | |
682 bcf switch_left ; and debounce switches | |
683 bcf switch_right | |
71
6beb680a6130
1.72beta - color-coded gaslist, small fix with stopwatch
heinrichsweikamp
parents:
68
diff
changeset
|
684 bsf lock_stopwatch_reset ; Lock the stopwatch reset for at least one second (Cleared in "calc_average_depth:") |
0 | 685 return |
686 | |
687 timeout_divemenu3: | |
64 | 688 movff char_O_deco_status,deco_status ; |
689 tstfsz deco_status ; deco_status=0 if decompression calculation done | |
0 | 690 bra timeout_divemenu1 ; No, skip updating the decoplan |
68 | 691 timeout_divemenu3x: |
64 | 692 call PLED_decoplan_gf_page_current ; Re-Draw Current page of GF Decoplan |
0 | 693 bra timeout_divemenu1 ; Check timeout |
694 | |
695 timeout_divemenu6: | |
696 ; Update Simulator Mask | |
697 call PLED_divemode_simulator_mask; Show mask | |
698 call PLED_divemenu_cursor ; update cursor | |
699 bra timeout_divemenu1 ; Check timeout |