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