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