comparison code_part1/OSTC_code_asm_part1/divemode.asm @ 492:19b9e19ea4da

+CHANGE: Velocity display updated every second +NEW: CF60: Show graphical velocity indicator (Ascend only)
author heinrichsweikamp
date Sun, 06 Nov 2011 11:02:03 +0100
parents c7b663939737
children e9b1f162799d
comparison
equal deleted inserted replaced
491:560764da0629 492:19b9e19ea4da
78 btfsc twosecupdate ; two seconds after the last call 78 btfsc twosecupdate ; two seconds after the last call
79 bra diveloop_loop1a2 ; Common Tasks 79 bra diveloop_loop1a2 ; Common Tasks
80 80
81 bsf twosecupdate ; Routines used in the "other second" 81 bsf twosecupdate ; Routines used in the "other second"
82 call calc_average_depth ; calculate average depth 82 call calc_average_depth ; calculate average depth
83 call calc_velocity ; calculate vertical velocity and display if > threshold (every two seconds) 83 ; call calc_velocity ; calculate vertical velocity and display if > threshold (every two seconds)
84 84
85 bra diveloop_loop1x ; Common Tasks 85 bra diveloop_loop1x ; Common Tasks
86 86
87 diveloop_loop1a2: 87 diveloop_loop1a2:
88 bcf twosecupdate 88 bcf twosecupdate
136 call timeout_divemenu ; Yes, so check for timeout divemenu 136 call timeout_divemenu ; Yes, so check for timeout divemenu
137 call set_leds_divemode ; Sets warnings, if required. Also Sets buzzer 137 call set_leds_divemode ; Sets warnings, if required. Also Sets buzzer
138 btfsc enter_error_sleep ; Enter Fatal Error Routine? 138 btfsc enter_error_sleep ; Enter Fatal Error Routine?
139 call fatal_error_sleep ; Yes (In Sleepmode_vxx.asm!) 139 call fatal_error_sleep ; Yes (In Sleepmode_vxx.asm!)
140 140
141 call calc_velocity ; calculate vertical velocity and display if > threshold
142
141 bcf onesecupdate ; one seconds update done 143 bcf onesecupdate ; one seconds update done
142 144
143 diveloop_loop3: 145 diveloop_loop3:
144 btfss menubit ; Divemode menu active? 146 btfss menubit ; Divemode menu active?
145 call test_switches_divemode ; No, Check switches normal 147 call test_switches_divemode ; No, Check switches normal
276 bra calc_deko_divemode2 ; Yes, calculate and display deco data ("first second") 278 bra calc_deko_divemode2 ; Yes, calculate and display deco data ("first second")
277 279
278 bsf twosecupdate ; No, but next second! 280 bsf twosecupdate ; No, but next second!
279 ; Routines used in the "other second" 281 ; Routines used in the "other second"
280 call calc_average_depth ; calculate average depth 282 call calc_average_depth ; calculate average depth
281 call calc_velocity ; calculate vertical velocity and display if > threshold (every two seconds) 283 ; call calc_velocity ; calculate vertical velocity and display if > threshold (every two seconds)
282 284
283 ; Calculate CNS 285 ; Calculate CNS
284 rcall set_actual_ppo2 ; Set char_I_actual_ppO2 286 rcall set_actual_ppo2 ; Set char_I_actual_ppO2
285 clrf WREG 287 clrf WREG
286 movff WREG,char_I_step_is_1min ; Make sure to be in 2sec mode. 288 movff WREG,char_I_step_is_1min ; Make sure to be in 2sec mode.
807 809
808 call sub16 ; sub_c = amb_pressure - last_pressure 810 call sub16 ; sub_c = amb_pressure - last_pressure
809 811
810 movff sub_c+0,xA+0 812 movff sub_c+0,xA+0
811 movff sub_c+1,xA+1 813 movff sub_c+1,xA+1
812 movlw d'39' ;77 when called every second.... 814 ;movlw d'39' ;77 when called every second....
815 movlw d'77' ;77 when called every second....
813 movwf xB+0 816 movwf xB+0
814 clrf xB+1 817 clrf xB+1
815 call mult16x16 ; differential pressure in mbar*77... 818 call mult16x16 ; differential pressure in mbar*77...
816 movff xC+0,divA+0 819 movff xC+0,divA+0
817 movff xC+1,divA+1 820 movff xC+1,divA+1
818 movlw d'7' 821 movlw d'7'
819 movwf divB 822 movwf divB
820 call div16 ; devided by 2^7 equals velocity in m/min 823 call div16 ; devided by 2^7 equals velocity in m/min
821 824
822 movlw d'99' 825 movlw d'99'
823 cpfsgt divA 826 cpfsgt divA ; Limit to 99m/min max.
824 bra calc_velocity3 827 bra calc_velocity3
825 movwf divA ; divA=99 828 movwf divA ; divA=99
826 829
827 calc_velocity3: 830 calc_velocity3:
828
829 GETCUSTOM8 d'5' ; threshold for display vertical velocity 831 GETCUSTOM8 d'5' ; threshold for display vertical velocity
830 subwf divA+0,W ; 832 subwf divA+0,W ;
831 833
832 btfss STATUS,C 834 btfss STATUS,C
833 bra do_not_display_velocity 835 bra do_not_display_velocity
834 836
835 update_velocity: 837 update_velocity:
836 bsf display_velocity 838 bsf display_velocity
839
840 GETCUSTOM8 d'60' ; use graphic velocity (=1)?
841 movwf lo
842 movlw d'1'
843 cpfseq lo ; =1?
844 bra update_velocity1 ; No
845
846 call PLED_display_velocity_graphical
847 return
848
849 update_velocity1:
837 call PLED_display_velocity 850 call PLED_display_velocity
838 return 851 return
839 852
840 do_not_display_velocity: 853 do_not_display_velocity:
841 btfss display_velocity ; Velocity was not displayed, do not delete 854 btfss display_velocity ; Velocity was not displayed, do not delete