Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/divemode.asm @ 85:8b813f67220f
renaming "Max Depth" to "max."
author | heinrichsweikamp |
---|---|
date | Wed, 08 Dec 2010 08:37:03 +0100 |
parents | 3e351e25f5d1 |
children | 6f8e3a08011e |
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 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
75
diff
changeset
|
1057 ; Dive finished (and longer then one minute or Apnoe timeout occured) |
0 | 1058 |
1059 btfsc FLAG_apnoe_mode ; Calc max. depth (again) for very short apnoe dives | |
1060 rcall apnoe_calc_maxdepth | |
1061 | |
1062 ; calculate desaturation time | |
1063 movff last_surfpressure_30min+0,int_I_pres_respiration+0 ; copy surface air pressure to deco routine | |
1064 movff last_surfpressure_30min+1,int_I_pres_respiration+1 ; 30min old values | |
1065 | |
1066 GETCUSTOM8 d'12' ; Desaturation multiplier % | |
1067 movwf wait_temp | |
1068 movff wait_temp,char_I_desaturation_multiplier | |
1069 | |
1070 ostc_debug 'G' ; Sends debug-information to screen if debugmode active | |
1071 call deco_main_calc_desaturation_time ; calculate desaturation time | |
1072 movlb b'00000001' ; select ram bank 1 | |
1073 rcall calculate_noflytime ; Calc NoFly time | |
1074 ostc_debug 'H' ; Sends debug-information to screen if debugmode active | |
1075 ; store header and ... | |
1076 movlw 0xFD ; .... End-of-Profile Bytes | |
1077 call write_external_eeprom | |
1078 movlw 0xFD | |
1079 call write_external_eeprom | |
1080 movlw 0xFE ; This positon will be overwritten for the next profile | |
1081 call write_external_eeprom ; and is required to find the newest dive after a firmware reset | |
1082 | |
1083 movff eeprom_header_address+0, eeprom_address+0 ; set header adress | |
1084 movff eeprom_header_address+1, eeprom_address+1 ; write header | |
1085 | |
1086 movlw 0xFA ; Header start | |
1087 call write_external_eeprom | |
1088 movlw 0xFA | |
1089 call write_external_eeprom | |
1090 movlw logbook_profile_version ; Defined in definitions_vxyy.asm | |
1091 call write_external_eeprom | |
1092 movf month,W ; Date | |
1093 call write_external_eeprom | |
1094 movf day,W | |
1095 call write_external_eeprom | |
1096 movf year,W | |
1097 call write_external_eeprom | |
1098 movf hours,W ; End of dive time | |
1099 call write_external_eeprom | |
1100 movf mins,W | |
1101 call write_external_eeprom | |
1102 | |
1103 btfss FLAG_apnoe_mode ; Store apnoe max or normal max (Which is only max from the last descent) | |
1104 bra end_dive1 ; Store normal depth | |
1105 | |
1106 movff apnoe_max_pressure+0,lo | |
1107 movff apnoe_max_pressure+1,hi | |
1108 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mBar] | |
1109 movff lo,apnoe_max_pressure+0 | |
1110 movff hi,apnoe_max_pressure+1 | |
1111 | |
1112 movf apnoe_max_pressure+0,W ; Max. depth | |
1113 call write_external_eeprom | |
1114 movf apnoe_max_pressure+1,W | |
1115 call write_external_eeprom | |
1116 bra end_dive2 ; skip | |
1117 | |
1118 end_dive1: | |
1119 movff max_pressure+0,lo | |
1120 movff max_pressure+1,hi | |
1121 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mBar] | |
1122 movff lo,max_pressure+0 | |
1123 movff hi,max_pressure+1 | |
1124 | |
1125 movf max_pressure+0,W ; Max. depth | |
1126 call write_external_eeprom | |
1127 movf max_pressure+1,W | |
1128 call write_external_eeprom | |
1129 | |
1130 end_dive2: | |
1131 movf divemins+0,W ; divetime minutes | |
1132 call write_external_eeprom | |
1133 movf divemins+1,W | |
1134 call write_external_eeprom | |
1135 movf divesecs,W ; divetime seconds | |
1136 call write_external_eeprom | |
1137 movf mintemp+0,W ; minimum temperature | |
1138 call write_external_eeprom | |
1139 movf mintemp+1,W | |
1140 call write_external_eeprom | |
1141 movf last_surfpressure_30min+0,W ; airpressure before dive | |
1142 call write_external_eeprom | |
1143 movf last_surfpressure_30min+1,W | |
1144 call write_external_eeprom | |
1145 movff int_O_desaturation_time+0,lo ; | |
1146 movff int_O_desaturation_time+1,hi | |
1147 movf lo,W ; desaturation time in minutes | |
1148 call write_external_eeprom | |
1149 movf hi,W ; | |
1150 call write_external_eeprom | |
1151 | |
1152 ; Gases.... | |
1153 read_int_eeprom d'6' ; Read byte (stored in EEDATA) | |
1154 movf EEDATA,W | |
1155 call write_external_eeprom | |
1156 read_int_eeprom d'7' ; Read byte (stored in EEDATA) | |
1157 movf EEDATA,W | |
1158 call write_external_eeprom | |
1159 | |
1160 read_int_eeprom d'10' ; Read byte (stored in EEDATA) | |
1161 movf EEDATA,W | |
1162 call write_external_eeprom | |
1163 read_int_eeprom d'11' ; Read byte (stored in EEDATA) | |
1164 movf EEDATA,W | |
1165 call write_external_eeprom | |
1166 | |
1167 read_int_eeprom d'14' ; Read byte (stored in EEDATA) | |
1168 movf EEDATA,W | |
1169 call write_external_eeprom | |
1170 read_int_eeprom d'15' ; Read byte (stored in EEDATA) | |
1171 movf EEDATA,W | |
1172 call write_external_eeprom | |
1173 | |
1174 read_int_eeprom d'18' ; Read byte (stored in EEDATA) | |
1175 movf EEDATA,W | |
1176 call write_external_eeprom | |
1177 read_int_eeprom d'19' ; Read byte (stored in EEDATA) | |
1178 movf EEDATA,W | |
1179 call write_external_eeprom | |
1180 | |
1181 read_int_eeprom d'22' ; Read byte (stored in EEDATA) | |
1182 movf EEDATA,W | |
1183 call write_external_eeprom | |
1184 read_int_eeprom d'23' ; Read byte (stored in EEDATA) | |
1185 movf EEDATA,W | |
1186 call write_external_eeprom | |
1187 | |
1188 read_int_eeprom d'24' ; % O2 Gas6 | |
1189 movf EEDATA,W | |
1190 call write_external_eeprom | |
1191 read_int_eeprom d'25' ; % He Gas6 | |
1192 movf EEDATA,W | |
1193 call write_external_eeprom | |
1194 read_int_eeprom d'33' ; start gas | |
1195 movf EEDATA,W | |
1196 call write_external_eeprom | |
1197 | |
1198 movlw softwareversion_x ; Firmware version | |
1199 call write_external_eeprom | |
1200 movlw softwareversion_y | |
1201 call write_external_eeprom | |
1202 movf batt_voltage+0,W ; Battery voltage | |
1203 call write_external_eeprom | |
1204 movf batt_voltage+1,W | |
1205 call write_external_eeprom | |
1206 | |
1207 GETCUSTOM8 d'20' ; sampling rate in WREG | |
1208 btfsc FLAG_apnoe_mode ; Apnoe mode? | |
1209 movlw d'1' ; Apnoe sampling rate | |
1210 call write_external_eeprom | |
1211 | |
1212 movlw d'2' ; information size temperature | |
1213 movwf temp1 ; copy to bits 0-3 | |
1214 swapf temp1,F ; swap nibbels 0-3 with 4-7 | |
1215 GETCUSTOM8 d'21' ; Divisor temperature | |
1216 addwf temp1,W ; copy to bits 0-3, result in WREG | |
1217 call write_external_eeprom | |
1218 | |
1219 movlw d'2' ; information size deco | |
1220 movwf temp1 ; copy to bits 0-3 | |
1221 swapf temp1,F ; swap nibbels 0-3 with 4-7 | |
1222 GETCUSTOM8 d'22' ; Divisor deco | |
1223 addwf temp1,W ; copy to bits 0-3, result in WREG | |
1224 call write_external_eeprom | |
1225 | |
1226 movlw d'2' ; information size tank | |
1227 movwf temp1 ; copy to bits 0-3 | |
1228 swapf temp1,F ; swap nibbels 0-3 with 4-7 | |
1229 GETCUSTOM8 d'23' ; Divisor Tank | |
1230 addwf temp1,W ; copy to bits 0-3, result in WREG | |
1231 call write_external_eeprom | |
1232 | |
1233 movlw d'3' ; information size pp02 | |
1234 movwf temp1 ; copy to bits 0-3 | |
1235 swapf temp1,F ; swap nibbels 0-3 with 4-7 | |
1236 GETCUSTOM8 d'24' ; Divisor pp02 | |
1237 addwf temp1,W ; copy to bits 0-3, result in WREG | |
1238 call write_external_eeprom | |
1239 | |
1240 movlw d'9' ; information size Decodebug | |
1241 movwf temp1 ; copy to bits 0-3 | |
1242 swapf temp1,F ; swap nibbels 0-3 with 4-7 | |
1243 GETCUSTOM8 d'25' ; Divisor Decodebug | |
1244 addwf temp1,W ; copy to bits 0-3, result in WREG | |
1245 call write_external_eeprom | |
1246 | |
1247 movlw d'0' ; information size nuy2 | |
1248 movwf temp1 ; copy to bits 0-3 | |
1249 swapf temp1,F ; swap nibbels 0-3 with 4-7 | |
1250 GETCUSTOM8 d'26' ; Divisor nuy2 | |
1251 addwf temp1,W ; copy to bits 0-3, result in WREG | |
1252 call write_external_eeprom | |
1253 | |
1254 read_int_eeprom d'26' ; Read Salinity from EEPROM | |
1255 movf EEDATA,W | |
1256 call write_external_eeprom ; Store Salinity to Dive | |
1257 | |
1258 movlw d'0' ; Spare | |
1259 call write_external_eeprom | |
1260 | |
1261 movlw 0xFB ; Header stop | |
1262 call write_external_eeprom | |
1263 movlw 0xFB | |
1264 call write_external_eeprom | |
1265 | |
1266 ; Increase total dive counter | |
1267 read_int_eeprom d'2' ; Read byte (stored in EEDATA) | |
1268 movff EEDATA,temp1 ; Low byte | |
1269 read_int_eeprom d'3' ; Read byte (stored in EEDATA) | |
1270 movff EEDATA,temp2 ; high byte | |
1271 bcf STATUS,C | |
1272 movlw d'1' | |
1273 addwf temp1 | |
1274 movlw d'0' | |
1275 addwfc temp2 | |
1276 movff temp1,EEDATA | |
1277 write_int_eeprom d'2' ; write byte stored in EEDATA | |
1278 movff temp2,EEDATA | |
1279 write_int_eeprom d'3' ; write byte stored in EEDATA | |
1280 | |
1281 GETCUSTOM15 .28 ; Logbook Offset -> lo, hi | |
1282 tstfsz lo ; lo=0? | |
1283 bra change_logbook_offset1 ; No, adjust offset | |
1284 tstfsz hi ; hi=0? | |
1285 bra change_logbook_offset1 ; No, adjust offset | |
1286 bra change_logbook_offset2 ; lo=0 and hi=0 -> skip Offset routine | |
1287 change_logbook_offset1: | |
1288 movlw d'1' | |
1289 addwf lo | |
1290 movlw d'0' | |
1291 addwfc hi | |
1292 movlw d'112' ; CF28 *4 Bytes... | |
1293 addlw 0x82 | |
1294 movwf EEADR | |
1295 movff lo,EEDATA | |
1296 call write_eeprom ; Lowbyte | |
1297 movlw d'112' ; CF28 *4 Bytes... | |
1298 addlw 0x83 | |
1299 movwf EEADR | |
1300 movff hi,EEDATA | |
1301 call write_eeprom ; Highbyte | |
1302 | |
1303 change_logbook_offset2: | |
25 | 1304 bcf LED_blue |
33 | 1305 |
1306 end_dive_common: | |
0 | 1307 bcf simulatormode_active ; if we were in simulator mode |
1308 | |
1309 btfsc restore_deco_data ; Restore decodata? | |
1310 call simulator_restore_tissue_data ; Yes! | |
1311 | |
1312 call deco_main_gradient_array | |
1313 movlb b'00000001' ; select ram bank 1 | |
1314 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
75
diff
changeset
|
1315 btfss restore_deco_data ; Restore decodata? |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
75
diff
changeset
|
1316 goto surfloop ; and return to surfaceloop |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
75
diff
changeset
|
1317 ;new 1.71beta: |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
75
diff
changeset
|
1318 clrf surface_interval+0 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
75
diff
changeset
|
1319 clrf surface_interval+1 ; Clear surface interval timer |
0 | 1320 goto surfloop ; and return to surfaceloop |
1321 | |
1322 timeout_divemode: | |
1323 btfss realdive ; Dive longer then one minute | |
1324 return | |
1325 | |
1326 btfsc FLAG_apnoe_mode ; In Apnoe mode? | |
1327 bra timeout_divemode2 ; Yes, use CF30 [min] for timeout | |
1328 | |
1329 btfsc simulatormode_active ; In Simulator mode? | |
1330 bra timeout_divemode3 ; Yes, use fixed 5 seconds timeout | |
1331 | |
1332 bcf divemode | |
1333 incf timeout_counter,F | |
1334 GETCUSTOM8 d'2' ; diveloop_timeout | |
1335 addlw d'2' ; adds two seconds in case timout=zero! | |
1336 btfsc STATUS,C ; > 255? | |
1337 movlw d'255' ; Set to 255... | |
1338 decf WREG,F ; Limit to 254 | |
1339 cpfsgt timeout_counter | |
1340 bsf divemode | |
1341 return | |
1342 | |
1343 timeout_divemode2: | |
1344 incf timeout_counter,F ; seconds... | |
1345 movlw d'60' | |
1346 cpfseq timeout_counter ; timeout_counter=60? | |
1347 return ; No. | |
1348 | |
1349 clrf timeout_counter | |
1350 bcf divemode | |
1351 incf apnoe_timeout_counter,F | |
1352 GETCUSTOM8 d'30' ; apnoe timeout [min] | |
1353 cpfseq apnoe_timeout_counter | |
1354 bsf divemode | |
1355 return | |
1356 | |
1357 timeout_divemode3: | |
1358 bcf divemode | |
1359 incf timeout_counter,F | |
1360 movlw d'5' ; Fixed timeout of 5 seconds | |
1361 cpfsgt timeout_counter | |
1362 bsf divemode | |
1363 return | |
1364 | |
1365 update_divemode1: ; update any second | |
1366 call set_dive_modes ; tests if depth>threshold | |
1367 | |
1368 btfsc divemode | |
1369 call set_max_depth ; update max. depth if required | |
1370 | |
1371 btfsc divemode | |
1372 call set_min_temp ; store min. temp if required | |
1373 | |
1374 bcf temp_changed ; Display temperature? | |
1375 movf temperature+0,W | |
1376 cpfseq last_temperature+0 | |
1377 bsf temp_changed ; Yes | |
1378 movf temperature+1,W | |
1379 cpfseq last_temperature+1 | |
1380 bsf temp_changed ; Yes | |
1381 btfsc temp_changed | |
1382 call PLED_temp_divemode ; Displays temperature | |
1383 | |
1384 bcf pres_changed ; Display new depth? | |
1385 movf amb_pressure+0,W | |
1386 cpfseq last_pressure+0 | |
1387 bsf pres_changed ; Yes | |
1388 movf amb_pressure+1,W | |
1389 cpfseq last_pressure+1 | |
1390 bsf pres_changed ; Yes | |
1391 | |
1392 btfsc simulatormode_active ; always update depth when in simulator mode | |
1393 bsf pres_changed | |
1394 | |
1395 btfsc pres_changed | |
1396 call PLED_depth ; Displays new depth | |
1397 return | |
1398 | |
1399 update_divemode60: ; update any minute | |
1400 call get_battery_voltage ; gets battery voltage | |
1401 call set_powersafe ; red LED blinking if battery is low | |
1402 call PLED_max_pressure ; No, use normal max. depth | |
1403 call check_temp_extrema ; check for new temperature extremas | |
1404 bcf oneminupdate | |
1405 return | |
1406 | |
1407 set_max_depth: | |
1408 movff max_pressure+0,sub_a+0 | |
1409 movff max_pressure+1,sub_a+1 | |
1410 movff rel_pressure+0,sub_b+0 | |
1411 movff rel_pressure+1,sub_b+1 | |
1412 call sub16 ; sub_c = sub_a - sub_b | |
1413 ; max_pressure<rel_pressure -> neg_flag=1 | |
1414 ; rel_pressure<=max_pressure -> neg_flag=0 | |
1415 btfss neg_flag | |
1416 return | |
1417 ;max_pressure<rel_pressure | |
1418 movff rel_pressure+0,max_pressure+0 | |
1419 movff rel_pressure+1,max_pressure+1 | |
1420 call PLED_max_pressure ; No, use normal max. depth | |
1421 return | |
1422 | |
1423 set_min_temp: | |
1424 movff mintemp+0,sub_a+0 | |
1425 movff mintemp+1,sub_a+1 | |
1426 movff temperature+0,sub_b+0 | |
1427 movff temperature+1,sub_b+1 | |
1428 call sub16 ; sub_c = sub_a - sub_b | |
1429 ; mintemp<T -> neg_flag=1 | |
1430 ; T<=mintemp -> neg_flag=0 | |
1431 btfsc neg_flag | |
1432 return | |
1433 ;mintemp>=T | |
1434 movff temperature+0,mintemp+0 | |
1435 movff temperature+1,mintemp+1 | |
1436 return | |
1437 | |
1438 set_dive_modes: | |
1439 bcf divemode2 ; Stop time | |
1440 | |
1441 GETCUSTOM8 .0 ; loads dive_threshold in WREG | |
1442 movwf sub_a+0 ; dive_treshold is in cm | |
1443 clrf sub_a+1 | |
1444 | |
1445 movff rel_pressure+0,sub_b+0 | |
1446 movff rel_pressure+1,sub_b+1 | |
1447 | |
1448 call sub16 ; sub_c = sub_a - sub_b | |
1449 | |
1450 btfss neg_flag | |
1451 bra set_dive_modes2 ; too shallow (rel_pressure<dive_threshold) | |
1452 | |
1453 btfsc realdive ; Dive longer than one minute? | |
1454 clrf timeout_counter | |
1455 | |
1456 bsf divemode | |
1457 bsf divemode2 ; displayed divetime is running | |
1458 return | |
1459 | |
1460 set_dive_modes2: | |
1461 btfss realdive ; dive longer then one minute? | |
1462 bcf divemode ; no -> this was no real dive | |
1463 return | |
1464 | |
1465 set_powersafe: | |
1466 btfsc low_battery_state ; battery warning alread active? | |
1467 bra set_powersafe2 ; Yes, but is it still required? | |
1468 ; battery voltage in mV (value*256+Lowbyte=actual treshold) | |
1469 movlw d'12' ; 3,328V | |
1470 cpfsgt batt_voltage+1 | |
1471 bra set_powersafe1 | |
1472 return | |
1473 | |
1474 set_powersafe1: | |
1475 movlw d'7' ; Type of Alarm (Battery Low) | |
1476 movwf AlarmType ; Copy to Alarm Register | |
1477 bsf event_occured ; Set Event Flag | |
1478 bsf low_battery_state ; set flag for battery warning | |
1479 return ; return | |
1480 | |
1481 set_powersafe2: | |
1482 movlw d'13' ; 3,584V | |
1483 cpfsgt batt_voltage+1 | |
1484 bra set_powersafe1 ; Still to low | |
1485 bcf low_battery_state ; clear flag for battery warning mode | |
1486 return | |
1487 | |
1488 calc_average_depth: | |
71
6beb680a6130
1.72beta - color-coded gaslist, small fix with stopwatch
heinrichsweikamp
parents:
69
diff
changeset
|
1489 bcf lock_stopwatch_reset ; Un-Lock the stopwatch reset option |
0 | 1490 ; 1. Add new 2xdepth to the Sum of depths registers |
1491 movff rel_pressure+0,b0_lo | |
1492 movff rel_pressure+1,b0_hi | |
1493 | |
1494 movf b0_lo,w | |
1495 addwf average_depth_hold+0,F | |
1496 movf b0_hi,w | |
1497 addwfc average_depth_hold+1,F | |
1498 movlw d'0' | |
1499 addwfc average_depth_hold+2,F | |
1500 addwfc average_depth_hold+3,F ; Will work up to 9999mBar*60*60*24=863913600mBar | |
1501 | |
1502 movf b0_lo,w | |
1503 addwf average_depth_hold+0,F | |
1504 movf b0_hi,w | |
1505 addwfc average_depth_hold+1,F | |
1506 movlw d'0' | |
1507 addwfc average_depth_hold+2,F | |
1508 addwfc average_depth_hold+3,F ; Will work up to 9999mBar*60*60*24=863913600mBar | |
1509 | |
1510 ; 2. Compute Average Depth on base of average_divesecs:2 | |
1511 | |
1512 movff average_divesecs+0,xB+0 | |
1513 movff average_divesecs+1,xB+1 ; Copy | |
1514 movff average_depth_hold+0,xC+0 | |
1515 movff average_depth_hold+1,xC+1 | |
1516 movff average_depth_hold+2,xC+2 | |
1517 movff average_depth_hold+3,xC+3 | |
1518 | |
1519 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
1520 movff xC+0,avr_rel_pressure+0 | |
1521 movff xC+1,avr_rel_pressure+1 | |
1522 return | |
1523 | |
1524 | |
1525 diveloop_boot: | |
49 | 1526 ostc_debug 'Q' ; Sends debug-information to screen if debugmode active |
0 | 1527 clrf max_pressure+0 ; clear some variables |
1528 clrf max_pressure+1 | |
1529 | |
1530 clrf avr_rel_pressure+0 | |
1531 clrf avr_rel_pressure+1 | |
1532 | |
1533 call PLED_brightness_low | |
1534 read_int_eeprom d'90' ; Brightness offset? (Dim>0, Normal = 0) | |
1535 movlw d'0' | |
1536 cpfsgt EEDATA | |
1537 call PLED_brightness_full | |
1538 | |
1539 clrf average_depth_hold+0 | |
1540 clrf average_depth_hold+1 | |
1541 clrf average_depth_hold+2 | |
1542 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
|
1543 movlw d'2' |
0 | 1544 movwf average_divesecs+0 |
1545 clrf average_divesecs+1 | |
1546 | |
1547 movlw d'1' | |
1548 movwf apnoe_max_pressure+0 | |
1549 clrf apnoe_max_pressure+1 | |
1550 clrf apnoe_surface_mins | |
1551 clrf apnoe_surface_secs | |
1552 clrf apnoe_mins | |
1553 clrf apnoe_secs | |
1554 clrf divemins+0 | |
1555 clrf divemins+1 | |
1556 clrf divesecs | |
1557 clrf samplesecs | |
1558 clrf apnoe_timeout_counter ; timeout in minutes | |
1559 clrf timeout_counter ; takes care of the timeout | |
1560 clrf timeout_counter2 ; Here: counts to six, then store deco data and temperature | |
1561 clrf AlarmType ; Clear all alarms | |
1562 bcf event_occured ; clear flag | |
71
6beb680a6130
1.72beta - color-coded gaslist, small fix with stopwatch
heinrichsweikamp
parents:
69
diff
changeset
|
1563 bcf lock_stopwatch_reset ; clear flag |
0 | 1564 bcf depth_greater_100m ; clear flag |
1565 setf last_diluent ; to be displayed after first calculation (range: 0 to 100 [%]) | |
3 | 1566 bcf dekostop_active |
1567 bcf is_bailout ;=1: CC mode, but bailout active! | |
8 | 1568 bcf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode |
1569 | |
0 | 1570 call get_free_EEPROM_location ; get last position in external EEPROM, may be up to 2 secs! |
1571 | |
1572 movff last_surfpressure_30min+1,int_I_pres_surface+1 ; HIGH copy surfacepressure to deco routine | |
1573 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; LOW copy surfacepressure to deco routine | |
1574 movff temperature+0,mintemp+0 ; Reset Min-Temp registers | |
1575 movff temperature+1,mintemp+1 ; Reset Min-Temp registers | |
1576 | |
1577 clrf wait_temp ; Used to clear Bankx registers | |
1578 movff wait_temp,char_O_GF_low_pointer | |
1579 movff wait_temp,char_O_actual_pointer | |
1580 lfsr FSR0,0x250 | |
1581 movlw 0x20 | |
1582 movwf wait_temp | |
1583 clear_deco_lists: ; Clear Deco list | |
1584 clrf POSTINC0 | |
1585 decfsz wait_temp,F | |
1586 bra clear_deco_lists | |
1587 lfsr FSR0,0x270 | |
1588 movlw 0x20 | |
1589 movwf wait_temp | |
1590 set_no_forced_stops: ; Init Deco list | |
1591 movlw 0x01 | |
1592 movwf POSTINC0 | |
1593 decfsz wait_temp,F | |
1594 bra set_no_forced_stops | |
1595 lfsr FSR0,0x290 ; clear int_O_calc_tissue_call_counter (DEBUG) | |
1596 clrf POSTINC0 | |
1597 clrf POSTINC0 | |
1598 | |
1599 ; Start with active Stopwatch? | |
1600 bsf stopwatch_active | |
1601 GETCUSTOM8 d'41' ; =1: Start with active Stopwatch | |
1602 movwf lo | |
1603 movlw d'1' | |
1604 cpfseq lo ; CF41=1? | |
1605 bcf stopwatch_active ; No! | |
1606 | |
1607 ; Init profile recording parameters | |
1608 GETCUSTOM8 d'20' ; sample rate | |
1609 movwf samplesecs_value ; to avoid EEPROM access in the ISR | |
1610 GETCUSTOM8 d'21' | |
1611 movwf divisor_temperature ; load divisors for profile storage | |
1612 GETCUSTOM8 d'22' | |
1613 movwf divisor_deco | |
1614 GETCUSTOM8 d'23' | |
1615 movwf divisor_tank | |
1616 GETCUSTOM8 d'24' | |
1617 movwf divisor_ppo2 | |
1618 GETCUSTOM8 d'25' | |
1619 movwf divisor_deco_debug | |
1620 GETCUSTOM8 d'26' | |
1621 movwf divisor_nuy2 | |
1622 | |
1623 btfss FLAG_apnoe_mode ; In Apnoe mode? | |
1624 bra divemode1 | |
1625 ; Overwrite some parameters in Apnoe mode.... | |
1626 movlw d'1' | |
1627 movwf samplesecs_value ; to avoid EEPROM access in the ISR | |
1628 | |
1629 divemode1: | |
1630 read_int_eeprom d'36' ; Read mix 1 ppO2 | |
1631 btfsc FLAG_const_ppO2_mode | |
1632 movff EEDATA,char_I_const_ppO2 ; Set ppO2 setpoint if in ppO2 mode | |
4 | 1633 movff EEDATA, ppO2_setpoint_store ; Store also in this byte... |
0 | 1634 |
21 | 1635 bcf LED_blue |
0 | 1636 bcf low_battery_state ; clear flag for battery warning mode |
1637 bcf header_stored | |
1638 bcf premenu | |
1639 bcf realdive | |
1640 bsf update_divetime ; set flag | |
1641 btfss simulatormode_active ; do not disable in simulator mode! | |
49 | 1642 call disable_rs232 ; Disable RS232 |
0 | 1643 |
1644 read_int_eeprom d'33' ; Read byte (stored in EEDATA) | |
1645 movff EEDATA,active_gas ; Read start gas (1-5) | |
1646 | |
1647 ; Read Start Gas and configure char_I_He_ratio, char_I_O2_ratio and char_I_N2_ratio | |
1648 decf active_gas,W ; Gas 0-4 | |
1649 mullw d'4' | |
1650 movf PRODL,W | |
1651 addlw d'7' ; = address for He ratio | |
1652 movwf EEADR | |
1653 call read_eeprom ; Read He ratio | |
1654 movff EEDATA,char_I_He_ratio ; And copy into hold register | |
1655 decf active_gas,W ; Gas 0-4 | |
1656 mullw d'4' | |
1657 movf PRODL,W | |
1658 addlw d'6' ; = address for O2 ratio | |
1659 movwf EEADR | |
1660 call read_eeprom ; Read O2 ratio | |
1661 movff EEDATA, char_I_O2_ratio ; O2 ratio | |
1662 movff char_I_He_ratio, wait_temp ; copy into bank1 register | |
1663 bsf STATUS,C ; Borrow bit | |
1664 movlw d'100' ; 100% | |
1665 subfwb wait_temp,W ; minus He | |
1666 bsf STATUS,C ; Borrow bit | |
1667 subfwb EEDATA,F ; minus O2 | |
1668 movff EEDATA, char_I_N2_ratio ; = N2! | |
1669 | |
1670 bcf multi_gf_display ; Do not display the multi-gf table screen | |
1671 return |