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