Mercurial > public > hwos_code
comparison src/divemode.asm @ 145:e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
author | heinrichsweikamp |
---|---|
date | Tue, 05 Aug 2014 16:55:09 +0200 |
parents | 2852b0bd6391 |
children | 022b886eddaf |
comparison
equal
deleted
inserted
replaced
144:b839972db982 | 145:e3ac5b2021bc |
---|---|
104 | 104 |
105 ; btfsc FLAG_ccr_mode ; In CCR mode | 105 ; btfsc FLAG_ccr_mode ; In CCR mode |
106 ; call TFT_active_gas_divemode ; Update Setpoint every second | 106 ; call TFT_active_gas_divemode ; Update Setpoint every second |
107 | 107 |
108 call compute_ppo2 ; compute mv_sensorX and ppo2_sensorX arrays | 108 call compute_ppo2 ; compute mv_sensorX and ppo2_sensorX arrays |
109 call check_sensors ; Check O2 sensor thresholds for fallback | |
109 | 110 |
110 bcf onesecupdate ; one seconds update done | 111 bcf onesecupdate ; one seconds update done |
111 | 112 |
112 diveloop_loop3: | 113 diveloop_loop3: |
113 rcall test_switches_divemode ; Check switches in divemode | 114 rcall test_switches_divemode ; Check switches in divemode |
281 movff char_I_const_ppO2, char_I_actual_ppO2 ; ...copy last ppO2 to buffer register | 282 movff char_I_const_ppO2, char_I_actual_ppO2 ; ...copy last ppO2 to buffer register |
282 return | 283 return |
283 | 284 |
284 | 285 |
285 calc_deko_divemode2: | 286 calc_deko_divemode2: |
286 bcf twosecupdate | 287 bcf twosecupdate |
287 | 288 |
288 btfsc FLAG_apnoe_mode ; Done for Apnoe or Gauge mode | 289 btfsc FLAG_apnoe_mode ; Done for Apnoe or Gauge mode |
289 return | 290 return |
290 btfsc FLAG_gauge_mode ; Done for Apnoe or Gauge mode | 291 btfsc FLAG_gauge_mode ; Done for Apnoe or Gauge mode |
291 return | 292 return |
292 | 293 |
293 extern deco_setup_dive | 294 extern deco_setup_dive |
294 call deco_setup_dive ; Pass all parameters to the C code | 295 call deco_setup_dive ; Pass all parameters to the C code |
296 | |
297 bcf setpoint_fallback ; =1: Fallback to SP1 due to external O2 sensor failure | |
295 | 298 |
296 TSTOSS opt_ccr_mode ; =0: Fixed SP, =1: Sensor | 299 TSTOSS opt_ccr_mode ; =0: Fixed SP, =1: Sensor |
297 bra calc_deko_divemode2a | 300 bra calc_deko_divemode2a |
298 rcall divemode_setup_sensor_values ; Setup sensor values | 301 rcall divemode_setup_sensor_values ; Setup sensor values |
302 movff sensor_setpoint,char_I_const_ppO2; Copy sensor result | |
303 | |
304 TSTOSS opt_sensor_fallback ; =1: Fallback to SP1 when sensor is lost | |
305 bra calc_deko_divemode2a ; Never fallback | |
306 ; Check if we should fallback to SP1 | |
307 btfsc use_02_sensor1 | |
308 bra calc_deko_divemode2a ; At least one sensor is active, no fallback | |
309 btfsc use_02_sensor2 | |
310 bra calc_deko_divemode2a ; At least one sensor is active, no fallback | |
311 btfsc use_02_sensor3 | |
312 bra calc_deko_divemode2a ; At least one sensor is active, no fallback | |
313 ; No sensor in use -> fallback | |
314 movff char_I_setpoint_cbar+0,char_I_const_ppO2 ; Setup fixed Setpoint (Always fallback to SP1), overwrite sensor result | |
315 bsf setpoint_fallback ; =1: Fallback to SP1 due to external O2 sensor failure | |
299 | 316 |
300 calc_deko_divemode2a: | 317 calc_deko_divemode2a: |
301 SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; C-code needs the ambient pressure | 318 SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; C-code needs the ambient pressure |
302 clrf WREG | 319 clrf WREG |
303 movff WREG,char_I_step_is_1min ; Force 2 second deco mode | 320 movff WREG,char_I_step_is_1min ; Force 2 second deco mode |
370 ; sum up sensor values (in xA:2) and active sensors in (xB:2) | 387 ; sum up sensor values (in xA:2) and active sensors in (xB:2) |
371 clrf xB+0 | 388 clrf xB+0 |
372 clrf xB+1 | 389 clrf xB+1 |
373 clrf xA+0 | 390 clrf xA+0 |
374 clrf xA+1 | 391 clrf xA+1 |
375 btfss sensor1_active ; Sensor1 active? | 392 btfss use_02_sensor1 ; Sensor1 active? |
376 bra divemode_setup_sensor_values2 ; No | 393 bra divemode_setup_sensor_values2 ; No |
377 movf o2_ppo2_sensor1,W | 394 movf o2_ppo2_sensor1,W |
378 addwf xA+0 | 395 addwf xA+0 |
379 movlw .0 | 396 movlw .0 |
380 addwfc xA+1 ; Add into xA:2 | 397 addwfc xA+1 ; Add into xA:2 |
381 incf xB+0,F ; Add a sensor | 398 incf xB+0,F ; Add a sensor |
382 divemode_setup_sensor_values2: | 399 divemode_setup_sensor_values2: |
383 btfss sensor2_active ; Sensor2 active? | 400 btfss use_02_sensor2 ; Sensor2 active? |
384 bra divemode_setup_sensor_values3 ; No | 401 bra divemode_setup_sensor_values3 ; No |
385 movf o2_ppo2_sensor2,W | 402 movf o2_ppo2_sensor2,W |
386 addwf xA+0 | 403 addwf xA+0 |
387 movlw .0 | 404 movlw .0 |
388 addwfc xA+1 ; Add into xA:2 | 405 addwfc xA+1 ; Add into xA:2 |
389 incf xB+0,F ; Add a sensor | 406 incf xB+0,F ; Add a sensor |
390 divemode_setup_sensor_values3: | 407 divemode_setup_sensor_values3: |
391 btfss sensor3_active ; Sensor3 active? | 408 btfss use_02_sensor3 ; Sensor3 active? |
392 bra divemode_setup_sensor_values4 ; No | 409 bra divemode_setup_sensor_values4 ; No |
393 movf o2_ppo2_sensor3,W | 410 movf o2_ppo2_sensor3,W |
394 addwf xA+0 | 411 addwf xA+0 |
395 movlw .0 | 412 movlw .0 |
396 addwfc xA+1 ; Add into xA:2 | 413 addwfc xA+1 ; Add into xA:2 |
397 incf xB+0,F ; Add a sensor | 414 incf xB+0,F ; Add a sensor |
398 divemode_setup_sensor_values4: | 415 divemode_setup_sensor_values4: |
399 call div16x16 ; xA/xB=xC with xA+0 as remainder | 416 call div16x16 ; xA/xB=xC with xA+0 as remainder |
400 movff xC+0,sensor_setpoint ; Copy result | 417 movff xC+0,sensor_setpoint ; Copy result |
401 movff sensor_setpoint,char_I_const_ppO2 ; use sensor ppO2 | |
402 return | 418 return |
403 | 419 |
404 calc_velocity: ; called every two seconds | 420 calc_velocity: ; called every two seconds |
405 btfss divemode | 421 btfss divemode |
406 bra do_not_display_velocity ; display velocity only in divemode (Not at the surface after dive) | 422 bra do_not_display_velocity ; display velocity only in divemode (Not at the surface after dive) |
1370 rcall check_and_store_gf_violation ; Yes, Sets warnings, if required | 1386 rcall check_and_store_gf_violation ; Yes, Sets warnings, if required |
1371 btfsc decostop_active ; In deco mode? | 1387 btfsc decostop_active ; In deco mode? |
1372 call TFT_ftts ; Show @+x time | 1388 call TFT_ftts ; Show @+x time |
1373 btfsc use_agf ; In aGF mode? | 1389 btfsc use_agf ; In aGF mode? |
1374 rcall warn_agf ; Yes, show a warning for it | 1390 rcall warn_agf ; Yes, show a warning for it |
1391 btfsc setpoint_fallback ; =1: Fallback to SP1 due to external O2 sensor failure | |
1392 rcall warn_fallback ; Show the warning | |
1375 | 1393 |
1376 divemode_check_for_warnings2: | 1394 divemode_check_for_warnings2: |
1377 ; Display the warning icon? | 1395 ; Display the warning icon? |
1378 btfsc warning_active ; Any warning active? | 1396 btfsc warning_active ; Any warning active? |
1379 call TFT_divemode_warning ; Yes | 1397 call TFT_divemode_warning ; Yes |
1547 return | 1565 return |
1548 | 1566 |
1549 warn_agf: | 1567 warn_agf: |
1550 incf warning_counter,F ; increase counter | 1568 incf warning_counter,F ; increase counter |
1551 call TFT_warning_agf ; Show aGF warning | 1569 call TFT_warning_agf ; Show aGF warning |
1552 ; bsf warning_active ; Set Warning flag | 1570 return |
1571 | |
1572 warn_fallback: | |
1573 incf warning_counter,F ; increase counter | |
1574 call TFT_warning_fallback ; Show fallback warning | |
1575 bsf warning_active ; Set Warning flag | |
1553 return | 1576 return |
1554 | 1577 |
1555 | 1578 |
1556 END | 1579 END |