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
|
|
89 call set_LEDg ; LEDg on
|
|
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
|
|
405
|
|
406 read_int_eeprom d'34'
|
|
407 movlw d'3'
|
|
408 cpfsgt EEDATA ; in multi-gf mode? Z16 GF OC=4 and Z16 GF CC=5
|
|
409 bra divemenu_see_decoplan1 ; No!
|
|
410
|
|
411 bra divemenu_see_decoplan1 ; Show normal plan! ToDo: MultiGF Plan....
|
|
412
|
|
413 bsf multi_gf_display ; Yes, display the multi-gf table screen
|
|
414 call PLED_ClearScreen ; clean up OLED
|
|
415 call PLED_MultiGF_deco_mask
|
|
416
|
|
417 movff char_O_deco_status,deco_status ;
|
|
418 tstfsz deco_status ; deco_status=0 if decompression calculation done
|
|
419 return ; calculation not yet finished!
|
|
420
|
|
421 call PLED_MultiGF_deco_all ; Display the new screen
|
|
422 return
|
|
423
|
|
424 divemenu_see_decoplan1:
|
|
425 call PLED_clear_divemode_menu ; Clear Menu
|
|
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:
|
|
435 bcf display_see_deco ; clear flag
|
|
436 bra timeout_divemenu2 ; quit menu!
|
|
437
|
|
438 divemenu_set_xgas2:
|
|
439 dcfsnz menupos,F
|
|
440 bra divemenu_set_xgas2_exit ; Use the gas6 configured and exit
|
|
441 dcfsnz menupos,F
|
|
442 bra divemenu_set_xgas2_o2plus ; Adjust O2+
|
|
443 dcfsnz menupos,F
|
|
444 bra divemenu_set_xgas2_o2minus ; Adjust O2-
|
|
445 dcfsnz menupos,F
|
|
446 bra divemenu_set_xgas2_heplus ; Adjust He+
|
|
447 dcfsnz menupos,F
|
|
448 bra divemenu_set_xgas2_heminus ; Adjust He-
|
|
449 return
|
|
450
|
|
451 divemenu_set_xgas2_heminus:
|
|
452 read_int_eeprom d'25' ; He value
|
|
453 movff EEDATA,lo
|
|
454 decf lo,F ; decrease He
|
|
455 movlw d'255'
|
|
456 cpfseq lo
|
|
457 bra divemenu_set_xgas2_heminus2
|
|
458 incf lo,F ; limit to min=0
|
|
459 divemenu_set_xgas2_heminus2:
|
|
460 movff lo, EEDATA
|
|
461 write_int_eeprom d'25' ; He Value
|
|
462
|
|
463 call PLED_divemode_set_xgas ; Redraw menu
|
|
464 movlw d'5'
|
|
465 movwf menupos ; reset cursor
|
|
466 return
|
|
467
|
|
468 divemenu_set_xgas2_heplus:
|
|
469 read_int_eeprom d'25' ; He value
|
|
470 movff EEDATA,lo
|
|
471 incf lo,F ; increase He
|
|
472 movlw d'101'
|
|
473 cpfseq lo
|
|
474 bra divemenu_set_xgas2_heplus2
|
|
475 movlw d'4' ; O2 Limit
|
|
476 movwf lo
|
|
477 divemenu_set_xgas2_heplus2: ; test if O2+He>100...
|
|
478 read_int_eeprom d'24' ; O2 value
|
|
479 movf EEDATA,W
|
|
480 addwf lo,W ; add He value
|
|
481 movwf hi ; store in temp
|
|
482 movlw d'101'
|
|
483 cpfseq hi ; O2 and He > 100?
|
|
484 bra divemenu_set_xgas2_heplus3 ; No!
|
|
485 decf lo,F ; reduce He again = unchanged after operation
|
|
486 divemenu_set_xgas2_heplus3: ; save current value
|
|
487 movff lo, EEDATA
|
|
488 write_int_eeprom d'25' ; He Value
|
|
489
|
|
490 call PLED_divemode_set_xgas ; Redraw menu
|
|
491 movlw d'4'
|
|
492 movwf menupos ; reset cursor
|
|
493 return
|
|
494
|
|
495 divemenu_set_xgas2_o2minus:
|
|
496 read_int_eeprom d'24' ; O2 value
|
|
497 movff EEDATA,lo
|
|
498 decf lo,F ; decrease O2
|
|
499 movlw d'3' ; Limit-1
|
|
500 cpfseq lo
|
|
501 bra divemenu_set_xgas2_o2minus2
|
|
502 incf lo,F ; limit to min=9
|
|
503 divemenu_set_xgas2_o2minus2:
|
|
504 movff lo, EEDATA
|
|
505 write_int_eeprom d'24' ; O2 Value
|
|
506
|
|
507 call PLED_divemode_set_xgas ; Redraw menu
|
|
508 movlw d'3'
|
|
509 movwf menupos ; reset cursor
|
|
510 return
|
|
511
|
|
512 divemenu_set_xgas2_o2plus:
|
|
513 read_int_eeprom d'24' ; O2 value
|
|
514 movff EEDATA,lo
|
|
515 incf lo,F ; increase O2
|
|
516 movlw d'101'
|
|
517 cpfseq lo
|
|
518 bra divemenu_set_xgas2_o2plus2
|
|
519 movlw d'5' ; O2 limit
|
|
520 movwf lo
|
|
521 divemenu_set_xgas2_o2plus2: ; test if O2+He>100...
|
|
522 read_int_eeprom d'25' ; He value
|
|
523 movf EEDATA,W
|
|
524 addwf lo,W ; add O2 value
|
|
525 movwf hi ; store in temp
|
|
526 movlw d'101'
|
|
527 cpfseq hi ; O2 and He > 100?
|
|
528 bra divemenu_set_xgas2_o2plus3 ; No!
|
|
529 decf lo,F ; reduce O2 again = unchanged after operation
|
|
530 divemenu_set_xgas2_o2plus3: ; save current value
|
|
531 movff lo, EEDATA
|
|
532 write_int_eeprom d'24' ; O2 Value
|
|
533
|
|
534 call PLED_divemode_set_xgas ; Redraw menu
|
|
535 movlw d'2'
|
|
536 movwf menupos ; reset cursor
|
|
537 return
|
|
538
|
|
539 divemenu_set_xgas2_exit:
|
|
540 read_int_eeprom d'25' ; Read He ratio
|
|
541 movff EEDATA,char_I_He_ratio ; And copy into hold register
|
|
542
|
|
543 read_int_eeprom d'24' ; Read O2 ratio
|
|
544 movff EEDATA, char_I_O2_ratio ; O2 ratio
|
|
545 movff char_I_He_ratio, wait_temp ; copy into bank1 register
|
|
546 bsf STATUS,C ;
|
|
547 movlw d'100' ; 100%
|
|
548 subfwb wait_temp,W ; minus He
|
|
549 subfwb EEDATA,F ; minus O2
|
|
550 movff EEDATA, char_I_N2_ratio ; = N2!
|
|
551 bsf manual_gas_changed ; set event flag
|
|
552 bsf event_occured ; set global event flag
|
|
553 bra timeout_divemenu2 ; quit underwater menu!
|
|
554
|
|
555 divemenu_set_bailout:
|
|
556 bsf display_set_gas ; set flag
|
|
557 call PLED_clear_divemode_menu ; Clear Menu
|
|
558
|
|
559 bcf FLAG_const_ppO2_mode ; Delete Flag to show all bailouts
|
|
560 bsf select_bailoutgas ; Set Flag for Bailout list
|
|
561 call PLED_gas_list ; Display all 5 gases
|
|
562 bsf FLAG_const_ppO2_mode ; Reset Flag
|
|
563
|
|
564 movlw d'1'
|
|
565 movwf menupos ; reset cursor
|
|
566 call PLED_divemenu_cursor ; update cursor
|
|
567 return
|
|
568
|
|
569 divemenu_set_gas:
|
|
570 btfsc FLAG_const_ppO2_mode ; in ppO2 mode?
|
17
|
571 bra divemenu_set_setpoint ; Yes, display SetPoint list
|
0
|
572
|
|
573 bsf display_set_gas ; set flag
|
|
574 call PLED_clear_divemode_menu ; Clear Menu
|
|
575 call PLED_gas_list ; Display all 5 gases
|
|
576 movlw d'1'
|
|
577 movwf menupos ; reset cursor
|
|
578 call PLED_divemenu_cursor ; update cursor
|
|
579 return
|
|
580
|
|
581 divemenu_set_setpoint:
|
|
582 bsf display_set_setpoint ; set flag
|
|
583 bsf display_set_gas ; set flag
|
|
584
|
|
585 call PLED_clear_divemode_menu ; Clear Menu
|
|
586 call PLED_splist_start ; Display SetPoints and Sensor results
|
|
587 movlw d'1'
|
|
588 movwf menupos ; reset cursor
|
|
589 call PLED_divemenu_cursor ; update cursor
|
|
590
|
|
591 return
|
|
592
|
|
593
|
|
594 divemenu_set_gas2:
|
|
595 btfsc select_bailoutgas ; Are we in the Bailout list?
|
|
596 bra divemenu_set_gas2a ; Yes, choose gas
|
|
597
|
|
598 btfss FLAG_const_ppO2_mode ; are we in ppO2 mode?
|
|
599 bra divemenu_set_gas2a ; no, choose gas
|
|
600 ; Yes, so select SP 1-3 or Sensor mode
|
|
601
|
3
|
602 bcf is_bailout ;=1: CC mode, but bailout active!
|
|
603 call PLED_show_ppO2_clear; Clear ppO2 value
|
|
604
|
0
|
605 divemenu_set_gas1:
|
|
606 movlw d'35' ; offset in memory
|
|
607 addwf menupos,W ; add SP number 0-2
|
|
608 movwf EEADR
|
|
609 call read_eeprom ; Read SetPoint
|
|
610 movff EEDATA, char_I_const_ppO2 ; Use SetPoint
|
4
|
611 movff EEDATA, ppO2_setpoint_store ; Store also in this byte...
|
0
|
612
|
|
613 divemenu_set_gas1a:
|
|
614 bcf display_set_setpoint ; Clear Display Flag
|
|
615 ; Now, Set correct Diluent (again)
|
17
|
616 ; read_int_eeprom d'33' ; Read byte (stored in EEDATA)
|
|
617 ; movff EEDATA,active_gas ; Read start gas (1-5)
|
|
618 ;
|
|
619 ; decf active_gas,W ; Gas 0-4
|
|
620 ; mullw d'4'
|
|
621 ; movf PRODL,W
|
|
622 ; addlw d'7' ; = address for He ratio
|
|
623 ; movwf EEADR
|
|
624 ; call read_eeprom ; Read He ratio
|
|
625 ; movff EEDATA,char_I_He_ratio ; And copy into hold register
|
|
626 ; decf active_gas,W ; Gas 0-4
|
|
627 ; mullw d'4'
|
|
628 ; movf PRODL,W
|
|
629 ; addlw d'6' ; = address for O2 ratio
|
|
630 ; movwf EEADR
|
|
631 ; call read_eeprom ; Read O2 ratio
|
|
632 ; movff EEDATA, char_I_O2_ratio ; O2 ratio
|
|
633 ; movff char_I_He_ratio, wait_temp ; copy into bank1 register
|
|
634 ; bsf STATUS,C ; Borrow bit
|
|
635 ; movlw d'100' ; 100%
|
|
636 ; subfwb wait_temp,W ; minus He
|
|
637 ; bsf STATUS,C ; Borrow bit
|
|
638 ; subfwb EEDATA,F ; minus O2
|
|
639 ; movff EEDATA, char_I_N2_ratio ; = N2!
|
|
640 ; call PLED_active_gas_clear ; Clear gas in case of AIR (Will be redrawn)
|
0
|
641
|
|
642 bsf stored_gas_changed ; set event flag
|
|
643 bsf event_occured ; set global event flag
|
|
644 bra timeout_divemenu2 ; quit menu!
|
|
645
|
|
646 divemenu_set_gas2a:
|
3
|
647 bsf is_bailout ;=1: CC mode, but bailout active!
|
0
|
648 clrf lo ; clear Setpoint, PLED_const_ppO2_value now displayes "Bail"
|
|
649 movff lo,char_I_const_ppO2
|
|
650
|
|
651 bcf display_set_gas ; clear flag
|
|
652 movff menupos,active_gas ; copy into active gas register
|
|
653 decf menupos,W ; # of selected gas (0-4)
|
|
654 mullw d'4' ; times 4...
|
|
655 movf PRODL,W ;
|
|
656 addlw d'7' ; +7 = address for He ratio
|
|
657 movwf EEADR
|
|
658 call read_eeprom ; Read He ratio
|
|
659 movff EEDATA,char_I_He_ratio ; And copy into hold register
|
|
660
|
|
661 decf menupos,W ; # of selected gas (0-4)
|
|
662 mullw d'4' ; times 4...
|
|
663 movf PRODL,W ;
|
|
664 addlw d'6' ; +6 = address for O2 ratio
|
|
665 movwf EEADR
|
|
666 call read_eeprom ; Read O2 ratio
|
|
667 movff EEDATA, char_I_O2_ratio ; O2 ratio
|
|
668 movff char_I_He_ratio, wait_temp ; copy into bank1 register
|
|
669 bsf STATUS,C ;
|
|
670 movlw d'100' ; 100%
|
|
671 subfwb wait_temp,W ; minus He
|
|
672 subfwb EEDATA,F ; minus O2
|
|
673 movff EEDATA, char_I_N2_ratio ; = N2!
|
|
674 bsf stored_gas_changed ; set event flag
|
|
675 bsf event_occured ; set global event flag
|
|
676 bra timeout_divemenu2 ; quit menu!
|
|
677
|
|
678 timeout_divemenu:
|
|
679 btfss menubit ; is the Dive mode menu displayed?
|
|
680 return ; No
|
|
681
|
|
682 btfsc display_see_l_tissue ; Are the leading tissue details displayed?
|
|
683 bra timeout_divemenu7 ; Yes, update them
|
|
684
|
|
685 btfsc display_set_simulator ; Is the Simulator Mask active?
|
|
686 bra timeout_divemenu6 ; Yes, update Simulator mask
|
|
687
|
|
688
|
|
689 btfss display_see_deco ; Is the decoplan active?
|
|
690 bra timeout_divemenu1 ; No, skip updating the decoplan
|
|
691
|
|
692 btfsc multi_gf_display ; display the multi-gf table screen?
|
|
693 bra timeout_divemenu3 ; Yes...
|
|
694
|
|
695 movff char_O_deco_status,deco_status ;
|
|
696 tstfsz deco_status ; deco_status=0 if decompression calculation done
|
|
697 bra timeout_divemenu1 ; No, skip updating the decoplan
|
|
698
|
|
699 call PLED_decoplan ; update the Decoplan
|
|
700
|
|
701 timeout_divemenu1:
|
|
702 incf timeout_counter3,F ; increase timeout_counter3
|
|
703 GETCUSTOM8 d'10' ; loads timeout_divemenu into WREG
|
|
704 cpfsgt timeout_counter3 ; ... longer then timeout_divemenu
|
|
705 return ; No!
|
|
706 timeout_divemenu2: ; quit divemode menu
|
|
707 btfss multi_gf_display ; Was the Multi-GF Table displayed?
|
|
708 bra timeout_divemenu2a ; No, normal OLED rebuild
|
|
709
|
|
710 ; Restore some outputs
|
|
711 bcf multi_gf_display ; Do not display the multi-gf table screen
|
|
712 call PLED_ClearScreen ; Yes, clean up OLED first
|
|
713 call PLED_temp_divemode ; Displays temperature
|
|
714 call PLED_max_pressure ; Max. Depth
|
|
715 btfsc dekostop_active
|
|
716 call PLED_display_deko_mask ; clear nostop time, display decodata
|
|
717 btfss dekostop_active
|
|
718 call PLED_display_ndl_mask ; Clear deco data, display nostop time
|
|
719
|
|
720 timeout_divemenu2a:
|
|
721 bcf multi_gf_display ; Do not display the multi-gf table screen
|
|
722 bcf menubit
|
|
723 bcf premenu ; Yes, clear flags and menu, display dive time and mask again
|
|
724 call PLED_active_gas_divemode ; Display gas, if required
|
|
725 call PLED_clear_divemode_menu; Clear dive mode menu
|
|
726 call PLED_divemode_mask ; Display mask
|
|
727 call PLED_divemins ; Display (new) divetime!
|
|
728 clrf timeout_counter3 ; Also clear timeout
|
|
729 bcf display_see_deco ; clear all display flags
|
|
730 bcf display_see_l_tissue
|
|
731 bcf display_set_gas
|
|
732 bcf display_set_graphs
|
|
733 bcf display_set_xgas
|
|
734 bcf display_set_setpoint
|
|
735 bcf display_set_simulator
|
|
736 bcf switch_left ; and debounce switches
|
|
737 bcf switch_right
|
|
738 return
|
|
739
|
|
740 timeout_divemenu3:
|
|
741 call PLED_MultiGF_deco_mask
|
|
742
|
|
743 movff char_O_deco_status,deco_status ;
|
|
744 tstfsz deco_status ; deco_status=0 if decompression calculation done
|
|
745 bra timeout_divemenu1 ; No, skip updating the decoplan
|
|
746
|
|
747 call PLED_MultiGF_deco_all ; Display the new screen
|
|
748 bra timeout_divemenu1 ; Check timeout
|
|
749
|
|
750 timeout_divemenu6:
|
|
751 ; Update Simulator Mask
|
|
752 call PLED_divemode_simulator_mask; Show mask
|
|
753 call PLED_divemenu_cursor ; update cursor
|
|
754 bra timeout_divemenu1 ; Check timeout
|
|
755
|
|
756 timeout_divemenu7:
|
|
757 ; Update Leading tissue infos
|
|
758 call PLED_show_leading_tissue ; Update infos about leading tissue
|
|
759 bra timeout_divemenu1 ; Check timeout |