Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/divemode.asm @ 301:a5fd8777a598
Display ppO2[Diluent] in CCR modes
author | heinrichsweikamp |
---|---|
date | Sat, 30 Apr 2011 10:40:18 +0200 |
parents | 21a0f7393468 |
children | 91371c7553f5 |
rev | line source |
---|---|
0 | 1 |
2 ; OSTC - diving computer code | |
3 ; Copyright (C) 2008 HeinrichsWeikamp GbR | |
4 | |
5 ; This program is free software: you can redistribute it and/or modify | |
6 ; it under the terms of the GNU General Public License as published by | |
7 ; the Free Software Foundation, either version 3 of the License, or | |
8 ; (at your option) any later version. | |
9 | |
10 ; This program is distributed in the hope that it will be useful, | |
11 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 ; GNU General Public License for more details. | |
14 | |
15 ; You should have received a copy of the GNU General Public License | |
16 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | |
18 | |
19 ; Mainroutines for divemode | |
20 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com | |
21 ; written: 10/01/05 | |
22 ; last updated: 15/05/08 | |
23 ; known bugs: | |
24 ; ToDo: | |
25 | |
26 diveloop: | |
27 call diveloop_boot ; Boot tasks for all modes | |
28 | |
256 | 29 ; start timer3 for deco routine CPU usesage monitor |
30 movlw b'00000011' | |
31 movwf T3CON ; Timer3 with 32768Hz clock running | |
32 | |
0 | 33 ; Startup Tasks for all modes |
34 ostc_debug 'R' ; Sends debug-information to screen if debugmode active | |
35 call PLED_ClearScreen ; clean up OLED | |
36 call PLED_divemode_mask ; Display mask | |
37 call PLED_active_gas_divemode ; Display gas, if required | |
38 call PLED_temp_divemode ; Displays temperature | |
39 | |
40 btfsc FLAG_apnoe_mode | |
41 bsf realdive ; Set Realdive flag in Apnoe mode | |
42 | |
43 btfsc gauge_mode | |
44 bra diveloop_loop ; Skip in gauge mode | |
45 btfsc FLAG_apnoe_mode | |
46 bra diveloop_loop ; Skip in apnoe mode | |
47 | |
48 ; Startup Tasks for deco modes | |
49 call PLED_display_ndl_mask ; display "no stop" if not in gauge or apnoe mode | |
50 | |
51 diveloop_loop: ; The diveloop starts here | |
52 btfss onesecupdate ; tasks any new second | |
263
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
53 bra diveloop_loop3 |
0 | 54 |
55 btfsc gauge_mode ; Only in gauge mode | |
56 bra diveloop_loop1a ; One Second Tasks in Gauge mode | |
57 btfsc FLAG_apnoe_mode ; Only in apnoe mode | |
58 bra diveloop_loop1b ; One Second Tasks in Apnoe mode | |
59 btfsc FLAG_const_ppO2_mode ; only in const_ppO2_mode | |
60 bra diveloop_loop1c ; One Second Tasks in const_ppO2 mode | |
61 | |
62 ; Tasks only for OC modes | |
63 call check_ppO2 ; check ppO2 and displays warning if required | |
64 call calc_deko_divemode ; calculate decompression and display result (any two seconds) | |
65 bra diveloop_loop1x ; Common Tasks | |
66 | |
67 ; Tasks only for Gauge mode | |
68 diveloop_loop1a: | |
106 | 69 btfss premenu ; Is the divemode menu active? |
0 | 70 call PLED_divemins ; display (new) divetime! |
71 call timeout_divemode ; dive finished? This routine sets the required flags | |
72 | |
73 btfsc twosecupdate ; two seconds after the last call | |
263
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
74 bra diveloop_loop1a2 ; Common Tasks |
0 | 75 |
263
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
76 bsf twosecupdate ; Routines used in the "other second" |
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
77 call calc_average_depth ; calculate average depth |
0 | 78 |
79 bra diveloop_loop1x ; Common Tasks | |
80 | |
81 diveloop_loop1a2: | |
82 bcf twosecupdate | |
83 bra diveloop_loop1x ; Common Tasks | |
84 | |
85 ; Tasks only for Apnoe mode | |
86 diveloop_loop1b: | |
87 call divemode_apnoe_tasks ; 1 sec. Apnoe tasks | |
88 bra diveloop_loop1x ; Common Tasks | |
89 | |
90 ; Tasks only for ppO2 mode | |
91 diveloop_loop1c: | |
92 call PLED_const_ppO2_value ; display const ppO2 setting in [Bar] | |
93 call calc_deko_divemode ; calculate decompression and display result (any two seconds) | |
3 | 94 btfsc is_bailout ; Are we in Bailout mode? |
95 call check_ppO2_bail ; Yes, display ppO2 (If required) | |
96 | |
0 | 97 bra diveloop_loop1x ; Common Tasks |
98 | |
99 ; Common Tasks for all modes | |
100 diveloop_loop1x: | |
263
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
101 call customview_second ; Do every-second tasks for the custom view area |
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
102 |
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
103 GETCUSTOM8 d'38' ; Show seconds (=1?) |
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
104 movwf lo |
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
105 movlw d'1' |
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
106 cpfseq lo ; =1? |
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
107 bra diveloop_loop1y ; No, minutes only |
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
108 bsf update_divetime ; Set Update flag |
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
109 diveloop_loop1y: |
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
110 btfss update_divetime ; display new divetime? |
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
111 bra diveloop_loop1z ; No |
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
112 btfsc premenu ; Is the divemode menu active? |
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
113 bra diveloop_loop1z ; Yes |
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
114 call PLED_divemins ; Display (new) divetime! |
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
115 |
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
116 diveloop_loop1z |
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
117 bcf update_divetime ; clear flag |
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
118 |
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
119 btfsc FLAG_const_ppO2_mode ; only in const_ppO2_mode |
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
120 call PLED_const_ppO2_value ; display const ppO2 setting in [Bar] |
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
121 btfsc ppO2_show_value ; show ppO2? |
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
122 call check_ppO2 ; check ppO2 and displays warning if required |
27c9bb14b008
making the seconds display in divemode smoother...
heinrichsweikamp
parents:
257
diff
changeset
|
123 |
0 | 124 call timeout_divemode ; dive finished? This routine sets the required flags |
125 btfsc low_battery_state ; If battery is low, then... | |
141 | 126 call update_batt_voltage_divemode ; Display Battery Warning Text |
0 | 127 btfsc premenu ; is Menu? displayed? |
128 call timeout_premenu_divemode ; No, so check for timeout premenu | |
129 btfsc menubit ; is the Dive mode menu displayed? | |
130 call timeout_divemenu ; Yes, so check for timeout divemenu | |
131 call set_leds_divemode ; Sets warnings, if required. Also Sets buzzer | |
132 btfsc enter_error_sleep ; Enter Fatal Error Routine? | |
16 | 133 call fatal_error_sleep ; Yes (In Sleepmode_vxx.asm!) |
0 | 134 |
135 bcf onesecupdate ; one seconds update done | |
136 | |
137 diveloop_loop3: | |
138 btfss menubit ; Divemode menu active? | |
139 call test_switches_divemode ; No, Check switches normal | |
140 | |
141 btfsc menubit ; Divemode menu active? | |
142 call test_switches_divemode_menu ; Yes, check switches divemode menu | |
143 | |
144 btfss divemode ; Dive finished? | |
145 bra end_dive ; Dive finished! | |
146 | |
147 btfsc pressure_refresh ; new pressure available? | |
148 call update_divemode1 ; Yes, display new depth | |
149 bcf pressure_refresh ; until new pressure is available | |
150 | |
151 btfsc oneminupdate ; one minute tasks | |
152 call update_divemode60 ; Update clock, etc. | |
153 | |
154 btfsc store_sample ; store new sample? | |
155 call store_dive_data ; Store profile data | |
156 | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
83
diff
changeset
|
157 btfsc toggle_customview ; Next view? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
83
diff
changeset
|
158 call customview_toggle ; Yes, show next customview (and delete this flag) |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
83
diff
changeset
|
159 |
2 | 160 btfsc menubit ; Sleep only with inactive menu... |
161 bra diveloop_loop4 | |
162 | |
163 btfsc simulatormode_active ; Do not sleep in Simualtor mode | |
164 bra diveloop_loop4 | |
165 | |
0 | 166 sleep |
167 nop | |
2 | 168 diveloop_loop4: |
0 | 169 bra diveloop_loop ; Loop the divemode |
170 | |
171 timeout_premenu_divemode: | |
128 | 172 incf timeout_counter3,F ; Yes... |
0 | 173 |
128 | 174 GETCUSTOM8 d'4' ; loads premenu_timeout into WREG |
175 cpfsgt timeout_counter3 ; ... longer then premenu_timeout | |
176 return ; No! | |
0 | 177 |
128 | 178 bcf premenu ; Yes, so clear "Menu?" and clear pre_menu bit |
179 call PLED_menu_clear ; Remove "Menu?" | |
0 | 180 return |
181 | |
128 | 182 divemode_apnoe_tasks: ; 1 sec. Apnoe tasks |
0 | 183 call PLED_display_apnoe_descent ; Show descent timer |
184 | |
185 btfsc divemode2 ; Time running? | |
186 bra divemode_apnoe_tasks2 ; New descent, reset data if flag is set | |
187 | |
188 call PLED_display_apnoe_surface | |
189 incf apnoe_surface_secs,F | |
190 movlw d'60' | |
191 cpfseq apnoe_surface_secs | |
192 bra divemode_apnoe_tasks1 | |
193 clrf apnoe_surface_secs | |
194 incf apnoe_surface_mins,F | |
195 | |
196 divemode_apnoe_tasks1: | |
197 bcf FLAG_active_descent ; Clear flag | |
198 btfsc divemode2 ; Time running? | |
199 return ; Yes, return | |
200 | |
201 bsf FLAG_active_descent ; Set Flag | |
202 return | |
203 | |
204 divemode_apnoe_tasks2: | |
205 btfss FLAG_active_descent ; Are descending? | |
206 return ; No, We are at the surface | |
207 rcall apnoe_calc_maxdepth ; Yes! | |
208 | |
209 divemode_apnoe_tasks3: | |
210 call PLED_apnoe_clear_surface ; Clear Surface timer | |
211 | |
212 clrf apnoe_timeout_counter ; Delete timeout | |
213 clrf apnoe_surface_secs | |
214 clrf apnoe_surface_mins | |
215 clrf apnoe_secs | |
216 clrf apnoe_mins ; Reset Descent time | |
217 clrf max_pressure+0 | |
218 clrf max_pressure+1 ; Reset Max. Depth | |
219 bcf FLAG_active_descent ; Clear flag | |
220 return | |
221 | |
222 apnoe_calc_maxdepth: | |
223 movff apnoe_max_pressure+0,sub_a+0 | |
224 movff apnoe_max_pressure+1,sub_a+1 | |
225 movff max_pressure+0,sub_b+0 | |
226 movff max_pressure+1,sub_b+1 | |
227 call sub16 ; sub_c = sub_a - sub_b | |
228 ; apnoe_max_pressure<max_pressure -> neg_flag=1 | |
229 ; max_pressure<=apnoe_max_pressure -> neg_flag=0 | |
230 btfss neg_flag | |
231 return | |
232 ;apnoe_max_pressure<max_pressure | |
233 movff max_pressure+0,apnoe_max_pressure+0 | |
234 movff max_pressure+1,apnoe_max_pressure+1 | |
235 return | |
236 | |
237 set_leds_divemode: | |
238 movff char_O_gradient_factor,lo ; gradient factor absolute | |
239 | |
240 GETCUSTOM8 d'14' ; threshold for LED warning | |
241 cpfslt lo ; | |
242 call warn_gf1 ; show warning, set flags | |
243 | |
244 movff char_I_deco_model,lo | |
245 decfsz lo,W ; jump over return if char_I_deco_model == 1 | |
246 return | |
247 | |
248 movff char_O_relative_gradient_GF,lo ; gradient factor relative (GF model) | |
249 | |
250 GETCUSTOM8 d'14' ; threshold for LED warning | |
251 cpfslt lo ; | |
252 call warn_gf1 ; show warning, set flags | |
253 | |
254 return | |
255 | |
256 warn_gf1: | |
257 movlw d'2' ; Type of Alarm | |
258 movwf AlarmType ; Copy to Alarm Register | |
259 bsf event_occured ; Set Event Flag | |
260 return | |
261 | |
262 calc_deko_divemode: | |
263 btfsc twosecupdate ; two seconds after the last call | |
264 bra calc_deko_divemode2 ; Yes, calculate and display deco data ("first second") | |
265 | |
49 | 266 bsf twosecupdate ; No, but next second! |
0 | 267 ; Routines used in the "other second" |
268 call calc_average_depth ; calculate average depth | |
269 call calc_velocity ; calculate vertical velocity and display if > threshold (every two seconds) | |
270 | |
292 | 271 ; Calculate CNS |
272 rcall set_actual_ppo2 ; Set char_I_actual_ppO2 | |
273 clrf WREG | |
274 movff WREG,char_I_step_is_1min ; Make sure to be in 2sec mode. | |
0 | 275 |
116 | 276 call deco_calc_CNS_fraction ; calculate CNS |
0 | 277 movlb b'00000001' ; rambank 1 selected |
278 | |
279 ; Check if CNS should be displayed | |
280 movff char_O_CNS_fraction,lo ; copy into bank1 | |
281 GETCUSTOM8 d'27' ; cns_display_high | |
282 subwf lo,W | |
283 btfsc STATUS,C | |
284 call PLED_display_cns ; Show CNS | |
8 | 285 call check_gas_change ; Checks if a better gas should be selected (by user) |
286 | |
0 | 287 ; Check for decompression gases if in decomode |
288 btfss dekostop_active | |
289 bra reset_decompression_gases ; While in NDL, do not set deompression gas | |
290 | |
286 | 291 ; Copy all gases to char_I_deco_N2_ratio and char_I_deco_He_ratio |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
292 divemode_check_decogases: ; CALLed from Simulator, too |
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
293 |
291 | 294 clrf EEADRH ; Make sure to select eeprom bank 0 |
295 read_int_eeprom d'7' ; Read He ratio | |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
296 movff EEDATA,char_I_deco_He_ratio+0 ; And copy into hold register |
291 | 297 read_int_eeprom d'6' ; Read O2 ratio |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
298 movff char_I_deco_He_ratio+0, wait_temp ; copy into bank1 register |
49 | 299 bsf STATUS,C ; |
300 movlw d'100' ; 100% | |
301 subfwb wait_temp,W ; minus He | |
302 subfwb EEDATA,F ; minus O2 | |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
303 movff EEDATA, char_I_deco_N2_ratio+0; = N2! |
0 | 304 |
291 | 305 read_int_eeprom d'11' ; Read He ratio |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
306 movff EEDATA,char_I_deco_He_ratio+1 ; And copy into hold register |
291 | 307 read_int_eeprom d'10' ; Read O2 ratio |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
308 movff char_I_deco_He_ratio+1, wait_temp ; copy into bank1 register |
49 | 309 bsf STATUS,C ; |
310 movlw d'100' ; 100% | |
311 subfwb wait_temp,W ; minus He | |
312 subfwb EEDATA,F ; minus O2 | |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
313 movff EEDATA, char_I_deco_N2_ratio+1; = N2! |
49 | 314 |
291 | 315 read_int_eeprom d'15' ; Read He ratio |
224 | 316 movff EEDATA,char_I_deco_He_ratio+2 ; And copy into hold register |
291 | 317 read_int_eeprom d'14' ; Read O2 ratio |
224 | 318 movff char_I_deco_He_ratio+2, wait_temp ; copy into bank1 register |
49 | 319 bsf STATUS,C ; |
320 movlw d'100' ; 100% | |
321 subfwb wait_temp,W ; minus He | |
322 subfwb EEDATA,F ; minus O2 | |
224 | 323 movff EEDATA, char_I_deco_N2_ratio+2; = N2! |
49 | 324 |
291 | 325 read_int_eeprom d'19' ; Read He ratio |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
326 movff EEDATA,char_I_deco_He_ratio+3 ; And copy into hold register |
291 | 327 read_int_eeprom d'17' ; Read O2 ratio |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
328 movff char_I_deco_He_ratio+3, wait_temp ; copy into bank1 register |
49 | 329 bsf STATUS,C ; |
330 movlw d'100' ; 100% | |
331 subfwb wait_temp,W ; minus He | |
332 subfwb EEDATA,F ; minus O2 | |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
333 movff EEDATA, char_I_deco_N2_ratio+3; = N2! |
0 | 334 |
291 | 335 read_int_eeprom d'23' ; Read He ratio |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
336 movff EEDATA,char_I_deco_He_ratio+4; And copy into hold register |
291 | 337 read_int_eeprom d'22' ; Read O2 ratio |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
338 movff char_I_deco_He_ratio+4, wait_temp ; copy into bank1 register |
39 | 339 bsf STATUS,C ; |
340 movlw d'100' ; 100% | |
341 subfwb wait_temp,W ; minus He | |
342 subfwb EEDATA,F ; minus O2 | |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
343 movff EEDATA, char_I_deco_N2_ratio+4; = N2! |
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
344 |
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
345 ; Copy depth of enabled gas into char_I_deco_gas_change |
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
346 ; Note gaslist_active is inited in diveloop_boot, and edited by |
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
347 ; the de-activation menu. So don't reread it from eeprom here. |
39 | 348 |
281 | 349 read_int_eeprom d'28' ; read gas_change_depth Gas1 |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
350 btfss gaslist_active,0 ; Apply depth? |
221 | 351 clrf EEDATA ; No, clear! |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
352 movff EEDATA,char_I_deco_gas_change+0 ; Yes! |
221 | 353 |
281 | 354 read_int_eeprom d'29' ; read gas_change_depth Gas2 |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
355 btfss gaslist_active,1 ; Apply depth? |
221 | 356 clrf EEDATA ; No, clear! |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
357 movff EEDATA,char_I_deco_gas_change+1 ; Yes! |
45 | 358 |
281 | 359 read_int_eeprom d'30' ; read gas_change_depth Gas3 |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
360 btfss gaslist_active,2 ; Apply depth? |
221 | 361 clrf EEDATA ; No, clear! |
222
638f8e17bd51
Prototyping deco_gas_volumes() to compute gas consumption per tank with decoplanning.
JeanDo
parents:
221
diff
changeset
|
362 movff EEDATA,char_I_deco_gas_change+2 ; Yes! |
221 | 363 |
281 | 364 read_int_eeprom d'31' ; read gas_change_depth Gas4 |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
365 btfss gaslist_active,3 ; Apply depth? |
221 | 366 clrf EEDATA ; No, clear! |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
367 movff EEDATA,char_I_deco_gas_change+3 ; Yes! |
221 | 368 |
281 | 369 read_int_eeprom d'32' ; read gas_change_depth Gas5 |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
370 btfss gaslist_active,4 ; Apply depth? |
221 | 371 clrf EEDATA ; No, clear! |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
372 movff EEDATA,char_I_deco_gas_change+4 ; Yes! |
38 | 373 |
374 ; Debugger | |
45 | 375 ; call enable_rs232 |
224 | 376 ; movff char_I_deco_He_ratio+4,TXREG |
39 | 377 ; call rs232_wait_tx ; wait for UART |
224 | 378 ; movff char_I_deco_N2_ratio+4,TXREG |
39 | 379 ; call rs232_wait_tx ; wait for UART |
224 | 380 ; movff char_I_deco_He_ratio+3,TXREG |
39 | 381 ; call rs232_wait_tx ; wait for UART |
224 | 382 ; movff char_I_deco_N2_ratio+3,TXREG |
39 | 383 ; call rs232_wait_tx ; wait for UART |
224 | 384 ; movff char_I_deco_He_ratio+2,TXREG |
39 | 385 ; call rs232_wait_tx ; wait for UART |
224 | 386 ; movff char_I_deco_N2_ratio+2,TXREG |
39 | 387 ; call rs232_wait_tx ; wait for UART |
224 | 388 ; movff char_I_deco_He_ratio+1,TXREG |
39 | 389 ; call rs232_wait_tx ; wait for UART |
224 | 390 ; movff char_I_deco_N2_ratio+1,TXREG |
39 | 391 ; call rs232_wait_tx ; wait for UART |
392 ; movff char_I_deco_He_ratio,TXREG | |
393 ; call rs232_wait_tx ; wait for UART | |
394 ; movff char_I_deco_N2_ratio,TXREG | |
395 ; call rs232_wait_tx ; wait for UART | |
396 ; movff char_I_deco_gas_change5,TXREG | |
397 ; call rs232_wait_tx ; wait for UART | |
398 ; movff char_I_deco_gas_change4,TXREG | |
399 ; call rs232_wait_tx ; wait for UART | |
400 ; movff char_I_deco_gas_change3,TXREG | |
221 | 401 ; call rs232_wait_tx ; wait for UART |
39 | 402 ; movff char_I_deco_gas_change2,TXREG |
403 ; call rs232_wait_tx ; wait for UART | |
404 ; movff char_I_deco_gas_change,TXREG | |
405 ; call rs232_wait_tx ; wait for UART | |
47 | 406 |
33 | 407 return |
0 | 408 |
292 | 409 ;----------------------------------------------------------------------------- |
410 ; calculate ppO2 in 0.01Bar (e.g. 150 = 1.50 Bar ppO2) | |
411 set_actual_ppo2: | |
412 movff amb_pressure+0,xA+0 ; P_amb in milibar (1000 = 1.000 bar). | |
413 movff amb_pressure+1,xA+1 | |
414 movlw d'10' | |
415 movwf xB+0 | |
416 clrf xB+1 | |
417 call div16x16 ; xC=p_amb/10 (100 = 1.00 bar). | |
418 movff xC+0,xA+0 | |
419 movff xC+1,xA+1 | |
420 movff char_I_O2_ratio,xB+0 | |
421 clrf xB+1 | |
422 call mult16x16 ; char_I_O2_ratio * (p_amb/10) | |
423 movff xC+0,xA+0 | |
424 movff xC+1,xA+1 | |
425 movlw d'100' | |
426 movwf xB+0 | |
427 clrf xB+1 | |
428 call div16x16 ; xC=(char_I_O2_ratio * p_amb/10)/100 | |
429 | |
430 ; Copy ppO2 for CNS calculation | |
431 tstfsz xC+1 ; Is ppO2 > 2.55bar ? | |
432 setf xC+0 ; yes: bound to 2.55... better than wrap around. | |
433 | |
434 movff xC+0, char_I_actual_ppO2 ; copy last ppO2 to buffer register | |
435 btfsc FLAG_const_ppO2_mode ; do in const_ppO2_mode | |
436 movff char_I_const_ppO2, char_I_actual_ppO2 ; copy last ppO2 to buffer register | |
437 return | |
438 | |
0 | 439 reset_decompression_gases: ; reset the deco gas while in NDL |
440 ostc_debug 'F' ; Sends debug-information to screen if debugmode active | |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
441 lfsr FSR2,char_I_deco_gas_change |
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
442 clrf POSTINC2 ; Clear Gas1 |
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
443 clrf POSTINC2 |
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
444 clrf POSTINC2 |
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
445 clrf POSTINC2 |
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
446 clrf POSTINC2 ; Clear Gas5 |
0 | 447 return |
448 | |
449 calc_deko_divemode2: | |
450 bcf twosecupdate | |
451 | |
452 btfsc gauge_mode ; ignore decompression calculation in gauge mode | |
453 return | |
454 btfsc FLAG_apnoe_mode ; ignore decompression calculation in apnoe mode | |
455 return | |
456 | |
457 ostc_debug 'B' ; Sends debug-information to screen if debugmode active | |
458 call divemode_prepare_flags_for_deco | |
292 | 459 clrf WREG |
460 movff WREG,char_I_step_is_1min ; Force 2 second deco mode | |
40 | 461 |
256 | 462 clrf TMR3L |
463 clrf TMR3H ; Reset Timer3 | |
464 | |
116 | 465 call deco_calc_hauptroutine ; calc_tissue |
0 | 466 movlb b'00000001' ; rambank 1 selected |
467 ostc_debug 'C' ; Sends debug-information to screen if debugmode active | |
468 | |
256 | 469 btfss debug_mode ; Are we in debugmode? |
470 bra calc_deko_divemode4 ; No... | |
471 | |
472 ; Show timer3 reading converted into ms (Error: +2,3%) in custom area | |
473 movff TMR3L,lo | |
474 movff TMR3H,hi | |
475 bcf STATUS,C | |
476 rrcf hi | |
477 rrcf lo ;/2 | |
478 bcf STATUS,C | |
479 rrcf hi | |
480 rrcf lo ;/4 | |
481 bcf STATUS,C | |
482 rrcf hi | |
483 rrcf lo ;/8 | |
484 bcf STATUS,C | |
485 rrcf hi | |
486 rrcf lo ;/16 | |
487 bcf STATUS,C | |
488 rrcf hi | |
489 rrcf lo ;/32 | |
490 | |
491 WIN_TOP .216 | |
492 WIN_LEFT .100 | |
493 WIN_FONT FT_SMALL | |
494 STRCPY "ms:" | |
495 output_16 | |
496 call word_processor | |
497 | |
498 calc_deko_divemode4: | |
499 | |
169
e26f49674956
Merge decoplan display for both GF and Buhlmann models.
JeanDo
parents:
167
diff
changeset
|
500 movff char_O_first_deco_depth,wait_temp ; copy ceiling to temp register |
0 | 501 tstfsz wait_temp ; Ceiling<0m? |
502 bra calc_deko_divemode3 ; Yes! | |
503 | |
504 btfsc dekostop_active | |
505 call PLED_display_ndl_mask ; Clear deco data, display nostop time | |
506 bcf dekostop_active ; clear flag | |
507 | |
508 clrf decodata+0 ; for profile memory | |
509 movff char_O_nullzeit,decodata+1 ; nostop time | |
510 | |
511 call PLED_display_ndl ; display no deco limit | |
512 return | |
513 | |
124 | 514 ;----------------------------------------------------------------------------- |
69 | 515 |
237 | 516 divemode_prepare_flags_for_deco: |
0 | 517 movff amb_pressure+0,int_I_pres_respiration+0 ; lo and copy result to deco routine |
518 movff amb_pressure+1,int_I_pres_respiration+1 ; hi | |
197 | 519 GETCUSTOM8 d'11' ; Saturation multiplier % |
520 movff WREG,char_I_saturation_multiplier | |
521 GETCUSTOM8 d'12' ; Desaturation multiplier % | |
522 movff WREG,char_I_desaturation_multiplier | |
523 GETCUSTOM8 d'16' ; Deco distance to decostop in 1/10 meter for simulation | |
524 movff WREG,char_I_deco_distance | |
525 GETCUSTOM8 d'29' ; Depth Last Deco in meter for simulation | |
526 movff WREG,char_I_depth_last_deco | |
203 | 527 movff divemins+0,int_I_divemins+0 ; Current dive time. |
528 movff divemins+1,int_I_divemins+1 | |
197 | 529 goto restart_set_modes_and_flags ; Sets decomode (char_I_deco_model) and flags (again) |
0 | 530 |
531 calc_deko_divemode3: | |
532 btfss dekostop_active | |
197 | 533 call PLED_display_deko_mask ; clear nostop time, display decodata |
0 | 534 bsf dekostop_active ; Set flag |
535 | |
169
e26f49674956
Merge decoplan display for both GF and Buhlmann models.
JeanDo
parents:
167
diff
changeset
|
536 movff char_O_first_deco_depth,decodata+0 ; ceiling |
e26f49674956
Merge decoplan display for both GF and Buhlmann models.
JeanDo
parents:
167
diff
changeset
|
537 movff char_O_first_deco_time,decodata+1 ; length of first stop in minues |
0 | 538 |
539 call PLED_display_deko ; display decodata | |
540 return | |
541 | |
542 store_dive_data: ; CF20 seconds gone | |
543 bcf store_sample ; update only any CF20 seconds | |
544 bsf update_divetime ; update divemins every CF20 seconds | |
545 | |
233 | 546 ifndef __DEBUG |
547 btfsc simulatormode_active ; Are we in simulator mode? | |
548 return ; Yes, discard everything | |
549 endif | |
33 | 550 |
0 | 551 btfsc header_stored ; Header already stored? |
71
6beb680a6130
1.72beta - color-coded gaslist, small fix with stopwatch
heinrichsweikamp
parents:
69
diff
changeset
|
552 bra store_dive_data2 ; Yes, store only profile data |
0 | 553 bsf header_stored ; Store header |
554 | |
555 movff eeprom_address+0, eeprom_header_address+0 ; store startposition | |
556 movff eeprom_address+1, eeprom_header_address+1 ; store startposition | |
557 | |
558 ; shift address for header | |
559 ; the header will be stored after the dive | |
560 incf_eeprom_address d'47' ; Macro, that adds 8Bit to eeprom_address:2 with banking at 0x8000 | |
561 | |
562 store_dive_data2: | |
563 movf rel_pressure+0,W ; store depth with every sample | |
564 call write_external_eeprom | |
565 movf rel_pressure+1,W | |
566 call write_external_eeprom | |
567 | |
568 ;First, find out how many bytes will append to this sample.... | |
569 clrf ProfileFlagByte ; clear number of bytes to append | |
570 | |
571 ; Check Extented informations | |
572 decfsz divisor_temperature,W ; Check divisor | |
573 bra check_extended1 | |
574 movlw d'2' ; Information length | |
575 addwf ProfileFlagByte,F ; add to ProfileFlagByte | |
576 check_extended1: | |
577 decfsz divisor_deco,W ; Check divisor | |
578 bra check_extended2 | |
579 movlw d'2' ; Information length | |
580 addwf ProfileFlagByte,F ; add to ProfileFlagByte | |
581 check_extended2: | |
582 decfsz divisor_tank,W ; Check divisor | |
583 bra check_extended3 | |
584 movlw d'2' ; Information length | |
585 addwf ProfileFlagByte,F ; add to ProfileFlagByte | |
586 check_extended3: | |
587 decfsz divisor_ppo2,W ; Check divisor | |
588 bra check_extended4 | |
589 movlw d'3' ; Information length | |
590 addwf ProfileFlagByte,F ; add to ProfileFlagByte | |
591 check_extended4: | |
592 decfsz divisor_deco_debug,W; Check divisor | |
593 bra check_extended5 | |
594 movlw d'9' ; Information length | |
595 addwf ProfileFlagByte,F ; add to ProfileFlagByte | |
596 check_extended5: | |
597 decfsz divisor_nuy2,W ; Check divisor | |
598 bra check_extended6 | |
599 movlw d'0' ; Information length | |
600 addwf ProfileFlagByte,F ; add to ProfileFlagByte | |
601 check_extended6: | |
602 | |
603 ; Second, check global event flag | |
604 btfss event_occured ; Check global event flag | |
605 bra store_dive_data3 ; No Event | |
606 movlw d'1' | |
607 addwf ProfileFlagByte,F ; add one byte (The EventByte) | |
608 | |
609 clrf EventByte ; reset EventByte | |
610 | |
611 movf AlarmType,W ; Type of Alarm Bit 0-3 | |
612 addwf EventByte,F ; Copy to EventByte Bit 0-3 | |
613 clrf AlarmType ; Reset AlarmType | |
614 | |
615 ; Third, check events and add aditional bytes | |
616 btfss manual_gas_changed ; Check flag | |
617 bra check_event1 | |
618 movlw d'2' ; Information length | |
619 addwf ProfileFlagByte,F ; add to ProfileFlagByte | |
620 bsf EventByte,4 ; Also set Flag in EventByte! | |
621 check_event1: | |
622 btfss stored_gas_changed ; Check flag | |
623 bra check_event2 | |
624 movlw d'1' ; Information length | |
625 addwf ProfileFlagByte,F ; add to ProfileFlagByte | |
626 bsf EventByte,5 ; Also set Flag in EventByte! | |
627 check_event2: | |
274
a728b4a1b660
Setpoint changes stored in profile, EAD and END displayed in divemode (Customview 7)
heinrichsweikamp
parents:
263
diff
changeset
|
628 btfss setpoint_changed ; Check flag |
a728b4a1b660
Setpoint changes stored in profile, EAD and END displayed in divemode (Customview 7)
heinrichsweikamp
parents:
263
diff
changeset
|
629 bra check_event3 |
a728b4a1b660
Setpoint changes stored in profile, EAD and END displayed in divemode (Customview 7)
heinrichsweikamp
parents:
263
diff
changeset
|
630 movlw d'1' ; Information length |
a728b4a1b660
Setpoint changes stored in profile, EAD and END displayed in divemode (Customview 7)
heinrichsweikamp
parents:
263
diff
changeset
|
631 addwf ProfileFlagByte,F ; add to ProfileFlagByte |
a728b4a1b660
Setpoint changes stored in profile, EAD and END displayed in divemode (Customview 7)
heinrichsweikamp
parents:
263
diff
changeset
|
632 bsf EventByte,6 ; Also set Flag in EventByte! |
a728b4a1b660
Setpoint changes stored in profile, EAD and END displayed in divemode (Customview 7)
heinrichsweikamp
parents:
263
diff
changeset
|
633 check_event3: |
0 | 634 bsf ProfileFlagByte,7 ; Set EventByte Flag in ProfileFlagByte |
635 | |
636 store_dive_data3: | |
637 movf ProfileFlagByte,W ; finally, write ProfileFlagByte! | |
638 call write_external_eeprom | |
639 | |
640 btfss event_occured ; Check global event flag (again) | |
641 bra store_dive_data4 ; No Event | |
642 | |
643 ; Store the EventByte + additional bytes now | |
644 movf EventByte,W | |
645 call write_external_eeprom | |
646 | |
274
a728b4a1b660
Setpoint changes stored in profile, EAD and END displayed in divemode (Customview 7)
heinrichsweikamp
parents:
263
diff
changeset
|
647 btfss manual_gas_changed ; Check flag |
0 | 648 bra store_dive_data3a |
649 read_int_eeprom d'24' ; % O2 Gas6 | |
650 movf EEDATA,W | |
651 call write_external_eeprom | |
652 read_int_eeprom d'25' ; % He Gas6 | |
653 movf EEDATA,W | |
654 call write_external_eeprom | |
274
a728b4a1b660
Setpoint changes stored in profile, EAD and END displayed in divemode (Customview 7)
heinrichsweikamp
parents:
263
diff
changeset
|
655 bcf manual_gas_changed ; Clear this event |
0 | 656 |
657 store_dive_data3a: | |
658 btfss stored_gas_changed ; Check flag | |
659 bra store_dive_data3b | |
660 movf active_gas,W ; Store active gas | |
661 call write_external_eeprom | |
274
a728b4a1b660
Setpoint changes stored in profile, EAD and END displayed in divemode (Customview 7)
heinrichsweikamp
parents:
263
diff
changeset
|
662 bcf stored_gas_changed ; Clear this event |
0 | 663 store_dive_data3b: |
664 | |
665 store_dive_data4: | |
666 | |
667 ; Store extended informations | |
668 decfsz divisor_temperature,F ; Check divisor | |
669 bra store_extended1 | |
670 rcall store_dive_temperature | |
671 store_extended1: | |
672 decfsz divisor_deco,F ; Check divisor | |
673 bra store_extended2 | |
674 rcall store_dive_decodata | |
675 store_extended2: | |
676 decfsz divisor_tank,F ; Check divisor | |
677 bra store_extended3 | |
678 rcall store_dive_tankdata | |
679 store_extended3: | |
680 decfsz divisor_ppo2,F ; Check divisor | |
681 bra store_extended4 | |
682 rcall store_dive_ppo2 | |
683 store_extended4: | |
684 decfsz divisor_deco_debug,F; Check divisor | |
685 bra store_extended5 | |
686 rcall store_dive_decodebug | |
687 store_extended5: | |
688 decfsz divisor_nuy2,F ; Check divisor | |
689 bra store_extended6 | |
690 rcall store_dive_nuy2 | |
691 store_extended6: | |
692 | |
693 ; The next block is required to take care of "store never" | |
694 btfsc divisor_temperature,7 ; Test highest Bit (Register must have been zero before the "decfsz" command!) | |
695 clrf divisor_temperature ; And clear register again, so it will never reach zero... | |
696 btfsc divisor_deco,7 ; Test highest Bit (Register must have been zero before the "decfsz" command!) | |
697 clrf divisor_deco ; And clear register again, so it will never reach zero... | |
698 btfsc divisor_tank,7 ; Test highest Bit (Register must have been zero before the "decfsz" command!) | |
699 clrf divisor_tank ; And clear register again, so it will never reach zero... | |
700 btfsc divisor_ppo2,7 ; Test highest Bit (Register must have been zero before the "decfsz" command!) | |
701 clrf divisor_ppo2 ; And clear register again, so it will never reach zero... | |
702 btfsc divisor_deco_debug,7 ; Test highest Bit (Register must have been zero before the "decfsz" command!) | |
703 clrf divisor_deco_debug ; And clear register again, so it will never reach zero... | |
704 btfsc divisor_nuy2,7 ; Test highest Bit (Register must have been zero before the "decfsz" command!) | |
705 clrf divisor_nuy2 ; And clear register again, so it will never reach zero... | |
706 | |
707 ostc_debug 'D' ; Sends debug-information to screen if debugmode active | |
274
a728b4a1b660
Setpoint changes stored in profile, EAD and END displayed in divemode (Customview 7)
heinrichsweikamp
parents:
263
diff
changeset
|
708 |
a728b4a1b660
Setpoint changes stored in profile, EAD and END displayed in divemode (Customview 7)
heinrichsweikamp
parents:
263
diff
changeset
|
709 ; SetPoint change appended to information due to compatibility reasons |
a728b4a1b660
Setpoint changes stored in profile, EAD and END displayed in divemode (Customview 7)
heinrichsweikamp
parents:
263
diff
changeset
|
710 btfss setpoint_changed ; Check flag |
a728b4a1b660
Setpoint changes stored in profile, EAD and END displayed in divemode (Customview 7)
heinrichsweikamp
parents:
263
diff
changeset
|
711 bra store_dive_data5 |
a728b4a1b660
Setpoint changes stored in profile, EAD and END displayed in divemode (Customview 7)
heinrichsweikamp
parents:
263
diff
changeset
|
712 movff char_I_const_ppO2,WREG ; SetPoint in cBar |
a728b4a1b660
Setpoint changes stored in profile, EAD and END displayed in divemode (Customview 7)
heinrichsweikamp
parents:
263
diff
changeset
|
713 call write_external_eeprom |
a728b4a1b660
Setpoint changes stored in profile, EAD and END displayed in divemode (Customview 7)
heinrichsweikamp
parents:
263
diff
changeset
|
714 bcf setpoint_changed ; Clear this event |
a728b4a1b660
Setpoint changes stored in profile, EAD and END displayed in divemode (Customview 7)
heinrichsweikamp
parents:
263
diff
changeset
|
715 |
a728b4a1b660
Setpoint changes stored in profile, EAD and END displayed in divemode (Customview 7)
heinrichsweikamp
parents:
263
diff
changeset
|
716 store_dive_data5: |
a728b4a1b660
Setpoint changes stored in profile, EAD and END displayed in divemode (Customview 7)
heinrichsweikamp
parents:
263
diff
changeset
|
717 bcf event_occured ; Clear the global event flag |
a728b4a1b660
Setpoint changes stored in profile, EAD and END displayed in divemode (Customview 7)
heinrichsweikamp
parents:
263
diff
changeset
|
718 return ; Done. (Sample with all informations written to EEPROM) |
0 | 719 |
720 store_dive_nuy2: | |
721 GETCUSTOM8 d'26' | |
722 movwf divisor_nuy2 ; Reload divisor from CF | |
723 return | |
724 | |
725 store_dive_decodebug: | |
171 | 726 ; Dump 9 bytes, int_O_DBS_bitfield .. char_O_NDL_at_20mtr |
727 lfsr FSR2, int_O_DBS_bitfield | |
728 movf POSTINC2,W | |
0 | 729 call write_external_eeprom ; Store in EEPROM |
171 | 730 movf POSTINC2,W |
0 | 731 call write_external_eeprom ; Store in EEPROM |
171 | 732 movf POSTINC2,W |
733 call write_external_eeprom ; Store in EEPROM | |
734 movf POSTINC2,W | |
0 | 735 call write_external_eeprom ; Store in EEPROM |
171 | 736 movf POSTINC2,W |
0 | 737 call write_external_eeprom ; Store in EEPROM |
171 | 738 movf POSTINC2,W |
0 | 739 call write_external_eeprom ; Store in EEPROM |
171 | 740 movf POSTINC2,W |
0 | 741 call write_external_eeprom ; Store in EEPROM |
171 | 742 movf POSTINC2,W |
0 | 743 call write_external_eeprom ; Store in EEPROM |
171 | 744 movf POSTINC2,W |
0 | 745 call write_external_eeprom ; Store in EEPROM |
746 GETCUSTOM8 d'25' | |
747 movwf divisor_deco_debug ; Reload divisor from CF | |
748 return | |
749 | |
750 store_dive_ppo2: | |
751 movlw 0x00 ; Dummy | |
752 call write_external_eeprom | |
753 movlw 0x00 ; Dummy | |
754 call write_external_eeprom | |
755 movlw 0x00 ; Dummy | |
756 call write_external_eeprom | |
757 GETCUSTOM8 d'24' | |
758 movwf divisor_ppo2 ; Reload divisor from CF | |
759 return | |
760 | |
761 store_dive_tankdata: | |
762 movlw d'0' ; Dummy Tank1 | |
763 call write_external_eeprom | |
764 movlw d'0' ; Dummy Tank2 | |
765 call write_external_eeprom | |
766 GETCUSTOM8 d'23' | |
767 movwf divisor_tank ; Reload divisor from CF | |
768 return | |
769 | |
770 store_dive_decodata: | |
771 movf decodata+0,W ; =0:no stop dive, if in deco mode: ceiling in m | |
772 call write_external_eeprom | |
773 movf decodata+1,W ; no stop time of length of first stop | |
774 call write_external_eeprom | |
775 GETCUSTOM8 d'22' | |
776 movwf divisor_deco ; Reload divisor from CF | |
777 return | |
778 | |
779 store_dive_temperature: | |
780 movf temperature+0,W ; append temperature to current sample! | |
781 call write_external_eeprom | |
782 movf temperature+1,W | |
783 call write_external_eeprom | |
784 GETCUSTOM8 d'21' | |
785 movwf divisor_temperature ; Reload divisor from CF | |
786 return | |
787 | |
788 calc_velocity: ; called every two seconds | |
789 btfss divemode | |
790 bra do_not_display_velocity ; display velocity only in divemode | |
791 | |
792 calc_velocity2: | |
793 movff amb_pressure+0,sub_a+0 | |
794 movff amb_pressure+1,sub_a+1 | |
795 movff last_pressure+0,sub_b+0 | |
796 movff last_pressure+1,sub_b+1 | |
797 movff amb_pressure+0,last_pressure+0 ; store old value for velocity | |
798 movff amb_pressure+1,last_pressure+1 | |
799 | |
800 call sub16 ; sub_c = amb_pressure - last_pressure | |
801 | |
802 movff sub_c+0,xA+0 | |
803 movff sub_c+1,xA+1 | |
804 movlw d'39' ;77 when called every second.... | |
805 movwf xB+0 | |
806 clrf xB+1 | |
807 call mult16x16 ; differential pressure in mBar*77... | |
808 movff xC+0,divA+0 | |
809 movff xC+1,divA+1 | |
810 movlw d'7' | |
811 movwf divB | |
812 call div16 ; devided by 2^7 equals velocity in m/min | |
813 | |
814 movlw d'99' | |
815 cpfsgt divA | |
816 bra calc_velocity3 | |
817 movwf divA ; divA=99 | |
818 | |
819 calc_velocity3: | |
820 | |
821 GETCUSTOM8 d'5' ; threshold for display vertical velocity | |
822 subwf divA+0,W ; | |
823 | |
824 btfss STATUS,C | |
825 bra do_not_display_velocity | |
826 | |
827 update_velocity: | |
828 bsf display_velocity | |
829 call PLED_display_velocity | |
830 return | |
831 | |
832 do_not_display_velocity: | |
833 btfss display_velocity ; Velocity was not displayed, do not delete | |
834 return | |
835 | |
836 bcf display_velocity ; Velocity was displayed, delete velocity now | |
837 call PLED_display_velocity_clear | |
838 return | |
839 | |
237 | 840 check_ppO2: ; check current ppO2 and display warning if required |
841 btfsc FLAG_const_ppO2_mode ; ignore in ppO2 mode.... | |
0 | 842 return |
843 | |
3 | 844 check_ppO2_bail: ; In CC mode but bailout active! |
0 | 845 movff amb_pressure+0,xA+0 |
846 movff amb_pressure+1,xA+1 | |
847 movlw d'10' | |
848 movwf xB+0 | |
849 clrf xB+1 | |
850 call div16x16 ; xC=p_amb/10 | |
851 movff xC+0,xA+0 | |
852 movff xC+1,xA+1 | |
853 movff char_I_O2_ratio,xB+0 | |
854 clrf xB+1 | |
855 call mult16x16 ; char_I_O2_ratio * p_amb/10 | |
856 | |
74 | 857 ; Check very high ppO2 manually |
858 tstfsz xC+2 ; char_I_O2_ratio * p_amb/10 > 65536, ppO2>6,55Bar? | |
859 bra check_ppO2_bail2 ; Yes, display Value! | |
860 | |
0 | 861 ; Check if ppO2 should be displayed |
862 movff xC+0,sub_b+0 | |
863 movff xC+1,sub_b+1 | |
864 GETCUSTOM8 d'19' ; ppo2_display_high | |
865 mullw d'100' ; ppo2_display_high*100 | |
866 movff PRODL,sub_a+0 | |
867 movff PRODH,sub_a+1 | |
868 call sub16 | |
869 bcf ppO2_show_value ; clear flag | |
870 btfsc neg_flag | |
871 bsf ppO2_show_value ; set flag if required | |
872 | |
873 ;check if we are within our warning thresholds! | |
874 bcf ppO2_warn_value ; clear flag | |
875 movff xC+0,sub_b+0 | |
876 movff xC+1,sub_b+1 | |
877 GETCUSTOM8 d'18' ; ppo2_warning_high | |
878 mullw d'100' ; ppo2_warning_high*100 | |
879 movff PRODL,sub_a+0 | |
880 movff PRODH,sub_a+1 | |
881 call sub16 | |
882 btfss neg_flag | |
883 bra check_ppO2_0 ; Not too high | |
884 | |
74 | 885 check_ppO2_bail2: |
886 bsf ppO2_show_value ; set flag if required | |
0 | 887 bsf ppO2_warn_value ; set flag |
888 movlw d'5' ; Type of Alarm | |
889 movwf AlarmType ; Copy to Alarm Register | |
890 bsf event_occured ; Set Event Flag | |
891 | |
892 check_ppO2_0: | |
893 movff xC+0,sub_b+0 | |
894 movff xC+1,sub_b+1 | |
210 | 895 GETCUSTOM8 d'17' ; ppo2_warning_low |
896 mullw d'100' ; ppo2_warning_low*100 | |
0 | 897 movff PRODL,sub_a+0 |
898 movff PRODH,sub_a+1 | |
899 call sub16 | |
900 btfsc neg_flag | |
901 bra check_ppO2_1 ; Not too low | |
902 | |
903 bsf ppO2_warn_value ; set flag | |
904 bsf ppO2_show_value ; show ppO2 if below threshold! | |
905 movlw d'4' ; Type of Alarm | |
906 movwf AlarmType ; Copy to Alarm Register | |
907 bsf event_occured ; Set Event Flag | |
908 | |
909 check_ppO2_1: | |
910 btfsc ppO2_show_value ; show value? | |
911 bra check_ppO2_2 ; yes! | |
912 | |
913 btfss ppO2_display_active ; is the value displayed? | |
914 bra check_ppO2_3 ; No, so clear not required | |
915 | |
916 call PLED_show_ppO2_clear; Clear ppO2 value | |
917 bcf ppO2_display_active ; clear flag | |
918 bra check_ppO2_3 ; done | |
919 | |
920 check_ppO2_2: | |
921 call PLED_show_ppO2 ; Display ppO2 (stored in xC) | |
922 bsf ppO2_display_active ; Set flag | |
923 | |
924 check_ppO2_3: | |
925 return ; done | |
926 | |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
927 ;============================================================================= |
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
928 ; Compare all enabled gas in list, to see if a better one is available. |
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
929 ; |
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
930 ; Output: better_gas_available |
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
931 ; |
210 | 932 check_gas_change: ; Checks if a better gas should be selected (by user) |
8 | 933 bcf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode |
934 | |
935 movff rel_pressure+0,xA+0 | |
936 movff rel_pressure+1,xA+1 | |
937 movlw d'100' | |
938 movwf xB+0 | |
939 clrf xB+1 | |
940 call div16x16 ; compute depth in full m -> result in xC+0 | |
941 | |
942 check_gas_change1: ; check gas1 | |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
943 btfss gaslist_active,0 ; check active flag |
8 | 944 bra check_gas_change2 ; skip inactive gases! |
945 movlw d'1' | |
946 cpfseq active_gas ; is this gas currently selected? | |
947 bra check_gas_change1x ; No... | |
948 bra check_gas_change2 ; Yes, skip depth check | |
949 check_gas_change1x: | |
950 read_int_eeprom d'28' ; read gas_change_depth | |
951 movlw d'3' | |
952 cpfsgt EEDATA ; Change depth>3m? | |
953 bra check_gas_change2 ; No, Change depth not deep enough, skip! | |
954 movf xC+0,W ; load depth in m into WREG | |
955 cpfsgt EEDATA ; gas_change_depth < current depth? | |
956 bra check_gas_change2 ; No, check next gas | |
957 movlw d'3' | |
958 subwf EEDATA,W ; Change depth-3m | |
959 cpfslt xC+0 ; current depth<Change depth-3m? | |
960 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | |
961 | |
962 check_gas_change2: ; check gas2 | |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
963 btfss gaslist_active,1 ; check active flag |
8 | 964 bra check_gas_change3 ; skip inactive gases! |
965 movlw d'2' | |
966 cpfseq active_gas ; is this gas currently selected? | |
967 bra check_gas_change2x ; No... | |
968 bra check_gas_change3 ; Yes, skip depth check | |
969 check_gas_change2x: | |
970 read_int_eeprom d'29' ; read gas_change_depth | |
971 movlw d'3' | |
972 cpfsgt EEDATA ; Change depth>3m? | |
973 bra check_gas_change3 ; No, Change depth not deep enough, skip! | |
974 movf xC+0,W ; load depth in m into WREG | |
975 cpfsgt EEDATA ; gas_change_depth < current depth? | |
976 bra check_gas_change3 ; No, check next gas | |
977 movlw d'3' | |
978 subwf EEDATA,W ; Change depth-3m | |
979 cpfslt xC+0 ; current depth<Change depth-3m? | |
980 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | |
981 | |
982 check_gas_change3: ; check gas3 | |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
983 btfss gaslist_active,2 ; check active flag |
8 | 984 bra check_gas_change4 ; skip inactive gases! |
985 movlw d'3' | |
986 cpfseq active_gas ; is this gas currently selected? | |
987 bra check_gas_change3x ; No... | |
988 bra check_gas_change4 ; Yes, skip depth check | |
989 check_gas_change3x: | |
990 read_int_eeprom d'30' ; read gas_change_depth | |
991 movlw d'3' | |
992 cpfsgt EEDATA ; Change depth>3m? | |
993 bra check_gas_change4 ; No, Change depth not deep enough, skip! | |
994 movf xC+0,W ; load depth in m into WREG | |
995 cpfsgt EEDATA ; gas_change_depth < current depth? | |
996 bra check_gas_change4 ; No, check next gas | |
997 movlw d'3' | |
998 subwf EEDATA,W ; Change depth-3m | |
999 cpfslt xC+0 ; current depth<Change depth-3m? | |
1000 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | |
1001 | |
1002 check_gas_change4: ; check gas4 | |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
1003 btfss gaslist_active,3 ; check active flag |
8 | 1004 bra check_gas_change5 ; skip inactive gases! |
1005 movlw d'4' | |
1006 cpfseq active_gas ; is this gas currently selected? | |
1007 bra check_gas_change4x ; No... | |
1008 bra check_gas_change5 ; Yes, skip depth check | |
1009 check_gas_change4x: | |
1010 read_int_eeprom d'31' ; read gas_change_depth | |
179
77ab44108c07
BUGFIX: Inactive gases greyed-out in Simulator results
Heinrichsweikamp
parents:
171
diff
changeset
|
1011 movlw d'3' |
8 | 1012 cpfsgt EEDATA ; Change depth>3m? |
1013 bra check_gas_change5 ; No, Change depth not deep enough, skip! | |
1014 movf xC+0,W ; load depth in m into WREG | |
1015 cpfsgt EEDATA ; gas_change_depth < current depth? | |
1016 bra check_gas_change5 ; No, check next gas | |
1017 movlw d'3' | |
1018 subwf EEDATA,W ; Change depth-3m | |
1019 cpfslt xC+0 ; current depth<Change depth-3m? | |
1020 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | |
1021 | |
1022 check_gas_change5: ; check gas5 | |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
1023 btfss gaslist_active,4 ; check active flag |
8 | 1024 bra check_gas_change6 ; skip inactive gases! |
1025 movlw d'5' | |
1026 cpfseq active_gas ; is this gas currently selected? | |
1027 bra check_gas_change5x ; No... | |
1028 bra check_gas_change6 ; Yes, skip depth check | |
1029 check_gas_change5x: | |
1030 read_int_eeprom d'32' ; read gas_change_depth | |
179
77ab44108c07
BUGFIX: Inactive gases greyed-out in Simulator results
Heinrichsweikamp
parents:
171
diff
changeset
|
1031 movlw d'3' |
8 | 1032 cpfsgt EEDATA ; Change depth>3m? |
1033 bra check_gas_change6 ; No, Change depth not deep enough, skip! | |
1034 movf xC+0,W ; load depth in m into WREG | |
1035 cpfsgt EEDATA ; gas_change_depth < current depth? | |
1036 bra check_gas_change6 ; No, check next gas | |
1037 movlw d'3' | |
1038 subwf EEDATA,W ; Change depth-3m | |
1039 cpfslt xC+0 ; current depth<Change depth-3m? | |
1040 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | |
1041 | |
1042 check_gas_change6: ;Done | |
210 | 1043 call PLED_active_gas_divemode; Display gas, if required (and with "*" if irequired...) |
8 | 1044 return |
1045 | |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
1046 ;============================================================================= |
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
1047 |
0 | 1048 calculate_noflytime: |
1049 ; calculate nofly time | |
1050 movff int_O_desaturation_time+0,xA+0 | |
1051 movff int_O_desaturation_time+1,xA+1 | |
251 | 1052 |
1053 btfsc xA+1,7 ; Is desat time negatif ? | |
1054 bra calculate_noflytime_3 ; Then surely not valid ! | |
1055 | |
0 | 1056 tstfsz xA+0 ; Desat=0? |
1057 bra calculate_noflytime2 | |
1058 tstfsz xA+1 ; Desat=0? | |
1059 bra calculate_noflytime2 | |
229
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
228
diff
changeset
|
1060 |
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
228
diff
changeset
|
1061 calculate_noflytime_3: |
0 | 1062 ; Desaturation time = zero |
229
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
228
diff
changeset
|
1063 clrf nofly_time+0 ; Clear nofly time |
0 | 1064 clrf nofly_time+1 ; Clear nofly time |
1065 bcf nofly_active ; Clear flag | |
1066 return | |
218 | 1067 |
0 | 1068 calculate_noflytime2: |
1069 movff xA+0,int_I_temp+0 | |
1070 movff xA+1,int_I_temp+1 | |
1071 GETCUSTOM8 .13 ; nofly_time_ratio | |
218 | 1072 movff WREG,char_I_temp |
0 | 1073 ostc_debug 'K' ; Sends debug-information to screen if debugmode active |
116 | 1074 call deco_calc_percentage |
0 | 1075 movlb b'00000001' ; select ram bank 1 |
1076 ostc_debug 'L' ; Sends debug-information to screen if debugmode active | |
1077 movff int_I_temp+0,xA+0 | |
1078 movff int_I_temp+1,xA+1 | |
1079 tstfsz xA+0 ; Desat=0? | |
1080 bra calculate_noflytime_2_final | |
1081 tstfsz xA+1 ; Desat=0? | |
1082 bra calculate_noflytime_2_final | |
229
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
228
diff
changeset
|
1083 bra calculate_noflytime_3 |
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
228
diff
changeset
|
1084 |
0 | 1085 calculate_noflytime_2_final: |
1086 movff xA+0,nofly_time+0 | |
1087 movff xA+1,nofly_time+1 | |
1088 bsf nofly_active ; Set flag | |
1089 return | |
1090 | |
1091 end_dive: | |
1092 btfss realdive ; dive longer then one minute | |
1093 goto end_dive_common ; No, discard everything | |
1094 | |
233 | 1095 ; In DEBUG compile, keep all simulated dives in logbook, Desat time, nofly, etc... |
1096 ifndef __DEBUG | |
1097 btfsc simulatormode_active ; Are we in simulator mode? | |
1098 goto end_dive_common ; Yes, discard everything | |
1099 endif | |
33 | 1100 |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
75
diff
changeset
|
1101 ; Dive finished (and longer then one minute or Apnoe timeout occured) |
0 | 1102 |
1103 btfsc FLAG_apnoe_mode ; Calc max. depth (again) for very short apnoe dives | |
1104 rcall apnoe_calc_maxdepth | |
1105 | |
1106 ; calculate desaturation time | |
251 | 1107 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; Pass surface to desat routine ! |
1108 movff last_surfpressure_30min+1,int_I_pres_surface+1 | |
0 | 1109 |
251 | 1110 GETCUSTOM8 d'12' ; Desaturation multiplier % |
229
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
228
diff
changeset
|
1111 movff WREG,char_I_desaturation_multiplier |
0 | 1112 |
1113 ostc_debug 'G' ; Sends debug-information to screen if debugmode active | |
251 | 1114 call deco_calc_desaturation_time ; calculate desaturation time |
229
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
228
diff
changeset
|
1115 movlb b'00000001' ; select ram bank 1 |
257
f8f869bafd92
Use timer TMR3 to limit loops in calc_hauptroutine_calc_deco()
JeanDo
parents:
256
diff
changeset
|
1116 call calc_deko_surfmode ; work-around for nofly bug |
229
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
228
diff
changeset
|
1117 rcall calculate_noflytime ; Calc NoFly time |
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
228
diff
changeset
|
1118 ostc_debug 'H' ; Sends debug-information to screen if debugmode active |
0 | 1119 ; store header and ... |
1120 movlw 0xFD ; .... End-of-Profile Bytes | |
1121 call write_external_eeprom | |
1122 movlw 0xFD | |
1123 call write_external_eeprom | |
1124 movlw 0xFE ; This positon will be overwritten for the next profile | |
229
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
228
diff
changeset
|
1125 call write_external_eeprom ; and is required to find the newest dive after a firmware reset |
0 | 1126 |
1127 movff eeprom_header_address+0, eeprom_address+0 ; set header adress | |
1128 movff eeprom_header_address+1, eeprom_address+1 ; write header | |
1129 | |
1130 movlw 0xFA ; Header start | |
1131 call write_external_eeprom | |
1132 movlw 0xFA | |
1133 call write_external_eeprom | |
229
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
228
diff
changeset
|
1134 movlw logbook_profile_version ; Defined in definitions_vxyy.asm |
0 | 1135 call write_external_eeprom |
229
85ea09d3b9d8
Nofly should not be reset after dive simulation (bug BB18).
JeanDo
parents:
228
diff
changeset
|
1136 movf month,W ; Date |
0 | 1137 call write_external_eeprom |
1138 movf day,W | |
1139 call write_external_eeprom | |
1140 movf year,W | |
1141 call write_external_eeprom | |
1142 movf hours,W ; End of dive time | |
1143 call write_external_eeprom | |
1144 movf mins,W | |
1145 call write_external_eeprom | |
1146 | |
1147 btfss FLAG_apnoe_mode ; Store apnoe max or normal max (Which is only max from the last descent) | |
1148 bra end_dive1 ; Store normal depth | |
1149 | |
1150 movff apnoe_max_pressure+0,lo | |
1151 movff apnoe_max_pressure+1,hi | |
1152 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mBar] | |
1153 movff lo,apnoe_max_pressure+0 | |
1154 movff hi,apnoe_max_pressure+1 | |
1155 | |
1156 movf apnoe_max_pressure+0,W ; Max. depth | |
1157 call write_external_eeprom | |
1158 movf apnoe_max_pressure+1,W | |
1159 call write_external_eeprom | |
1160 bra end_dive2 ; skip | |
1161 | |
1162 end_dive1: | |
1163 movff max_pressure+0,lo | |
1164 movff max_pressure+1,hi | |
1165 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mBar] | |
1166 movff lo,max_pressure+0 | |
1167 movff hi,max_pressure+1 | |
1168 | |
1169 movf max_pressure+0,W ; Max. depth | |
1170 call write_external_eeprom | |
1171 movf max_pressure+1,W | |
1172 call write_external_eeprom | |
1173 | |
1174 end_dive2: | |
1175 movf divemins+0,W ; divetime minutes | |
1176 call write_external_eeprom | |
1177 movf divemins+1,W | |
1178 call write_external_eeprom | |
1179 movf divesecs,W ; divetime seconds | |
1180 call write_external_eeprom | |
1181 movf mintemp+0,W ; minimum temperature | |
1182 call write_external_eeprom | |
1183 movf mintemp+1,W | |
1184 call write_external_eeprom | |
1185 movf last_surfpressure_30min+0,W ; airpressure before dive | |
1186 call write_external_eeprom | |
1187 movf last_surfpressure_30min+1,W | |
1188 call write_external_eeprom | |
1189 movff int_O_desaturation_time+0,lo ; | |
1190 movff int_O_desaturation_time+1,hi | |
1191 movf lo,W ; desaturation time in minutes | |
1192 call write_external_eeprom | |
1193 movf hi,W ; | |
1194 call write_external_eeprom | |
1195 | |
1196 ; Gases.... | |
1197 read_int_eeprom d'6' ; Read byte (stored in EEDATA) | |
1198 movf EEDATA,W | |
1199 call write_external_eeprom | |
1200 read_int_eeprom d'7' ; Read byte (stored in EEDATA) | |
1201 movf EEDATA,W | |
1202 call write_external_eeprom | |
1203 | |
1204 read_int_eeprom d'10' ; Read byte (stored in EEDATA) | |
1205 movf EEDATA,W | |
1206 call write_external_eeprom | |
1207 read_int_eeprom d'11' ; Read byte (stored in EEDATA) | |
1208 movf EEDATA,W | |
1209 call write_external_eeprom | |
1210 | |
1211 read_int_eeprom d'14' ; Read byte (stored in EEDATA) | |
1212 movf EEDATA,W | |
1213 call write_external_eeprom | |
1214 read_int_eeprom d'15' ; Read byte (stored in EEDATA) | |
1215 movf EEDATA,W | |
1216 call write_external_eeprom | |
1217 | |
1218 read_int_eeprom d'18' ; Read byte (stored in EEDATA) | |
1219 movf EEDATA,W | |
1220 call write_external_eeprom | |
1221 read_int_eeprom d'19' ; Read byte (stored in EEDATA) | |
1222 movf EEDATA,W | |
1223 call write_external_eeprom | |
1224 | |
1225 read_int_eeprom d'22' ; Read byte (stored in EEDATA) | |
1226 movf EEDATA,W | |
1227 call write_external_eeprom | |
1228 read_int_eeprom d'23' ; Read byte (stored in EEDATA) | |
1229 movf EEDATA,W | |
1230 call write_external_eeprom | |
1231 | |
1232 read_int_eeprom d'24' ; % O2 Gas6 | |
1233 movf EEDATA,W | |
1234 call write_external_eeprom | |
1235 read_int_eeprom d'25' ; % He Gas6 | |
1236 movf EEDATA,W | |
1237 call write_external_eeprom | |
1238 read_int_eeprom d'33' ; start gas | |
1239 movf EEDATA,W | |
1240 call write_external_eeprom | |
1241 | |
1242 movlw softwareversion_x ; Firmware version | |
1243 call write_external_eeprom | |
1244 movlw softwareversion_y | |
1245 call write_external_eeprom | |
1246 movf batt_voltage+0,W ; Battery voltage | |
1247 call write_external_eeprom | |
1248 movf batt_voltage+1,W | |
1249 call write_external_eeprom | |
1250 | |
1251 GETCUSTOM8 d'20' ; sampling rate in WREG | |
1252 btfsc FLAG_apnoe_mode ; Apnoe mode? | |
1253 movlw d'1' ; Apnoe sampling rate | |
1254 call write_external_eeprom | |
1255 | |
1256 movlw d'2' ; information size temperature | |
1257 movwf temp1 ; copy to bits 0-3 | |
1258 swapf temp1,F ; swap nibbels 0-3 with 4-7 | |
1259 GETCUSTOM8 d'21' ; Divisor temperature | |
1260 addwf temp1,W ; copy to bits 0-3, result in WREG | |
1261 call write_external_eeprom | |
1262 | |
1263 movlw d'2' ; information size deco | |
1264 movwf temp1 ; copy to bits 0-3 | |
1265 swapf temp1,F ; swap nibbels 0-3 with 4-7 | |
1266 GETCUSTOM8 d'22' ; Divisor deco | |
1267 addwf temp1,W ; copy to bits 0-3, result in WREG | |
1268 call write_external_eeprom | |
1269 | |
1270 movlw d'2' ; information size tank | |
1271 movwf temp1 ; copy to bits 0-3 | |
1272 swapf temp1,F ; swap nibbels 0-3 with 4-7 | |
1273 GETCUSTOM8 d'23' ; Divisor Tank | |
1274 addwf temp1,W ; copy to bits 0-3, result in WREG | |
1275 call write_external_eeprom | |
1276 | |
1277 movlw d'3' ; information size pp02 | |
1278 movwf temp1 ; copy to bits 0-3 | |
1279 swapf temp1,F ; swap nibbels 0-3 with 4-7 | |
1280 GETCUSTOM8 d'24' ; Divisor pp02 | |
1281 addwf temp1,W ; copy to bits 0-3, result in WREG | |
1282 call write_external_eeprom | |
1283 | |
1284 movlw d'9' ; information size Decodebug | |
1285 movwf temp1 ; copy to bits 0-3 | |
1286 swapf temp1,F ; swap nibbels 0-3 with 4-7 | |
1287 GETCUSTOM8 d'25' ; Divisor Decodebug | |
1288 addwf temp1,W ; copy to bits 0-3, result in WREG | |
1289 call write_external_eeprom | |
1290 | |
1291 movlw d'0' ; information size nuy2 | |
1292 movwf temp1 ; copy to bits 0-3 | |
1293 swapf temp1,F ; swap nibbels 0-3 with 4-7 | |
1294 GETCUSTOM8 d'26' ; Divisor nuy2 | |
1295 addwf temp1,W ; copy to bits 0-3, result in WREG | |
1296 call write_external_eeprom | |
1297 | |
1298 read_int_eeprom d'26' ; Read Salinity from EEPROM | |
1299 movf EEDATA,W | |
1300 call write_external_eeprom ; Store Salinity to Dive | |
253
3a4096f32526
show CNS in logbook for all dives made with V1.84beta and later
heinrichsweikamp
parents:
251
diff
changeset
|
1301 |
3a4096f32526
show CNS in logbook for all dives made with V1.84beta and later
heinrichsweikamp
parents:
251
diff
changeset
|
1302 movff char_O_CNS_fraction,WREG ; copy into bank1 |
3a4096f32526
show CNS in logbook for all dives made with V1.84beta and later
heinrichsweikamp
parents:
251
diff
changeset
|
1303 call write_external_eeprom ; Stores CNS% |
0 | 1304 |
1305 movlw 0xFB ; Header stop | |
1306 call write_external_eeprom | |
1307 movlw 0xFB | |
1308 call write_external_eeprom | |
1309 | |
1310 ; Increase total dive counter | |
1311 read_int_eeprom d'2' ; Read byte (stored in EEDATA) | |
1312 movff EEDATA,temp1 ; Low byte | |
1313 read_int_eeprom d'3' ; Read byte (stored in EEDATA) | |
1314 movff EEDATA,temp2 ; high byte | |
1315 bcf STATUS,C | |
1316 movlw d'1' | |
1317 addwf temp1 | |
1318 movlw d'0' | |
1319 addwfc temp2 | |
1320 movff temp1,EEDATA | |
1321 write_int_eeprom d'2' ; write byte stored in EEDATA | |
1322 movff temp2,EEDATA | |
1323 write_int_eeprom d'3' ; write byte stored in EEDATA | |
1324 | |
1325 GETCUSTOM15 .28 ; Logbook Offset -> lo, hi | |
1326 tstfsz lo ; lo=0? | |
1327 bra change_logbook_offset1 ; No, adjust offset | |
1328 tstfsz hi ; hi=0? | |
1329 bra change_logbook_offset1 ; No, adjust offset | |
1330 bra change_logbook_offset2 ; lo=0 and hi=0 -> skip Offset routine | |
1331 change_logbook_offset1: | |
1332 movlw d'1' | |
1333 addwf lo | |
1334 movlw d'0' | |
1335 addwfc hi | |
1336 movlw d'112' ; CF28 *4 Bytes... | |
1337 addlw 0x82 | |
1338 movwf EEADR | |
1339 movff lo,EEDATA | |
1340 call write_eeprom ; Lowbyte | |
1341 movlw d'112' ; CF28 *4 Bytes... | |
1342 addlw 0x83 | |
1343 movwf EEADR | |
1344 movff hi,EEDATA | |
1345 call write_eeprom ; Highbyte | |
1346 | |
1347 change_logbook_offset2: | |
25 | 1348 bcf LED_blue |
129
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1349 clrf surface_interval+0 |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1350 clrf surface_interval+1 ; Clear surface interval timer |
33 | 1351 |
1352 end_dive_common: | |
0 | 1353 bcf simulatormode_active ; if we were in simulator mode |
1354 | |
1355 btfsc restore_deco_data ; Restore decodata? | |
1356 call simulator_restore_tissue_data ; Yes! | |
1357 | |
1358 goto surfloop ; and return to surfaceloop | |
1359 | |
1360 timeout_divemode: | |
1361 btfss realdive ; Dive longer then one minute | |
1362 return | |
1363 | |
1364 btfsc FLAG_apnoe_mode ; In Apnoe mode? | |
1365 bra timeout_divemode2 ; Yes, use CF30 [min] for timeout | |
1366 | |
233 | 1367 ifndef __DEBUG |
1368 btfsc simulatormode_active ; In Simulator mode? | |
1369 bra timeout_divemode3 ; Yes, use fixed 5 seconds timeout | |
1370 endif | |
0 | 1371 |
1372 bcf divemode | |
1373 incf timeout_counter,F | |
1374 GETCUSTOM8 d'2' ; diveloop_timeout | |
1375 addlw d'2' ; adds two seconds in case timout=zero! | |
1376 btfsc STATUS,C ; > 255? | |
1377 movlw d'255' ; Set to 255... | |
1378 decf WREG,F ; Limit to 254 | |
1379 cpfsgt timeout_counter | |
1380 bsf divemode | |
1381 return | |
1382 | |
1383 timeout_divemode2: | |
1384 incf timeout_counter,F ; seconds... | |
1385 movlw d'60' | |
1386 cpfseq timeout_counter ; timeout_counter=60? | |
1387 return ; No. | |
1388 | |
1389 clrf timeout_counter | |
1390 bcf divemode | |
1391 incf apnoe_timeout_counter,F | |
1392 GETCUSTOM8 d'30' ; apnoe timeout [min] | |
1393 cpfseq apnoe_timeout_counter | |
1394 bsf divemode | |
1395 return | |
1396 | |
1397 timeout_divemode3: | |
1398 bcf divemode | |
1399 incf timeout_counter,F | |
1400 movlw d'5' ; Fixed timeout of 5 seconds | |
1401 cpfsgt timeout_counter | |
1402 bsf divemode | |
1403 return | |
1404 | |
1405 update_divemode1: ; update any second | |
1406 call set_dive_modes ; tests if depth>threshold | |
1407 | |
1408 btfsc divemode | |
1409 call set_max_depth ; update max. depth if required | |
1410 | |
1411 btfsc divemode | |
1412 call set_min_temp ; store min. temp if required | |
1413 | |
1414 bcf temp_changed ; Display temperature? | |
1415 movf temperature+0,W | |
1416 cpfseq last_temperature+0 | |
1417 bsf temp_changed ; Yes | |
1418 movf temperature+1,W | |
1419 cpfseq last_temperature+1 | |
1420 bsf temp_changed ; Yes | |
1421 btfsc temp_changed | |
1422 call PLED_temp_divemode ; Displays temperature | |
1423 | |
1424 bcf pres_changed ; Display new depth? | |
1425 movf amb_pressure+0,W | |
1426 cpfseq last_pressure+0 | |
1427 bsf pres_changed ; Yes | |
1428 movf amb_pressure+1,W | |
1429 cpfseq last_pressure+1 | |
1430 bsf pres_changed ; Yes | |
1431 | |
1432 btfsc simulatormode_active ; always update depth when in simulator mode | |
1433 bsf pres_changed | |
1434 | |
1435 btfsc pres_changed | |
1436 call PLED_depth ; Displays new depth | |
1437 return | |
1438 | |
1439 update_divemode60: ; update any minute | |
1440 call get_battery_voltage ; gets battery voltage | |
1441 call set_powersafe ; red LED blinking if battery is low | |
1442 call PLED_max_pressure ; No, use normal max. depth | |
1443 call check_temp_extrema ; check for new temperature extremas | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
83
diff
changeset
|
1444 call customview_minute ; Do every-minute tasks for the custom view area |
0 | 1445 bcf oneminupdate |
1446 return | |
1447 | |
1448 set_max_depth: | |
1449 movff max_pressure+0,sub_a+0 | |
1450 movff max_pressure+1,sub_a+1 | |
1451 movff rel_pressure+0,sub_b+0 | |
1452 movff rel_pressure+1,sub_b+1 | |
1453 call sub16 ; sub_c = sub_a - sub_b | |
1454 ; max_pressure<rel_pressure -> neg_flag=1 | |
1455 ; rel_pressure<=max_pressure -> neg_flag=0 | |
1456 btfss neg_flag | |
1457 return | |
1458 ;max_pressure<rel_pressure | |
1459 movff rel_pressure+0,max_pressure+0 | |
1460 movff rel_pressure+1,max_pressure+1 | |
1461 call PLED_max_pressure ; No, use normal max. depth | |
1462 return | |
1463 | |
1464 set_min_temp: | |
1465 movff mintemp+0,sub_a+0 | |
1466 movff mintemp+1,sub_a+1 | |
1467 movff temperature+0,sub_b+0 | |
1468 movff temperature+1,sub_b+1 | |
1469 call sub16 ; sub_c = sub_a - sub_b | |
1470 ; mintemp<T -> neg_flag=1 | |
1471 ; T<=mintemp -> neg_flag=0 | |
1472 btfsc neg_flag | |
1473 return | |
1474 ;mintemp>=T | |
1475 movff temperature+0,mintemp+0 | |
1476 movff temperature+1,mintemp+1 | |
1477 return | |
1478 | |
1479 set_dive_modes: | |
239 | 1480 btfsc high_altitude_mode ; In high altitude (Fly) mode? |
1481 bra set_dive_modes3 ; Yes | |
1482 | |
0 | 1483 bcf divemode2 ; Stop time |
1484 | |
1485 GETCUSTOM8 .0 ; loads dive_threshold in WREG | |
1486 movwf sub_a+0 ; dive_treshold is in cm | |
1487 clrf sub_a+1 | |
1488 movff rel_pressure+0,sub_b+0 | |
1489 movff rel_pressure+1,sub_b+1 | |
239 | 1490 call sub16 ; sub_c = sub_a - sub_b |
0 | 1491 |
1492 btfss neg_flag | |
239 | 1493 bra set_dive_modes2 ; too shallow (rel_pressure<dive_threshold) |
0 | 1494 |
239 | 1495 btfsc realdive ; Dive longer than one minute? |
1496 clrf timeout_counter ; Yes, reset timout counter | |
0 | 1497 |
239 | 1498 bsf divemode ; (Re-)Set divemode flag |
0 | 1499 bsf divemode2 ; displayed divetime is running |
1500 return | |
1501 | |
1502 set_dive_modes2: | |
1503 btfss realdive ; dive longer then one minute? | |
1504 bcf divemode ; no -> this was no real dive | |
1505 return | |
1506 | |
239 | 1507 set_dive_modes3: |
1508 movlw HIGH d'1075' ; hard-wired 1075mBar threshold | |
1509 movwf sub_a+1 | |
1510 movlw LOW d'1075' ; hard-wired 1075mBar threshold | |
1511 movwf sub_a+0 | |
1512 movff rel_pressure+0,sub_b+0 | |
1513 movff rel_pressure+1,sub_b+1 | |
1514 call sub16 ; sub_c = sub_a - sub_b | |
1515 | |
1516 btfss neg_flag | |
1517 bra set_dive_modes2 ; too shallow (rel_pressure<dive_threshold) | |
1518 | |
1519 bsf divemode ; (Re-)Set divemode flag | |
1520 bsf divemode2 ; displayed divetime is running | |
1521 return | |
1522 | |
0 | 1523 set_powersafe: |
1524 btfsc low_battery_state ; battery warning alread active? | |
1525 bra set_powersafe2 ; Yes, but is it still required? | |
1526 ; battery voltage in mV (value*256+Lowbyte=actual treshold) | |
1527 movlw d'12' ; 3,328V | |
1528 cpfsgt batt_voltage+1 | |
1529 bra set_powersafe1 | |
1530 return | |
1531 | |
1532 set_powersafe1: | |
1533 movlw d'7' ; Type of Alarm (Battery Low) | |
1534 movwf AlarmType ; Copy to Alarm Register | |
1535 bsf event_occured ; Set Event Flag | |
1536 bsf low_battery_state ; set flag for battery warning | |
1537 return ; return | |
1538 | |
1539 set_powersafe2: | |
1540 movlw d'13' ; 3,584V | |
1541 cpfsgt batt_voltage+1 | |
1542 bra set_powersafe1 ; Still to low | |
1543 bcf low_battery_state ; clear flag for battery warning mode | |
1544 return | |
1545 | |
1546 calc_average_depth: | |
111 | 1547 btfsc reset_average_depth ; Reset the Avewrage depth? |
1548 rcall reset_average1 ; Reset the resettable average depth | |
1549 | |
0 | 1550 ; 1. Add new 2xdepth to the Sum of depths registers |
1551 movff rel_pressure+0,b0_lo | |
129
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1552 movff rel_pressure+1,b0_hi ; Buffer... |
0 | 1553 |
1554 movf b0_lo,w | |
1555 addwf average_depth_hold+0,F | |
1556 movf b0_hi,w | |
1557 addwfc average_depth_hold+1,F | |
1558 movlw d'0' | |
1559 addwfc average_depth_hold+2,F | |
1560 addwfc average_depth_hold+3,F ; Will work up to 9999mBar*60*60*24=863913600mBar | |
1561 | |
1562 movf b0_lo,w | |
1563 addwf average_depth_hold+0,F | |
1564 movf b0_hi,w | |
1565 addwfc average_depth_hold+1,F | |
1566 movlw d'0' | |
1567 addwfc average_depth_hold+2,F | |
1568 addwfc average_depth_hold+3,F ; Will work up to 9999mBar*60*60*24=863913600mBar | |
1569 | |
129
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1570 ; Do the same for the _total registers (Non-Resettable) |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1571 movf b0_lo,w |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1572 addwf average_depth_hold_total+0,F |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1573 movf b0_hi,w |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1574 addwfc average_depth_hold_total+1,F |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1575 movlw d'0' |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1576 addwfc average_depth_hold_total+2,F |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1577 addwfc average_depth_hold_total+3,F ; Will work up to 9999mBar*60*60*24=863913600mBar |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1578 |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1579 movf b0_lo,w |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1580 addwf average_depth_hold_total+0,F |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1581 movf b0_hi,w |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1582 addwfc average_depth_hold_total+1,F |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1583 movlw d'0' |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1584 addwfc average_depth_hold_total+2,F |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1585 addwfc average_depth_hold_total+3,F ; Will work up to 9999mBar*60*60*24=863913600mBar |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1586 |
0 | 1587 ; 2. Compute Average Depth on base of average_divesecs:2 |
1588 movff average_divesecs+0,xB+0 | |
1589 movff average_divesecs+1,xB+1 ; Copy | |
1590 movff average_depth_hold+0,xC+0 | |
1591 movff average_depth_hold+1,xC+1 | |
1592 movff average_depth_hold+2,xC+2 | |
1593 movff average_depth_hold+3,xC+3 | |
1594 | |
1595 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
1596 movff xC+0,avr_rel_pressure+0 | |
1597 movff xC+1,avr_rel_pressure+1 | |
129
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1598 |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1599 ; Compute Total Average Depth on base of divemins:2 and divesecs |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1600 movff divemins+0,xA+0 |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1601 movff divemins+1,xA+1 |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1602 movlw d'60' |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1603 movwf xB+0 |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1604 clrf xB+1 |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1605 call mult16x16 ; xC:4=xA:2*xB:2 |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1606 movf divesecs,W |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1607 addwf xC+0,F |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1608 movlw d'0' |
228 | 1609 addwfc xC+1,F ; xC:2 holds total dive seconds |
129
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1610 movlw d'3' ; 2+1 |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1611 btfss divesecs,0 ; divesecs even? |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1612 movlw d'2' ; Yes, do not add +1 |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1613 addwf xC+0,F |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1614 movlw d'0' |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1615 addwfc xC+1,F |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1616 ; Ignore xC+2 and xC+3. Total Average will only work up to divetime=1092:16 |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1617 movff xC+0,xB+0 |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1618 movff xC+1,xB+1 ; Copy |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1619 movff average_depth_hold_total+0,xC+0 |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1620 movff average_depth_hold_total+1,xC+1 |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1621 movff average_depth_hold_total+2,xC+2 |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1622 movff average_depth_hold_total+3,xC+3 |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1623 |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1624 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1625 movff xC+0,avr_rel_pressure_total+0 |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1626 movff xC+1,avr_rel_pressure_total+1 |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1627 |
0 | 1628 return |
1629 | |
111 | 1630 reset_average1: |
1631 clrf average_depth_hold+0 | |
1632 clrf average_depth_hold+1 | |
1633 clrf average_depth_hold+2 | |
1634 clrf average_depth_hold+3 ; Clear average depth register | |
1635 movlw d'2' | |
1636 movwf average_divesecs+0 | |
1637 clrf average_divesecs+1 | |
1638 bcf reset_average_depth ; Clear flag | |
1639 return | |
0 | 1640 |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
1641 ;============================================================================= |
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
1642 ; Setup everything to enter divemode. |
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
1643 ; |
0 | 1644 diveloop_boot: |
49 | 1645 ostc_debug 'Q' ; Sends debug-information to screen if debugmode active |
0 | 1646 clrf max_pressure+0 ; clear some variables |
1647 clrf max_pressure+1 | |
1648 | |
1649 clrf avr_rel_pressure+0 | |
1650 clrf avr_rel_pressure+1 | |
1651 | |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
1652 clrf EEADRH ; Make sure to select eeprom bank 0 |
0 | 1653 call PLED_brightness_low |
1654 read_int_eeprom d'90' ; Brightness offset? (Dim>0, Normal = 0) | |
1655 movlw d'0' | |
1656 cpfsgt EEDATA | |
1657 call PLED_brightness_full | |
1658 | |
1659 movlw d'1' | |
1660 movwf apnoe_max_pressure+0 | |
1661 clrf apnoe_max_pressure+1 | |
1662 clrf apnoe_surface_mins | |
1663 clrf apnoe_surface_secs | |
1664 clrf apnoe_mins | |
1665 clrf apnoe_secs | |
1666 clrf divemins+0 | |
1667 clrf divemins+1 | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
83
diff
changeset
|
1668 clrf menupos3 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
83
diff
changeset
|
1669 bcf menu3_active |
0 | 1670 clrf divesecs |
1671 clrf samplesecs | |
1672 clrf apnoe_timeout_counter ; timeout in minutes | |
1673 clrf timeout_counter ; takes care of the timeout | |
1674 clrf timeout_counter2 ; Here: counts to six, then store deco data and temperature | |
1675 clrf AlarmType ; Clear all alarms | |
1676 bcf event_occured ; clear flag | |
274
a728b4a1b660
Setpoint changes stored in profile, EAD and END displayed in divemode (Customview 7)
heinrichsweikamp
parents:
263
diff
changeset
|
1677 bcf setpoint_changed ; clear flag |
111 | 1678 rcall reset_average1 ; Reset the resettable average depth |
129
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1679 clrf average_depth_hold_total+0 |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1680 clrf average_depth_hold_total+1 |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1681 clrf average_depth_hold_total+2 |
06c4899ddb4b
Custom views in dive mode configrable (New CF50-CF53)
Heinrichsweikamp
parents:
124
diff
changeset
|
1682 clrf average_depth_hold_total+3 ; Clear Non-Resettable Average |
0 | 1683 bcf depth_greater_100m ; clear flag |
1684 setf last_diluent ; to be displayed after first calculation (range: 0 to 100 [%]) | |
3 | 1685 bcf dekostop_active |
1686 bcf is_bailout ;=1: CC mode, but bailout active! | |
8 | 1687 bcf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode |
1688 | |
0 | 1689 call get_free_EEPROM_location ; get last position in external EEPROM, may be up to 2 secs! |
1690 | |
237 | 1691 btfss simulatormode_active |
1692 bra diveloop_boot_1 | |
1693 ; Normal mode = Surface pressure is the pressure 30mn before dive. | |
0 | 1694 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; LOW copy surfacepressure to deco routine |
237 | 1695 movff last_surfpressure_30min+1,int_I_pres_surface+1 ; HIGH copy surfacepressure to deco routine |
1696 bra diveloop_boot_2 | |
1697 | |
1698 diveloop_boot_1: | |
1699 ; Simulator mode: Surface pressure is 1bar. | |
1700 movlw LOW .1000 | |
1701 movff WREG,int_I_pres_surface+0 ; LOW copy surfacepressure to deco routine | |
1702 movlw HIGH .1000 | |
1703 movff WREG,int_I_pres_surface+1 ; HIGH copy surfacepressure to deco routine | |
1704 | |
1705 diveloop_boot_2: | |
1706 movff temperature+0,mintemp+0 ; Reset Min-Temp registers | |
1707 movff temperature+1,mintemp+1 ; Reset Min-Temp registers | |
0 | 1708 |
1709 ; Init profile recording parameters | |
237 | 1710 GETCUSTOM8 d'20' ; sample rate |
1711 movwf samplesecs_value ; to avoid EEPROM access in the ISR | |
0 | 1712 GETCUSTOM8 d'21' |
237 | 1713 movwf divisor_temperature ; load divisors for profile storage |
0 | 1714 GETCUSTOM8 d'22' |
1715 movwf divisor_deco | |
1716 GETCUSTOM8 d'23' | |
1717 movwf divisor_tank | |
1718 GETCUSTOM8 d'24' | |
1719 movwf divisor_ppo2 | |
1720 GETCUSTOM8 d'25' | |
1721 movwf divisor_deco_debug | |
1722 GETCUSTOM8 d'26' | |
1723 movwf divisor_nuy2 | |
1724 | |
1725 btfss FLAG_apnoe_mode ; In Apnoe mode? | |
1726 bra divemode1 | |
1727 ; Overwrite some parameters in Apnoe mode.... | |
1728 movlw d'1' | |
1729 movwf samplesecs_value ; to avoid EEPROM access in the ISR | |
1730 | |
1731 divemode1: | |
1732 read_int_eeprom d'36' ; Read mix 1 ppO2 | |
1733 btfsc FLAG_const_ppO2_mode | |
292 | 1734 movff EEDATA,char_I_const_ppO2 ; Set ppO2 setpoint if in ppO2 mode |
1735 movff EEDATA,ppO2_setpoint_store ; Store also in this byte... | |
0 | 1736 |
21 | 1737 bcf LED_blue |
0 | 1738 bcf low_battery_state ; clear flag for battery warning mode |
1739 bcf header_stored | |
1740 bcf premenu | |
1741 bcf realdive | |
1742 bsf update_divetime ; set flag | |
1743 btfss simulatormode_active ; do not disable in simulator mode! | |
49 | 1744 call disable_rs232 ; Disable RS232 |
0 | 1745 |
292 | 1746 ; Read Start Gas and configure char_I_He_ratio, char_I_O2_ratio and char_I_N2_ratio |
1747 set_first_gas: | |
0 | 1748 read_int_eeprom d'33' ; Read byte (stored in EEDATA) |
1749 movff EEDATA,active_gas ; Read start gas (1-5) | |
1750 | |
1751 decf active_gas,W ; Gas 0-4 | |
1752 mullw d'4' | |
1753 movf PRODL,W | |
1754 addlw d'7' ; = address for He ratio | |
1755 movwf EEADR | |
1756 call read_eeprom ; Read He ratio | |
1757 movff EEDATA,char_I_He_ratio ; And copy into hold register | |
292 | 1758 |
1759 decf EEADR,F | |
0 | 1760 call read_eeprom ; Read O2 ratio |
1761 movff EEDATA, char_I_O2_ratio ; O2 ratio | |
292 | 1762 |
0 | 1763 movff char_I_He_ratio, wait_temp ; copy into bank1 register |
1764 bsf STATUS,C ; Borrow bit | |
1765 movlw d'100' ; 100% | |
1766 subfwb wait_temp,W ; minus He | |
1767 bsf STATUS,C ; Borrow bit | |
1768 subfwb EEDATA,F ; minus O2 | |
1769 movff EEDATA, char_I_N2_ratio ; = N2! | |
1770 | |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
1771 ; Configure gaslist_active flag register |
281 | 1772 read_int_eeprom d'27' |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
1773 movff EEDATA, gaslist_active |
281 | 1774 return |