Mercurial > public > hwos_code
comparison src/divemode.asm @ 399:db25f2028074
CHANGE: New segmented speed graph in divemode
NEW: Safety Stop can be configured (Start-, End- and reset-depth + length of stop) via PC
author | heinrichsweikamp |
---|---|
date | Tue, 24 Nov 2015 16:22:52 +0100 |
parents | 1f2e35f5a5aa |
children | 6e60012bb3fc |
comparison
equal
deleted
inserted
replaced
398:1f2e35f5a5aa | 399:db25f2028074 |
---|---|
450 call div16x16 ; xA/xB=xC with xA+0 as remainder | 450 call div16x16 ; xA/xB=xC with xA+0 as remainder |
451 movff xC+0,sensor_setpoint ; Copy result | 451 movff xC+0,sensor_setpoint ; Copy result |
452 return | 452 return |
453 | 453 |
454 calc_velocity: ; called every two seconds | 454 calc_velocity: ; called every two seconds |
455 btfss divemode | 455 btfsc display_velocity |
456 return ; display velocity only in divemode (Not at the surface after dive) | 456 bra calc_velocity1 ; Always update if already displayed |
457 | 457 btfss divemode2 |
458 calc_velocity2: | 458 return ; display velocity only if deepter then 1m (Not at the surface after the dive) |
459 calc_velocity1: | |
459 SAFE_2BYTE_COPY amb_pressure, sub_a | 460 SAFE_2BYTE_COPY amb_pressure, sub_a |
460 movff last_pressure_velocity+0,sub_b+0 | 461 movff last_pressure_velocity+0,sub_b+0 |
461 movff last_pressure_velocity+1,sub_b+1 | 462 movff last_pressure_velocity+1,sub_b+1 |
462 movff sub_a+0,last_pressure_velocity+0 ; store old value for velocity | 463 movff sub_a+0,last_pressure_velocity+0 ; store old value for velocity |
463 movff sub_a+1,last_pressure_velocity+1 | 464 movff sub_a+1,last_pressure_velocity+1 |
484 cpfsgt divA+0 ; limit to 99m/min | 485 cpfsgt divA+0 ; limit to 99m/min |
485 bra calc_velocity3 | 486 bra calc_velocity3 |
486 movwf divA+0 ; divA=99 | 487 movwf divA+0 ; divA=99 |
487 | 488 |
488 calc_velocity3: | 489 calc_velocity3: |
490 ; Copy old speeds | |
491 movff old_velocity+2,old_velocity+3 | |
492 movff old_velocity+1,old_velocity+2 | |
493 movff old_velocity+0,old_velocity+1 | |
494 movff divA+0,old_velocity+0 | |
495 | |
496 ; movff old_velocity+3,WREG | |
497 ; addwf divA+0,F ; add old speed | |
498 ; bcf STATUS,C | |
499 ; rrcf divA+0,F ; /2 | |
500 ; movff old_velocity+2,WREG | |
501 ; addwf divA+0,F ; add old speed | |
502 ; bcf STATUS,C | |
503 ; rrcf divA+0,F ; /2 | |
504 ; movff old_velocity+1,WREG | |
505 ; addwf divA+0,F ; add old speed | |
506 ; bcf STATUS,C | |
507 ; rrcf divA+0,F ; /2 | |
508 ; movff old_velocity+0,WREG | |
509 ; addwf divA+0,F ; add old speed | |
510 ; bcf STATUS,C | |
511 ; rrcf divA+0,F ; /2 | |
489 call TFT_display_velocity ; With divA+0 = m/min... | 512 call TFT_display_velocity ; With divA+0 = m/min... |
490 return | 513 return |
491 | 514 |
492 | 515 |
493 ;============================================================================= | 516 ;============================================================================= |
496 TSTOSS opt_enable_safetystop ; =1: A safety stop is shown | 519 TSTOSS opt_enable_safetystop ; =1: A safety stop is shown |
497 bra delete_safety_stop ; No, don't show safety stop | 520 bra delete_safety_stop ; No, don't show safety stop |
498 | 521 |
499 btfsc decostop_active ; Is a deco stop displayed? | 522 btfsc decostop_active ; Is a deco stop displayed? |
500 bra delete_safety_stop ; Yes, don't show safety stop | 523 bra delete_safety_stop ; Yes, don't show safety stop |
501 ; Below "safety_stop_reset"? Set flag and reset count-down timer | 524 ; Below "opt_safety_stop_reset"? Set flag and reset count-down timer |
502 SAFE_2BYTE_COPY rel_pressure, lo | 525 SAFE_2BYTE_COPY rel_pressure, lo |
503 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | 526 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] |
504 movff lo,sub_a+0 | 527 movff lo,sub_a+0 |
505 movff hi,sub_a+1 | 528 movff hi,sub_a+1 |
506 movlw LOW safety_stop_reset | 529 movff opt_safety_stop_reset,WREG ; [cbar] |
507 movwf sub_b+0 | 530 mullw .10 ; mbar in PRODL:H |
508 movlw HIGH safety_stop_reset | 531 movff PRODL,sub_b+0 |
509 movwf sub_b+1 | 532 movff PRODH,sub_b+1 |
510 call subU16 ; sub_c = sub_a - sub_b | 533 call subU16 ; sub_c = sub_a - sub_b |
511 btfss neg_flag | 534 btfss neg_flag |
512 bra reset_safety_stop ; Below 10m, reset safety stop | 535 bra reset_safety_stop ; Below 10m, reset safety stop |
513 | 536 |
514 ; Above "safety_stop_end"? Clear flag. | 537 ; Above "opt_safety_stop_end"? Clear flag. |
515 SAFE_2BYTE_COPY rel_pressure, lo | 538 SAFE_2BYTE_COPY rel_pressure, lo |
516 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | 539 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] |
517 movff lo,sub_a+0 | 540 movff lo,sub_a+0 |
518 movff hi,sub_a+1 | 541 movff hi,sub_a+1 |
519 movlw LOW safety_stop_end | 542 movff opt_safety_stop_end,WREG ; [cbar] |
520 movwf sub_b+0 | 543 mullw .10 ; mbar in PRODL:H |
521 movlw HIGH safety_stop_end | 544 movff PRODL,sub_b+0 |
522 movwf sub_b+1 | 545 movff PRODH,sub_b+1 |
523 call subU16 ; sub_c = sub_a - sub_b | 546 call subU16 ; sub_c = sub_a - sub_b |
524 btfsc neg_flag | 547 btfsc neg_flag |
525 bra delete_safety_stop ; Above 3m, remove safety stop | 548 bra delete_safety_stop ; Above 3m, remove safety stop |
526 | 549 |
527 ; Above "safety_stop_start"? Activate safety stop | 550 ; Above "opt_safety_stop_start"? Activate safety stop |
528 SAFE_2BYTE_COPY rel_pressure, lo | 551 SAFE_2BYTE_COPY rel_pressure, lo |
529 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] | 552 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] |
530 movff lo,sub_a+0 | 553 movff lo,sub_a+0 |
531 movff hi,sub_a+1 | 554 movff hi,sub_a+1 |
532 movlw LOW safety_stop_start | 555 movff opt_safety_stop_start,WREG ; [cbar] |
533 movwf sub_b+0 | 556 mullw .10 ; mbar in PRODL:H |
534 movlw HIGH safety_stop_start | 557 movff PRODL,sub_b+0 |
535 movwf sub_b+1 | 558 movff PRODH,sub_b+1 |
536 call subU16 ; sub_c = sub_a - sub_b | 559 call subU16 ; sub_c = sub_a - sub_b |
537 btfsc neg_flag | 560 btfsc neg_flag |
538 bra acivate_safety_stop ; Above 5m, activate safety stop | 561 bra acivate_safety_stop ; Above 5m, activate safety stop |
539 bra reset_safety_stop2 ; Pause safety stop | 562 bra reset_safety_stop2 ; Pause safety stop |
540 | 563 |
546 delete_safety_stop: | 569 delete_safety_stop: |
547 clrf safety_stop_countdown ; reset timer | 570 clrf safety_stop_countdown ; reset timer |
548 bra reset_safety_stop2 ; Remove safety stop from display | 571 bra reset_safety_stop2 ; Remove safety stop from display |
549 | 572 |
550 reset_safety_stop: | 573 reset_safety_stop: |
551 movlw safety_stop_length ;[s] | 574 movff opt_safety_stop_length,safety_stop_countdown ; reset timer |
552 movwf safety_stop_countdown ; reset timer | |
553 reset_safety_stop2: | 575 reset_safety_stop2: |
554 bcf show_safety_stop ; Clear flag | 576 bcf show_safety_stop ; Clear flag |
555 btfss safety_stop_active ; Safety stop shown | 577 btfss safety_stop_active ; Safety stop shown |
556 return ; No, don't delete it | 578 return ; No, don't delete it |
557 bcf safety_stop_active ; Clear flag | 579 bcf safety_stop_active ; Clear flag |
1405 bcf blinking_setpoint ; Reset blinking SP flag | 1427 bcf blinking_setpoint ; Reset blinking SP flag |
1406 call compute_ppo2 ; compute mv_sensorX and ppo2_sensorX arrays | 1428 call compute_ppo2 ; compute mv_sensorX and ppo2_sensorX arrays |
1407 bsf voting_logic_sensor1 | 1429 bsf voting_logic_sensor1 |
1408 bsf voting_logic_sensor2 | 1430 bsf voting_logic_sensor2 |
1409 bsf voting_logic_sensor3 | 1431 bsf voting_logic_sensor3 |
1410 rcall divemode_setup_sensor_values ; setup sensor values | 1432 call divemode_setup_sensor_values ; setup sensor values |
1411 | 1433 |
1412 ; Setup first SP for Fixed or Auto mode | 1434 ; Setup first SP for Fixed or Auto mode |
1413 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP | 1435 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP |
1414 sublw .1 ; opt_ccr_mode = 1 (Sensor)? | 1436 sublw .1 ; opt_ccr_mode = 1 (Sensor)? |
1415 movff char_I_setpoint_cbar+0,char_I_const_ppO2 ; No, setup fixed Setpoint (Always start with SP1) | 1437 movff char_I_setpoint_cbar+0,char_I_const_ppO2 ; No, setup fixed Setpoint (Always start with SP1) |