comparison code_part1/OSTC_code_asm_part1/sleepmode.asm @ 361:88660a400338 64kByte Logbook

Updated 64K logbook to changeset 360.
author JeanDo
date Wed, 08 Jun 2011 01:37:14 +0200
parents 562f1bc79f3c cec312042b94
children ab962c4b19d6
comparison
equal deleted inserted replaced
357:562f1bc79f3c 361:88660a400338
62 btfsc enter_error_sleep ; Enter Fatal Error Routine? 62 btfsc enter_error_sleep ; Enter Fatal Error Routine?
63 call fatal_error_sleep ; Yes (In Sleepmode_vxx.asm!) 63 call fatal_error_sleep ; Yes (In Sleepmode_vxx.asm!)
64 64
65 call calc_surface_interval ; Increases Surface-Interval time 65 call calc_surface_interval ; Increases Surface-Interval time
66 call nofly_timeout60 ; check for no fly time 66 call nofly_timeout60 ; check for no fly time
67 ; adjust airpressure compensation any 15 minutes 67
68 ;---- adjust airpressure compensation any 15 minutes
68 incf divemins+1,F ; counts to 14... 69 incf divemins+1,F ; counts to 14...
69 movlw d'14' 70 movlw d'14'
70 cpfsgt divemins+1 71 cpfsgt divemins+1
71 bra onemin_sleep2 ; 15 minutes not done! 72 bra onemin_sleep2 ; 15 minutes not done!
73 clrf divemins+1 ; reset counter
72 74
73 rcall pressuretest_sleep_fast ; Gets pressure without averaging (faster!) 75 rcall pressuretest_sleep_fast ; Gets pressure without averaging (faster!)
74 76
75 SAFE_2BYTE_COPY amb_pressure_avg, amb_pressure ; copy for compatibility 77 SAFE_2BYTE_COPY amb_pressure_avg, amb_pressure ; copy for compatibility
76 78
77 call check_temp_extrema ; Check for temperature extremas 79 call check_temp_extrema ; Check for temperature extremas
78 80
79 call deco_calc_CNS_decrease_15min ; compute CNS decay in sleep only 81 call deco_calc_CNS_decrease_15min ; compute CNS decay in sleep only
80 movlb b'00000001' 82 movlb b'00000001'
83
81 movff last_surfpressure_15min+0,last_surfpressure_30min+0 ; save older airpressure 84 movff last_surfpressure_15min+0,last_surfpressure_30min+0 ; save older airpressure
82 movff last_surfpressure_15min+1,last_surfpressure_30min+1 ; save older airpressure 85 movff last_surfpressure_15min+1,last_surfpressure_30min+1 ; save older airpressure
83 SAFE_2BYTE_COPY amb_pressure, last_surfpressure_15min ; save new airpressure 86 SAFE_2BYTE_COPY amb_pressure, last_surfpressure_15min ; save new airpressure
84 87
85 clrf divemins+1 ; reset counter
86 GETCUSTOM15 d'7' ; loads max_sufpressure into lo, hi 88 GETCUSTOM15 d'7' ; loads max_sufpressure into lo, hi
87 movff lo,sub_a+0 ; max. "allowed" airpressure in mBar 89 movff lo,sub_a+0 ; max. "allowed" airpressure in mBar
88 movff hi,sub_a+1 90 movff hi,sub_a+1
89 movff last_surfpressure_15min+0,sub_b+0 91 movff last_surfpressure_15min+0,sub_b+0
90 movff last_surfpressure_15min+1,sub_b+1 92 movff last_surfpressure_15min+1,sub_b+1
91 call sub16 ; sub_c = sub_a - sub_b 93 call sub16 ; sub_c = sub_a - sub_b
92 btfsc neg_flag 94 btfss neg_flag ; Is 1080mbar < amb_pressure ?
93 bra onemin_sleep1 95 bra onemin_sleep2 ; NO: current airpressure is lower then "allowed" airpressure, ok!
94 bra onemin_sleep2 ; current airpressure is lower then "allowed" airpressure, ok! 96
95 onemin_sleep1: ; not ok! Overwrite with max. "allowed" airpressure 97 ; not ok! Overwrite with max. "allowed" airpressure
96 GETCUSTOM15 d'7' ; loads max_sufpressure into lo, hi 98 GETCUSTOM15 d'7' ; loads max_sufpressure into lo, hi
97 movff lo,last_surfpressure_15min+0 ; max. "allowed" airpressure in mBar 99 movff lo,last_surfpressure_15min+0 ; max. "allowed" airpressure in mBar
98 movff hi,last_surfpressure_15min+1 ; max. "allowed" airpressure in mBar 100 movff hi,last_surfpressure_15min+1 ; max. "allowed" airpressure in mBar
99 101
100 onemin_sleep2: 102 onemin_sleep2:
101 ;calc_deko_sleepmode:
102 SAFE_2BYTE_COPY amb_pressure, int_I_pres_respiration ; LOW copy pressure to deco routine 103 SAFE_2BYTE_COPY amb_pressure, int_I_pres_respiration ; LOW copy pressure to deco routine
103 GETCUSTOM8 d'11' ; Saturation multiplier % 104 GETCUSTOM8 d'11' ; Saturation multiplier %
104 movff WREG,char_I_saturation_multiplier 105 movff WREG,char_I_saturation_multiplier
105 GETCUSTOM8 d'12' ; Desaturation multiplier % 106 GETCUSTOM8 d'12' ; Desaturation multiplier %
106 movff WREG,char_I_desaturation_multiplier 107 movff WREG,char_I_desaturation_multiplier
126 bcf LED_blue ; Clear nofly LED 127 bcf LED_blue ; Clear nofly LED
127 incf divemins+0,F ; counts to #test_pressure_in_sleep (5) 128 incf divemins+0,F ; counts to #test_pressure_in_sleep (5)
128 movlw d'5' 129 movlw d'5'
129 cpfsgt divemins+0 ; here: temp variable 130 cpfsgt divemins+0 ; here: temp variable
130 bra onesec_sleep1 ; #test_pressure_in_sleep not done yet 131 bra onesec_sleep1 ; #test_pressure_in_sleep not done yet
132 clrf divemins+0
133
131 rcall pressuretest_sleep_fast ; Gets pressure without averaging (faster!) 134 rcall pressuretest_sleep_fast ; Gets pressure without averaging (faster!)
132 135
133 ; compare current ambient pressure with threshold 136 ; compare current ambient pressure with threshold CF6==1160mbar.
134 GETCUSTOM15 d'6' ; loads pressure threshold into lo,hi 137 GETCUSTOM15 d'6' ; loads pressure threshold into lo,hi
135 movff lo,sub_a+0 ; power on if ambient pressure is greater threshold 138 movff lo,sub_a+0 ; power on if ambient pressure is greater threshold
136 movff hi,sub_a+1 139 movff hi,sub_a+1
137 SAFE_2BYTE_COPY amb_pressure_avg, sub_b 140 SAFE_2BYTE_COPY amb_pressure_avg, sub_b
138 call sub16 ; sub_c = sub_a - sub_b 141 call sub16 ; Is (1160mbar - averaged(amb_pressure)) < 0 ?
139 bsf sleepmode 142 bsf sleepmode
140 btfsc neg_flag ; Wake up from Sleep? 143 btfsc neg_flag ; Wake up from Sleep?
141 bcf sleepmode ; amb_pressure>pressure_offset_divemode: wake up! 144 bcf sleepmode ; amb_pressure>pressure_offset_divemode: wake up!
142 clrf divemins+0 145
143 onesec_sleep1: 146 onesec_sleep1:
144 bcf onesecupdate ; all done. 147 bcf onesecupdate ; all done.
145 btfsc switch_left 148 btfsc switch_left
146 bra onesec_sleep1a 149 bra onesec_sleep1a
147 btfsc switch_right 150 btfsc switch_right
157 bcf INTCON,INT0IF ; Clear flag 160 bcf INTCON,INT0IF ; Clear flag
158 bcf INTCON3,INT1IF ; Clear flag 161 bcf INTCON3,INT1IF ; Clear flag
159 bcf switch_right 162 bcf switch_right
160 bcf switch_left 163 bcf switch_left
161 bcf T0CON,TMR0ON ; Stop Timer 0 164 bcf T0CON,TMR0ON ; Stop Timer 0
162 bcf sleepmode ; wake up! 165 bcf sleepmode ; wake up!
163 166
164 ; Restart altimeter averaging, so next averaging starts right over... 167 ; Restart altimeter averaging, so next averaging starts right over...
165 call altimeter_restart 168 call altimeter_restart
166 169
167 return 170 return