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 ; Mainroutines for divemode
|
|
20 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com
|
|
21 ; written: 10/01/05
|
|
22 ; last updated: 15/05/08
|
|
23 ; known bugs:
|
|
24 ; ToDo:
|
|
25
|
|
26 diveloop:
|
|
27 call diveloop_boot ; Boot tasks for all modes
|
|
28
|
|
29 ; Startup Tasks for all modes
|
|
30 ostc_debug 'R' ; Sends debug-information to screen if debugmode active
|
|
31 call PLED_ClearScreen ; clean up OLED
|
|
32 call PLED_divemode_mask ; Display mask
|
|
33 call PLED_active_gas_divemode ; Display gas, if required
|
|
34 call PLED_temp_divemode ; Displays temperature
|
|
35
|
|
36 btfsc FLAG_apnoe_mode
|
|
37 bsf realdive ; Set Realdive flag in Apnoe mode
|
|
38
|
|
39 btfsc gauge_mode
|
|
40 bra diveloop_loop ; Skip in gauge mode
|
|
41 btfsc FLAG_apnoe_mode
|
|
42 bra diveloop_loop ; Skip in apnoe mode
|
|
43
|
|
44 ; Startup Tasks for deco modes
|
|
45 call PLED_display_ndl_mask ; display "no stop" if not in gauge or apnoe mode
|
|
46
|
|
47 diveloop_loop: ; The diveloop starts here
|
|
48 btfss onesecupdate ; tasks any new second
|
|
49 bra diveloop_loop2
|
|
50
|
|
51 btfsc gauge_mode ; Only in gauge mode
|
|
52 bra diveloop_loop1a ; One Second Tasks in Gauge mode
|
|
53 btfsc FLAG_apnoe_mode ; Only in apnoe mode
|
|
54 bra diveloop_loop1b ; One Second Tasks in Apnoe mode
|
|
55 btfsc FLAG_const_ppO2_mode ; only in const_ppO2_mode
|
|
56 bra diveloop_loop1c ; One Second Tasks in const_ppO2 mode
|
|
57
|
|
58 ; Tasks only for OC modes
|
|
59 call check_ppO2 ; check ppO2 and displays warning if required
|
|
60 call calc_deko_divemode ; calculate decompression and display result (any two seconds)
|
|
61 bra diveloop_loop1x ; Common Tasks
|
|
62
|
|
63 ; Tasks only for Gauge mode
|
|
64 diveloop_loop1a:
|
|
65 btfss premenu ; Is the divemode menu active?
|
|
66 call PLED_divemins ; display (new) divetime!
|
|
67 call timeout_divemode ; dive finished? This routine sets the required flags
|
|
68
|
|
69 btfsc stopwatch_active ; =1: Show Average Depth instead of Temperature
|
|
70 call PLED_stopwatch_show ; Show stopwatch only in Average mode
|
|
71
|
|
72 btfsc twosecupdate ; two seconds after the last call
|
|
73 bra diveloop_loop1a2 ; Common Tasks
|
|
74
|
|
75 bsf twosecupdate ; Routines used in the "other second"
|
|
76 call calc_average_depth ; calculate average depth
|
|
77
|
|
78 bra diveloop_loop1x ; Common Tasks
|
|
79
|
|
80 diveloop_loop1a2:
|
|
81 bcf twosecupdate
|
|
82 bra diveloop_loop1x ; Common Tasks
|
|
83
|
|
84 ; Tasks only for Apnoe mode
|
|
85 diveloop_loop1b:
|
|
86 call divemode_apnoe_tasks ; 1 sec. Apnoe tasks
|
|
87 bra diveloop_loop1x ; Common Tasks
|
|
88
|
|
89 ; Tasks only for ppO2 mode
|
|
90 diveloop_loop1c:
|
|
91 call PLED_const_ppO2_value ; display const ppO2 setting in [Bar]
|
|
92 call calc_deko_divemode ; calculate decompression and display result (any two seconds)
|
|
93 bra diveloop_loop1x ; Common Tasks
|
|
94
|
|
95 ; Common Tasks for all modes
|
|
96 diveloop_loop1x:
|
|
97 call timeout_divemode ; dive finished? This routine sets the required flags
|
|
98 btfsc low_battery_state ; If battery is low, then...
|
|
99 call update_batt_voltage_divemode ; Display Battery Symbol/Voltage!
|
|
100 btfsc premenu ; is Menu? displayed?
|
|
101 call timeout_premenu_divemode ; No, so check for timeout premenu
|
|
102 btfsc menubit ; is the Dive mode menu displayed?
|
|
103 call timeout_divemenu ; Yes, so check for timeout divemenu
|
|
104 call set_leds_divemode ; Sets warnings, if required. Also Sets buzzer
|
|
105 btfsc enter_error_sleep ; Enter Fatal Error Routine?
|
|
106 goto fatal_error_sleep ; Yes (In Sleepmode_vxx.asm!)
|
|
107
|
|
108 btfsc stopwatch_active ; =1: Show Average Depth instead of Temperature
|
|
109 call PLED_stopwatch_show ; Show stopwatch only in Average mode
|
|
110
|
|
111 bcf onesecupdate ; one seconds update done
|
|
112
|
|
113 GETCUSTOM8 d'38' ; Show seconds (=1?)
|
|
114 movwf lo
|
|
115 movlw d'1'
|
|
116 cpfseq lo ; =1?
|
|
117 bra diveloop_loop2 ; No, minutes only
|
|
118 bsf update_divetime ; Set Update flag
|
|
119
|
|
120
|
|
121 diveloop_loop2:
|
|
122 btfss update_divetime ; display new divetime?
|
|
123 bra diveloop_loop3 ; No
|
|
124 btfsc premenu ; Is the divemode menu active?
|
|
125 bra diveloop_loop2a ; Yes
|
|
126 call PLED_divemins ; Display (new) divetime!
|
|
127 btfsc FLAG_const_ppO2_mode ; only in const_ppO2_mode
|
|
128 call PLED_const_ppO2_value ; display const ppO2 setting in [Bar]
|
|
129 btfsc ppO2_show_value ; show ppO2?
|
|
130 call check_ppO2 ; check ppO2 and displays warning if required
|
|
131
|
|
132 diveloop_loop2a:
|
|
133 bcf update_divetime ; clear flag
|
|
134
|
|
135
|
|
136 diveloop_loop3:
|
|
137 btfss menubit ; Divemode menu active?
|
|
138 call test_switches_divemode ; No, Check switches normal
|
|
139
|
|
140 btfsc menubit ; Divemode menu active?
|
|
141 call test_switches_divemode_menu ; Yes, check switches divemode menu
|
|
142
|
|
143 btfss divemode ; Dive finished?
|
|
144 bra end_dive ; Dive finished!
|
|
145
|
|
146 btfsc pressure_refresh ; new pressure available?
|
|
147 call update_divemode1 ; Yes, display new depth
|
|
148 bcf pressure_refresh ; until new pressure is available
|
|
149
|
|
150 btfsc oneminupdate ; one minute tasks
|
|
151 call update_divemode60 ; Update clock, etc.
|
|
152
|
|
153 btfsc store_sample ; store new sample?
|
|
154 call store_dive_data ; Store profile data
|
|
155
|
2
|
156 btfsc menubit ; Sleep only with inactive menu...
|
|
157 bra diveloop_loop4
|
|
158
|
|
159 btfsc simulatormode_active ; Do not sleep in Simualtor mode
|
|
160 bra diveloop_loop4
|
|
161
|
0
|
162 sleep
|
|
163 nop
|
2
|
164 diveloop_loop4:
|
0
|
165 bra diveloop_loop ; Loop the divemode
|
|
166
|
|
167 timeout_premenu_divemode:
|
|
168 incf timeout_counter3,F ; Yes...
|
|
169
|
|
170 GETCUSTOM8 d'4' ; loads premenu_timeout into WREG
|
|
171 cpfsgt timeout_counter3 ; ... longer then premenu_timeout
|
|
172 return ; No!
|
|
173
|
|
174 bcf premenu ; Yes, so clear "Menu?" and clear pre_menu bit
|
|
175 call PLED_menu_clear ; Remove "Menu?"
|
|
176 return
|
|
177
|
|
178 divemode_apnoe_tasks: ; 1 sec. Apnoe tasks
|
|
179 call PLED_display_apnoe_descent ; Show descent timer
|
|
180
|
|
181 btfsc divemode2 ; Time running?
|
|
182 bra divemode_apnoe_tasks2 ; New descent, reset data if flag is set
|
|
183
|
|
184 call PLED_display_apnoe_surface
|
|
185 incf apnoe_surface_secs,F
|
|
186 movlw d'60'
|
|
187 cpfseq apnoe_surface_secs
|
|
188 bra divemode_apnoe_tasks1
|
|
189 clrf apnoe_surface_secs
|
|
190 incf apnoe_surface_mins,F
|
|
191
|
|
192 divemode_apnoe_tasks1:
|
|
193 bcf FLAG_active_descent ; Clear flag
|
|
194 btfsc divemode2 ; Time running?
|
|
195 return ; Yes, return
|
|
196
|
|
197 bsf FLAG_active_descent ; Set Flag
|
|
198 return
|
|
199
|
|
200 divemode_apnoe_tasks2:
|
|
201 btfss FLAG_active_descent ; Are descending?
|
|
202 return ; No, We are at the surface
|
|
203 rcall apnoe_calc_maxdepth ; Yes!
|
|
204
|
|
205 divemode_apnoe_tasks3:
|
|
206 call PLED_apnoe_clear_surface ; Clear Surface timer
|
|
207
|
|
208 clrf apnoe_timeout_counter ; Delete timeout
|
|
209 clrf apnoe_surface_secs
|
|
210 clrf apnoe_surface_mins
|
|
211 clrf apnoe_secs
|
|
212 clrf apnoe_mins ; Reset Descent time
|
|
213 clrf max_pressure+0
|
|
214 clrf max_pressure+1 ; Reset Max. Depth
|
|
215 bcf FLAG_active_descent ; Clear flag
|
|
216 return
|
|
217
|
|
218 apnoe_calc_maxdepth:
|
|
219 movff apnoe_max_pressure+0,sub_a+0
|
|
220 movff apnoe_max_pressure+1,sub_a+1
|
|
221 movff max_pressure+0,sub_b+0
|
|
222 movff max_pressure+1,sub_b+1
|
|
223 call sub16 ; sub_c = sub_a - sub_b
|
|
224 ; apnoe_max_pressure<max_pressure -> neg_flag=1
|
|
225 ; max_pressure<=apnoe_max_pressure -> neg_flag=0
|
|
226 btfss neg_flag
|
|
227 return
|
|
228 ;apnoe_max_pressure<max_pressure
|
|
229 movff max_pressure+0,apnoe_max_pressure+0
|
|
230 movff max_pressure+1,apnoe_max_pressure+1
|
|
231 return
|
|
232
|
|
233 set_leds_divemode:
|
|
234 call clear_LEDy ; LEDy OFF
|
|
235 movff char_O_gradient_factor,lo ; gradient factor absolute
|
|
236
|
|
237 GETCUSTOM8 d'14' ; threshold for LED warning
|
|
238 cpfslt lo ;
|
|
239 call warn_gf1 ; show warning, set flags
|
|
240
|
|
241 btfsc ppO2_warn_value ; warn because of too high ppO2?
|
|
242 call set_LEDy ; Yes
|
|
243
|
|
244 movff char_I_deco_model,lo
|
|
245 decfsz lo,W ; jump over return if char_I_deco_model == 1
|
|
246 return
|
|
247
|
|
248 movff char_O_relative_gradient_GF,lo ; gradient factor relative (GF model)
|
|
249
|
|
250 GETCUSTOM8 d'14' ; threshold for LED warning
|
|
251 cpfslt lo ;
|
|
252 call warn_gf1 ; show warning, set flags
|
|
253
|
|
254 btfsc ppO2_warn_value ; warn because of too high ppO2?
|
|
255 call set_LEDy ; Yes
|
|
256
|
|
257 return
|
|
258
|
|
259 warn_gf1:
|
|
260 call set_LEDy ; LED Yellow on
|
|
261 movlw d'2' ; Type of Alarm
|
|
262 movwf AlarmType ; Copy to Alarm Register
|
|
263 bsf event_occured ; Set Event Flag
|
|
264 return
|
|
265
|
|
266 calc_deko_divemode:
|
|
267 btfsc twosecupdate ; two seconds after the last call
|
|
268 bra calc_deko_divemode2 ; Yes, calculate and display deco data ("first second")
|
|
269
|
|
270 ; Routines used in the "other second"
|
|
271
|
|
272 bsf twosecupdate ; No, but next second!
|
|
273 call calc_average_depth ; calculate average depth
|
|
274 call calc_velocity ; calculate vertical velocity and display if > threshold (every two seconds)
|
|
275
|
|
276 ; calculate ppO2 in 0.1Bar (e.g. 150 = 1.50Bar ppO2)
|
|
277 movff amb_pressure+0,xA+0
|
|
278 movff amb_pressure+1,xA+1
|
|
279 movlw LOW d'10'
|
|
280 movwf xB+0
|
|
281 movlw HIGH d'10'
|
|
282 clrf xB+1
|
|
283 call div16x16 ; xC=p_amb/10
|
|
284 movff xC+0,xA+0
|
|
285 movff xC+1,xA+1
|
|
286 movff char_I_O2_ratio,xB+0
|
|
287 clrf xB+1
|
|
288 call mult16x16 ; char_I_O2_ratio * p_amb/10
|
|
289 movff xC+0,xA+0
|
|
290 movff xC+1,xA+1
|
|
291 movlw LOW d'100'
|
|
292 movwf xB+0
|
|
293 movlw HIGH d'100'
|
|
294 clrf xB+1
|
|
295 call div16x16 ; xC=(char_I_O2_ratio * p_amb/10)/100
|
|
296
|
|
297 ; Copy ppO2 for CNS calculation
|
|
298 movff xC+0, char_I_actual_ppO2 ; copy last ppO2 to buffer register
|
|
299 btfsc FLAG_const_ppO2_mode ; do in const_ppO2_mode
|
|
300 movff char_I_const_ppO2, char_I_actual_ppO2 ; copy last ppO2 to buffer register
|
|
301
|
|
302 ; Calculate CNS
|
|
303 call main_calc_CNS_fraction ; calculate CNS
|
|
304 movlb b'00000001' ; rambank 1 selected
|
|
305
|
|
306 ; Check if CNS should be displayed
|
|
307 movff char_O_CNS_fraction,lo ; copy into bank1
|
|
308 GETCUSTOM8 d'27' ; cns_display_high
|
|
309 subwf lo,W
|
|
310 btfsc STATUS,C
|
|
311 call PLED_display_cns ; Show CNS
|
|
312
|
|
313 ; Check for decompression gases if in decomode
|
|
314 divemode_check_decogases: ; CALLed from Simulator
|
|
315 btfss dekostop_active
|
|
316 bra reset_decompression_gases ; While in NDL, do not set deompression gas
|
|
317 ; 1. Find active gas with deepest change depth < current depth
|
|
318 ; 2. Set Decogas
|
|
319
|
|
320 movff rel_pressure+0,xA+0
|
|
321 movff rel_pressure+1,xA+1
|
|
322 movlw d'100'
|
|
323 movwf xB+0
|
|
324 clrf xB+1
|
|
325 call div16x16 ; compute depth in full m -> result in xC+0
|
|
326 clrf lo ; clear depth for comparison
|
|
327
|
|
328 ; check gas1
|
|
329 read_int_eeprom d'27' ; read flag register
|
|
330 btfss EEDATA,0 ; check active flag
|
|
331 bra check_decogas2 ; skip inactive gases!
|
|
332 read_int_eeprom d'28' ; read gas_change_depth
|
|
333 movf xC+0,W ; load depth in m into WREG
|
|
334 cpfslt EEDATA ; gas_change_depth > current depth?
|
|
335 bra check_decogas2 ; W < EEDATA -> current depth lower then gas_change_depth
|
|
336
|
|
337 movff EEDATA,lo ; deepest gas_change_depth in lo
|
|
338 movlw d'1'
|
|
339 movwf hi ; Decogas # in hi (1-5)
|
|
340
|
|
341 check_decogas2:
|
|
342 read_int_eeprom d'27' ; read flag register
|
|
343 btfss EEDATA,1 ; check active flag
|
|
344 bra check_decogas3 ; skip inactive gases!
|
|
345 read_int_eeprom d'29' ; read gas_change_depth
|
|
346 movf xC+0,W ; load depth in m into WREG
|
|
347 cpfslt EEDATA ; gas_change_depth > current depth?
|
|
348 bra check_decogas3 ; W < EEDATA -> current depth lower then gas_change_depth
|
|
349
|
|
350 read_int_eeprom d'29' ; read gas_change_depth
|
|
351 movf lo,W ; load current gas_change_depth into WREG
|
|
352 cpfsgt EEDATA ; last gas_change_depth > current gas_change_depth ?
|
|
353 bra check_decogas3 ; W < lo -> last gas_change_depth > current gas_change_depth
|
|
354 movff EEDATA,lo ; deepest gas_change_depth in lo
|
|
355 movlw d'2'
|
|
356 movwf hi ; Decogas # in hi (1-5)
|
|
357
|
|
358 check_decogas3:
|
|
359 read_int_eeprom d'27' ; read flag register
|
|
360 btfss EEDATA,2 ; check active flag
|
|
361 bra check_decogas4 ; skip inactive gases!
|
|
362 read_int_eeprom d'30' ; read gas_change_depth
|
|
363 movf xC+0,W ; load depth in m into WREG
|
|
364 cpfslt EEDATA ; gas_change_depth > current depth?
|
|
365 bra check_decogas4 ; W < EEDATA -> current depth lower then gas_change_depth
|
|
366
|
|
367 read_int_eeprom d'30' ; read gas_change_depth
|
|
368 movf lo,W ; load current gas_change_depth into WREG
|
|
369 cpfsgt EEDATA ; last gas_change_depth > current gas_change_depth ?
|
|
370 bra check_decogas4 ; W < lo -> last gas_change_depth > current gas_change_depth
|
|
371 movff EEDATA,lo ; deepest gas_change_depth in lo
|
|
372 movlw d'3'
|
|
373 movwf hi ; Decogas # in hi (1-5)
|
|
374
|
|
375 check_decogas4:
|
|
376 read_int_eeprom d'27' ; read flag register
|
|
377 btfss EEDATA,3 ; check active flag
|
|
378 bra check_decogas5 ; skip inactive gases!
|
|
379 read_int_eeprom d'31' ; read gas_change_depth
|
|
380 movf xC+0,W ; load depth in m into WREG
|
|
381 cpfslt EEDATA ; gas_change_depth > current depth?
|
|
382 bra check_decogas5 ; W < EEDATA -> current depth lower then gas_change_depth
|
|
383
|
|
384 read_int_eeprom d'31' ; read gas_change_depth
|
|
385 movf lo,W ; load current gas_change_depth into WREG
|
|
386 cpfsgt EEDATA ; last gas_change_depth > current gas_change_depth ?
|
|
387 bra check_decogas5 ; W < lo -> last gas_change_depth > current gas_change_depth
|
|
388 movff EEDATA,lo ; deepest gas_change_depth in lo
|
|
389 movlw d'4'
|
|
390 movwf hi ; Decogas # in hi (1-5)
|
|
391
|
|
392 check_decogas5:
|
|
393 read_int_eeprom d'27' ; read flag register
|
|
394 btfss EEDATA,4 ; check active flag
|
|
395 bra check_decogas_done ; skip inactive gases!
|
|
396 read_int_eeprom d'32' ; read gas_change_depth
|
|
397 movf xC+0,W ; load depth in m into WREG
|
|
398 cpfslt EEDATA ; gas_change_depth > current depth?
|
|
399 bra check_decogas_done ; W < EEDATA -> current depth lower then gas_change_depth
|
|
400
|
|
401 read_int_eeprom d'32' ; read gas_change_depth
|
|
402 movf lo,W ; load current gas_change_depth into WREG
|
|
403 cpfsgt EEDATA ; last gas_change_depth > current gas_change_depth ?
|
|
404 bra check_decogas_done ; W < lo -> last gas_change_depth > current gas_change_depth
|
|
405 movff EEDATA,lo ; deepest gas_change_depth in lo
|
|
406 movlw d'5'
|
|
407 movwf hi ; Decogas # in hi (1-5)
|
|
408
|
|
409 check_decogas_done:
|
|
410 ostc_debug 'E' ; Sends debug-information to screen if debugmode active
|
|
411
|
|
412 decf hi,F ; Gas 0-4
|
|
413 movff lo, char_I_deco_gas_change ; copy change_depth
|
|
414
|
|
415 movf hi,W ; Gas 0-4
|
|
416 mullw d'4'
|
|
417 movf PRODL,W
|
|
418 addlw d'7' ; = address for He ratio
|
|
419 movwf EEADR
|
|
420 call read_eeprom ; Read He ratio
|
|
421 movff EEDATA,char_I_deco_He_ratio ; And copy into hold register
|
|
422
|
|
423
|
|
424 movf hi,W ; Gas 0-4
|
|
425 mullw d'4'
|
|
426 movf PRODL,W
|
|
427 addlw d'6' ; = address for O2 ratio
|
|
428 movwf EEADR
|
|
429 call read_eeprom ; Read O2 ratio
|
|
430
|
|
431 movff char_I_deco_He_ratio, wait_temp ; copy into bank1 register
|
|
432 bsf STATUS,C ; Borrow bit
|
|
433 movlw d'100' ; 100%
|
|
434 subfwb wait_temp,W ; minus He
|
|
435 bsf STATUS,C ; Borrow bit
|
|
436 subfwb EEDATA,F ; minus O2
|
|
437 movff EEDATA, char_I_deco_N2_ratio ; = N2!
|
|
438 bra skip_decompression_gases
|
|
439
|
|
440 reset_decompression_gases: ; reset the deco gas while in NDL
|
|
441 ostc_debug 'F' ; Sends debug-information to screen if debugmode active
|
|
442 clrf lo
|
|
443 movff lo, char_I_deco_gas_change ; clear
|
|
444 movff lo, char_I_deco_N2_ratio ; clear
|
|
445 movff lo, char_I_deco_He_ratio ; clear
|
|
446 skip_decompression_gases:
|
|
447 ;call PLED_gaschange_DEBUG
|
|
448 return
|
|
449
|
|
450 calc_deko_divemode2:
|
|
451 bcf twosecupdate
|
|
452
|
|
453 btfsc gauge_mode ; ignore decompression calculation in gauge mode
|
|
454 return
|
|
455 btfsc FLAG_apnoe_mode ; ignore decompression calculation in apnoe mode
|
|
456 return
|
|
457
|
|
458 ostc_debug 'B' ; Sends debug-information to screen if debugmode active
|
|
459 call divemode_prepare_flags_for_deco
|
|
460 call deco_main_calc_hauptroutine ; calc_tissue
|
|
461 movlb b'00000001' ; rambank 1 selected
|
|
462 ostc_debug 'C' ; Sends debug-information to screen if debugmode active
|
|
463
|
|
464 movff char_O_deco_status,deco_status ;
|
|
465 tstfsz deco_status ; deco_status=0 if decompression calculation done
|
|
466 return ; calculation not yet finished!
|
|
467
|
|
468 movff char_O_array_decodepth+0,wait_temp ; copy ceiling to temp register
|
|
469 tstfsz wait_temp ; Ceiling<0m?
|
|
470 bra calc_deko_divemode3 ; Yes!
|
|
471
|
|
472 btfsc dekostop_active
|
|
473 call PLED_display_ndl_mask ; Clear deco data, display nostop time
|
|
474 bcf dekostop_active ; clear flag
|
|
475
|
|
476 clrf decodata+0 ; for profile memory
|
|
477 movff char_O_nullzeit,decodata+1 ; nostop time
|
|
478
|
|
479 call PLED_display_ndl ; display no deco limit
|
|
480 return
|
|
481
|
|
482 divemode_prepare_flags_for_deco:
|
|
483 movff amb_pressure+0,int_I_pres_respiration+0 ; lo and copy result to deco routine
|
|
484 movff amb_pressure+1,int_I_pres_respiration+1 ; hi
|
|
485 GETCUSTOM8 d'11' ; Saturation multiplier %
|
|
486 movwf wait_temp
|
|
487 movff wait_temp,char_I_saturation_multiplier
|
|
488 GETCUSTOM8 d'12' ; Desaturation multiplier %
|
|
489 movwf wait_temp
|
|
490 movff wait_temp,char_I_desaturation_multiplier
|
|
491 GETCUSTOM8 d'16' ; Deco distance to decostop in 1/10 meter for simulation
|
|
492 movwf wait_temp
|
|
493 movff wait_temp,char_I_deco_distance
|
|
494 GETCUSTOM8 d'29' ; Depth Last Deco in meter for simulation
|
|
495 movwf wait_temp
|
|
496 movff wait_temp,char_I_depth_last_deco
|
|
497 call restart_set_modes_and_flags ; Sets decomode (char_I_deco_model) and flags (again)
|
|
498 return
|
|
499
|
|
500 calc_deko_divemode3:
|
|
501 btfss dekostop_active
|
|
502 call PLED_display_deko_mask ; clear nostop time, display decodata
|
|
503 bsf dekostop_active ; Set flag
|
|
504
|
|
505 movff char_O_array_decodepth+0,decodata+0 ; ceiling
|
|
506 movff char_O_array_decotime,decodata+1 ; length of first stop in minues
|
|
507
|
|
508 call PLED_display_deko ; display decodata
|
|
509 return
|
|
510
|
|
511 store_dive_data: ; CF20 seconds gone
|
|
512 bcf store_sample ; update only any CF20 seconds
|
|
513 bsf update_divetime ; update divemins every CF20 seconds
|
|
514
|
|
515 call clear_LEDg ; LEDg off
|
|
516
|
|
517 btfsc header_stored ; Header already stored?
|
|
518 bra store_dive_data2 ; Yes, store only profile data
|
|
519 bsf header_stored ; Store header
|
|
520
|
|
521 movff eeprom_address+0, eeprom_header_address+0 ; store startposition
|
|
522 movff eeprom_address+1, eeprom_header_address+1 ; store startposition
|
|
523
|
|
524 ; shift address for header
|
|
525 ; the header will be stored after the dive
|
|
526 incf_eeprom_address d'47' ; Macro, that adds 8Bit to eeprom_address:2 with banking at 0x8000
|
|
527
|
|
528 store_dive_data2:
|
|
529 movf rel_pressure+0,W ; store depth with every sample
|
|
530 call write_external_eeprom
|
|
531 movf rel_pressure+1,W
|
|
532 call write_external_eeprom
|
|
533
|
|
534 ;First, find out how many bytes will append to this sample....
|
|
535 clrf ProfileFlagByte ; clear number of bytes to append
|
|
536
|
|
537 ; Check Extented informations
|
|
538 decfsz divisor_temperature,W ; Check divisor
|
|
539 bra check_extended1
|
|
540 movlw d'2' ; Information length
|
|
541 addwf ProfileFlagByte,F ; add to ProfileFlagByte
|
|
542 check_extended1:
|
|
543 decfsz divisor_deco,W ; Check divisor
|
|
544 bra check_extended2
|
|
545 movlw d'2' ; Information length
|
|
546 addwf ProfileFlagByte,F ; add to ProfileFlagByte
|
|
547 check_extended2:
|
|
548 decfsz divisor_tank,W ; Check divisor
|
|
549 bra check_extended3
|
|
550 movlw d'2' ; Information length
|
|
551 addwf ProfileFlagByte,F ; add to ProfileFlagByte
|
|
552 check_extended3:
|
|
553 decfsz divisor_ppo2,W ; Check divisor
|
|
554 bra check_extended4
|
|
555 movlw d'3' ; Information length
|
|
556 addwf ProfileFlagByte,F ; add to ProfileFlagByte
|
|
557 check_extended4:
|
|
558 decfsz divisor_deco_debug,W; Check divisor
|
|
559 bra check_extended5
|
|
560 movlw d'9' ; Information length
|
|
561 addwf ProfileFlagByte,F ; add to ProfileFlagByte
|
|
562 check_extended5:
|
|
563 decfsz divisor_nuy2,W ; Check divisor
|
|
564 bra check_extended6
|
|
565 movlw d'0' ; Information length
|
|
566 addwf ProfileFlagByte,F ; add to ProfileFlagByte
|
|
567 check_extended6:
|
|
568
|
|
569 ; Second, check global event flag
|
|
570 btfss event_occured ; Check global event flag
|
|
571 bra store_dive_data3 ; No Event
|
|
572 movlw d'1'
|
|
573 addwf ProfileFlagByte,F ; add one byte (The EventByte)
|
|
574
|
|
575 clrf EventByte ; reset EventByte
|
|
576
|
|
577 movf AlarmType,W ; Type of Alarm Bit 0-3
|
|
578 addwf EventByte,F ; Copy to EventByte Bit 0-3
|
|
579 clrf AlarmType ; Reset AlarmType
|
|
580
|
|
581 ; Third, check events and add aditional bytes
|
|
582 btfss manual_gas_changed ; Check flag
|
|
583 bra check_event1
|
|
584 movlw d'2' ; Information length
|
|
585 addwf ProfileFlagByte,F ; add to ProfileFlagByte
|
|
586 bsf EventByte,4 ; Also set Flag in EventByte!
|
|
587 check_event1:
|
|
588 btfss stored_gas_changed ; Check flag
|
|
589 bra check_event2
|
|
590 movlw d'1' ; Information length
|
|
591 addwf ProfileFlagByte,F ; add to ProfileFlagByte
|
|
592 bsf EventByte,5 ; Also set Flag in EventByte!
|
|
593 check_event2:
|
|
594 bsf ProfileFlagByte,7 ; Set EventByte Flag in ProfileFlagByte
|
|
595
|
|
596 store_dive_data3:
|
|
597 movf ProfileFlagByte,W ; finally, write ProfileFlagByte!
|
|
598 call write_external_eeprom
|
|
599
|
|
600 btfss event_occured ; Check global event flag (again)
|
|
601 bra store_dive_data4 ; No Event
|
|
602
|
|
603 ; Store the EventByte + additional bytes now
|
|
604 movf EventByte,W
|
|
605 call write_external_eeprom
|
|
606
|
|
607 btfss manual_gas_changed ; Check flag
|
|
608 bra store_dive_data3a
|
|
609 read_int_eeprom d'24' ; % O2 Gas6
|
|
610 movf EEDATA,W
|
|
611 call write_external_eeprom
|
|
612 read_int_eeprom d'25' ; % He Gas6
|
|
613 movf EEDATA,W
|
|
614 call write_external_eeprom
|
|
615
|
|
616 store_dive_data3a:
|
|
617 btfss stored_gas_changed ; Check flag
|
|
618 bra store_dive_data3b
|
|
619 movf active_gas,W ; Store active gas
|
|
620 call write_external_eeprom
|
|
621
|
|
622 store_dive_data3b:
|
|
623
|
|
624 store_dive_data4:
|
|
625 bcf event_occured ; Clear the global event flag
|
|
626 bcf manual_gas_changed ; Clear all events
|
|
627 bcf stored_gas_changed ; Clear all events
|
|
628
|
|
629 ; Store extended informations
|
|
630 decfsz divisor_temperature,F ; Check divisor
|
|
631 bra store_extended1
|
|
632 rcall store_dive_temperature
|
|
633 store_extended1:
|
|
634 decfsz divisor_deco,F ; Check divisor
|
|
635 bra store_extended2
|
|
636 rcall store_dive_decodata
|
|
637 store_extended2:
|
|
638 decfsz divisor_tank,F ; Check divisor
|
|
639 bra store_extended3
|
|
640 rcall store_dive_tankdata
|
|
641 store_extended3:
|
|
642 decfsz divisor_ppo2,F ; Check divisor
|
|
643 bra store_extended4
|
|
644 rcall store_dive_ppo2
|
|
645 store_extended4:
|
|
646 decfsz divisor_deco_debug,F; Check divisor
|
|
647 bra store_extended5
|
|
648 rcall store_dive_decodebug
|
|
649 store_extended5:
|
|
650 decfsz divisor_nuy2,F ; Check divisor
|
|
651 bra store_extended6
|
|
652 rcall store_dive_nuy2
|
|
653 store_extended6:
|
|
654
|
|
655 ; The next block is required to take care of "store never"
|
|
656 btfsc divisor_temperature,7 ; Test highest Bit (Register must have been zero before the "decfsz" command!)
|
|
657 clrf divisor_temperature ; And clear register again, so it will never reach zero...
|
|
658 btfsc divisor_deco,7 ; Test highest Bit (Register must have been zero before the "decfsz" command!)
|
|
659 clrf divisor_deco ; And clear register again, so it will never reach zero...
|
|
660 btfsc divisor_tank,7 ; Test highest Bit (Register must have been zero before the "decfsz" command!)
|
|
661 clrf divisor_tank ; And clear register again, so it will never reach zero...
|
|
662 btfsc divisor_ppo2,7 ; Test highest Bit (Register must have been zero before the "decfsz" command!)
|
|
663 clrf divisor_ppo2 ; And clear register again, so it will never reach zero...
|
|
664 btfsc divisor_deco_debug,7 ; Test highest Bit (Register must have been zero before the "decfsz" command!)
|
|
665 clrf divisor_deco_debug ; And clear register again, so it will never reach zero...
|
|
666 btfsc divisor_nuy2,7 ; Test highest Bit (Register must have been zero before the "decfsz" command!)
|
|
667 clrf divisor_nuy2 ; And clear register again, so it will never reach zero...
|
|
668
|
|
669 ostc_debug 'D' ; Sends debug-information to screen if debugmode active
|
|
670 return ; Done.
|
|
671
|
|
672 store_dive_nuy2:
|
|
673 GETCUSTOM8 d'26'
|
|
674 movwf divisor_nuy2 ; Reload divisor from CF
|
|
675 return
|
|
676
|
|
677 store_dive_decodebug:
|
|
678 movff 0x931,divisor_deco_debug ; Used as temp
|
|
679 movf divisor_deco_debug,W ; copy to WREG
|
|
680 call write_external_eeprom ; Store in EEPROM
|
|
681 movff 0x930,divisor_deco_debug ; Used as temp
|
|
682 movf divisor_deco_debug,W ; copy to WREG
|
|
683 call write_external_eeprom ; Store in EEPROM
|
|
684 movff 0x933,divisor_deco_debug ; Used as temp
|
|
685 movf divisor_deco_debug,W ; copy to WREG
|
|
686 call write_external_eeprom ; Store in EEPROM
|
|
687 movff 0x932,divisor_deco_debug ; Used as temp
|
|
688 movf divisor_deco_debug,W ; copy to WREG
|
|
689 call write_external_eeprom ; Store in EEPROM
|
|
690 movff 0x935,divisor_deco_debug ; Used as temp
|
|
691 movf divisor_deco_debug,W ; copy to WREG
|
|
692 call write_external_eeprom ; Store in EEPROM
|
|
693 movff 0x934,divisor_deco_debug ; Used as temp
|
|
694 movf divisor_deco_debug,W ; copy to WREG
|
|
695 call write_external_eeprom ; Store in EEPROM
|
|
696 movff 0x937,divisor_deco_debug ; Used as temp
|
|
697 movf divisor_deco_debug,W ; copy to WREG
|
|
698 call write_external_eeprom ; Store in EEPROM
|
|
699 movff 0x936,divisor_deco_debug ; Used as temp
|
|
700 movf divisor_deco_debug,W ; copy to WREG
|
|
701 call write_external_eeprom ; Store in EEPROM
|
|
702 movff 0x938,divisor_deco_debug ; Used as temp
|
|
703 movf divisor_deco_debug,W ; copy to WREG
|
|
704 call write_external_eeprom ; Store in EEPROM
|
|
705 GETCUSTOM8 d'25'
|
|
706 movwf divisor_deco_debug ; Reload divisor from CF
|
|
707 return
|
|
708
|
|
709 store_dive_ppo2:
|
|
710 movlw 0x00 ; Dummy
|
|
711 call write_external_eeprom
|
|
712 movlw 0x00 ; Dummy
|
|
713 call write_external_eeprom
|
|
714 movlw 0x00 ; Dummy
|
|
715 call write_external_eeprom
|
|
716 GETCUSTOM8 d'24'
|
|
717 movwf divisor_ppo2 ; Reload divisor from CF
|
|
718 return
|
|
719
|
|
720 store_dive_tankdata:
|
|
721 movlw d'0' ; Dummy Tank1
|
|
722 call write_external_eeprom
|
|
723 movlw d'0' ; Dummy Tank2
|
|
724 call write_external_eeprom
|
|
725 GETCUSTOM8 d'23'
|
|
726 movwf divisor_tank ; Reload divisor from CF
|
|
727 return
|
|
728
|
|
729 store_dive_decodata:
|
|
730 movf decodata+0,W ; =0:no stop dive, if in deco mode: ceiling in m
|
|
731 call write_external_eeprom
|
|
732 movf decodata+1,W ; no stop time of length of first stop
|
|
733 call write_external_eeprom
|
|
734 GETCUSTOM8 d'22'
|
|
735 movwf divisor_deco ; Reload divisor from CF
|
|
736 return
|
|
737
|
|
738 store_dive_temperature:
|
|
739 movf temperature+0,W ; append temperature to current sample!
|
|
740 call write_external_eeprom
|
|
741 movf temperature+1,W
|
|
742 call write_external_eeprom
|
|
743 GETCUSTOM8 d'21'
|
|
744 movwf divisor_temperature ; Reload divisor from CF
|
|
745 return
|
|
746
|
|
747 calc_velocity: ; called every two seconds
|
|
748 btfss divemode
|
|
749 bra do_not_display_velocity ; display velocity only in divemode
|
|
750
|
|
751 calc_velocity2:
|
|
752 movff amb_pressure+0,sub_a+0
|
|
753 movff amb_pressure+1,sub_a+1
|
|
754 movff last_pressure+0,sub_b+0
|
|
755 movff last_pressure+1,sub_b+1
|
|
756 movff amb_pressure+0,last_pressure+0 ; store old value for velocity
|
|
757 movff amb_pressure+1,last_pressure+1
|
|
758
|
|
759 call sub16 ; sub_c = amb_pressure - last_pressure
|
|
760
|
|
761 movff sub_c+0,xA+0
|
|
762 movff sub_c+1,xA+1
|
|
763 movlw d'39' ;77 when called every second....
|
|
764 movwf xB+0
|
|
765 clrf xB+1
|
|
766 call mult16x16 ; differential pressure in mBar*77...
|
|
767 movff xC+0,divA+0
|
|
768 movff xC+1,divA+1
|
|
769 movlw d'7'
|
|
770 movwf divB
|
|
771 call div16 ; devided by 2^7 equals velocity in m/min
|
|
772
|
|
773 movlw d'99'
|
|
774 cpfsgt divA
|
|
775 bra calc_velocity3
|
|
776 movwf divA ; divA=99
|
|
777
|
|
778 calc_velocity3:
|
|
779
|
|
780 GETCUSTOM8 d'5' ; threshold for display vertical velocity
|
|
781 subwf divA+0,W ;
|
|
782
|
|
783 btfss STATUS,C
|
|
784 bra do_not_display_velocity
|
|
785
|
|
786 update_velocity:
|
|
787 bsf display_velocity
|
|
788 call PLED_display_velocity
|
|
789 return
|
|
790
|
|
791 do_not_display_velocity:
|
|
792 btfss display_velocity ; Velocity was not displayed, do not delete
|
|
793 return
|
|
794
|
|
795 bcf display_velocity ; Velocity was displayed, delete velocity now
|
|
796 call PLED_display_velocity_clear
|
|
797 return
|
|
798
|
|
799 check_ppO2: ; check current ppO2 and display warning if required
|
|
800 btfsc FLAG_const_ppO2_mode ; ignore in ppO2 mode....
|
|
801 return
|
|
802
|
|
803 movff amb_pressure+0,xA+0
|
|
804 movff amb_pressure+1,xA+1
|
|
805 movlw d'10'
|
|
806 movwf xB+0
|
|
807 clrf xB+1
|
|
808 call div16x16 ; xC=p_amb/10
|
|
809 movff xC+0,xA+0
|
|
810 movff xC+1,xA+1
|
|
811 movff char_I_O2_ratio,xB+0
|
|
812 clrf xB+1
|
|
813 call mult16x16 ; char_I_O2_ratio * p_amb/10
|
|
814
|
|
815 ; Check if ppO2 should be displayed
|
|
816 movff xC+0,sub_b+0
|
|
817 movff xC+1,sub_b+1
|
|
818 GETCUSTOM8 d'19' ; ppo2_display_high
|
|
819 mullw d'100' ; ppo2_display_high*100
|
|
820 movff PRODL,sub_a+0
|
|
821 movff PRODH,sub_a+1
|
|
822 call sub16
|
|
823 bcf ppO2_show_value ; clear flag
|
|
824 btfsc neg_flag
|
|
825 bsf ppO2_show_value ; set flag if required
|
|
826
|
|
827 ;check if we are within our warning thresholds!
|
|
828 bcf ppO2_warn_value ; clear flag
|
|
829 movff xC+0,sub_b+0
|
|
830 movff xC+1,sub_b+1
|
|
831 GETCUSTOM8 d'18' ; ppo2_warning_high
|
|
832 mullw d'100' ; ppo2_warning_high*100
|
|
833 movff PRODL,sub_a+0
|
|
834 movff PRODH,sub_a+1
|
|
835 call sub16
|
|
836 btfss neg_flag
|
|
837 bra check_ppO2_0 ; Not too high
|
|
838
|
|
839 bsf ppO2_warn_value ; set flag
|
|
840 movlw d'5' ; Type of Alarm
|
|
841 movwf AlarmType ; Copy to Alarm Register
|
|
842 bsf event_occured ; Set Event Flag
|
|
843
|
|
844 check_ppO2_0:
|
|
845 movff xC+0,sub_b+0
|
|
846 movff xC+1,sub_b+1
|
|
847 GETCUSTOM8 d'17' ; ppo2_warning_low
|
|
848 mullw d'100' ; ppo2_warning_low*100
|
|
849 movff PRODL,sub_a+0
|
|
850 movff PRODH,sub_a+1
|
|
851 call sub16
|
|
852 btfsc neg_flag
|
|
853 bra check_ppO2_1 ; Not too low
|
|
854
|
|
855 bsf ppO2_warn_value ; set flag
|
|
856 bsf ppO2_show_value ; show ppO2 if below threshold!
|
|
857 movlw d'4' ; Type of Alarm
|
|
858 movwf AlarmType ; Copy to Alarm Register
|
|
859 bsf event_occured ; Set Event Flag
|
|
860
|
|
861 check_ppO2_1:
|
|
862 btfsc ppO2_show_value ; show value?
|
|
863 bra check_ppO2_2 ; yes!
|
|
864
|
|
865 btfss ppO2_display_active ; is the value displayed?
|
|
866 bra check_ppO2_3 ; No, so clear not required
|
|
867
|
|
868 call PLED_show_ppO2_clear; Clear ppO2 value
|
|
869 bcf ppO2_display_active ; clear flag
|
|
870 bra check_ppO2_3 ; done
|
|
871
|
|
872 check_ppO2_2:
|
|
873 call PLED_show_ppO2 ; Display ppO2 (stored in xC)
|
|
874 bsf ppO2_display_active ; Set flag
|
|
875
|
|
876 check_ppO2_3:
|
|
877 return ; done
|
|
878
|
|
879
|
|
880 calculate_noflytime:
|
|
881 ; calculate nofly time
|
|
882 movff int_O_desaturation_time+0,xA+0
|
|
883 movff int_O_desaturation_time+1,xA+1
|
|
884 tstfsz xA+0 ; Desat=0?
|
|
885 bra calculate_noflytime2
|
|
886 tstfsz xA+1 ; Desat=0?
|
|
887 bra calculate_noflytime2
|
|
888 ; Desaturation time = zero
|
|
889 movlw d'1'
|
|
890 movwf nofly_time+0 ; Clear nofly time
|
|
891 clrf nofly_time+1 ; Clear nofly time
|
|
892 bcf nofly_active ; Clear flag
|
|
893 return
|
|
894
|
|
895 calculate_noflytime2:
|
|
896 movff xA+0,int_I_temp+0
|
|
897 movff xA+1,int_I_temp+1
|
|
898 GETCUSTOM8 .13 ; nofly_time_ratio
|
|
899 movwf xB+0
|
|
900 movff xB,char_I_temp
|
|
901 ostc_debug 'K' ; Sends debug-information to screen if debugmode active
|
|
902 call main_calc_percentage
|
|
903 movlb b'00000001' ; select ram bank 1
|
|
904 ostc_debug 'L' ; Sends debug-information to screen if debugmode active
|
|
905 movff int_I_temp+0,xA+0
|
|
906 movff int_I_temp+1,xA+1
|
|
907 tstfsz xA+0 ; Desat=0?
|
|
908 bra calculate_noflytime_2_final
|
|
909 tstfsz xA+1 ; Desat=0?
|
|
910 bra calculate_noflytime_2_final
|
|
911 ; noflytime = zero
|
|
912 movlw d'1'
|
|
913 movwf nofly_time+0 ; Clear nofly time
|
|
914 clrf nofly_time+1 ; Clear nofly time
|
|
915 bcf nofly_active ; Clear flag
|
|
916 return
|
|
917 calculate_noflytime_2_final:
|
|
918 movff xA+0,nofly_time+0
|
|
919 movff xA+1,nofly_time+1
|
|
920 bsf nofly_active ; Set flag
|
|
921 return
|
|
922
|
|
923 end_dive:
|
|
924 btfss realdive ; dive longer then one minute
|
|
925 goto end_dive_common ; No, discard everything
|
|
926
|
|
927 ; Dive finished (and longer then one minute or Apnoe timeout occured)
|
|
928
|
|
929 btfsc FLAG_apnoe_mode ; Calc max. depth (again) for very short apnoe dives
|
|
930 rcall apnoe_calc_maxdepth
|
|
931
|
|
932 ; calculate desaturation time
|
|
933 movff last_surfpressure_30min+0,int_I_pres_respiration+0 ; copy surface air pressure to deco routine
|
|
934 movff last_surfpressure_30min+1,int_I_pres_respiration+1 ; 30min old values
|
|
935
|
|
936 GETCUSTOM8 d'12' ; Desaturation multiplier %
|
|
937 movwf wait_temp
|
|
938 movff wait_temp,char_I_desaturation_multiplier
|
|
939
|
|
940 ostc_debug 'G' ; Sends debug-information to screen if debugmode active
|
|
941 call deco_main_calc_desaturation_time ; calculate desaturation time
|
|
942 movlb b'00000001' ; select ram bank 1
|
|
943 rcall calculate_noflytime ; Calc NoFly time
|
|
944 ostc_debug 'H' ; Sends debug-information to screen if debugmode active
|
|
945 ; store header and ...
|
|
946 movlw 0xFD ; .... End-of-Profile Bytes
|
|
947 call write_external_eeprom
|
|
948 movlw 0xFD
|
|
949 call write_external_eeprom
|
|
950 movlw 0xFE ; This positon will be overwritten for the next profile
|
|
951 call write_external_eeprom ; and is required to find the newest dive after a firmware reset
|
|
952
|
|
953 movff eeprom_header_address+0, eeprom_address+0 ; set header adress
|
|
954 movff eeprom_header_address+1, eeprom_address+1 ; write header
|
|
955
|
|
956 movlw 0xFA ; Header start
|
|
957 call write_external_eeprom
|
|
958 movlw 0xFA
|
|
959 call write_external_eeprom
|
|
960 movlw logbook_profile_version ; Defined in definitions_vxyy.asm
|
|
961 call write_external_eeprom
|
|
962 movf month,W ; Date
|
|
963 call write_external_eeprom
|
|
964 movf day,W
|
|
965 call write_external_eeprom
|
|
966 movf year,W
|
|
967 call write_external_eeprom
|
|
968 movf hours,W ; End of dive time
|
|
969 call write_external_eeprom
|
|
970 movf mins,W
|
|
971 call write_external_eeprom
|
|
972
|
|
973 btfss FLAG_apnoe_mode ; Store apnoe max or normal max (Which is only max from the last descent)
|
|
974 bra end_dive1 ; Store normal depth
|
|
975
|
|
976 movff apnoe_max_pressure+0,lo
|
|
977 movff apnoe_max_pressure+1,hi
|
|
978 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mBar]
|
|
979 movff lo,apnoe_max_pressure+0
|
|
980 movff hi,apnoe_max_pressure+1
|
|
981
|
|
982 movf apnoe_max_pressure+0,W ; Max. depth
|
|
983 call write_external_eeprom
|
|
984 movf apnoe_max_pressure+1,W
|
|
985 call write_external_eeprom
|
|
986 bra end_dive2 ; skip
|
|
987
|
|
988 end_dive1:
|
|
989 movff max_pressure+0,lo
|
|
990 movff max_pressure+1,hi
|
|
991 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mBar]
|
|
992 movff lo,max_pressure+0
|
|
993 movff hi,max_pressure+1
|
|
994
|
|
995 movf max_pressure+0,W ; Max. depth
|
|
996 call write_external_eeprom
|
|
997 movf max_pressure+1,W
|
|
998 call write_external_eeprom
|
|
999
|
|
1000 end_dive2:
|
|
1001 movf divemins+0,W ; divetime minutes
|
|
1002 call write_external_eeprom
|
|
1003 movf divemins+1,W
|
|
1004 call write_external_eeprom
|
|
1005 movf divesecs,W ; divetime seconds
|
|
1006 call write_external_eeprom
|
|
1007 movf mintemp+0,W ; minimum temperature
|
|
1008 call write_external_eeprom
|
|
1009 movf mintemp+1,W
|
|
1010 call write_external_eeprom
|
|
1011 movf last_surfpressure_30min+0,W ; airpressure before dive
|
|
1012 call write_external_eeprom
|
|
1013 movf last_surfpressure_30min+1,W
|
|
1014 call write_external_eeprom
|
|
1015 movff int_O_desaturation_time+0,lo ;
|
|
1016 movff int_O_desaturation_time+1,hi
|
|
1017 movf lo,W ; desaturation time in minutes
|
|
1018 call write_external_eeprom
|
|
1019 movf hi,W ;
|
|
1020 call write_external_eeprom
|
|
1021
|
|
1022 ; Gases....
|
|
1023 read_int_eeprom d'6' ; Read byte (stored in EEDATA)
|
|
1024 movf EEDATA,W
|
|
1025 call write_external_eeprom
|
|
1026 read_int_eeprom d'7' ; Read byte (stored in EEDATA)
|
|
1027 movf EEDATA,W
|
|
1028 call write_external_eeprom
|
|
1029
|
|
1030 read_int_eeprom d'10' ; Read byte (stored in EEDATA)
|
|
1031 movf EEDATA,W
|
|
1032 call write_external_eeprom
|
|
1033 read_int_eeprom d'11' ; Read byte (stored in EEDATA)
|
|
1034 movf EEDATA,W
|
|
1035 call write_external_eeprom
|
|
1036
|
|
1037 read_int_eeprom d'14' ; Read byte (stored in EEDATA)
|
|
1038 movf EEDATA,W
|
|
1039 call write_external_eeprom
|
|
1040 read_int_eeprom d'15' ; Read byte (stored in EEDATA)
|
|
1041 movf EEDATA,W
|
|
1042 call write_external_eeprom
|
|
1043
|
|
1044 read_int_eeprom d'18' ; Read byte (stored in EEDATA)
|
|
1045 movf EEDATA,W
|
|
1046 call write_external_eeprom
|
|
1047 read_int_eeprom d'19' ; Read byte (stored in EEDATA)
|
|
1048 movf EEDATA,W
|
|
1049 call write_external_eeprom
|
|
1050
|
|
1051 read_int_eeprom d'22' ; Read byte (stored in EEDATA)
|
|
1052 movf EEDATA,W
|
|
1053 call write_external_eeprom
|
|
1054 read_int_eeprom d'23' ; Read byte (stored in EEDATA)
|
|
1055 movf EEDATA,W
|
|
1056 call write_external_eeprom
|
|
1057
|
|
1058 read_int_eeprom d'24' ; % O2 Gas6
|
|
1059 movf EEDATA,W
|
|
1060 call write_external_eeprom
|
|
1061 read_int_eeprom d'25' ; % He Gas6
|
|
1062 movf EEDATA,W
|
|
1063 call write_external_eeprom
|
|
1064 read_int_eeprom d'33' ; start gas
|
|
1065 movf EEDATA,W
|
|
1066 call write_external_eeprom
|
|
1067
|
|
1068 movlw softwareversion_x ; Firmware version
|
|
1069 call write_external_eeprom
|
|
1070 movlw softwareversion_y
|
|
1071 call write_external_eeprom
|
|
1072 movf batt_voltage+0,W ; Battery voltage
|
|
1073 call write_external_eeprom
|
|
1074 movf batt_voltage+1,W
|
|
1075 call write_external_eeprom
|
|
1076
|
|
1077 GETCUSTOM8 d'20' ; sampling rate in WREG
|
|
1078 btfsc FLAG_apnoe_mode ; Apnoe mode?
|
|
1079 movlw d'1' ; Apnoe sampling rate
|
|
1080 call write_external_eeprom
|
|
1081
|
|
1082 movlw d'2' ; information size temperature
|
|
1083 movwf temp1 ; copy to bits 0-3
|
|
1084 swapf temp1,F ; swap nibbels 0-3 with 4-7
|
|
1085 GETCUSTOM8 d'21' ; Divisor temperature
|
|
1086 addwf temp1,W ; copy to bits 0-3, result in WREG
|
|
1087 call write_external_eeprom
|
|
1088
|
|
1089 movlw d'2' ; information size deco
|
|
1090 movwf temp1 ; copy to bits 0-3
|
|
1091 swapf temp1,F ; swap nibbels 0-3 with 4-7
|
|
1092 GETCUSTOM8 d'22' ; Divisor deco
|
|
1093 addwf temp1,W ; copy to bits 0-3, result in WREG
|
|
1094 call write_external_eeprom
|
|
1095
|
|
1096 movlw d'2' ; information size tank
|
|
1097 movwf temp1 ; copy to bits 0-3
|
|
1098 swapf temp1,F ; swap nibbels 0-3 with 4-7
|
|
1099 GETCUSTOM8 d'23' ; Divisor Tank
|
|
1100 addwf temp1,W ; copy to bits 0-3, result in WREG
|
|
1101 call write_external_eeprom
|
|
1102
|
|
1103 movlw d'3' ; information size pp02
|
|
1104 movwf temp1 ; copy to bits 0-3
|
|
1105 swapf temp1,F ; swap nibbels 0-3 with 4-7
|
|
1106 GETCUSTOM8 d'24' ; Divisor pp02
|
|
1107 addwf temp1,W ; copy to bits 0-3, result in WREG
|
|
1108 call write_external_eeprom
|
|
1109
|
|
1110 movlw d'9' ; information size Decodebug
|
|
1111 movwf temp1 ; copy to bits 0-3
|
|
1112 swapf temp1,F ; swap nibbels 0-3 with 4-7
|
|
1113 GETCUSTOM8 d'25' ; Divisor Decodebug
|
|
1114 addwf temp1,W ; copy to bits 0-3, result in WREG
|
|
1115 call write_external_eeprom
|
|
1116
|
|
1117 movlw d'0' ; information size nuy2
|
|
1118 movwf temp1 ; copy to bits 0-3
|
|
1119 swapf temp1,F ; swap nibbels 0-3 with 4-7
|
|
1120 GETCUSTOM8 d'26' ; Divisor nuy2
|
|
1121 addwf temp1,W ; copy to bits 0-3, result in WREG
|
|
1122 call write_external_eeprom
|
|
1123
|
|
1124 read_int_eeprom d'26' ; Read Salinity from EEPROM
|
|
1125 movf EEDATA,W
|
|
1126 call write_external_eeprom ; Store Salinity to Dive
|
|
1127
|
|
1128 movlw d'0' ; Spare
|
|
1129 call write_external_eeprom
|
|
1130
|
|
1131 movlw 0xFB ; Header stop
|
|
1132 call write_external_eeprom
|
|
1133 movlw 0xFB
|
|
1134 call write_external_eeprom
|
|
1135
|
|
1136 ; Increase total dive counter
|
|
1137 read_int_eeprom d'2' ; Read byte (stored in EEDATA)
|
|
1138 movff EEDATA,temp1 ; Low byte
|
|
1139 read_int_eeprom d'3' ; Read byte (stored in EEDATA)
|
|
1140 movff EEDATA,temp2 ; high byte
|
|
1141 bcf STATUS,C
|
|
1142 movlw d'1'
|
|
1143 addwf temp1
|
|
1144 movlw d'0'
|
|
1145 addwfc temp2
|
|
1146 movff temp1,EEDATA
|
|
1147 write_int_eeprom d'2' ; write byte stored in EEDATA
|
|
1148 movff temp2,EEDATA
|
|
1149 write_int_eeprom d'3' ; write byte stored in EEDATA
|
|
1150
|
|
1151 GETCUSTOM15 .28 ; Logbook Offset -> lo, hi
|
|
1152 tstfsz lo ; lo=0?
|
|
1153 bra change_logbook_offset1 ; No, adjust offset
|
|
1154 tstfsz hi ; hi=0?
|
|
1155 bra change_logbook_offset1 ; No, adjust offset
|
|
1156 bra change_logbook_offset2 ; lo=0 and hi=0 -> skip Offset routine
|
|
1157 change_logbook_offset1:
|
|
1158 movlw d'1'
|
|
1159 addwf lo
|
|
1160 movlw d'0'
|
|
1161 addwfc hi
|
|
1162 movlw d'112' ; CF28 *4 Bytes...
|
|
1163 addlw 0x82
|
|
1164 movwf EEADR
|
|
1165 movff lo,EEDATA
|
|
1166 call write_eeprom ; Lowbyte
|
|
1167 movlw d'112' ; CF28 *4 Bytes...
|
|
1168 addlw 0x83
|
|
1169 movwf EEADR
|
|
1170 movff hi,EEDATA
|
|
1171 call write_eeprom ; Highbyte
|
|
1172
|
|
1173 change_logbook_offset2:
|
|
1174 bcf simulatormode_active ; if we were in simulator mode
|
|
1175 call clear_LEDusb
|
|
1176
|
|
1177 end_dive_common:
|
|
1178 btfsc restore_deco_data ; Restore decodata?
|
|
1179 call simulator_restore_tissue_data ; Yes!
|
|
1180
|
|
1181 call deco_main_gradient_array
|
|
1182 movlb b'00000001' ; select ram bank 1
|
|
1183
|
|
1184 clrf surface_interval+0
|
|
1185 clrf surface_interval+1 ; Clear surface interval timer
|
|
1186
|
|
1187 goto surfloop ; and return to surfaceloop
|
|
1188
|
|
1189 timeout_divemode:
|
|
1190 btfss realdive ; Dive longer then one minute
|
|
1191 return
|
|
1192
|
|
1193 btfsc FLAG_apnoe_mode ; In Apnoe mode?
|
|
1194 bra timeout_divemode2 ; Yes, use CF30 [min] for timeout
|
|
1195
|
|
1196 btfsc simulatormode_active ; In Simulator mode?
|
|
1197 bra timeout_divemode3 ; Yes, use fixed 5 seconds timeout
|
|
1198
|
|
1199 bcf divemode
|
|
1200 incf timeout_counter,F
|
|
1201 GETCUSTOM8 d'2' ; diveloop_timeout
|
|
1202 addlw d'2' ; adds two seconds in case timout=zero!
|
|
1203 btfsc STATUS,C ; > 255?
|
|
1204 movlw d'255' ; Set to 255...
|
|
1205 decf WREG,F ; Limit to 254
|
|
1206 cpfsgt timeout_counter
|
|
1207 bsf divemode
|
|
1208 return
|
|
1209
|
|
1210 timeout_divemode2:
|
|
1211 incf timeout_counter,F ; seconds...
|
|
1212 movlw d'60'
|
|
1213 cpfseq timeout_counter ; timeout_counter=60?
|
|
1214 return ; No.
|
|
1215
|
|
1216 clrf timeout_counter
|
|
1217 bcf divemode
|
|
1218 incf apnoe_timeout_counter,F
|
|
1219 GETCUSTOM8 d'30' ; apnoe timeout [min]
|
|
1220 cpfseq apnoe_timeout_counter
|
|
1221 bsf divemode
|
|
1222 return
|
|
1223
|
|
1224 timeout_divemode3:
|
|
1225 bcf divemode
|
|
1226 incf timeout_counter,F
|
|
1227 movlw d'5' ; Fixed timeout of 5 seconds
|
|
1228 cpfsgt timeout_counter
|
|
1229 bsf divemode
|
|
1230 return
|
|
1231
|
|
1232 update_divemode1: ; update any second
|
|
1233 call set_dive_modes ; tests if depth>threshold
|
|
1234
|
|
1235 btfsc divemode
|
|
1236 call set_max_depth ; update max. depth if required
|
|
1237
|
|
1238 btfsc divemode
|
|
1239 call set_min_temp ; store min. temp if required
|
|
1240
|
|
1241 bcf temp_changed ; Display temperature?
|
|
1242 movf temperature+0,W
|
|
1243 cpfseq last_temperature+0
|
|
1244 bsf temp_changed ; Yes
|
|
1245 movf temperature+1,W
|
|
1246 cpfseq last_temperature+1
|
|
1247 bsf temp_changed ; Yes
|
|
1248 btfsc temp_changed
|
|
1249 call PLED_temp_divemode ; Displays temperature
|
|
1250
|
|
1251 bcf pres_changed ; Display new depth?
|
|
1252 movf amb_pressure+0,W
|
|
1253 cpfseq last_pressure+0
|
|
1254 bsf pres_changed ; Yes
|
|
1255 movf amb_pressure+1,W
|
|
1256 cpfseq last_pressure+1
|
|
1257 bsf pres_changed ; Yes
|
|
1258
|
|
1259 btfsc simulatormode_active ; always update depth when in simulator mode
|
|
1260 bsf pres_changed
|
|
1261
|
|
1262 btfsc pres_changed
|
|
1263 call PLED_depth ; Displays new depth
|
|
1264 return
|
|
1265
|
|
1266 update_divemode60: ; update any minute
|
|
1267 call get_battery_voltage ; gets battery voltage
|
|
1268 call set_powersafe ; red LED blinking if battery is low
|
|
1269 call PLED_max_pressure ; No, use normal max. depth
|
|
1270 call check_temp_extrema ; check for new temperature extremas
|
|
1271 bcf oneminupdate
|
|
1272 return
|
|
1273
|
|
1274 set_max_depth:
|
|
1275 movff max_pressure+0,sub_a+0
|
|
1276 movff max_pressure+1,sub_a+1
|
|
1277 movff rel_pressure+0,sub_b+0
|
|
1278 movff rel_pressure+1,sub_b+1
|
|
1279 call sub16 ; sub_c = sub_a - sub_b
|
|
1280 ; max_pressure<rel_pressure -> neg_flag=1
|
|
1281 ; rel_pressure<=max_pressure -> neg_flag=0
|
|
1282 btfss neg_flag
|
|
1283 return
|
|
1284 ;max_pressure<rel_pressure
|
|
1285 movff rel_pressure+0,max_pressure+0
|
|
1286 movff rel_pressure+1,max_pressure+1
|
|
1287 call PLED_max_pressure ; No, use normal max. depth
|
|
1288 return
|
|
1289
|
|
1290 set_min_temp:
|
|
1291 movff mintemp+0,sub_a+0
|
|
1292 movff mintemp+1,sub_a+1
|
|
1293 movff temperature+0,sub_b+0
|
|
1294 movff temperature+1,sub_b+1
|
|
1295 call sub16 ; sub_c = sub_a - sub_b
|
|
1296 ; mintemp<T -> neg_flag=1
|
|
1297 ; T<=mintemp -> neg_flag=0
|
|
1298 btfsc neg_flag
|
|
1299 return
|
|
1300 ;mintemp>=T
|
|
1301 movff temperature+0,mintemp+0
|
|
1302 movff temperature+1,mintemp+1
|
|
1303 return
|
|
1304
|
|
1305 set_dive_modes:
|
|
1306 bcf divemode2 ; Stop time
|
|
1307
|
|
1308 GETCUSTOM8 .0 ; loads dive_threshold in WREG
|
|
1309 movwf sub_a+0 ; dive_treshold is in cm
|
|
1310 clrf sub_a+1
|
|
1311
|
|
1312 movff rel_pressure+0,sub_b+0
|
|
1313 movff rel_pressure+1,sub_b+1
|
|
1314
|
|
1315 call sub16 ; sub_c = sub_a - sub_b
|
|
1316
|
|
1317 btfss neg_flag
|
|
1318 bra set_dive_modes2 ; too shallow (rel_pressure<dive_threshold)
|
|
1319
|
|
1320 btfsc realdive ; Dive longer than one minute?
|
|
1321 clrf timeout_counter
|
|
1322
|
|
1323 bsf divemode
|
|
1324 bsf divemode2 ; displayed divetime is running
|
|
1325 return
|
|
1326
|
|
1327 set_dive_modes2:
|
|
1328 btfss realdive ; dive longer then one minute?
|
|
1329 bcf divemode ; no -> this was no real dive
|
|
1330 return
|
|
1331
|
|
1332 set_powersafe:
|
|
1333 btfsc low_battery_state ; battery warning alread active?
|
|
1334 bra set_powersafe2 ; Yes, but is it still required?
|
|
1335 ; battery voltage in mV (value*256+Lowbyte=actual treshold)
|
|
1336 movlw d'12' ; 3,328V
|
|
1337 cpfsgt batt_voltage+1
|
|
1338 bra set_powersafe1
|
|
1339 return
|
|
1340
|
|
1341 set_powersafe1:
|
|
1342 movlw d'7' ; Type of Alarm (Battery Low)
|
|
1343 movwf AlarmType ; Copy to Alarm Register
|
|
1344 bsf event_occured ; Set Event Flag
|
|
1345 bsf low_battery_state ; set flag for battery warning
|
|
1346 return ; return
|
|
1347
|
|
1348 set_powersafe2:
|
|
1349 movlw d'13' ; 3,584V
|
|
1350 cpfsgt batt_voltage+1
|
|
1351 bra set_powersafe1 ; Still to low
|
|
1352 bcf low_battery_state ; clear flag for battery warning mode
|
|
1353 return
|
|
1354
|
|
1355 calc_average_depth:
|
|
1356 ; 1. Add new 2xdepth to the Sum of depths registers
|
|
1357 movff rel_pressure+0,b0_lo
|
|
1358 movff rel_pressure+1,b0_hi
|
|
1359
|
|
1360 movf b0_lo,w
|
|
1361 addwf average_depth_hold+0,F
|
|
1362 movf b0_hi,w
|
|
1363 addwfc average_depth_hold+1,F
|
|
1364 movlw d'0'
|
|
1365 addwfc average_depth_hold+2,F
|
|
1366 addwfc average_depth_hold+3,F ; Will work up to 9999mBar*60*60*24=863913600mBar
|
|
1367
|
|
1368 movf b0_lo,w
|
|
1369 addwf average_depth_hold+0,F
|
|
1370 movf b0_hi,w
|
|
1371 addwfc average_depth_hold+1,F
|
|
1372 movlw d'0'
|
|
1373 addwfc average_depth_hold+2,F
|
|
1374 addwfc average_depth_hold+3,F ; Will work up to 9999mBar*60*60*24=863913600mBar
|
|
1375
|
|
1376 ; 2. Compute Average Depth on base of average_divesecs:2
|
|
1377
|
|
1378 movff average_divesecs+0,xB+0
|
|
1379 movff average_divesecs+1,xB+1 ; Copy
|
|
1380 movff average_depth_hold+0,xC+0
|
|
1381 movff average_depth_hold+1,xC+1
|
|
1382 movff average_depth_hold+2,xC+2
|
|
1383 movff average_depth_hold+3,xC+3
|
|
1384
|
|
1385 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
|
|
1386 movff xC+0,avr_rel_pressure+0
|
|
1387 movff xC+1,avr_rel_pressure+1
|
|
1388 return
|
|
1389
|
|
1390
|
|
1391 diveloop_boot:
|
|
1392 ostc_debug 'Q' ; Sends debug-information to screen if debugmode active
|
|
1393 clrf max_pressure+0 ; clear some variables
|
|
1394 clrf max_pressure+1
|
|
1395
|
|
1396 clrf avr_rel_pressure+0
|
|
1397 clrf avr_rel_pressure+1
|
|
1398
|
|
1399 call PLED_brightness_low
|
|
1400 read_int_eeprom d'90' ; Brightness offset? (Dim>0, Normal = 0)
|
|
1401 movlw d'0'
|
|
1402 cpfsgt EEDATA
|
|
1403 call PLED_brightness_full
|
|
1404
|
|
1405 clrf average_depth_hold+0
|
|
1406 clrf average_depth_hold+1
|
|
1407 clrf average_depth_hold+2
|
|
1408 clrf average_depth_hold+3 ; Clear average depth register
|
|
1409 movlw d'1'
|
|
1410 movwf average_divesecs+0
|
|
1411 clrf average_divesecs+1
|
|
1412
|
|
1413 movlw d'1'
|
|
1414 movwf apnoe_max_pressure+0
|
|
1415 clrf apnoe_max_pressure+1
|
|
1416 clrf apnoe_surface_mins
|
|
1417 clrf apnoe_surface_secs
|
|
1418 clrf apnoe_mins
|
|
1419 clrf apnoe_secs
|
|
1420 clrf divemins+0
|
|
1421 clrf divemins+1
|
|
1422 clrf divesecs
|
|
1423 clrf samplesecs
|
|
1424 clrf apnoe_timeout_counter ; timeout in minutes
|
|
1425 clrf timeout_counter ; takes care of the timeout
|
|
1426 clrf timeout_counter2 ; Here: counts to six, then store deco data and temperature
|
|
1427 clrf AlarmType ; Clear all alarms
|
|
1428 bcf event_occured ; clear flag
|
|
1429 bcf depth_greater_100m ; clear flag
|
|
1430 setf last_diluent ; to be displayed after first calculation (range: 0 to 100 [%])
|
|
1431 clrf char_last_pointer
|
|
1432 bcf dekostop_active
|
|
1433 call get_free_EEPROM_location ; get last position in external EEPROM, may be up to 2 secs!
|
|
1434
|
|
1435 movff last_surfpressure_30min+1,int_I_pres_surface+1 ; HIGH copy surfacepressure to deco routine
|
|
1436 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; LOW copy surfacepressure to deco routine
|
|
1437 movff temperature+0,mintemp+0 ; Reset Min-Temp registers
|
|
1438 movff temperature+1,mintemp+1 ; Reset Min-Temp registers
|
|
1439
|
|
1440 clrf wait_temp ; Used to clear Bankx registers
|
|
1441 movff wait_temp,char_O_GF_low_pointer
|
|
1442 movff wait_temp,char_O_actual_pointer
|
|
1443 lfsr FSR0,0x250
|
|
1444 movlw 0x20
|
|
1445 movwf wait_temp
|
|
1446 clear_deco_lists: ; Clear Deco list
|
|
1447 clrf POSTINC0
|
|
1448 decfsz wait_temp,F
|
|
1449 bra clear_deco_lists
|
|
1450 lfsr FSR0,0x270
|
|
1451 movlw 0x20
|
|
1452 movwf wait_temp
|
|
1453 set_no_forced_stops: ; Init Deco list
|
|
1454 movlw 0x01
|
|
1455 movwf POSTINC0
|
|
1456 decfsz wait_temp,F
|
|
1457 bra set_no_forced_stops
|
|
1458 lfsr FSR0,0x290 ; clear int_O_calc_tissue_call_counter (DEBUG)
|
|
1459 clrf POSTINC0
|
|
1460 clrf POSTINC0
|
|
1461
|
|
1462 ; Load GF values into RAM
|
|
1463 GETCUSTOM8 d'32' ; GF low
|
|
1464 movff EEDATA,char_I_GF_Lo_percentage
|
|
1465 GETCUSTOM8 d'33' ; GF high
|
|
1466 movff EEDATA,char_I_GF_Hi_percentage
|
|
1467
|
|
1468 ; Start with active Stopwatch?
|
|
1469 bsf stopwatch_active
|
|
1470 GETCUSTOM8 d'41' ; =1: Start with active Stopwatch
|
|
1471 movwf lo
|
|
1472 movlw d'1'
|
|
1473 cpfseq lo ; CF41=1?
|
|
1474 bcf stopwatch_active ; No!
|
|
1475
|
|
1476 ; Init profile recording parameters
|
|
1477 GETCUSTOM8 d'20' ; sample rate
|
|
1478 movwf samplesecs_value ; to avoid EEPROM access in the ISR
|
|
1479 GETCUSTOM8 d'21'
|
|
1480 movwf divisor_temperature ; load divisors for profile storage
|
|
1481 GETCUSTOM8 d'22'
|
|
1482 movwf divisor_deco
|
|
1483 GETCUSTOM8 d'23'
|
|
1484 movwf divisor_tank
|
|
1485 GETCUSTOM8 d'24'
|
|
1486 movwf divisor_ppo2
|
|
1487 GETCUSTOM8 d'25'
|
|
1488 movwf divisor_deco_debug
|
|
1489 GETCUSTOM8 d'26'
|
|
1490 movwf divisor_nuy2
|
|
1491
|
|
1492 btfss FLAG_apnoe_mode ; In Apnoe mode?
|
|
1493 bra divemode1
|
|
1494 ; Overwrite some parameters in Apnoe mode....
|
|
1495 movlw d'1'
|
|
1496 movwf samplesecs_value ; to avoid EEPROM access in the ISR
|
|
1497
|
|
1498 divemode1:
|
|
1499 read_int_eeprom d'36' ; Read mix 1 ppO2
|
|
1500 btfsc FLAG_const_ppO2_mode
|
|
1501 movff EEDATA,char_I_const_ppO2 ; Set ppO2 setpoint if in ppO2 mode
|
|
1502
|
|
1503 call clear_LEDnofly ; Clear flags
|
|
1504 bcf low_battery_state ; clear flag for battery warning mode
|
|
1505 bcf header_stored
|
|
1506 bcf premenu
|
|
1507 bcf realdive
|
|
1508 bsf update_divetime ; set flag
|
|
1509 btfss simulatormode_active ; do not disable in simulator mode!
|
|
1510 call disable_rs232 ; Disable RS232 unless in external O2 Sensor mode
|
|
1511
|
|
1512 read_int_eeprom d'33' ; Read byte (stored in EEDATA)
|
|
1513 movff EEDATA,active_gas ; Read start gas (1-5)
|
|
1514
|
|
1515 ; Read Start Gas and configure char_I_He_ratio, char_I_O2_ratio and char_I_N2_ratio
|
|
1516 decf active_gas,W ; Gas 0-4
|
|
1517 mullw d'4'
|
|
1518 movf PRODL,W
|
|
1519 addlw d'7' ; = address for He ratio
|
|
1520 movwf EEADR
|
|
1521 call read_eeprom ; Read He ratio
|
|
1522 movff EEDATA,char_I_He_ratio ; And copy into hold register
|
|
1523 decf active_gas,W ; Gas 0-4
|
|
1524 mullw d'4'
|
|
1525 movf PRODL,W
|
|
1526 addlw d'6' ; = address for O2 ratio
|
|
1527 movwf EEADR
|
|
1528 call read_eeprom ; Read O2 ratio
|
|
1529 movff EEDATA, char_I_O2_ratio ; O2 ratio
|
|
1530 movff char_I_He_ratio, wait_temp ; copy into bank1 register
|
|
1531 bsf STATUS,C ; Borrow bit
|
|
1532 movlw d'100' ; 100%
|
|
1533 subfwb wait_temp,W ; minus He
|
|
1534 bsf STATUS,C ; Borrow bit
|
|
1535 subfwb EEDATA,F ; minus O2
|
|
1536 movff EEDATA, char_I_N2_ratio ; = N2!
|
|
1537
|
|
1538 ; New in 1.09 - DecoGas can be configured to achieve exact decompression proposal
|
|
1539 ; required variables
|
|
1540 ; These values are set when the OSTC is in decompression mode - will be done in routine "check_decogas"
|
|
1541 ; char_I_deco_gas_change; ; next gas change in meter
|
|
1542 ; char_I_deco_N2_ratio; ; next gas N2
|
|
1543 ; char_I_deco_He_ratio; ; next gas He
|
|
1544 clrf lo
|
|
1545 movff lo, char_I_deco_gas_change ; clear
|
|
1546 movff lo, char_I_deco_N2_ratio ; clear
|
|
1547 movff lo, char_I_deco_He_ratio ; clear
|
|
1548 bcf multi_gf_display ; Do not display the multi-gf table screen
|
|
1549 return |