Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/divemode.asm @ 72:77f1556457b1
added missing source file
author | heinrichsweikamp |
---|---|
date | Sun, 14 Nov 2010 19:13:42 +0100 |
parents | 6beb680a6130 |
children | a1ccb92b59cd |
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 | |
819 ; Check if ppO2 should be displayed | |
820 movff xC+0,sub_b+0 | |
821 movff xC+1,sub_b+1 | |
822 GETCUSTOM8 d'19' ; ppo2_display_high | |
823 mullw d'100' ; ppo2_display_high*100 | |
824 movff PRODL,sub_a+0 | |
825 movff PRODH,sub_a+1 | |
826 call sub16 | |
827 bcf ppO2_show_value ; clear flag | |
828 btfsc neg_flag | |
829 bsf ppO2_show_value ; set flag if required | |
830 | |
831 ;check if we are within our warning thresholds! | |
832 bcf ppO2_warn_value ; clear flag | |
833 movff xC+0,sub_b+0 | |
834 movff xC+1,sub_b+1 | |
835 GETCUSTOM8 d'18' ; ppo2_warning_high | |
836 mullw d'100' ; ppo2_warning_high*100 | |
837 movff PRODL,sub_a+0 | |
838 movff PRODH,sub_a+1 | |
839 call sub16 | |
840 btfss neg_flag | |
841 bra check_ppO2_0 ; Not too high | |
842 | |
843 bsf ppO2_warn_value ; set flag | |
844 movlw d'5' ; Type of Alarm | |
845 movwf AlarmType ; Copy to Alarm Register | |
846 bsf event_occured ; Set Event Flag | |
847 | |
848 check_ppO2_0: | |
849 movff xC+0,sub_b+0 | |
850 movff xC+1,sub_b+1 | |
851 GETCUSTOM8 d'17' ; ppo2_warning_low | |
852 mullw d'100' ; ppo2_warning_low*100 | |
853 movff PRODL,sub_a+0 | |
854 movff PRODH,sub_a+1 | |
855 call sub16 | |
856 btfsc neg_flag | |
857 bra check_ppO2_1 ; Not too low | |
858 | |
859 bsf ppO2_warn_value ; set flag | |
860 bsf ppO2_show_value ; show ppO2 if below threshold! | |
861 movlw d'4' ; Type of Alarm | |
862 movwf AlarmType ; Copy to Alarm Register | |
863 bsf event_occured ; Set Event Flag | |
864 | |
865 check_ppO2_1: | |
866 btfsc ppO2_show_value ; show value? | |
867 bra check_ppO2_2 ; yes! | |
868 | |
869 btfss ppO2_display_active ; is the value displayed? | |
870 bra check_ppO2_3 ; No, so clear not required | |
871 | |
872 call PLED_show_ppO2_clear; Clear ppO2 value | |
873 bcf ppO2_display_active ; clear flag | |
874 bra check_ppO2_3 ; done | |
875 | |
876 check_ppO2_2: | |
877 call PLED_show_ppO2 ; Display ppO2 (stored in xC) | |
878 bsf ppO2_display_active ; Set flag | |
879 | |
880 check_ppO2_3: | |
881 return ; done | |
882 | |
883 | |
8 | 884 check_gas_change: ; Checks if a better gas should be selected (by user) |
885 bcf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | |
886 | |
887 movff rel_pressure+0,xA+0 | |
888 movff rel_pressure+1,xA+1 | |
889 movlw d'100' | |
890 movwf xB+0 | |
891 clrf xB+1 | |
892 call div16x16 ; compute depth in full m -> result in xC+0 | |
893 | |
894 check_gas_change1: ; check gas1 | |
895 read_int_eeprom d'27' ; read flag register | |
896 btfss EEDATA,0 ; check active flag | |
897 bra check_gas_change2 ; skip inactive gases! | |
898 movlw d'1' | |
899 cpfseq active_gas ; is this gas currently selected? | |
900 bra check_gas_change1x ; No... | |
901 bra check_gas_change2 ; Yes, skip depth check | |
902 check_gas_change1x: | |
903 read_int_eeprom d'28' ; read gas_change_depth | |
904 movlw d'3' | |
905 cpfsgt EEDATA ; Change depth>3m? | |
906 bra check_gas_change2 ; No, Change depth not deep enough, skip! | |
907 movf xC+0,W ; load depth in m into WREG | |
908 cpfsgt EEDATA ; gas_change_depth < current depth? | |
909 bra check_gas_change2 ; No, check next gas | |
910 movlw d'3' | |
911 subwf EEDATA,W ; Change depth-3m | |
912 cpfslt xC+0 ; current depth<Change depth-3m? | |
913 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | |
914 | |
915 check_gas_change2: ; check gas2 | |
916 read_int_eeprom d'27' ; read flag register | |
917 btfss EEDATA,1 ; check active flag | |
918 bra check_gas_change3 ; skip inactive gases! | |
919 movlw d'2' | |
920 cpfseq active_gas ; is this gas currently selected? | |
921 bra check_gas_change2x ; No... | |
922 bra check_gas_change3 ; Yes, skip depth check | |
923 check_gas_change2x: | |
924 read_int_eeprom d'29' ; read gas_change_depth | |
925 movlw d'3' | |
926 cpfsgt EEDATA ; Change depth>3m? | |
927 bra check_gas_change3 ; No, Change depth not deep enough, skip! | |
928 movf xC+0,W ; load depth in m into WREG | |
929 cpfsgt EEDATA ; gas_change_depth < current depth? | |
930 bra check_gas_change3 ; No, check next gas | |
931 movlw d'3' | |
932 subwf EEDATA,W ; Change depth-3m | |
933 cpfslt xC+0 ; current depth<Change depth-3m? | |
934 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | |
935 | |
936 check_gas_change3: ; check gas3 | |
937 read_int_eeprom d'27' ; read flag register | |
938 btfss EEDATA,2 ; check active flag | |
939 bra check_gas_change4 ; skip inactive gases! | |
940 movlw d'3' | |
941 cpfseq active_gas ; is this gas currently selected? | |
942 bra check_gas_change3x ; No... | |
943 bra check_gas_change4 ; Yes, skip depth check | |
944 check_gas_change3x: | |
945 read_int_eeprom d'30' ; read gas_change_depth | |
946 movlw d'3' | |
947 cpfsgt EEDATA ; Change depth>3m? | |
948 bra check_gas_change4 ; No, Change depth not deep enough, skip! | |
949 movf xC+0,W ; load depth in m into WREG | |
950 cpfsgt EEDATA ; gas_change_depth < current depth? | |
951 bra check_gas_change4 ; No, check next gas | |
952 movlw d'3' | |
953 subwf EEDATA,W ; Change depth-3m | |
954 cpfslt xC+0 ; current depth<Change depth-3m? | |
955 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | |
956 | |
957 check_gas_change4: ; check gas4 | |
958 read_int_eeprom d'27' ; read flag register | |
959 btfss EEDATA,3 ; check active flag | |
960 bra check_gas_change5 ; skip inactive gases! | |
961 movlw d'4' | |
962 cpfseq active_gas ; is this gas currently selected? | |
963 bra check_gas_change4x ; No... | |
964 bra check_gas_change5 ; Yes, skip depth check | |
965 check_gas_change4x: | |
966 read_int_eeprom d'31' ; read gas_change_depth | |
967 cpfsgt EEDATA ; Change depth>3m? | |
968 bra check_gas_change5 ; No, Change depth not deep enough, skip! | |
969 movf xC+0,W ; load depth in m into WREG | |
970 cpfsgt EEDATA ; gas_change_depth < current depth? | |
971 bra check_gas_change5 ; No, check next gas | |
972 movlw d'3' | |
973 subwf EEDATA,W ; Change depth-3m | |
974 cpfslt xC+0 ; current depth<Change depth-3m? | |
975 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | |
976 | |
977 check_gas_change5: ; check gas5 | |
978 read_int_eeprom d'27' ; read flag register | |
979 btfss EEDATA,4 ; check active flag | |
980 bra check_gas_change6 ; skip inactive gases! | |
981 movlw d'5' | |
982 cpfseq active_gas ; is this gas currently selected? | |
983 bra check_gas_change5x ; No... | |
984 bra check_gas_change6 ; Yes, skip depth check | |
985 check_gas_change5x: | |
986 read_int_eeprom d'32' ; read gas_change_depth | |
987 cpfsgt EEDATA ; Change depth>3m? | |
988 bra check_gas_change6 ; No, Change depth not deep enough, skip! | |
989 movf xC+0,W ; load depth in m into WREG | |
990 cpfsgt EEDATA ; gas_change_depth < current depth? | |
991 bra check_gas_change6 ; No, check next gas | |
992 movlw d'3' | |
993 subwf EEDATA,W ; Change depth-3m | |
994 cpfslt xC+0 ; current depth<Change depth-3m? | |
995 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | |
996 | |
997 check_gas_change6: ;Done | |
998 call PLED_active_gas_divemode ; Display gas, if required (and with "*" if irequired...) | |
999 return | |
1000 | |
0 | 1001 calculate_noflytime: |
1002 ; calculate nofly time | |
1003 movff int_O_desaturation_time+0,xA+0 | |
1004 movff int_O_desaturation_time+1,xA+1 | |
1005 tstfsz xA+0 ; Desat=0? | |
1006 bra calculate_noflytime2 | |
1007 tstfsz xA+1 ; Desat=0? | |
1008 bra calculate_noflytime2 | |
1009 ; Desaturation time = zero | |
1010 movlw d'1' | |
1011 movwf nofly_time+0 ; Clear nofly time | |
1012 clrf nofly_time+1 ; Clear nofly time | |
1013 bcf nofly_active ; Clear flag | |
1014 return | |
1015 | |
1016 calculate_noflytime2: | |
1017 movff xA+0,int_I_temp+0 | |
1018 movff xA+1,int_I_temp+1 | |
1019 GETCUSTOM8 .13 ; nofly_time_ratio | |
1020 movwf xB+0 | |
1021 movff xB,char_I_temp | |
1022 ostc_debug 'K' ; Sends debug-information to screen if debugmode active | |
1023 call main_calc_percentage | |
1024 movlb b'00000001' ; select ram bank 1 | |
1025 ostc_debug 'L' ; Sends debug-information to screen if debugmode active | |
1026 movff int_I_temp+0,xA+0 | |
1027 movff int_I_temp+1,xA+1 | |
1028 tstfsz xA+0 ; Desat=0? | |
1029 bra calculate_noflytime_2_final | |
1030 tstfsz xA+1 ; Desat=0? | |
1031 bra calculate_noflytime_2_final | |
1032 ; noflytime = zero | |
1033 movlw d'1' | |
1034 movwf nofly_time+0 ; Clear nofly time | |
1035 clrf nofly_time+1 ; Clear nofly time | |
1036 bcf nofly_active ; Clear flag | |
1037 return | |
1038 calculate_noflytime_2_final: | |
1039 movff xA+0,nofly_time+0 | |
1040 movff xA+1,nofly_time+1 | |
1041 bsf nofly_active ; Set flag | |
1042 return | |
1043 | |
1044 end_dive: | |
1045 btfss realdive ; dive longer then one minute | |
1046 goto end_dive_common ; No, discard everything | |
1047 | |
33 | 1048 btfsc simulatormode_active ; Are we in simulator mode? |
1049 goto end_dive_common ; Yes, discard everything | |
1050 | |
0 | 1051 ; Dive finished (and longer then one minute or Apnoe timeout occured) |
1052 | |
1053 btfsc FLAG_apnoe_mode ; Calc max. depth (again) for very short apnoe dives | |
1054 rcall apnoe_calc_maxdepth | |
1055 | |
1056 ; calculate desaturation time | |
1057 movff last_surfpressure_30min+0,int_I_pres_respiration+0 ; copy surface air pressure to deco routine | |
1058 movff last_surfpressure_30min+1,int_I_pres_respiration+1 ; 30min old values | |
1059 | |
1060 GETCUSTOM8 d'12' ; Desaturation multiplier % | |
1061 movwf wait_temp | |
1062 movff wait_temp,char_I_desaturation_multiplier | |
1063 | |
1064 ostc_debug 'G' ; Sends debug-information to screen if debugmode active | |
1065 call deco_main_calc_desaturation_time ; calculate desaturation time | |
1066 movlb b'00000001' ; select ram bank 1 | |
1067 rcall calculate_noflytime ; Calc NoFly time | |
1068 ostc_debug 'H' ; Sends debug-information to screen if debugmode active | |
1069 ; store header and ... | |
1070 movlw 0xFD ; .... End-of-Profile Bytes | |
1071 call write_external_eeprom | |
1072 movlw 0xFD | |
1073 call write_external_eeprom | |
1074 movlw 0xFE ; This positon will be overwritten for the next profile | |
1075 call write_external_eeprom ; and is required to find the newest dive after a firmware reset | |
1076 | |
1077 movff eeprom_header_address+0, eeprom_address+0 ; set header adress | |
1078 movff eeprom_header_address+1, eeprom_address+1 ; write header | |
1079 | |
1080 movlw 0xFA ; Header start | |
1081 call write_external_eeprom | |
1082 movlw 0xFA | |
1083 call write_external_eeprom | |
1084 movlw logbook_profile_version ; Defined in definitions_vxyy.asm | |
1085 call write_external_eeprom | |
1086 movf month,W ; Date | |
1087 call write_external_eeprom | |
1088 movf day,W | |
1089 call write_external_eeprom | |
1090 movf year,W | |
1091 call write_external_eeprom | |
1092 movf hours,W ; End of dive time | |
1093 call write_external_eeprom | |
1094 movf mins,W | |
1095 call write_external_eeprom | |
1096 | |
1097 btfss FLAG_apnoe_mode ; Store apnoe max or normal max (Which is only max from the last descent) | |
1098 bra end_dive1 ; Store normal depth | |
1099 | |
1100 movff apnoe_max_pressure+0,lo | |
1101 movff apnoe_max_pressure+1,hi | |
1102 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mBar] | |
1103 movff lo,apnoe_max_pressure+0 | |
1104 movff hi,apnoe_max_pressure+1 | |
1105 | |
1106 movf apnoe_max_pressure+0,W ; Max. depth | |
1107 call write_external_eeprom | |
1108 movf apnoe_max_pressure+1,W | |
1109 call write_external_eeprom | |
1110 bra end_dive2 ; skip | |
1111 | |
1112 end_dive1: | |
1113 movff max_pressure+0,lo | |
1114 movff max_pressure+1,hi | |
1115 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mBar] | |
1116 movff lo,max_pressure+0 | |
1117 movff hi,max_pressure+1 | |
1118 | |
1119 movf max_pressure+0,W ; Max. depth | |
1120 call write_external_eeprom | |
1121 movf max_pressure+1,W | |
1122 call write_external_eeprom | |
1123 | |
1124 end_dive2: | |
1125 movf divemins+0,W ; divetime minutes | |
1126 call write_external_eeprom | |
1127 movf divemins+1,W | |
1128 call write_external_eeprom | |
1129 movf divesecs,W ; divetime seconds | |
1130 call write_external_eeprom | |
1131 movf mintemp+0,W ; minimum temperature | |
1132 call write_external_eeprom | |
1133 movf mintemp+1,W | |
1134 call write_external_eeprom | |
1135 movf last_surfpressure_30min+0,W ; airpressure before dive | |
1136 call write_external_eeprom | |
1137 movf last_surfpressure_30min+1,W | |
1138 call write_external_eeprom | |
1139 movff int_O_desaturation_time+0,lo ; | |
1140 movff int_O_desaturation_time+1,hi | |
1141 movf lo,W ; desaturation time in minutes | |
1142 call write_external_eeprom | |
1143 movf hi,W ; | |
1144 call write_external_eeprom | |
1145 | |
1146 ; Gases.... | |
1147 read_int_eeprom d'6' ; Read byte (stored in EEDATA) | |
1148 movf EEDATA,W | |
1149 call write_external_eeprom | |
1150 read_int_eeprom d'7' ; Read byte (stored in EEDATA) | |
1151 movf EEDATA,W | |
1152 call write_external_eeprom | |
1153 | |
1154 read_int_eeprom d'10' ; Read byte (stored in EEDATA) | |
1155 movf EEDATA,W | |
1156 call write_external_eeprom | |
1157 read_int_eeprom d'11' ; Read byte (stored in EEDATA) | |
1158 movf EEDATA,W | |
1159 call write_external_eeprom | |
1160 | |
1161 read_int_eeprom d'14' ; Read byte (stored in EEDATA) | |
1162 movf EEDATA,W | |
1163 call write_external_eeprom | |
1164 read_int_eeprom d'15' ; Read byte (stored in EEDATA) | |
1165 movf EEDATA,W | |
1166 call write_external_eeprom | |
1167 | |
1168 read_int_eeprom d'18' ; Read byte (stored in EEDATA) | |
1169 movf EEDATA,W | |
1170 call write_external_eeprom | |
1171 read_int_eeprom d'19' ; Read byte (stored in EEDATA) | |
1172 movf EEDATA,W | |
1173 call write_external_eeprom | |
1174 | |
1175 read_int_eeprom d'22' ; Read byte (stored in EEDATA) | |
1176 movf EEDATA,W | |
1177 call write_external_eeprom | |
1178 read_int_eeprom d'23' ; Read byte (stored in EEDATA) | |
1179 movf EEDATA,W | |
1180 call write_external_eeprom | |
1181 | |
1182 read_int_eeprom d'24' ; % O2 Gas6 | |
1183 movf EEDATA,W | |
1184 call write_external_eeprom | |
1185 read_int_eeprom d'25' ; % He Gas6 | |
1186 movf EEDATA,W | |
1187 call write_external_eeprom | |
1188 read_int_eeprom d'33' ; start gas | |
1189 movf EEDATA,W | |
1190 call write_external_eeprom | |
1191 | |
1192 movlw softwareversion_x ; Firmware version | |
1193 call write_external_eeprom | |
1194 movlw softwareversion_y | |
1195 call write_external_eeprom | |
1196 movf batt_voltage+0,W ; Battery voltage | |
1197 call write_external_eeprom | |
1198 movf batt_voltage+1,W | |
1199 call write_external_eeprom | |
1200 | |
1201 GETCUSTOM8 d'20' ; sampling rate in WREG | |
1202 btfsc FLAG_apnoe_mode ; Apnoe mode? | |
1203 movlw d'1' ; Apnoe sampling rate | |
1204 call write_external_eeprom | |
1205 | |
1206 movlw d'2' ; information size temperature | |
1207 movwf temp1 ; copy to bits 0-3 | |
1208 swapf temp1,F ; swap nibbels 0-3 with 4-7 | |
1209 GETCUSTOM8 d'21' ; Divisor temperature | |
1210 addwf temp1,W ; copy to bits 0-3, result in WREG | |
1211 call write_external_eeprom | |
1212 | |
1213 movlw d'2' ; information size deco | |
1214 movwf temp1 ; copy to bits 0-3 | |
1215 swapf temp1,F ; swap nibbels 0-3 with 4-7 | |
1216 GETCUSTOM8 d'22' ; Divisor deco | |
1217 addwf temp1,W ; copy to bits 0-3, result in WREG | |
1218 call write_external_eeprom | |
1219 | |
1220 movlw d'2' ; information size tank | |
1221 movwf temp1 ; copy to bits 0-3 | |
1222 swapf temp1,F ; swap nibbels 0-3 with 4-7 | |
1223 GETCUSTOM8 d'23' ; Divisor Tank | |
1224 addwf temp1,W ; copy to bits 0-3, result in WREG | |
1225 call write_external_eeprom | |
1226 | |
1227 movlw d'3' ; information size pp02 | |
1228 movwf temp1 ; copy to bits 0-3 | |
1229 swapf temp1,F ; swap nibbels 0-3 with 4-7 | |
1230 GETCUSTOM8 d'24' ; Divisor pp02 | |
1231 addwf temp1,W ; copy to bits 0-3, result in WREG | |
1232 call write_external_eeprom | |
1233 | |
1234 movlw d'9' ; information size Decodebug | |
1235 movwf temp1 ; copy to bits 0-3 | |
1236 swapf temp1,F ; swap nibbels 0-3 with 4-7 | |
1237 GETCUSTOM8 d'25' ; Divisor Decodebug | |
1238 addwf temp1,W ; copy to bits 0-3, result in WREG | |
1239 call write_external_eeprom | |
1240 | |
1241 movlw d'0' ; information size nuy2 | |
1242 movwf temp1 ; copy to bits 0-3 | |
1243 swapf temp1,F ; swap nibbels 0-3 with 4-7 | |
1244 GETCUSTOM8 d'26' ; Divisor nuy2 | |
1245 addwf temp1,W ; copy to bits 0-3, result in WREG | |
1246 call write_external_eeprom | |
1247 | |
1248 read_int_eeprom d'26' ; Read Salinity from EEPROM | |
1249 movf EEDATA,W | |
1250 call write_external_eeprom ; Store Salinity to Dive | |
1251 | |
1252 movlw d'0' ; Spare | |
1253 call write_external_eeprom | |
1254 | |
1255 movlw 0xFB ; Header stop | |
1256 call write_external_eeprom | |
1257 movlw 0xFB | |
1258 call write_external_eeprom | |
1259 | |
1260 ; Increase total dive counter | |
1261 read_int_eeprom d'2' ; Read byte (stored in EEDATA) | |
1262 movff EEDATA,temp1 ; Low byte | |
1263 read_int_eeprom d'3' ; Read byte (stored in EEDATA) | |
1264 movff EEDATA,temp2 ; high byte | |
1265 bcf STATUS,C | |
1266 movlw d'1' | |
1267 addwf temp1 | |
1268 movlw d'0' | |
1269 addwfc temp2 | |
1270 movff temp1,EEDATA | |
1271 write_int_eeprom d'2' ; write byte stored in EEDATA | |
1272 movff temp2,EEDATA | |
1273 write_int_eeprom d'3' ; write byte stored in EEDATA | |
1274 | |
1275 GETCUSTOM15 .28 ; Logbook Offset -> lo, hi | |
1276 tstfsz lo ; lo=0? | |
1277 bra change_logbook_offset1 ; No, adjust offset | |
1278 tstfsz hi ; hi=0? | |
1279 bra change_logbook_offset1 ; No, adjust offset | |
1280 bra change_logbook_offset2 ; lo=0 and hi=0 -> skip Offset routine | |
1281 change_logbook_offset1: | |
1282 movlw d'1' | |
1283 addwf lo | |
1284 movlw d'0' | |
1285 addwfc hi | |
1286 movlw d'112' ; CF28 *4 Bytes... | |
1287 addlw 0x82 | |
1288 movwf EEADR | |
1289 movff lo,EEDATA | |
1290 call write_eeprom ; Lowbyte | |
1291 movlw d'112' ; CF28 *4 Bytes... | |
1292 addlw 0x83 | |
1293 movwf EEADR | |
1294 movff hi,EEDATA | |
1295 call write_eeprom ; Highbyte | |
1296 | |
1297 change_logbook_offset2: | |
25 | 1298 bcf LED_blue |
33 | 1299 |
1300 end_dive_common: | |
0 | 1301 bcf simulatormode_active ; if we were in simulator mode |
1302 | |
1303 btfsc restore_deco_data ; Restore decodata? | |
1304 call simulator_restore_tissue_data ; Yes! | |
1305 | |
1306 call deco_main_gradient_array | |
1307 movlb b'00000001' ; select ram bank 1 | |
1308 | |
64 | 1309 btfss restore_deco_data ; Restore decodata? |
1310 goto surfloop ; and return to surfaceloop | |
1311 ;new 1.71beta: | |
0 | 1312 clrf surface_interval+0 |
1313 clrf surface_interval+1 ; Clear surface interval timer | |
1314 goto surfloop ; and return to surfaceloop | |
1315 | |
1316 timeout_divemode: | |
1317 btfss realdive ; Dive longer then one minute | |
1318 return | |
1319 | |
1320 btfsc FLAG_apnoe_mode ; In Apnoe mode? | |
1321 bra timeout_divemode2 ; Yes, use CF30 [min] for timeout | |
1322 | |
1323 btfsc simulatormode_active ; In Simulator mode? | |
1324 bra timeout_divemode3 ; Yes, use fixed 5 seconds timeout | |
1325 | |
1326 bcf divemode | |
1327 incf timeout_counter,F | |
1328 GETCUSTOM8 d'2' ; diveloop_timeout | |
1329 addlw d'2' ; adds two seconds in case timout=zero! | |
1330 btfsc STATUS,C ; > 255? | |
1331 movlw d'255' ; Set to 255... | |
1332 decf WREG,F ; Limit to 254 | |
1333 cpfsgt timeout_counter | |
1334 bsf divemode | |
1335 return | |
1336 | |
1337 timeout_divemode2: | |
1338 incf timeout_counter,F ; seconds... | |
1339 movlw d'60' | |
1340 cpfseq timeout_counter ; timeout_counter=60? | |
1341 return ; No. | |
1342 | |
1343 clrf timeout_counter | |
1344 bcf divemode | |
1345 incf apnoe_timeout_counter,F | |
1346 GETCUSTOM8 d'30' ; apnoe timeout [min] | |
1347 cpfseq apnoe_timeout_counter | |
1348 bsf divemode | |
1349 return | |
1350 | |
1351 timeout_divemode3: | |
1352 bcf divemode | |
1353 incf timeout_counter,F | |
1354 movlw d'5' ; Fixed timeout of 5 seconds | |
1355 cpfsgt timeout_counter | |
1356 bsf divemode | |
1357 return | |
1358 | |
1359 update_divemode1: ; update any second | |
1360 call set_dive_modes ; tests if depth>threshold | |
1361 | |
1362 btfsc divemode | |
1363 call set_max_depth ; update max. depth if required | |
1364 | |
1365 btfsc divemode | |
1366 call set_min_temp ; store min. temp if required | |
1367 | |
1368 bcf temp_changed ; Display temperature? | |
1369 movf temperature+0,W | |
1370 cpfseq last_temperature+0 | |
1371 bsf temp_changed ; Yes | |
1372 movf temperature+1,W | |
1373 cpfseq last_temperature+1 | |
1374 bsf temp_changed ; Yes | |
1375 btfsc temp_changed | |
1376 call PLED_temp_divemode ; Displays temperature | |
1377 | |
1378 bcf pres_changed ; Display new depth? | |
1379 movf amb_pressure+0,W | |
1380 cpfseq last_pressure+0 | |
1381 bsf pres_changed ; Yes | |
1382 movf amb_pressure+1,W | |
1383 cpfseq last_pressure+1 | |
1384 bsf pres_changed ; Yes | |
1385 | |
1386 btfsc simulatormode_active ; always update depth when in simulator mode | |
1387 bsf pres_changed | |
1388 | |
1389 btfsc pres_changed | |
1390 call PLED_depth ; Displays new depth | |
1391 return | |
1392 | |
1393 update_divemode60: ; update any minute | |
1394 call get_battery_voltage ; gets battery voltage | |
1395 call set_powersafe ; red LED blinking if battery is low | |
1396 call PLED_max_pressure ; No, use normal max. depth | |
1397 call check_temp_extrema ; check for new temperature extremas | |
1398 bcf oneminupdate | |
1399 return | |
1400 | |
1401 set_max_depth: | |
1402 movff max_pressure+0,sub_a+0 | |
1403 movff max_pressure+1,sub_a+1 | |
1404 movff rel_pressure+0,sub_b+0 | |
1405 movff rel_pressure+1,sub_b+1 | |
1406 call sub16 ; sub_c = sub_a - sub_b | |
1407 ; max_pressure<rel_pressure -> neg_flag=1 | |
1408 ; rel_pressure<=max_pressure -> neg_flag=0 | |
1409 btfss neg_flag | |
1410 return | |
1411 ;max_pressure<rel_pressure | |
1412 movff rel_pressure+0,max_pressure+0 | |
1413 movff rel_pressure+1,max_pressure+1 | |
1414 call PLED_max_pressure ; No, use normal max. depth | |
1415 return | |
1416 | |
1417 set_min_temp: | |
1418 movff mintemp+0,sub_a+0 | |
1419 movff mintemp+1,sub_a+1 | |
1420 movff temperature+0,sub_b+0 | |
1421 movff temperature+1,sub_b+1 | |
1422 call sub16 ; sub_c = sub_a - sub_b | |
1423 ; mintemp<T -> neg_flag=1 | |
1424 ; T<=mintemp -> neg_flag=0 | |
1425 btfsc neg_flag | |
1426 return | |
1427 ;mintemp>=T | |
1428 movff temperature+0,mintemp+0 | |
1429 movff temperature+1,mintemp+1 | |
1430 return | |
1431 | |
1432 set_dive_modes: | |
1433 bcf divemode2 ; Stop time | |
1434 | |
1435 GETCUSTOM8 .0 ; loads dive_threshold in WREG | |
1436 movwf sub_a+0 ; dive_treshold is in cm | |
1437 clrf sub_a+1 | |
1438 | |
1439 movff rel_pressure+0,sub_b+0 | |
1440 movff rel_pressure+1,sub_b+1 | |
1441 | |
1442 call sub16 ; sub_c = sub_a - sub_b | |
1443 | |
1444 btfss neg_flag | |
1445 bra set_dive_modes2 ; too shallow (rel_pressure<dive_threshold) | |
1446 | |
1447 btfsc realdive ; Dive longer than one minute? | |
1448 clrf timeout_counter | |
1449 | |
1450 bsf divemode | |
1451 bsf divemode2 ; displayed divetime is running | |
1452 return | |
1453 | |
1454 set_dive_modes2: | |
1455 btfss realdive ; dive longer then one minute? | |
1456 bcf divemode ; no -> this was no real dive | |
1457 return | |
1458 | |
1459 set_powersafe: | |
1460 btfsc low_battery_state ; battery warning alread active? | |
1461 bra set_powersafe2 ; Yes, but is it still required? | |
1462 ; battery voltage in mV (value*256+Lowbyte=actual treshold) | |
1463 movlw d'12' ; 3,328V | |
1464 cpfsgt batt_voltage+1 | |
1465 bra set_powersafe1 | |
1466 return | |
1467 | |
1468 set_powersafe1: | |
1469 movlw d'7' ; Type of Alarm (Battery Low) | |
1470 movwf AlarmType ; Copy to Alarm Register | |
1471 bsf event_occured ; Set Event Flag | |
1472 bsf low_battery_state ; set flag for battery warning | |
1473 return ; return | |
1474 | |
1475 set_powersafe2: | |
1476 movlw d'13' ; 3,584V | |
1477 cpfsgt batt_voltage+1 | |
1478 bra set_powersafe1 ; Still to low | |
1479 bcf low_battery_state ; clear flag for battery warning mode | |
1480 return | |
1481 | |
1482 calc_average_depth: | |
71
6beb680a6130
1.72beta - color-coded gaslist, small fix with stopwatch
heinrichsweikamp
parents:
69
diff
changeset
|
1483 bcf lock_stopwatch_reset ; Un-Lock the stopwatch reset option |
0 | 1484 ; 1. Add new 2xdepth to the Sum of depths registers |
1485 movff rel_pressure+0,b0_lo | |
1486 movff rel_pressure+1,b0_hi | |
1487 | |
1488 movf b0_lo,w | |
1489 addwf average_depth_hold+0,F | |
1490 movf b0_hi,w | |
1491 addwfc average_depth_hold+1,F | |
1492 movlw d'0' | |
1493 addwfc average_depth_hold+2,F | |
1494 addwfc average_depth_hold+3,F ; Will work up to 9999mBar*60*60*24=863913600mBar | |
1495 | |
1496 movf b0_lo,w | |
1497 addwf average_depth_hold+0,F | |
1498 movf b0_hi,w | |
1499 addwfc average_depth_hold+1,F | |
1500 movlw d'0' | |
1501 addwfc average_depth_hold+2,F | |
1502 addwfc average_depth_hold+3,F ; Will work up to 9999mBar*60*60*24=863913600mBar | |
1503 | |
1504 ; 2. Compute Average Depth on base of average_divesecs:2 | |
1505 | |
1506 movff average_divesecs+0,xB+0 | |
1507 movff average_divesecs+1,xB+1 ; Copy | |
1508 movff average_depth_hold+0,xC+0 | |
1509 movff average_depth_hold+1,xC+1 | |
1510 movff average_depth_hold+2,xC+2 | |
1511 movff average_depth_hold+3,xC+3 | |
1512 | |
1513 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
1514 movff xC+0,avr_rel_pressure+0 | |
1515 movff xC+1,avr_rel_pressure+1 | |
1516 return | |
1517 | |
1518 | |
1519 diveloop_boot: | |
49 | 1520 ostc_debug 'Q' ; Sends debug-information to screen if debugmode active |
0 | 1521 clrf max_pressure+0 ; clear some variables |
1522 clrf max_pressure+1 | |
1523 | |
1524 clrf avr_rel_pressure+0 | |
1525 clrf avr_rel_pressure+1 | |
1526 | |
1527 call PLED_brightness_low | |
1528 read_int_eeprom d'90' ; Brightness offset? (Dim>0, Normal = 0) | |
1529 movlw d'0' | |
1530 cpfsgt EEDATA | |
1531 call PLED_brightness_full | |
1532 | |
1533 clrf average_depth_hold+0 | |
1534 clrf average_depth_hold+1 | |
1535 clrf average_depth_hold+2 | |
1536 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
|
1537 movlw d'2' |
0 | 1538 movwf average_divesecs+0 |
1539 clrf average_divesecs+1 | |
1540 | |
1541 movlw d'1' | |
1542 movwf apnoe_max_pressure+0 | |
1543 clrf apnoe_max_pressure+1 | |
1544 clrf apnoe_surface_mins | |
1545 clrf apnoe_surface_secs | |
1546 clrf apnoe_mins | |
1547 clrf apnoe_secs | |
1548 clrf divemins+0 | |
1549 clrf divemins+1 | |
1550 clrf divesecs | |
1551 clrf samplesecs | |
1552 clrf apnoe_timeout_counter ; timeout in minutes | |
1553 clrf timeout_counter ; takes care of the timeout | |
1554 clrf timeout_counter2 ; Here: counts to six, then store deco data and temperature | |
1555 clrf AlarmType ; Clear all alarms | |
1556 bcf event_occured ; clear flag | |
71
6beb680a6130
1.72beta - color-coded gaslist, small fix with stopwatch
heinrichsweikamp
parents:
69
diff
changeset
|
1557 bcf lock_stopwatch_reset ; clear flag |
0 | 1558 bcf depth_greater_100m ; clear flag |
1559 setf last_diluent ; to be displayed after first calculation (range: 0 to 100 [%]) | |
3 | 1560 bcf dekostop_active |
1561 bcf is_bailout ;=1: CC mode, but bailout active! | |
8 | 1562 bcf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode |
1563 | |
0 | 1564 call get_free_EEPROM_location ; get last position in external EEPROM, may be up to 2 secs! |
1565 | |
1566 movff last_surfpressure_30min+1,int_I_pres_surface+1 ; HIGH copy surfacepressure to deco routine | |
1567 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; LOW copy surfacepressure to deco routine | |
1568 movff temperature+0,mintemp+0 ; Reset Min-Temp registers | |
1569 movff temperature+1,mintemp+1 ; Reset Min-Temp registers | |
1570 | |
1571 clrf wait_temp ; Used to clear Bankx registers | |
1572 movff wait_temp,char_O_GF_low_pointer | |
1573 movff wait_temp,char_O_actual_pointer | |
1574 lfsr FSR0,0x250 | |
1575 movlw 0x20 | |
1576 movwf wait_temp | |
1577 clear_deco_lists: ; Clear Deco list | |
1578 clrf POSTINC0 | |
1579 decfsz wait_temp,F | |
1580 bra clear_deco_lists | |
1581 lfsr FSR0,0x270 | |
1582 movlw 0x20 | |
1583 movwf wait_temp | |
1584 set_no_forced_stops: ; Init Deco list | |
1585 movlw 0x01 | |
1586 movwf POSTINC0 | |
1587 decfsz wait_temp,F | |
1588 bra set_no_forced_stops | |
1589 lfsr FSR0,0x290 ; clear int_O_calc_tissue_call_counter (DEBUG) | |
1590 clrf POSTINC0 | |
1591 clrf POSTINC0 | |
1592 | |
1593 ; Start with active Stopwatch? | |
1594 bsf stopwatch_active | |
1595 GETCUSTOM8 d'41' ; =1: Start with active Stopwatch | |
1596 movwf lo | |
1597 movlw d'1' | |
1598 cpfseq lo ; CF41=1? | |
1599 bcf stopwatch_active ; No! | |
1600 | |
1601 ; Init profile recording parameters | |
1602 GETCUSTOM8 d'20' ; sample rate | |
1603 movwf samplesecs_value ; to avoid EEPROM access in the ISR | |
1604 GETCUSTOM8 d'21' | |
1605 movwf divisor_temperature ; load divisors for profile storage | |
1606 GETCUSTOM8 d'22' | |
1607 movwf divisor_deco | |
1608 GETCUSTOM8 d'23' | |
1609 movwf divisor_tank | |
1610 GETCUSTOM8 d'24' | |
1611 movwf divisor_ppo2 | |
1612 GETCUSTOM8 d'25' | |
1613 movwf divisor_deco_debug | |
1614 GETCUSTOM8 d'26' | |
1615 movwf divisor_nuy2 | |
1616 | |
1617 btfss FLAG_apnoe_mode ; In Apnoe mode? | |
1618 bra divemode1 | |
1619 ; Overwrite some parameters in Apnoe mode.... | |
1620 movlw d'1' | |
1621 movwf samplesecs_value ; to avoid EEPROM access in the ISR | |
1622 | |
1623 divemode1: | |
1624 read_int_eeprom d'36' ; Read mix 1 ppO2 | |
1625 btfsc FLAG_const_ppO2_mode | |
1626 movff EEDATA,char_I_const_ppO2 ; Set ppO2 setpoint if in ppO2 mode | |
4 | 1627 movff EEDATA, ppO2_setpoint_store ; Store also in this byte... |
0 | 1628 |
21 | 1629 bcf LED_blue |
0 | 1630 bcf low_battery_state ; clear flag for battery warning mode |
1631 bcf header_stored | |
1632 bcf premenu | |
1633 bcf realdive | |
1634 bsf update_divetime ; set flag | |
1635 btfss simulatormode_active ; do not disable in simulator mode! | |
49 | 1636 call disable_rs232 ; Disable RS232 |
0 | 1637 |
1638 read_int_eeprom d'33' ; Read byte (stored in EEDATA) | |
1639 movff EEDATA,active_gas ; Read start gas (1-5) | |
1640 | |
1641 ; Read Start Gas and configure char_I_He_ratio, char_I_O2_ratio and char_I_N2_ratio | |
1642 decf active_gas,W ; Gas 0-4 | |
1643 mullw d'4' | |
1644 movf PRODL,W | |
1645 addlw d'7' ; = address for He ratio | |
1646 movwf EEADR | |
1647 call read_eeprom ; Read He ratio | |
1648 movff EEDATA,char_I_He_ratio ; And copy into hold register | |
1649 decf active_gas,W ; Gas 0-4 | |
1650 mullw d'4' | |
1651 movf PRODL,W | |
1652 addlw d'6' ; = address for O2 ratio | |
1653 movwf EEADR | |
1654 call read_eeprom ; Read O2 ratio | |
1655 movff EEDATA, char_I_O2_ratio ; O2 ratio | |
1656 movff char_I_He_ratio, wait_temp ; copy into bank1 register | |
1657 bsf STATUS,C ; Borrow bit | |
1658 movlw d'100' ; 100% | |
1659 subfwb wait_temp,W ; minus He | |
1660 bsf STATUS,C ; Borrow bit | |
1661 subfwb EEDATA,F ; minus O2 | |
1662 movff EEDATA, char_I_N2_ratio ; = N2! | |
1663 | |
1664 bcf multi_gf_display ; Do not display the multi-gf table screen | |
1665 return |