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?
|
|
571 bra divemenu_set_setpoint ; Yes, display SetPoint/Sensor result list
|
|
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
|
|
602 divemenu_set_gas1:
|
|
603 movlw d'35' ; offset in memory
|
|
604 addwf menupos,W ; add SP number 0-2
|
|
605 movwf EEADR
|
|
606 call read_eeprom ; Read SetPoint
|
|
607 movff EEDATA, char_I_const_ppO2 ; Use SetPoint
|
|
608
|
|
609 divemenu_set_gas1a:
|
|
610 bcf display_set_setpoint ; Clear Display Flag
|
|
611 ; Now, Set correct Diluent (again)
|
|
612 read_int_eeprom d'33' ; Read byte (stored in EEDATA)
|
|
613 movff EEDATA,active_gas ; Read start gas (1-5)
|
|
614
|
|
615 decf active_gas,W ; Gas 0-4
|
|
616 mullw d'4'
|
|
617 movf PRODL,W
|
|
618 addlw d'7' ; = address for He ratio
|
|
619 movwf EEADR
|
|
620 call read_eeprom ; Read He ratio
|
|
621 movff EEDATA,char_I_He_ratio ; And copy into hold register
|
|
622 decf active_gas,W ; Gas 0-4
|
|
623 mullw d'4'
|
|
624 movf PRODL,W
|
|
625 addlw d'6' ; = address for O2 ratio
|
|
626 movwf EEADR
|
|
627 call read_eeprom ; Read O2 ratio
|
|
628 movff EEDATA, char_I_O2_ratio ; O2 ratio
|
|
629 movff char_I_He_ratio, wait_temp ; copy into bank1 register
|
|
630 bsf STATUS,C ; Borrow bit
|
|
631 movlw d'100' ; 100%
|
|
632 subfwb wait_temp,W ; minus He
|
|
633 bsf STATUS,C ; Borrow bit
|
|
634 subfwb EEDATA,F ; minus O2
|
|
635 movff EEDATA, char_I_N2_ratio ; = N2!
|
|
636
|
|
637 call PLED_active_gas_clear ; Clear gas in case of AIR (Will be redrawn)
|
|
638
|
|
639 bsf stored_gas_changed ; set event flag
|
|
640 bsf event_occured ; set global event flag
|
|
641 bra timeout_divemenu2 ; quit menu!
|
|
642
|
|
643 divemenu_set_gas2a:
|
|
644 clrf lo ; clear Setpoint, PLED_const_ppO2_value now displayes "Bail"
|
|
645 movff lo,char_I_const_ppO2
|
|
646
|
|
647 bcf display_set_gas ; clear flag
|
|
648 movff menupos,active_gas ; copy into active gas register
|
|
649 decf menupos,W ; # of selected gas (0-4)
|
|
650 mullw d'4' ; times 4...
|
|
651 movf PRODL,W ;
|
|
652 addlw d'7' ; +7 = address for He ratio
|
|
653 movwf EEADR
|
|
654 call read_eeprom ; Read He ratio
|
|
655 movff EEDATA,char_I_He_ratio ; And copy into hold register
|
|
656
|
|
657 decf menupos,W ; # of selected gas (0-4)
|
|
658 mullw d'4' ; times 4...
|
|
659 movf PRODL,W ;
|
|
660 addlw d'6' ; +6 = address for O2 ratio
|
|
661 movwf EEADR
|
|
662 call read_eeprom ; Read O2 ratio
|
|
663 movff EEDATA, char_I_O2_ratio ; O2 ratio
|
|
664 movff char_I_He_ratio, wait_temp ; copy into bank1 register
|
|
665 bsf STATUS,C ;
|
|
666 movlw d'100' ; 100%
|
|
667 subfwb wait_temp,W ; minus He
|
|
668 subfwb EEDATA,F ; minus O2
|
|
669 movff EEDATA, char_I_N2_ratio ; = N2!
|
|
670 bsf stored_gas_changed ; set event flag
|
|
671 bsf event_occured ; set global event flag
|
|
672 bra timeout_divemenu2 ; quit menu!
|
|
673
|
|
674 timeout_divemenu:
|
|
675 btfss menubit ; is the Dive mode menu displayed?
|
|
676 return ; No
|
|
677
|
|
678 btfsc display_see_l_tissue ; Are the leading tissue details displayed?
|
|
679 bra timeout_divemenu7 ; Yes, update them
|
|
680
|
|
681 btfsc display_set_simulator ; Is the Simulator Mask active?
|
|
682 bra timeout_divemenu6 ; Yes, update Simulator mask
|
|
683
|
|
684
|
|
685 btfss display_see_deco ; Is the decoplan active?
|
|
686 bra timeout_divemenu1 ; No, skip updating the decoplan
|
|
687
|
|
688 btfsc multi_gf_display ; display the multi-gf table screen?
|
|
689 bra timeout_divemenu3 ; Yes...
|
|
690
|
|
691 movff char_O_deco_status,deco_status ;
|
|
692 tstfsz deco_status ; deco_status=0 if decompression calculation done
|
|
693 bra timeout_divemenu1 ; No, skip updating the decoplan
|
|
694
|
|
695 call PLED_decoplan ; update the Decoplan
|
|
696
|
|
697 timeout_divemenu1:
|
|
698 incf timeout_counter3,F ; increase timeout_counter3
|
|
699 GETCUSTOM8 d'10' ; loads timeout_divemenu into WREG
|
|
700 cpfsgt timeout_counter3 ; ... longer then timeout_divemenu
|
|
701 return ; No!
|
|
702 timeout_divemenu2: ; quit divemode menu
|
|
703 btfss multi_gf_display ; Was the Multi-GF Table displayed?
|
|
704 bra timeout_divemenu2a ; No, normal OLED rebuild
|
|
705
|
|
706 ; Restore some outputs
|
|
707 bcf multi_gf_display ; Do not display the multi-gf table screen
|
|
708 call PLED_ClearScreen ; Yes, clean up OLED first
|
|
709 call PLED_temp_divemode ; Displays temperature
|
|
710 call PLED_max_pressure ; Max. Depth
|
|
711 btfsc dekostop_active
|
|
712 call PLED_display_deko_mask ; clear nostop time, display decodata
|
|
713 btfss dekostop_active
|
|
714 call PLED_display_ndl_mask ; Clear deco data, display nostop time
|
|
715
|
|
716 timeout_divemenu2a:
|
|
717 bcf multi_gf_display ; Do not display the multi-gf table screen
|
|
718 bcf menubit
|
|
719 bcf premenu ; Yes, clear flags and menu, display dive time and mask again
|
|
720 call PLED_active_gas_divemode ; Display gas, if required
|
|
721 call PLED_clear_divemode_menu; Clear dive mode menu
|
|
722 call PLED_divemode_mask ; Display mask
|
|
723 call PLED_divemins ; Display (new) divetime!
|
|
724 clrf timeout_counter3 ; Also clear timeout
|
|
725 bcf display_see_deco ; clear all display flags
|
|
726 bcf display_see_l_tissue
|
|
727 bcf display_set_gas
|
|
728 bcf display_set_graphs
|
|
729 bcf display_set_xgas
|
|
730 bcf display_set_setpoint
|
|
731 bcf display_set_simulator
|
|
732 bcf switch_left ; and debounce switches
|
|
733 bcf switch_right
|
|
734 return
|
|
735
|
|
736 timeout_divemenu3:
|
|
737 call PLED_MultiGF_deco_mask
|
|
738
|
|
739 movff char_O_deco_status,deco_status ;
|
|
740 tstfsz deco_status ; deco_status=0 if decompression calculation done
|
|
741 bra timeout_divemenu1 ; No, skip updating the decoplan
|
|
742
|
|
743 call PLED_MultiGF_deco_all ; Display the new screen
|
|
744 bra timeout_divemenu1 ; Check timeout
|
|
745
|
|
746 timeout_divemenu6:
|
|
747 ; Update Simulator Mask
|
|
748 call PLED_divemode_simulator_mask; Show mask
|
|
749 call PLED_divemenu_cursor ; update cursor
|
|
750 bra timeout_divemenu1 ; Check timeout
|
|
751
|
|
752 timeout_divemenu7:
|
|
753 ; Update Leading tissue infos
|
|
754 call PLED_show_leading_tissue ; Update infos about leading tissue
|
|
755 bra timeout_divemenu1 ; Check timeout |