comparison src/divemode.asm @ 195:bca0f054f023

allow auto-return from setpoint fallback
author heinrichsweikamp
date Wed, 05 Nov 2014 14:43:13 +0100
parents 901c10831e4e
children 3bbfac29ba3e
comparison
equal deleted inserted replaced
194:c241d3af0e47 195:bca0f054f023
106 106
107 ; btfsc FLAG_ccr_mode ; In CCR mode 107 ; btfsc FLAG_ccr_mode ; In CCR mode
108 ; call TFT_active_gas_divemode ; Update Setpoint every second 108 ; call TFT_active_gas_divemode ; Update Setpoint every second
109 109
110 call compute_ppo2 ; compute mv_sensorX and ppo2_sensorX arrays 110 call compute_ppo2 ; compute mv_sensorX and ppo2_sensorX arrays
111 call check_sensors ; Check O2 sensor thresholds for fallback
112 111
113 diveloop_loop3: 112 diveloop_loop3:
114 rcall test_switches_divemode ; Check switches in divemode 113 rcall test_switches_divemode ; Check switches in divemode
115 114
116 global diveloop_loop4 115 global diveloop_loop4
280 ; No Bailout, check for ccr mode 279 ; No Bailout, check for ccr mode
281 btfsc FLAG_ccr_mode ; If FLAG_ccr_mode=1... 280 btfsc FLAG_ccr_mode ; If FLAG_ccr_mode=1...
282 movff char_I_const_ppO2, char_I_actual_ppO2 ; ...copy last ppO2 to buffer register 281 movff char_I_const_ppO2, char_I_actual_ppO2 ; ...copy last ppO2 to buffer register
283 return 282 return
284 283
284 check_fallback_clear:
285 call check_sensors ; Setups "use_O2_sensorX" flags
286 ; Copy use flags to voting logic flags in case we are no longer in fallback
287 btfsc use_O2_sensor1
288 bsf voting_logic_sensor1
289 btfsc use_O2_sensor2
290 bsf voting_logic_sensor2
291 btfsc use_O2_sensor3
292 bsf voting_logic_sensor3
293 rcall divemode_setup_sensor_values ; Setup sensor values
294 call check_sensors ; Check O2 sensor thresholds for fallback
295 return
285 296
286 calc_deko_divemode2: 297 calc_deko_divemode2:
287 bcf twosecupdate 298 bcf twosecupdate
288 299
289 btfsc FLAG_apnoe_mode ; Done for Apnoe or Gauge mode 300 btfsc FLAG_apnoe_mode ; Done for Apnoe or Gauge mode
291 btfsc FLAG_gauge_mode ; Done for Apnoe or Gauge mode 302 btfsc FLAG_gauge_mode ; Done for Apnoe or Gauge mode
292 return 303 return
293 304
294 extern deco_setup_dive 305 extern deco_setup_dive
295 call deco_setup_dive ; Pass all parameters to the C code 306 call deco_setup_dive ; Pass all parameters to the C code
307
308
309 btfsc setpoint_fallback ; Are we in Fallback?
310 rcall check_fallback_clear ; Yes, check if we still have fallback condition
296 311
297 bcf setpoint_fallback ; =1: Fallback to SP1 due to external O2 sensor failure 312 bcf setpoint_fallback ; =1: Fallback to SP1 due to external O2 sensor failure
298 313
299 btfss FLAG_ccr_mode ; In CCR mode? 314 btfss FLAG_ccr_mode ; In CCR mode?
300 bra calc_deko_divemode2a ; Skip all the following if not in CCR mode 315 bra calc_deko_divemode2a ; Skip all the following if not in CCR mode
301 316
302 TSTOSS opt_ccr_mode ; =0: Fixed SP, =1: Sensor 317 TSTOSS opt_ccr_mode ; =0: Fixed SP, =1: Sensor
303 bra calc_deko_divemode2a 318 bra calc_deko_divemode2a
304 rcall divemode_setup_sensor_values ; Setup sensor values 319 rcall divemode_setup_sensor_values ; Setup sensor values
320 call check_sensors ; Check O2 sensor thresholds for fallback
305 movff sensor_setpoint,char_I_const_ppO2; Copy sensor result 321 movff sensor_setpoint,char_I_const_ppO2; Copy sensor result
306 322
307 TSTOSS opt_sensor_fallback ; =1: Fallback to SP1 when sensor is lost 323 TSTOSS opt_sensor_fallback ; =1: Fallback to SP1 when sensor is lost
308 bra calc_deko_divemode2a ; Never fallback 324 bra calc_deko_divemode2a ; Never fallback
309 325