comparison code_part1/OSTC_code_asm_part1/divemode.asm @ 598:f3735da18809

NEW: CF65: Show a safety stop for no-deco dives Texts 194 and 227 need translation
author heinrichsweikamp
date Sun, 24 Jun 2012 12:45:34 +0200
parents 16f4eafc197e
children 76b85952b9cd
comparison
equal deleted inserted replaced
597:8172a7ce6db1 598:f3735da18809
65 bra diveloop_loop1c ; One Second Tasks in const_ppO2 mode 65 bra diveloop_loop1c ; One Second Tasks in const_ppO2 mode
66 66
67 ; Tasks only for OC modes 67 ; Tasks only for OC modes
68 call check_ppO2 ; check ppO2 and displays warning if required 68 call check_ppO2 ; check ppO2 and displays warning if required
69 call calc_deko_divemode ; calculate decompression and display result (any two seconds) 69 call calc_deko_divemode ; calculate decompression and display result (any two seconds)
70 btfsc show_safety_stop ; Show the safety stop?
71 call PLED_show_safety_stop ; Yes, show/delete if done.
70 bra diveloop_loop1x ; Common Tasks 72 bra diveloop_loop1x ; Common Tasks
71 73
72 ; Tasks only for Gauge mode 74 ; Tasks only for Gauge mode
73 diveloop_loop1a: 75 diveloop_loop1a:
74 btfss premenu ; Is the divemode menu active? 76 btfss premenu ; Is the divemode menu active?
95 97
96 ; Tasks only for ppO2 mode 98 ; Tasks only for ppO2 mode
97 diveloop_loop1c: 99 diveloop_loop1c:
98 call PLED_const_ppO2_value ; display const ppO2 setting in [bar] 100 call PLED_const_ppO2_value ; display const ppO2 setting in [bar]
99 call calc_deko_divemode ; calculate decompression and display result (any two seconds) 101 call calc_deko_divemode ; calculate decompression and display result (any two seconds)
102 btfsc show_safety_stop ; Show the safety stop?
103 call PLED_show_safety_stop ; Yes, show/delete if done.
100 btfsc is_bailout ; Are we in Bailout mode? 104 btfsc is_bailout ; Are we in Bailout mode?
101 call check_ppO2_bail ; Yes, display ppO2 (If required) 105 call check_ppO2_bail ; Yes, display ppO2 (If required)
102 106
103 bra diveloop_loop1x ; Common Tasks 107 bra diveloop_loop1x ; Common Tasks
104 108
216 return 220 return
217 221
218 divemode_apnoe_tasks2: 222 divemode_apnoe_tasks2:
219 btfss FLAG_active_descent ; Are descending? 223 btfss FLAG_active_descent ; Are descending?
220 return ; No, We are at the surface 224 return ; No, We are at the surface
221 rcall apnoe_calc_maxdepth ; Yes! 225 call apnoe_calc_maxdepth ; Yes!
222 226
223 divemode_apnoe_tasks3: 227 divemode_apnoe_tasks3:
224 call PLED_apnoe_clear_surface ; Clear Surface timer 228 call PLED_apnoe_clear_surface ; Clear Surface timer
225 229
226 clrf apnoe_timeout_counter ; Delete timeout 230 clrf apnoe_timeout_counter ; Delete timeout
271 275
272 bsf twosecupdate ; No, but next second! 276 bsf twosecupdate ; No, but next second!
273 ; Routines used in the "other second" 277 ; Routines used in the "other second"
274 call calc_average_depth ; calculate average depth 278 call calc_average_depth ; calculate average depth
275 call calc_velocity ; calculate vertical velocity and display if > threshold (every two seconds) 279 call calc_velocity ; calculate vertical velocity and display if > threshold (every two seconds)
280 call set_reset_safety_stop ; Set flags for safety stop and/or reset safety stop
276 281
277 ; Calculate CNS 282 ; Calculate CNS
278 clrf WREG 283 clrf WREG
279 movff WREG,char_I_step_is_1min ; Make sure to be in 2sec mode. 284 movff WREG,char_I_step_is_1min ; Make sure to be in 2sec mode.
280 285
371 read_int_eeprom d'32' ; read gas_change_depth Gas5 376 read_int_eeprom d'32' ; read gas_change_depth Gas5
372 btfss gaslist_active,4 ; Apply depth? 377 btfss gaslist_active,4 ; Apply depth?
373 clrf EEDATA ; No, clear! 378 clrf EEDATA ; No, clear!
374 movff EEDATA,char_I_deco_gas_change+4 ; Yes! 379 movff EEDATA,char_I_deco_gas_change+4 ; Yes!
375 return 380 return
381
382 set_reset_safety_stop: ; Set flags for safety stop and/or reset safety stop
383 GETCUSTOM8 d'65' ; Use safety stop
384 decfsz WREG,F ; WREG=1?
385 bra delete_safety_stop ; No, don't show safety stop
386
387 btfsc dekostop_active ; Is a deco stop displayed?
388 bra delete_safety_stop ; Yes, don't show safety stop
389 ; Below "safety_stop_reset"? Set flag and reset count-down timer
390 SAFE_2BYTE_COPY rel_pressure, lo
391 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar]
392 movff lo,sub_a+0
393 movff hi,sub_a+1
394 movlw LOW safety_stop_reset
395 movwf sub_b+0
396 movlw HIGH safety_stop_reset
397 movwf sub_b+1
398 call sub16 ; sub_c = sub_a - sub_b
399 btfss neg_flag
400 bra reset_safety_stop ; Below 10m, reset safety stop
401
402 ; Above "safety_stop_end"? Clear flag.
403 SAFE_2BYTE_COPY rel_pressure, lo
404 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar]
405 movff lo,sub_a+0
406 movff hi,sub_a+1
407 movlw LOW safety_stop_end
408 movwf sub_b+0
409 movlw HIGH safety_stop_end
410 movwf sub_b+1
411 call sub16 ; sub_c = sub_a - sub_b
412 btfsc neg_flag
413 bra delete_safety_stop ; Above 3m, remove safety stop
414
415 ; Above "safety_stop_start"? Activate safety stop
416 SAFE_2BYTE_COPY rel_pressure, lo
417 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar]
418 movff lo,sub_a+0
419 movff hi,sub_a+1
420 movlw LOW safety_stop_start
421 movwf sub_b+0
422 movlw HIGH safety_stop_start
423 movwf sub_b+1
424 call sub16 ; sub_c = sub_a - sub_b
425 btfsc neg_flag
426 bra acivate_safety_stop ; Above 5m, activate safety stop
427
428 bra reset_safety_stop2 ; Pause safety stop
429
430 acivate_safety_stop:
431 tstfsz safety_stop_countdown ; Countdown at zero?
432 bsf show_safety_stop ; No, Set flag!
433 return
434
435 delete_safety_stop:
436 bcf show_safety_stop ; Clear flag
437 clrf safety_stop_countdown ; reset timer
438 return ; Done.
439
440 reset_safety_stop:
441 movlw safety_stop_length ;[s]
442 movwf safety_stop_countdown ; reset timer
443 reset_safety_stop2:
444 btfss safety_stop_active ; Safety stop shown
445 return ; No, don't delete it
446 bcf show_safety_stop ; Clear flag
447 bcf safety_stop_active ; Clear flag
448 call PLED_clear_decoarea ; Yes, Clear stop
449 goto PLED_display_ndl_mask ; Show NDL again (And return)
376 450
377 ;----------------------------------------------------------------------------- 451 ;-----------------------------------------------------------------------------
378 ; calculate ppO2 in 0.01bar (e.g. 150 = 1.50 bar ppO2) 452 ; calculate ppO2 in 0.01bar (e.g. 150 = 1.50 bar ppO2)
379 set_actual_ppo2: 453 set_actual_ppo2:
380 SAFE_2BYTE_COPY amb_pressure, xA ; P_amb in millibar (1000 = 1.00 bar). 454 SAFE_2BYTE_COPY amb_pressure, xA ; P_amb in millibar (1000 = 1.00 bar).
914 bcf ppO2_show_value ; clear flag 988 bcf ppO2_show_value ; clear flag
915 btfsc neg_flag 989 btfsc neg_flag
916 bsf ppO2_show_value ; set flag if required 990 bsf ppO2_show_value ; set flag if required
917 991
918 ;check if we are within our warning thresholds! 992 ;check if we are within our warning thresholds!
919 bcf ppO2_warn_value ; clear flag
920 movff xC+0,sub_b+0 993 movff xC+0,sub_b+0
921 movff xC+1,sub_b+1 994 movff xC+1,sub_b+1
922 GETCUSTOM8 d'18' ; ppo2_warning_high 995 GETCUSTOM8 d'18' ; ppo2_warning_high
923 mullw d'100' ; ppo2_warning_high*100 996 mullw d'100' ; ppo2_warning_high*100
924 movff PRODL,sub_a+0 997 movff PRODL,sub_a+0
927 btfss neg_flag 1000 btfss neg_flag
928 bra check_ppO2_0 ; Not too high 1001 bra check_ppO2_0 ; Not too high
929 1002
930 check_ppO2_bail2: 1003 check_ppO2_bail2:
931 bsf ppO2_show_value ; set flag if required 1004 bsf ppO2_show_value ; set flag if required
932 bsf ppO2_warn_value ; set flag
933 movlw d'5' ; Type of Alarm 1005 movlw d'5' ; Type of Alarm
934 movwf AlarmType ; Copy to Alarm Register 1006 movwf AlarmType ; Copy to Alarm Register
935 bsf event_occured ; Set Event Flag 1007 bsf event_occured ; Set Event Flag
936 1008
937 check_ppO2_0: 1009 check_ppO2_0:
943 movff PRODH,sub_a+1 1015 movff PRODH,sub_a+1
944 call sub16 1016 call sub16
945 btfsc neg_flag 1017 btfsc neg_flag
946 bra check_ppO2_1 ; Not too low 1018 bra check_ppO2_1 ; Not too low
947 1019
948 bsf ppO2_warn_value ; set flag
949 bsf ppO2_show_value ; show ppO2 if below threshold! 1020 bsf ppO2_show_value ; show ppO2 if below threshold!
950 movlw d'4' ; Type of Alarm 1021 movlw d'4' ; Type of Alarm
951 movwf AlarmType ; Copy to Alarm Register 1022 movwf AlarmType ; Copy to Alarm Register
952 bsf event_occured ; Set Event Flag 1023 bsf event_occured ; Set Event Flag
953 1024
1146 endif 1217 endif
1147 1218
1148 ; Dive finished (and longer then one minute or Apnoe timeout occured) 1219 ; Dive finished (and longer then one minute or Apnoe timeout occured)
1149 1220
1150 btfsc FLAG_apnoe_mode ; Calc max. depth (again) for very short apnoe dives 1221 btfsc FLAG_apnoe_mode ; Calc max. depth (again) for very short apnoe dives
1151 rcall apnoe_calc_maxdepth 1222 call apnoe_calc_maxdepth
1152 1223
1153 ; calculate desaturation time 1224 ; calculate desaturation time
1154 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; Pass surface to desat routine ! 1225 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; Pass surface to desat routine !
1155 movff last_surfpressure_30min+1,int_I_pres_surface+1 1226 movff last_surfpressure_30min+1,int_I_pres_surface+1
1156 1227
1808 ; setf last_diluent ; to be displayed after first calculation (range: 0 to 100 [%]) 1879 ; setf last_diluent ; to be displayed after first calculation (range: 0 to 100 [%])
1809 bcf dekostop_active 1880 bcf dekostop_active
1810 bcf is_bailout ;=1: CC mode, but bailout active! 1881 bcf is_bailout ;=1: CC mode, but bailout active!
1811 bcf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode 1882 bcf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode
1812 bcf tts_extra_time ;=1: Compute TTS if extra time spent at current depth 1883 bcf tts_extra_time ;=1: Compute TTS if extra time spent at current depth
1884 bcf show_safety_stop ;=1: Show the safety stop
1885 clrf safety_stop_countdown ; Clear count-down
1813 1886
1814 call get_free_EEPROM_location ; get last position in external EEPROM, may be up to 2 secs! 1887 call get_free_EEPROM_location ; get last position in external EEPROM, may be up to 2 secs!
1815 1888
1816 btfsc simulatormode_active 1889 btfsc simulatormode_active
1817 bra diveloop_boot_1 1890 bra diveloop_boot_1