Mercurial > public > hwos_code
comparison src/divemode.asm @ 631:185ba2f91f59
3.09 beta 1 release
author | heinrichsweikamp |
---|---|
date | Fri, 28 Feb 2020 15:45:07 +0100 |
parents | cd58f7fc86db |
children | 4050675965ea |
comparison
equal
deleted
inserted
replaced
630:4cd81bdbf15c | 631:185ba2f91f59 |
---|---|
1 ;============================================================================= | 1 ;============================================================================= |
2 ; | 2 ; |
3 ; File divemode.asm combined next generation V3.04.3 | 3 ; File divemode.asm combined next generation V3.08.8 |
4 ; | 4 ; |
5 ; Dive Mode | 5 ; Dive Mode |
6 ; | 6 ; |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. |
8 ;============================================================================= | 8 ;============================================================================= |
29 | 29 |
30 | 30 |
31 extern do_line_menu | 31 extern do_line_menu |
32 extern do_main_divemenu | 32 extern do_main_divemenu |
33 extern menu_draw_lines_divemode | 33 extern menu_draw_lines_divemode |
34 extern option_save_all | |
35 extern init_recording_params | 34 extern init_recording_params |
35 extern option_check_and_store_all | |
36 | 36 |
37 IFDEF _compass | 37 IFDEF _compass |
38 extern TFT_dive_compass_heading | 38 extern TFT_dive_compass_heading |
39 ENDIF | 39 ENDIF |
40 | 40 |
41 IFDEF _cave_mode | |
42 extern do_main_cavemenu | |
43 ENDIF | |
41 | 44 |
42 ;---- Private local Variables ------------------------------------------------- | 45 ;---- Private local Variables ------------------------------------------------- |
43 | 46 |
44 CBLOCK local1 ; max size is 16 Byte !!! | 47 CBLOCK local1 ; max size is 16 Byte !!! |
45 sensor_setpoint ; sensor ppo2 in 0.01bar for deco routine | 48 sensor_setpoint ; sensor ppo2 in 0.01bar for deco routine |
76 #DEFINE FLAG_TFT_active_gas_divemode TFT_output_flags_1,2 ; =1: show active gas and dive mode | 79 #DEFINE FLAG_TFT_active_gas_divemode TFT_output_flags_1,2 ; =1: show active gas and dive mode |
77 #DEFINE FLAG_TFT_apnoe_surface_time TFT_output_flags_1,3 ; =1: show apnoe mode surface time | 80 #DEFINE FLAG_TFT_apnoe_surface_time TFT_output_flags_1,3 ; =1: show apnoe mode surface time |
78 #DEFINE FLAG_TFT_depth_maximum_apnoe TFT_output_flags_1,4 ; =1: show maximum depth of last apnoe dive | 81 #DEFINE FLAG_TFT_depth_maximum_apnoe TFT_output_flags_1,4 ; =1: show maximum depth of last apnoe dive |
79 #DEFINE FLAG_TFT_clear_apnoe_surface TFT_output_flags_1,5 ; =1: clear apnoe mode surface data from screen | 82 #DEFINE FLAG_TFT_clear_apnoe_surface TFT_output_flags_1,5 ; =1: clear apnoe mode surface data from screen |
80 #DEFINE FLAG_TFT_apnoe_divetime TFT_output_flags_1,6 ; =1: show apnoe mode dive times | 83 #DEFINE FLAG_TFT_apnoe_divetime TFT_output_flags_1,6 ; =1: show apnoe mode dive times |
81 ; TFT_output_flags_1,7 ; --- unused | 84 #DEFINE FLAG_TFT_temperature TFT_output_flags_1,7 ; =1: show temperature (or resettable dive time when in compass view) |
82 | 85 |
83 ; TFT_output_flags_2 - phase 2: every second - before deco calculations, deco modes only | 86 ; TFT_output_flags_2 - phase 2: every second - before deco calculations, deco modes only |
84 #DEFINE FLAG_TFT_divemode_mask TFT_output_flags_2,0 ; =1: show dive mode mask | 87 #DEFINE FLAG_TFT_divemode_mask TFT_output_flags_2,0 ; =1: show dive mode mask |
85 #DEFINE FLAG_TFT_divetime TFT_output_flags_2,1 ; =1: show dive time | 88 #DEFINE FLAG_TFT_divetime TFT_output_flags_2,1 ; =1: show dive time |
86 #DEFINE FLAG_TFT_safety_stop_show TFT_output_flags_2,2 ; =1: show safety stop | 89 #DEFINE FLAG_TFT_safety_stop_show TFT_output_flags_2,2 ; =1: show safety stop |
87 #DEFINE FLAG_TFT_safety_stop_clear TFT_output_flags_2,3 ; =1: clear safety stop | 90 #DEFINE FLAG_TFT_safety_stop_clear TFT_output_flags_2,3 ; =1: clear safety stop |
88 #DEFINE FLAG_TFT_temperature TFT_output_flags_2,4 ; =1: show temperature (or resettable dive time when in compass view) | 91 ; TFT_output_flags_2,4 ; --- unused |
89 ; TFT_output_flags_2,5 ; --- unused | 92 ; TFT_output_flags_2,5 ; --- unused |
90 ; TFT_output_flags_2,6 ; --- unused | 93 ; TFT_output_flags_2,6 ; --- unused |
91 ; TFT_output_flags_2,7 ; --- unused | 94 ; TFT_output_flags_2,7 ; --- unused |
92 | 95 |
93 ; TFT_output_flags_3 - phase 3: every second - after deco calculations, deco modes only | 96 ; TFT_output_flags_3 - phase 3: every second - after deco calculations, deco modes only |
99 #DEFINE FLAG_TFT_display_tts TFT_output_flags_3,5 ; =1: show deco TTS data | 102 #DEFINE FLAG_TFT_display_tts TFT_output_flags_3,5 ; =1: show deco TTS data |
100 ; TFT_output_flags_3,6 ; --- unused | 103 ; TFT_output_flags_3,6 ; --- unused |
101 ; TFT_output_flags_3,7 ; --- unused | 104 ; TFT_output_flags_3,7 ; --- unused |
102 | 105 |
103 ; TFT_output_flags_4 - phase 4: every second - after deco calculations, all modes | 106 ; TFT_output_flags_4 - phase 4: every second - after deco calculations, all modes |
104 #DEFINE FLAG_TFT_customview_mask TFT_output_flags_4,0 ; =1: show the custom view mask | 107 #DEFINE FLAG_TFT_customview_callup TFT_output_flags_4,0 ; =1: show the custom view mask |
105 #DEFINE FLAG_TFT_sign_show TFT_output_flags_4,1 ; =1: show the advice / attention / warning sign | 108 #DEFINE FLAG_TFT_sign_show TFT_output_flags_4,1 ; =1: show the advice / attention / warning sign |
106 #DEFINE FLAG_TFT_sign_clear TFT_output_flags_4,2 ; =1: clear the advice / attention / warning sign | 109 #DEFINE FLAG_TFT_sign_clear TFT_output_flags_4,2 ; =1: clear the advice / attention / warning sign |
107 #DEFINE FLAG_TFT_message_clear_both TFT_output_flags_4,3 ; =1: clear messages, both rows | 110 #DEFINE FLAG_TFT_message_clear_both TFT_output_flags_4,3 ; =1: clear messages, both rows |
108 #DEFINE FLAG_TFT_message_clear_2nd TFT_output_flags_4,4 ; =1: clear messages, 2nd row only | 111 #DEFINE FLAG_TFT_message_clear_2nd TFT_output_flags_4,4 ; =1: clear messages, 2nd row only |
109 #DEFINE FLAG_TFT_velocity_show TFT_output_flags_4,5 ; =1: show vertical velocity | 112 #DEFINE FLAG_TFT_velocity_show TFT_output_flags_4,5 ; =1: show vertical velocity |
130 ; xmitter_flags_mesg,5 ; --- unused | 133 ; xmitter_flags_mesg,5 ; --- unused |
131 ; xmitter_flags_mesg,6 ; --- unused | 134 ; xmitter_flags_mesg,6 ; --- unused |
132 ; xmitter_flags_mesg,7 ; --- unused | 135 ; xmitter_flags_mesg,7 ; --- unused |
133 | 136 |
134 ; various Flags | 137 ; various Flags |
135 #DEFINE FLAG_backtrack_full DM_flags_local,0 ; =1: the backtracking storage is full | 138 #DEFINE new_deco_data_avail DM_flags_local,0 ; =1: new NDL or deco data available |
136 #DEFINE new_deco_data_avail DM_flags_local,1 ; =1: new NDL or deco data available | 139 #DEFINE o2_sensors_agree DM_flags_local,1 ; =1: the ppO2 of all sensors are within the threshold range |
137 #DEFINE o2_sensors_agree DM_flags_local,2 ; =1: the ppO2 of all sensors are within the threshold range | 140 #DEFINE update_menu DM_flags_local,2 ; =1: redraw the dive menu |
138 #DEFINE update_menu DM_flags_local,3 ; =1: redraw the dive menu | 141 #DEFINE FLAG_SP2_used DM_flags_local,3 ; =1: setpoint 2 has been auto-selected already |
139 #DEFINE FLAG_SP2_used DM_flags_local,4 ; =1: setpoint 2 has been auto-selected already | 142 #DEFINE FLAG_SP3_used DM_flags_local,4 ; =1: setpoint 3 has been auto-selected already |
140 #DEFINE FLAG_SP3_used DM_flags_local,5 ; =1: setpoint 3 has been auto-selected already | 143 #DEFINE FLAG_SP4_used DM_flags_local,5 ; =1: setpoint 4 has been auto-selected already |
141 #DEFINE FLAG_SP4_used DM_flags_local,6 ; =1: setpoint 4 has been auto-selected already | 144 #DEFINE FLAG_SP5_used DM_flags_local,6 ; =1: setpoint 5 has been auto-selected already |
142 #DEFINE FLAG_SP5_used DM_flags_local,7 ; =1: setpoint 5 has been auto-selected already | 145 ; DM_flags_local,7 ; --- unused |
143 | 146 |
144 | 147 |
145 dmode CODE | 148 dmode CODE |
146 | 149 |
147 ;============================================================================= | 150 ;============================================================================= |
154 bsf reset_timebase ; request ISR to reset the main timebase, | 157 bsf reset_timebase ; request ISR to reset the main timebase, |
155 ; as we are in dive mode the dive timers will be reset as well | 158 ; as we are in dive mode the dive timers will be reset as well |
156 | 159 |
157 ; reset global flags | 160 ; reset global flags |
158 clrf DM_flags_state ; clear all flags for dive mode status | 161 clrf DM_flags_state ; clear all flags for dive mode status |
159 clrf DM_flags_request ; clear all flags for user requests | |
160 clrf DM_flags_event ; clear all flags for data recording events | 162 clrf DM_flags_event ; clear all flags for data recording events |
163 clrf DM_flags_request ; clear all flags for user requests / general | |
164 IFDEF _cave_mode | |
165 clrf DM_flags_cavereq ; clear all flags for user requests / cave mode | |
166 ENDIF | |
161 clrf DM_flags_layout1 ; clear all flags for display control / layout (1) | 167 clrf DM_flags_layout1 ; clear all flags for display control / layout (1) |
162 clrf DM_flags_layout2 ; clear all flags for display control / layout (2) | 168 clrf DM_flags_layout2 ; clear all flags for display control / layout (2) |
169 clrf DM_flags_layout3 ; clear all flags for display control / layout (3) | |
163 clrf DM_flags_message ; clear all flags for display control / messages | 170 clrf DM_flags_message ; clear all flags for display control / messages |
164 clrf DM_flags_gas_dil ; clear all flags for display control / gases and diluents | 171 clrf DM_flags_gas_dil ; clear all flags for display control / gases, diluents, depth |
165 | 172 |
166 bcf dive_main_menu ; clear dive main menu flag | 173 bcf dive_main_menu ; clear dive main menu flag |
167 bcf dive_options_menu ; clear dive options menu flag | 174 bcf dive_options_menu ; clear dive options menu flag |
168 | 175 |
169 ; reset local flags | 176 ; reset local flags |
173 clrf TFT_output_flags_4 ; clear all flags for TFT output phase 4 | 180 clrf TFT_output_flags_4 ; clear all flags for TFT output phase 4 |
174 clrf xmitter_flags_stat ; clear all pressure transmitter status flags | 181 clrf xmitter_flags_stat ; clear all pressure transmitter status flags |
175 clrf xmitter_flags_mesg ; clear all pressure transmitter message flags | 182 clrf xmitter_flags_mesg ; clear all pressure transmitter message flags |
176 clrf DM_flags_local ; clear all the various other flags, too | 183 clrf DM_flags_local ; clear all the various other flags, too |
177 | 184 |
178 ; set initial screen layout | 185 ; configure screen layout (all flags were cleared above) |
179 bcf alt_layout_active ; default to normal layout | |
180 TSTOSC opt_layout ; alternative layout enabled? | 186 TSTOSC opt_layout ; alternative layout enabled? |
181 bsf alt_layout_active ; YES - start with alternative layout | 187 bsf alt_layout_active ; YES - start with alternative layout |
182 | 188 |
183 IFDEF _gas_contingency | 189 ; configure tissue graphics (all flags were cleared above) |
184 ; disable gas contingency mode (may be left over activated by deco calculator) | 190 TSTOSS opt_tissue_graphics ; shall show: 0= pres+sat, 1= N2+He |
185 clrf WREG | 191 bsf tissue_graphic_layout ; YES - show press+sat |
186 movff WREG,char_I_gas_contingency | 192 |
187 ENDIF | 193 TSTOSC char_I_model ; GF factors enabled? |
194 bsf tissue_graphic_gf ; YES - show GF lines | |
195 | |
188 | 196 |
189 ; boot tasks for all modes | 197 ; boot tasks for all modes |
190 call diveloop_boot | 198 call diveloop_boot |
191 | 199 |
192 ; startup tasks for all modes | 200 ; startup tasks for all modes |
197 call TFT_show_divemode_mask ; display static dive mode mask | 205 call TFT_show_divemode_mask ; display static dive mode mask |
198 call TFT_Display_FadeIn ; dim up the display | 206 call TFT_Display_FadeIn ; dim up the display |
199 | 207 |
200 ; reload and redraw last custom view | 208 ; reload and redraw last custom view |
201 movff customview_divemode,active_customview | 209 movff customview_divemode,active_customview |
202 bsf FLAG_TFT_customview_mask | 210 bsf FLAG_TFT_customview_callup |
203 | 211 |
204 bcf divetime_longer_1min ; the dive has just begun | 212 bcf divetime_longer_1min ; the dive has just begun |
205 btfsc FLAG_apnoe_mode ; in apnea mode? | 213 btfsc FLAG_apnoe_mode ; in apnea mode? |
206 bsf divetime_longer_1min ; YES - force dive to have lasted for longer than 1 minute already | 214 bsf divetime_longer_1min ; YES - force dive to have lasted for longer than 1 minute already |
207 btfsc sensor_override_active ; in simulator mode? | 215 btfsc sensor_override_active ; in simulator mode? |
261 bra diveloop_loop_11 ; YES - done with 1/2 second tasks | 269 bra diveloop_loop_11 ; YES - done with 1/2 second tasks |
262 btfsc FLAG_apnoe_mode ; NO - in apnoe mode? | 270 btfsc FLAG_apnoe_mode ; NO - in apnoe mode? |
263 bra diveloop_loop_11 ; YES - done with 1/2 second tasks | 271 bra diveloop_loop_11 ; YES - done with 1/2 second tasks |
264 | 272 |
265 ; tasks every 1/2 second in deco modes | 273 ; tasks every 1/2 second in deco modes |
266 call calc_deco_engine ; ##### calculate decompression ##### | 274 call callup_deco_engine ; ##### manage and invoke the deco calculation engine ##### |
267 bra diveloop_loop_11 ; done with 1/2 second tasks | 275 bra diveloop_loop_11 ; done with 1/2 second tasks |
268 | 276 |
269 diveloop_loop_2: | 277 diveloop_loop_2: |
270 ; tasks every 1/1 second (code includes tasks every 1/2 second that fall onto the full second) | 278 ; tasks every 1/1 second (code includes tasks every 1/2 second that fall onto the full second) |
271 bcf trigger_full_second ; clear flag for new 1/1 second | 279 bcf trigger_full_second ; clear flag for new 1/1 second |
307 MOVLI .10,xB | 315 MOVLI .10,xB |
308 call div16x16 ; xC = xA / xB = absolute pressure / 10 | 316 call div16x16 ; xC = xA / xB = absolute pressure / 10 |
309 MOVII xC,pressure_abs_10 ; store result for later use | 317 MOVII xC,pressure_abs_10 ; store result for later use |
310 | 318 |
311 ; compute current depth in meters | 319 ; compute current depth in meters |
312 MOVII pressure_rel_cur_cached,xA ; copy current relative pressure to xA | 320 MOVII pressure_rel_cur_cached,mpr ; copy current relative pressure in [mbar] to MPR |
313 ADDLI .50, xA ; add 0.5 meter = 50 mbar for rounding up/down at 0.5 meters | 321 call convert_pres_to_depth ; convert pressure in [mbar] to depth in [cm] |
314 MOVLI .100,xB ; divide by 100 to turn mbar into meters | 322 ADDLI .50,mpr ; add 50 cm for rounding up/down around 0.5 meters |
323 MOVII mpr, xA ; copy depth in [cm] into xA | |
324 MOVLI .100,xB ; load factor 100 cm/m into xB | |
315 call div16x16 ; xC = xA / xB = depth in full meters | 325 call div16x16 ; xC = xA / xB = depth in full meters |
316 movff xC+0,depth_meter ; store result in depth_meter, only LSB of result needed | 326 movff xC+0,depth_meter ; store result as depth in [m], only low byte needed |
317 | 327 |
318 IFDEF _ccr_pscr | 328 IFDEF _ccr_pscr |
319 ; adjust auto-setpoint | 329 ; adjust auto-setpoint |
320 btfsc FLAG_ccr_mode ; in CCR mode? | 330 btfsc FLAG_ccr_mode ; in CCR mode? |
321 call check_dive_autosp ; YES - check for Auto-SP | 331 call check_dive_autosp ; YES - check for Auto-SP |
336 rcall calc_deko_divemode_sensor ; YES - do sensor data acquisition if applicable | 346 rcall calc_deko_divemode_sensor ; YES - do sensor data acquisition if applicable |
337 btfsc FLAG_pscr_mode ; in pSCR mode? | 347 btfsc FLAG_pscr_mode ; in pSCR mode? |
338 rcall calc_deko_divemode_sensor ; YES - do sensor data acquisition if applicable | 348 rcall calc_deko_divemode_sensor ; YES - do sensor data acquisition if applicable |
339 ENDIF | 349 ENDIF |
340 | 350 |
351 IFDEF _cave_mode | |
352 btfss cave_mode ; cave mode switched on? | |
353 bra diveloop_loop_4a ; NO - no backtracking depth recording | |
354 btfsc dive_turned ; dive turned? | |
355 bra diveloop_loop_4a ; YES - no backtracking depth recording | |
356 btfsc backtrack_entire_full ; backtracking storage entirely used up? | |
357 bra diveloop_loop_4a ; YES - no backtracking depth recording | |
358 | |
359 incf backtrack_deltatime,F ; increment time elapsed since last depth recording | |
360 movlw .59 ; load WREG with coding of last second of a minute | |
361 cpfsgt backtrack_deltatime ; time elapsed since last depth recording > 59 seconds? | |
362 bra diveloop_loop_4a ; NO - no backtracking depth recording now | |
363 rcall write_backtrack_1min_depth ; - store a backtracking depth data set | |
364 ENDIF | |
365 | |
366 diveloop_loop_4a: | |
367 ; continue tasks every 1/1 second | |
368 | |
341 btfsc FLAG_apnoe_mode ; in apnoe mode? | 369 btfsc FLAG_apnoe_mode ; in apnoe mode? |
342 rcall divemode_apnoe_tasks ; YES - do 1 sec. apnoe tasks | 370 rcall divemode_apnoe_tasks ; YES - do 1 sec. apnoe tasks |
343 | 371 |
344 ; display all animated (blinking) values at the beginning of each full second to have a stable timebase | 372 ; display all animated (blinking) values at the beginning of each full second to have a stable timebase |
345 rcall TFT_output_1 ; do display updates | 373 rcall TFT_output_1 ; do display updates |
374 INCI divesecs_avg_total ; increment the total dive time | 402 INCI divesecs_avg_total ; increment the total dive time |
375 | 403 |
376 btfsc FLAG_gauge_mode ; in gauge mode? | 404 btfsc FLAG_gauge_mode ; in gauge mode? |
377 bra diveloop_loop_7 ; YES - skip deco calculations | 405 bra diveloop_loop_7 ; YES - skip deco calculations |
378 | 406 |
379 call calc_deco_engine ; ##### calculate decompression ##### | 407 call callup_deco_engine ; ##### manage and invoke the deco calculation engine ##### |
380 | 408 |
381 btfsc new_deco_data_avail ; new NDL or deco data available? | 409 btfsc new_deco_data_avail ; new NDL or deco data available? |
382 call show_new_deco_data ; YES - update the display and update the decostop_active flag | 410 call show_new_deco_data ; YES - update the display and update the decostop_active flag |
383 | 411 |
384 btfsc decostop_active ; in deco mode? | 412 btfsc decostop_active ; in deco mode? |
394 call check_gas_best ; YES - check if a better gas cue can be given | 422 call check_gas_best ; YES - check if a better gas cue can be given |
395 | 423 |
396 diveloop_loop_8: | 424 diveloop_loop_8: |
397 ; deco mode tasks alternating every 2 seconds on resettable dive time | 425 ; deco mode tasks alternating every 2 seconds on resettable dive time |
398 btfss divesecs_avg_trip+0,0 ; on even second of resettable dive time? | 426 btfss divesecs_avg_trip+0,0 ; on even second of resettable dive time? |
399 rcall calc_average_depth ; YES - calculate average depth | 427 call calc_average_depth ; YES - calculate average depth |
400 btfsc divesecs_avg_trip+0,0 ; on odd second of resettable dive time? | 428 btfsc divesecs_avg_trip+0,0 ; on odd second of resettable dive time? |
401 rcall safety_stop_control ; YES - exercise safety stop control | 429 rcall safety_stop_control ; YES - exercise safety stop control |
402 | 430 |
403 diveloop_loop_9: | 431 diveloop_loop_9: |
404 ; deco mode tasks every 1/1 second | 432 ; deco mode tasks every 1/1 second |
406 rcall TFT_output_3 ; do display updates | 434 rcall TFT_output_3 ; do display updates |
407 | 435 |
408 diveloop_loop_10: | 436 diveloop_loop_10: |
409 ; common tasks every 1/1 second | 437 ; common tasks every 1/1 second |
410 rcall timeout_divemode ; check for timeout condition | 438 rcall timeout_divemode ; check for timeout condition |
411 rcall check_dive_modes ; test if depth still deeper than threshold | 439 call check_dive_modes ; test if depth still deeper than threshold |
412 | 440 |
413 btfsc trigger_full_minute ; has next minute begun? | 441 btfsc trigger_full_minute ; has next minute begun? |
414 rcall update_divemode60 ; YES - update clock, etc. | 442 rcall update_divemode60 ; YES - update clock, etc. |
415 | 443 |
416 btfss FLAG_oc_mode ; are we in OC mode? | 444 btfss FLAG_oc_mode ; are we in OC mode? |
434 bsf FLAG_TFT_active_gas_divemode; redraw gas and setpoint (eventually needed to restore the "Bailout" text) | 462 bsf FLAG_TFT_active_gas_divemode; redraw gas and setpoint (eventually needed to restore the "Bailout" text) |
435 | 463 |
436 btfsc request_next_custview ; shall show next custom view? | 464 btfsc request_next_custview ; shall show next custom view? |
437 call dive_customview_toggle ; YES - show next custom view (and delete this flag) | 465 call dive_customview_toggle ; YES - show next custom view (and delete this flag) |
438 | 466 |
439 btfsc request_gaschange ; shall change gas? | 467 btfsc request_gas_change ; shall change gas? |
440 call gas_switched_common ; YES | 468 call gas_switch_common ; YES |
469 | |
470 btfsc request_gas_update ; shall update the gases? | |
471 call gas_update_common ; YES | |
441 | 472 |
442 btfsc request_toggle_GF ; shall toggle GF/aGF? | 473 btfsc request_toggle_GF ; shall toggle GF/aGF? |
443 rcall divemodemode_togglegf ; YES | 474 rcall divemodemode_togglegf ; YES |
444 | 475 |
445 IFDEF _cave_mode | 476 IFDEF _cave_mode |
446 btfsc request_turn_dive ; shall turn dive? | 477 btfsc request_cave_off_turned ; shall switch cave mode off and set the dive as turned? |
447 rcall divemodemode_toggleturn ; YES | 478 rcall cavemode_switch_off_turned ; YES |
479 | |
480 btfsc request_cave_toggle ; shall toggle cave mode off/on? | |
481 rcall cavemode_toggle_onoff ; YES | |
482 | |
483 btfsc request_turn_turn ; shall turn the dive? | |
484 rcall cavemode_turndive_turn ; YES | |
485 | |
486 btfsc request_turn_toggle ; shall toggle the turn dive state? | |
487 rcall cavemode_turndive_toggle ; YES | |
488 | |
489 btfsc request_waypoint_set ; shall set a waypoint? | |
490 rcall cavemode_waypoint_set ; YES | |
491 | |
492 btfsc request_waypoint_out ; shall step one waypoint out of the cave? | |
493 rcall cavemode_waypoint_out ; YES | |
494 | |
495 btfsc request_waypoint_in ; shall step one waypoint into the cave? | |
496 rcall cavemode_waypoint_in ; YES | |
448 ENDIF | 497 ENDIF |
449 | 498 |
450 btfsc request_set_marker ; shall set a marker? | 499 btfsc request_set_marker ; shall set a marker? |
451 call set_logbook_marker ; YES | 500 call set_logbook_marker ; YES |
452 | 501 |
473 call TFT_show_depth ; YES - display depth | 522 call TFT_show_depth ; YES - display depth |
474 btfsc FLAG_TFT_depth_maximum ; shall show max depth? | 523 btfsc FLAG_TFT_depth_maximum ; shall show max depth? |
475 call TFT_show_max_depth ; YES - display max depth | 524 call TFT_show_max_depth ; YES - display max depth |
476 btfsc FLAG_TFT_active_gas_divemode ; shall show active gas and dive mode? | 525 btfsc FLAG_TFT_active_gas_divemode ; shall show active gas and dive mode? |
477 call TFT_show_active_gas_divemode ; YES - display gas, setpoint and mode | 526 call TFT_show_active_gas_divemode ; YES - display gas, setpoint and mode |
527 btfsc FLAG_TFT_temperature ; shall show temperature? | |
528 call TFT_show_temp_divemode ; YES - display temperature (or resettable dive time) | |
478 | 529 |
479 btfsc FLAG_TFT_apnoe_surface_time ; shall show apnoe mode surface time? | 530 btfsc FLAG_TFT_apnoe_surface_time ; shall show apnoe mode surface time? |
480 call TFT_show_apnoe_surface ; YES - show apnoe mode surface time | 531 call TFT_show_apnoe_surface ; YES - show apnoe mode surface time |
481 btfsc FLAG_TFT_depth_maximum_apnoe ; shall show max. depth of last dive? | 532 btfsc FLAG_TFT_depth_maximum_apnoe ; shall show max. depth of last dive? |
482 call TFT_show_apnoe_max_depth ; YES - show max. depth of last dive | 533 call TFT_show_apnoe_max_depth ; YES - show max. depth of last dive |
493 call TFT_show_divetime ; YES - show dive time | 544 call TFT_show_divetime ; YES - show dive time |
494 btfsc FLAG_TFT_safety_stop_show ; shall show safety stop? | 545 btfsc FLAG_TFT_safety_stop_show ; shall show safety stop? |
495 call TFT_safety_stop_show ; YES - show safety stop | 546 call TFT_safety_stop_show ; YES - show safety stop |
496 btfsc FLAG_TFT_safety_stop_clear ; shall clear safety stop? | 547 btfsc FLAG_TFT_safety_stop_clear ; shall clear safety stop? |
497 call TFT_safety_stop_clear ; YES - clear safety stop | 548 call TFT_safety_stop_clear ; YES - clear safety stop |
498 btfsc FLAG_TFT_temperature ; shall show temperature? | |
499 call TFT_show_temp_divemode ; YES - display temperature (or resettable dive time) | |
500 clrf TFT_output_flags_2 ; mark all TFT updates done | 549 clrf TFT_output_flags_2 ; mark all TFT updates done |
501 goto dive_customview_second ; do every-second tasks for the custom view area (in sync with the dive time) and return | 550 goto dive_customview_second ; do every-second tasks for the custom view area (in sync with the dive time) and return |
502 | 551 |
503 TFT_output_3: ; every second - after deco calculations, deco modes only | 552 TFT_output_3: ; every second - after deco calculations, deco modes only |
504 btfsc FLAG_TFT_clear_deco_data ; shall clear deco data (NDL or stop & TTS)? | 553 btfsc FLAG_TFT_clear_deco_data ; shall clear deco data (NDL or stop & TTS)? |
515 call TFT_show_tts ; YES - show deco TTS | 564 call TFT_show_tts ; YES - show deco TTS |
516 clrf TFT_output_flags_3 ; mark all TFT updates done | 565 clrf TFT_output_flags_3 ; mark all TFT updates done |
517 return ; done | 566 return ; done |
518 | 567 |
519 TFT_output_4: ; every second - after deco calculations, all modes | 568 TFT_output_4: ; every second - after deco calculations, all modes |
520 btfsc FLAG_TFT_customview_mask ; shall redraw the custom view mask? | 569 btfsc FLAG_TFT_customview_callup ; shall show a custom view? |
521 call dive_customview_mask ; YES - redraw custom view mask | 570 call dive_customview_callup ; YES - show a custom view |
522 btfsc FLAG_TFT_velocity_show ; shall show vertical velocity? | 571 btfsc FLAG_TFT_velocity_show ; shall show vertical velocity? |
523 call TFT_velocity_show ; YES - show vertical velocity? | 572 call TFT_velocity_show ; YES - show vertical velocity |
524 btfsc FLAG_TFT_velocity_clear ; shall clear vertical velocity? | 573 btfsc FLAG_TFT_velocity_clear ; shall clear vertical velocity? |
525 call TFT_velocity_clear ; YES - clear vertical velocity? | 574 call TFT_velocity_clear ; YES - clear vertical velocity |
526 btfsc FLAG_TFT_sign_show ; shall show the advice / attention / warning sign? | 575 btfsc FLAG_TFT_sign_show ; shall show the advice / attention / warning sign? |
527 call TFT_divemode_sign_show ; YES - show sign | 576 call TFT_divemode_sign_show ; YES - show sign |
528 btfsc FLAG_TFT_sign_clear ; shall clear the advice / attention / warning sign? | 577 btfsc FLAG_TFT_sign_clear ; shall clear the advice / attention / warning sign? |
529 call TFT_divemode_sign_clear ; YES - clear sign | 578 call TFT_divemode_sign_clear ; YES - clear sign |
530 btfsc FLAG_TFT_message_clear_both ; shall clear all messages? | 579 btfsc FLAG_TFT_message_clear_both ; shall clear all messages? |
567 MOVII pressure_rel_max_cached,apnoe_max_pressure ; YES - store new overall max depth | 616 MOVII pressure_rel_max_cached,apnoe_max_pressure ; YES - store new overall max depth |
568 return ; - done | 617 return ; - done |
569 | 618 |
570 ; -------------------------------------------------------------------------------------- | 619 ; -------------------------------------------------------------------------------------- |
571 | 620 |
572 calc_deco_engine: | 621 ; Manage and invoke the Deco Calculation Engine |
573 ; check deco engine state and switch between normal and alternative plan calculations | 622 ; ============================================= |
623 ; Any reconfiguration done here only affects the deco calculation (prediction), not the | |
624 ; settings for the calculations done on the real tissues. The later ones are only altered | |
625 ; in case of a gas change, in case of a real bailout, or in case a switchback to setpoint | |
626 ; or sensor is done. | |
627 ; On event of a gas change, a diluent change, a real bailout, or a switchback, the settings | |
628 ; for the deco calculation are also automatically changed to match with the settings for the | |
629 ; real tissues. This is all done in the function 'gas_switch_common' which is triggered by | |
630 ; the flag 'request_gas_change'. | |
631 | |
632 ; Deco Engine Calculation Schedules: | |
574 ; | 633 ; |
575 ; Remark: Any reconfigurations done here do only affect the ascent & deco calculation settings, | 634 ; Schedule Dive Mode Bailout fTTS Gas Needs Plan Deco Mode Planning Modes |
576 ; not the settings for the calculations done on the real tissues. The later ones are only | 635 ; --------------------------------------------------------------------------------------------- |
577 ; altered in case of a gas change, or in case of a real bailout or switchback to setpoint | 636 ; |
578 ; or sensor, respectively. | 637 ; 1a) OC no no (yes) norm OC (gas needs) |
579 ; In case of a gas change or real bailout/switchback, the settings for the deco calculations | 638 ; alt -- -- |
580 ; are also changed to match the settings for the real tissues. This is done on signal through | 639 ; |
581 ; 'request_gaschange' and will also leave the deco engine status in state as if having done | 640 ; 1b) OC no YES (yes) norm OC -- |
582 ; the alternative plan last. | 641 ; alt OC fTTS, (gas needs) |
642 ; | |
643 ; 2a) Loop no no no norm Loop -- | |
644 ; alt -- -- | |
645 ; | |
646 ; 2b) Loop no yes no norm Loop -- | |
647 ; alt Loop fTTS | |
648 ; | |
649 ; 2c) Loop no (yes) YES norm Loop -- | |
650 ; alt OC gas needs, (fTTS*) | |
651 ; | |
652 ; 3) Loop YES n/a (yes) norm OC bailout, (gas needs) | |
653 ; alt -- -- | |
654 ; _____________________________________________________________________________________________ | |
655 ; norm: normal plan, alt: alternative plan, -- none, (): optional, n/a: not applicable | |
656 ; * suppressed when in cave mode and dive is turned | |
657 | |
658 | |
659 callup_deco_engine: | |
583 | 660 |
584 ; get working copies of char_O_main_status and char_O_deco_status | 661 ; get working copies of char_O_main_status and char_O_deco_status |
585 movff char_O_main_status,hi ; get char_O_main_status into hi | 662 movff char_O_main_status,hi ; get char_O_main_status into hi |
586 movff char_O_deco_status,lo ; get char_O_deco_status into lo | 663 movff char_O_deco_status,lo ; get char_O_deco_status into lo |
587 | 664 |
588 ; check state of deco calculations | 665 ; check state of deco calculations |
589 btfsc lo,DECO_COMPLETED_NORM ; finished calculations for normal plan? | 666 btfsc request_restart_engine ; restart of the deco engine requested? |
590 bra calc_deco_engine_alt ; YES - do an alternative plan next (or a normal one with more features enabled) | 667 bra calc_deco_engine_restart ; YES - start a new normal plan |
591 btfsc lo,DECO_COMPLETED_ALT ; finished calculations for alternative plan? | 668 btfsc lo,DECO_COMPLETED_NORM ; NO - finished calculations for normal plan? |
592 bra calc_deco_engine_norm ; YES - do a normal plan next | 669 bra calc_deco_engine_alt ; YES - eventually do an alternative plan next |
593 bra calc_deco_engine_cont ; NO to both - continue calculations / do first invocation in INIT mode | 670 btfsc lo,DECO_COMPLETED_ALT ; NO - finished calculations for alternative plan? |
671 bra calc_deco_engine_norm ; YES - do a normal plan next | |
672 bra calc_deco_engine_exec ; NO - continue executing current calculation | |
673 | |
674 calc_deco_engine_restart: | |
675 bcf request_restart_engine ; clear request flag | |
676 bcf lo,DECO_COMPLETED_NORM ; clear completion flag from normal plan if applicable | |
677 ;bra calc_deco_engine_norm ; continue with calculating a normal plan | |
678 | |
679 ; ---- normal plans ---- | |
594 | 680 |
595 calc_deco_engine_norm: | 681 calc_deco_engine_norm: |
596 ; Last cycle did an alternative plan, or the deco engine has been restarted because of a gas change etc. | 682 bcf lo,DECO_COMPLETED_ALT ; clear completion flag from alternative plan |
597 ; --> Reconfigure to normal plan for next computation cycle. | 683 IFDEF _ccr_pscr |
598 bcf lo,DECO_COMPLETED_ALT ; clear flag indicating last plan was an alternative one | 684 btfsc bailout_mode ; in real bailout? |
599 bsf lo,DECO_START_NORM ; set flag to calculate a normal deco plan next | 685 bra calc_deco_engine_norm_3 ; YES - configure real bailout schedule |
600 bcf lo,DECO_ASCENT_FLAG ; clear flag for delayed ascent calculation | 686 btfss FLAG_oc_mode ; in OC dive mode? |
601 bcf lo,DECO_BAILOUT_FLAG ; clear flag for bailout mode | 687 bra calc_deco_engine_norm_2 ; NO - configure loop schedules |
602 bcf hi,DECO_VOLUME_FLAG ; clear flag for gas needs calculation | 688 ;bra calc_deco_engine_norm_1 ; YES - configure OC schedules |
689 ENDIF | |
690 | |
691 calc_deco_engine_norm_1: | |
692 ; normal OC schedules | |
693 TSTOSC char_I_extra_time ; delay mode activated? | |
694 bra calc_deco_engine_norm_1b ; YES - schedule 1b in normal plan | |
695 ;bra calc_deco_engine_norm_1a ; NO - schedule 1a in normal plan | |
696 | |
697 calc_deco_engine_norm_1a: | |
698 ; normal schedule 1a: OC with optional gas needs | |
699 ; bcf lo,DECO_BAILOUT_FLAG ; switch off bailout mode (will never be activated in this plan) | |
700 ; bcf lo,DECO_DELAY_FLAG ; switch off delay mode (will never be activated in this plan) | |
701 ; bcf hi,DECO_VOLUME_FLAG ; switch off gas needs calculation by default (if on, will always be on) | |
702 TSTOSC opt_calc_gasvolume ; shall calculate gas needs? | |
703 bsf hi,DECO_VOLUME_FLAG ; YES - switch on gas needs calculation | |
704 bra calc_deco_engine_norm_start ; start deco engine in normal plan | |
705 | |
706 calc_deco_engine_norm_1b: | |
707 ; normal schedule 1b: OC without delay and gas needs | |
708 ; bcf lo,DECO_BAILOUT_FLAG ; switch off bailout mode (will never be activated in this plan) | |
709 bcf lo,DECO_DELAY_FLAG ; switch off delay mode | |
710 bcf hi,DECO_VOLUME_FLAG ; switch off gas needs calculation | |
711 bra calc_deco_engine_norm_start ; start deco engine in normal plan | |
712 | |
713 IFDEF _ccr_pscr | |
714 calc_deco_engine_norm_2: | |
715 ; normal loop schedules | |
716 TSTOSC opt_calc_gasvolume ; gas needs calculation activated? | |
717 bra calc_deco_engine_norm_2c ; YES - schedule 2c in normal plan | |
718 ;bra calc_deco_engine_norm_2ab ; NO - schedules 2a and 2b in normal plan are identical | |
719 | |
720 calc_deco_engine_norm_2ab: | |
721 ; normal schedule 2a & 2b: loop without anything | |
722 bcf lo,DECO_BAILOUT_FLAG ; switch off bailout mode (may return from real bailout) | |
723 ; bcf hi,DECO_VOLUME_FLAG ; switch off gas needs calculation (will never be activated in this plans) | |
724 bcf lo,DECO_DELAY_FLAG ; switch off delay mode (may have been set in alt. plan 2b) | |
725 bra calc_deco_engine_norm_start ; start deco engine in normal plan | |
726 | |
727 calc_deco_engine_norm_2c: | |
728 ; normal schedule 2c: loop with switch-back from simulated bailout | |
729 ; switch to CCR/pSCR | |
730 movf active_dil,W ; get current diluent | |
731 call deco_setup_cc_diluents_pre ; set up deco calculation in CCR/pSCR mode with diluents | |
732 calc_deco_engine_norm_2c_XX: | |
733 bcf lo,DECO_BAILOUT_FLAG ; switch off bailout mode (may return from real bailout) | |
734 bcf hi,DECO_VOLUME_FLAG ; switch off gas needs calculation | |
735 bcf lo,DECO_DELAY_FLAG ; switch off delay mode | |
736 bra calc_deco_engine_norm_start ; start deco engine in normal plan | |
737 | |
738 calc_deco_engine_norm_3: | |
739 ; real bailout schedule | |
740 bcf lo,DECO_DELAY_FLAG ; switch off delay mode | |
741 bcf hi,DECO_VOLUME_FLAG ; switch off gas needs calculation by default | |
742 TSTOSC opt_calc_gasvolume ; shall calculate gas needs? | |
743 bsf hi,DECO_VOLUME_FLAG ; YES - switch on gas needs calculation | |
744 bsf lo,DECO_BAILOUT_FLAG ; switch on bailout mode | |
745 ;bra calc_deco_engine_norm_start ; start deco engine in normal plan | |
746 ENDIF ; _ccr_pscr | |
747 | |
748 calc_deco_engine_norm_start: | |
749 bsf lo,DECO_START_NORM ; calculate a normal plan | |
750 bra calc_deco_engine_start ; start deco engine | |
751 | |
752 ; ---- alternative plans ---- | |
753 | |
754 calc_deco_engine_alt: | |
755 bcf lo,DECO_COMPLETED_NORM ; clear completion flag from normal plan | |
756 IFDEF _ccr_pscr | |
757 btfsc bailout_mode ; in real bailout? | |
758 bra calc_deco_engine_norm_3 ; YES - schedule 3 has no alternative plan | |
759 btfss FLAG_oc_mode ; in OC dive mode? | |
760 bra calc_deco_engine_alt_2 ; NO - loop schedules | |
761 ;bra calc_deco_engine_alt_1 ; YES - OC schedules | |
762 ENDIF ; _ccr_pscr | |
763 | |
764 calc_deco_engine_alt_1: | |
765 ; alternative OC schedules | |
766 TSTOSS char_I_extra_time ; delay mode activated? | |
767 bra calc_deco_engine_norm_1a ; NO - schedule 1a has no alternative plan | |
603 IFDEF _cave_mode | 768 IFDEF _cave_mode |
604 bcf hi,DECO_CAVE_MODE ; clear flag for cave mode | 769 btfsc dive_turned ; YES - in cave mode and dive turned? |
605 ENDIF | 770 bra calc_deco_engine_norm_1a ; YES - suppress delay mode -> do schedule 1a in normal plan |
771 ENDIF | |
772 ;bra calc_deco_engine_alt_1b ; NO - do schedule 1b in alternative plan | |
773 | |
774 calc_deco_engine_alt_1b: | |
775 ; alternative schedule 1b: OC with delay and optional gas needs | |
776 ; bcf lo,DECO_BAILOUT_FLAG ; switch off bailout mode (will never be activated in this plan) | |
777 ; bcf hi,DECO_VOLUME_FLAG ; switch off gas needs calculation by default (comes in switched off state) | |
778 TSTOSC opt_calc_gasvolume ; shall calculate gas needs? | |
779 bsf hi,DECO_VOLUME_FLAG ; YES - switch on gas needs calculation | |
780 bsf lo,DECO_DELAY_FLAG ; switch on delay mode | |
781 bra calc_deco_engine_alt_start ; start deco engine in alternative plan | |
606 | 782 |
607 IFDEF _ccr_pscr | 783 IFDEF _ccr_pscr |
608 btfsc FLAG_ccr_mode ; in CCR mode? | 784 calc_deco_engine_alt_2: |
609 bra calc_deco_engine_norm_loop ; YES - reload diluents and reconfigure CCR mode if not in bailout | 785 ; alternative loop schedules |
610 btfsc FLAG_pscr_mode ; in pSCR mode? | 786 TSTOSC opt_calc_gasvolume ; gas needs calculation activated? |
611 bra calc_deco_engine_norm_loop ; YES - reload diluents and reconfigure pSCR mode if not in bailout | 787 bra calc_deco_engine_alt_2c ; YES - 2c in alternative plan |
612 ;bra calc_deco_engine_norm_OC ; neither in CCR nor pSCR mode, so reload OC gases and reconfigure OC mode | 788 TSTOSS char_I_extra_time ; NO - delay mode activated? |
613 ; (first cycle omits gas needs calculation for faster first deco results) | 789 bra calc_deco_engine_norm_2ab ; NO - schedule 2a has no alternative plan |
614 ENDIF | 790 ;bra calc_deco_engine_alt_2b ; YES - schedule 2b in alternative plan |
615 | 791 |
616 calc_deco_engine_norm_OC: | 792 calc_deco_engine_alt_2b: |
617 movff active_gas,WREG ; get current OC gas | 793 ; alternative schedule 2b: loop with delay |
618 call deco_setup_oc_gases_pre ; set up deco calculations in OC mode with OC gases | 794 ; bcf lo,DECO_BAILOUT_FLAG ; switch off bailout mode (will be deactivated in normal plan) |
619 bra calc_deco_engine_start ; start deco engine | 795 ; bcf hi,DECO_VOLUME_FLAG ; switch off gas needs calculation (will never be activated in this plan) |
620 | 796 bsf lo,DECO_DELAY_FLAG ; switch on delay mode |
621 IFDEF _ccr_pscr | 797 bra calc_deco_engine_alt_start ; start deco engine in normal plan |
622 calc_deco_engine_norm_loop: ; switch to loop calculation if not in a real bailout situation | 798 |
623 btfsc bailout_mode ; check if a real bailout situation is present | 799 calc_deco_engine_alt_2c: |
624 bra calc_deco_engine_norm_OC ; YES - revert to OC mode | 800 ; alternative schedule 2c: simulated bailout (if possible) |
625 ; NO - switch to loop calculation: | 801 decf best_gas_number,W ; get best gas number -1 into WREG. If not available, WREG will be 255 now. If not computed yet, WREG will be 254 now. |
626 movff active_dil,WREG ; - get current diluent | 802 btfsc WREG,7 ; WREG < 128 (a bailout gas is available)? |
627 call deco_setup_cc_diluents_pre ; - set up deco calculations in CCR/pSCR mode with diluents | 803 bra calc_deco_engine_alt_2c_XX ; NO - no bailout plan possible because no bailout gas available to switch to |
628 bra calc_deco_engine_start ; - start deco engine | 804 movf best_gas_number,W ; YES - get number of best gas into WREG |
629 ENDIF | 805 call deco_setup_oc_gases_pre ; - set up deco calculation in OC mode with OC gases |
630 | 806 ; bcf lo,DECO_DELAY_FLAG ; - switch off delay mode by default (comes in switched off state) |
631 calc_deco_engine_alt: | 807 TSTOSC char_I_extra_time ; - delay mode activated? |
632 ; A normal plan was computed in the last cycle. For the next calculation cycle the mode may be switched | 808 bsf lo,DECO_DELAY_FLAG ; YES - switch on delay mode |
633 ; to alternative plan, or stay in normal plan but with certain features enabled... | |
634 bcf lo,DECO_ASCENT_FLAG ; clear flag for delayed ascent calculation | |
635 bcf lo,DECO_BAILOUT_FLAG ; clear flag for bailout mode | |
636 bcf hi,DECO_VOLUME_FLAG ; clear flag for gas needs calculation | |
637 IFDEF _cave_mode | 809 IFDEF _cave_mode |
638 bcf hi,DECO_CAVE_MODE ; clear flag for cave mode | 810 btfsc dive_turned ; in cave mode and dive turned? |
639 ENDIF | 811 bcf lo,DECO_DELAY_FLAG ; YES - suppress delay mode |
640 | 812 ENDIF |
641 btfsc bailout_mode ; check if a real bailout situation is present | 813 bsf lo,DECO_BAILOUT_FLAG ; - switch on bailout mode |
642 bra calc_deco_engine_alt_1 ; YES - stay in normal plan mode and preclude delayed ascent calculation | 814 bsf hi,DECO_VOLUME_FLAG ; - switch on gas needs calculation |
643 TSTOSS char_I_extra_time ; NO - check if a delayed ascent is enabled | 815 bra calc_deco_engine_alt_start ; - start deco engine in alternative plan |
644 bra calc_deco_engine_alt_1 ; NO - stay in normal plan mode and preclude delayed ascent calculation | 816 calc_deco_engine_alt_2c_XX: |
645 bcf lo,DECO_COMPLETED_NORM ; YES - clear flag indicating last plan was a normal one | 817 call inval_alternative_plan_data ; invalidate all alternative (bailout) plan data because they are not applicable any more |
646 bsf lo,DECO_START_ALT ; - set flag to calculate an alternative deco plan next | 818 bra calc_deco_engine_norm_start ; continue calculating as normal plan |
647 bsf lo,DECO_ASCENT_FLAG ; - set flag for delayed ascent | 819 ENDIF ; _ccr_pscr |
648 | 820 |
649 calc_deco_engine_alt_1: | 821 calc_deco_engine_alt_start: |
650 TSTOSS opt_calc_asc_gasvolume ; check if gas volume calculation is enabled | 822 bsf lo,DECO_START_ALT ; calculate an alternative plan |
651 bra calc_deco_engine_start ; NO - no volume calculation, no simulated bailout plan in this case | 823 ;bra calc_deco_engine_start ; start deco engine |
652 bsf hi,DECO_VOLUME_FLAG ; YES - set gas needs calculation flag | 824 |
653 | 825 ; ---- start deco engine ---- |
654 btfsc bailout_mode ; check if a real bailout situation is present | 826 |
655 bra calc_deco_engine_start ; YES - normal plan already does bailout (OC) calculation "for real" | 827 calc_deco_engine_start: |
656 | |
657 IFDEF _cave_mode | 828 IFDEF _cave_mode |
658 bsf hi,DECO_CAVE_MODE ; activate cave mode by default | 829 bcf hi,DECO_CAVE_MODE ; deactivate cave mode by default |
659 btfss cave_mode ; cave mode switched on? | 830 btfss cave_mode ; cave mode switched on? |
660 bcf hi,DECO_CAVE_MODE ; NO - deactivate p2deco cave mode again | 831 bra calc_deco_engine_start_1 ; NO - keep deactivated, no backtracking depth recording |
661 btfsc dive_turned ; dive turned? | 832 bsf hi,DECO_CAVE_MODE ; YES - activate cave mode |
662 bcf hi,DECO_CAVE_MODE ; YES - deactivate p2deco cave mode again | 833 btfss dive_turned ; - dive turned? |
663 btfsc FLAG_backtrack_full ; backtracking storage full? | 834 call write_backtrack_deltatime ; NO - update current delta time |
664 bcf hi,DECO_CAVE_MODE ; YES - deactivate p2deco cave mode again | 835 ENDIF |
665 ENDIF | 836 calc_deco_engine_start_1: |
666 | |
667 btfss lo,DECO_MODE_LOOP_FLAG ; NO - has a loop mode calculation been done during the normal plan? | |
668 bra calc_deco_engine_start ; NO - when not in loop mode, no simulated bailout to be done | |
669 decf best_gas_number,W ; YES - get best gas number -1 into WREG. If not available, WREG will be 255 now. If not computed yet, WREG will be 254 now. | |
670 btfsc WREG,7 ; - WREG < 128 (a bailout gas is available)? | |
671 bra calc_deco_engine_alt_2 ; NO - no simulated bailout possible because no bailout gas available to switch to | |
672 bcf lo,DECO_COMPLETED_NORM ; YES - clear flag indicating last plan was a normal one | |
673 bsf lo,DECO_START_ALT ; - set flag to calculate an alternative deco plan next | |
674 bsf lo,DECO_BAILOUT_FLAG ; - set flag for bailout mode (enables gas switches before 1st stop) | |
675 movf best_gas_number,W ; - put number of best gas into WREG | |
676 call deco_setup_oc_gases_pre ; - set up deco calculations in OC mode with OC gases | |
677 bra calc_deco_engine_start ; - start in alternative plan mode | |
678 | |
679 calc_deco_engine_alt_2: | |
680 bcf lo,DECO_START_ALT ; clear flag to calculate an alternative deco plan next | |
681 bsf lo,DECO_START_NORM ; set flag to calculate a normal deco plan next | |
682 bcf lo,DECO_ASCENT_FLAG ; clear flag for delayed ascent calculation | |
683 bcf hi,DECO_VOLUME_FLAG ; clear flag for gas needs calculation | |
684 IFDEF _cave_mode | |
685 bcf hi,DECO_CAVE_MODE ; clear flag for cave mode | |
686 ENDIF | |
687 call inval_alternative_plan_data ; invalidate all alternative (bailout) plan data because they are not applicable any more | |
688 | |
689 calc_deco_engine_start: | |
690 movff hi,char_O_main_status ; write-back char_O_main_status to deco engine interface | 837 movff hi,char_O_main_status ; write-back char_O_main_status to deco engine interface |
691 movff lo,char_O_deco_status ; write-back char_O_deco_status to deco engine interface | 838 movff lo,char_O_deco_status ; write-back char_O_deco_status to deco engine interface |
692 | 839 |
693 calc_deco_engine_cont: | 840 calc_deco_engine_exec: |
694 ; +++++++++++++++++++++++++++++++++++++ | 841 ; +++++++++++++++++++++++++++++++++++++ |
695 call deco_calc_hauptroutine ; invoke the deco engine (C-code) | 842 call deco_calc_hauptroutine ; invoke the deco engine (C-code) |
696 banksel common ; back to bank common | 843 banksel common ; back to bank common |
697 ; +++++++++++++++++++++++++++++++++++++ | 844 ; +++++++++++++++++++++++++++++++++++++ |
698 | 845 |
846 ifdef _debug_output | |
699 call TFT_debug_output ; debug output of scheduling performance data | 847 call TFT_debug_output ; debug output of scheduling performance data |
848 endif | |
700 | 849 |
701 ; check if new calculation results for normal plan mode are available | 850 ; check if new calculation results for normal plan mode are available |
702 movff char_O_deco_status,WREG ; get deco status of deco engine | 851 movff char_O_deco_status,WREG ; get deco status of deco engine |
703 btfsc WREG,DECO_COMPLETED_NORM ; new calculation results for normal plan available? | 852 btfsc WREG,DECO_COMPLETED_NORM ; new calculation results for normal plan available? |
704 bsf new_deco_data_avail ; YES - set flag for new NDL or deco data available | 853 bsf new_deco_data_avail ; YES - set flag for new NDL or deco data available |
705 return ; done | 854 |
706 | 855 ; done |
856 return | |
857 | |
858 ; ------------------------------------------------------------------------------------------------- | |
707 | 859 |
708 show_new_deco_data: | 860 show_new_deco_data: |
709 bcf new_deco_data_avail ; reset flag for new NDL or deco data available | 861 bcf new_deco_data_avail ; reset flag for new NDL or deco data available |
710 movff char_O_deco_info,WREG ; get the deco info vector | 862 movff char_O_deco_info,WREG ; get the deco info vector |
711 btfsc WREG,deco_stops ; deco stops found? | 863 btfsc WREG,deco_stops_norm ; deco stops found? |
712 bra show_new_deco_data_deco ; YES - in deco | 864 bra show_new_deco_data_deco ; YES - in deco |
713 ;bra show_new_deco_data_ndl ; NO - within NDL | 865 ;bra show_new_deco_data_ndl ; NO - within NDL |
714 | 866 |
715 show_new_deco_data_ndl: ; within NDL | 867 show_new_deco_data_ndl: ; within NDL |
716 btfsc decostop_active ; been in deco mode before? | 868 btfsc decostop_active ; been in deco mode before? |
730 bsf FLAG_TFT_display_tts ; display TTS time (display or stop data is managed somewhere else) | 882 bsf FLAG_TFT_display_tts ; display TTS time (display or stop data is managed somewhere else) |
731 return | 883 return |
732 | 884 |
733 ;============================================================================= | 885 ;============================================================================= |
734 | 886 |
887 IFDEF _ccr_pscr | |
735 IFDEF _external_sensor | 888 IFDEF _external_sensor |
736 | 889 |
737 global calc_deko_divemode_sensor | 890 global calc_deko_divemode_sensor |
738 calc_deko_divemode_sensor: | 891 calc_deko_divemode_sensor: |
739 ; sensor acquisition code | 892 ; sensor acquisition code |
1015 return ; NO - not in dive mode, return | 1168 return ; NO - not in dive mode, return |
1016 movff opt_ccr_mode,WREG ; YES - =0: Fixed SP, =1: Sensor, =2: Auto SP | 1169 movff opt_ccr_mode,WREG ; YES - =0: Fixed SP, =1: Sensor, =2: Auto SP |
1017 decfsz WREG,W ; - opt_ccr_mode = 1 (sensors)? | 1170 decfsz WREG,W ; - opt_ccr_mode = 1 (sensors)? |
1018 return ; NO - not using the sensors in the moment | 1171 return ; NO - not using the sensors in the moment |
1019 show_sensors_custview: | 1172 show_sensors_custview: |
1020 movlw index_ppo2_sensors-1 ; YES - custom view number one below ppO2 sensors | 1173 btfsc custom_view_locked ; YES - custom view locked? |
1021 movwf active_customview ; - set custom view number | 1174 return ; YES - done |
1022 bsf request_next_custview ; - initiate toggle to desired custom view -> ppO2 sensors | 1175 movlw index_ppo2_sensors ; NO - get custom view number of ppO2 sensors |
1023 return | 1176 goto dive_customview_show ; - draw custom view and return |
1024 | 1177 |
1025 check_sensor_voting_helper: | 1178 check_sensor_voting_helper: |
1026 movf lo,W | 1179 movf lo,W |
1027 cpfsgt sensor_setpoint | 1180 cpfsgt sensor_setpoint |
1028 bra check_sensor_voting_helper2 ; lo < sensor_setpoint | 1181 bra check_sensor_voting_helper2 ; lo < sensor_setpoint |
1040 movf sensor_setpoint,W | 1193 movf sensor_setpoint,W |
1041 subwf lo,F | 1194 subwf lo,F |
1042 bra check_sensor_voting_helper1 | 1195 bra check_sensor_voting_helper1 |
1043 | 1196 |
1044 ENDIF ; _external_sensor | 1197 ENDIF ; _external_sensor |
1198 ENDIF ; _ccr_pscr | |
1045 | 1199 |
1046 ;============================================================================= | 1200 ;============================================================================= |
1047 | 1201 |
1048 divemodemode_togglegf: ; toggle aGF/GF | 1202 divemodemode_togglegf: |
1049 bcf request_toggle_GF ; clear request flag | 1203 bcf request_toggle_GF ; clear request flag |
1050 btg use_aGF ; toggle normal / alternative GF factor selection | 1204 goto restart_deco_engine ; restart the deco engine and return |
1051 btfsc use_aGF ; alternative GF factors activated? | |
1052 bra divemodemode_togglegf_1 ; YES - branch to using aGF | |
1053 movff opt_GF_low, char_I_GF_Low_percentage ; NO - use normal GF factor low | |
1054 movff opt_GF_high,char_I_GF_High_percentage ; - use normal GF factor high | |
1055 bra divemodemode_togglegf_2 ; - continue with common part | |
1056 divemodemode_togglegf_1: | |
1057 movff opt_aGF_low, char_I_GF_Low_percentage ; YES - use alternative GF factor low | |
1058 movff opt_aGF_high,char_I_GF_High_percentage ; - use alternative GF factor high | |
1059 divemodemode_togglegf_2: | |
1060 call TFT_gf_factors_mask ; update custom view mask to show which one is in use | |
1061 ; the custom view itself has been called from divemenu_tree before | |
1062 goto restart_deco_engine ; ...and return | |
1063 | 1205 |
1064 ;============================================================================= | 1206 ;============================================================================= |
1065 | 1207 |
1066 IFDEF _cave_mode | 1208 IFDEF _cave_mode |
1067 | 1209 |
1068 divemodemode_toggleturn: | 1210 cavemode_toggle_onoff: |
1069 bcf request_turn_dive ; clear request flag | 1211 bcf request_cave_toggle ; clear request flag |
1070 btg dive_turned ; toggle dive turned state | 1212 btg cave_mode ; toggle the on/off state |
1071 btfsc FLAG_backtrack_full ; backtracking storage full? | 1213 return ; done |
1072 bsf dive_turned ; YES - allow only activating turned state | 1214 |
1073 goto set_logbook_marker ; set a logbook marker (and return) | 1215 cavemode_switch_off_turned: |
1216 bcf request_cave_off_turned ; clear request flag | |
1217 bcf cave_mode ; switch cave mode off | |
1218 bra cavemode_turndive_turn_exec ; set dive as turned (and return) | |
1219 | |
1220 | |
1221 global cavemode_turndive_check | |
1222 cavemode_turndive_check: | |
1223 btfss cave_mode ; cave mode switched on? | |
1224 retlw 1 ; NO - signal not allowed | |
1225 btfss dive_turned ; YES - is the dive currently turned? | |
1226 retlw 0 ; NO - command is allowed | |
1227 movf backtrack_waypoint_turn,W ; YES - copy turn point number to WREG | |
1228 cpfslt backtrack_waypoint_num ; - current waypoint number < turn point number ? | |
1229 retlw 1 ; NO - signal not allowed | |
1230 retlw 0 ; YES - command is allowed | |
1231 | |
1232 cavemode_turndive_toggle: | |
1233 bcf request_turn_toggle ; clear request flag | |
1234 rcall cavemode_turndive_check ; check if command is allowed | |
1235 tstfsz WREG ; command allowed? | |
1236 return ; NO - abort | |
1237 btfss dive_turned ; YES - is the dive currently turned? | |
1238 bra cavemode_turndive_turn_exec ; NO - turn the dive | |
1239 bra request_turndive_cont_exec ; YES - continue the dive | |
1240 | |
1241 cavemode_turndive_turn: | |
1242 bcf request_turn_turn ; clear request flag | |
1243 btfss cave_mode ; cave mode switched on? | |
1244 return ; NO - abort | |
1245 btfsc dive_turned ; YES - is the dive already turned? | |
1246 return ; YES - nothing to do any more | |
1247 ;bra cavemode_turndive_turn_exec ; NO - turn the dive | |
1248 | |
1249 cavemode_turndive_turn_exec: | |
1250 bsf dive_turned ; set dive as turned | |
1251 call set_logbook_marker ; set a logbook marker | |
1252 goto write_backtrack_turnpoint ; write a turn-point waypoint (and return) | |
1253 | |
1254 request_turndive_cont_exec: | |
1255 bcf dive_turned ; set dive as not turned any more | |
1256 bcf backtrack_shutdown ; set backtracking as not shut down any more | |
1257 call set_logbook_marker ; set a logbook marker | |
1258 goto resume_backtrack_recording ; append further logging after current waypoint (and return) | |
1259 | |
1260 | |
1261 global cavemode_waypoint_set_check | |
1262 cavemode_waypoint_set_check: | |
1263 btfss cave_mode ; cave mode switched on? | |
1264 retlw 1 ; NO - command not allowed | |
1265 btfsc dive_turned ; YES - is the dive turned? | |
1266 retlw 1 ; YES - no setting of waypoints on way out, command not allowed | |
1267 btfsc backtrack_entire_full ; NO - storage entirely used up? | |
1268 retlw 1 ; YES - out of storage capacity, command not allowed | |
1269 movlw backtrack_waypoint_max ; NO - get highest allowed waypoint number | |
1270 cpfslt backtrack_waypoint_num ; - current waypoint number < max allowed number? | |
1271 retlw 1 ; NO - command not allowed | |
1272 retlw 0 ; YES - command is allowed | |
1273 | |
1274 cavemode_waypoint_set: | |
1275 bcf request_waypoint_set ; clear request flag | |
1276 rcall cavemode_waypoint_set_check ; check if command is allowed to execute | |
1277 tstfsz WREG ; command allowed? | |
1278 return ; NO - no waypoint setting possible, abort | |
1279 call set_logbook_marker ; YES - set a logbook marker | |
1280 goto write_backtrack_waypoint ; - execute command (and return) | |
1281 | |
1282 | |
1283 global cavemode_waypoint_out_check | |
1284 cavemode_waypoint_out_check: | |
1285 btfss cave_mode ; cave mode switched on? | |
1286 retlw 1 ; NO - command not allowed | |
1287 btfss dive_turned ; YES - is the dive turned? | |
1288 retlw 1 ; NO - no stepping back on way in, command not allowed | |
1289 btfsc waypoint_reached_first ; YES - already at first waypoint? | |
1290 retlw 1 ; YES - command not allowed | |
1291 retlw 0 ; NO - command is allowed | |
1292 | |
1293 cavemode_waypoint_out: | |
1294 bcf request_waypoint_out ; clear request flag | |
1295 rcall cavemode_waypoint_out_check ; check if command is allowed to execute | |
1296 tstfsz WREG ; command allowed? | |
1297 return ; NO - no further out possible, abort | |
1298 goto backtrack_waypoint_go_out ; YES - execute the command (and return) | |
1299 | |
1300 | |
1301 global cavemode_waypoint_in_check | |
1302 cavemode_waypoint_in_check: | |
1303 btfss cave_mode ; cave mode switched on? | |
1304 retlw 1 ; NO - command not allowed | |
1305 btfss dive_turned ; YES - is the dive turned? | |
1306 retlw 1 ; NO - no stepping forward on way in, command not allowed | |
1307 btfsc waypoint_reached_last ; YES - already at last waypoint? | |
1308 retlw 1 ; YES - command not allowed | |
1309 retlw 0 ; NO - command is allowed | |
1310 | |
1311 cavemode_waypoint_in: | |
1312 bcf request_waypoint_in ; clear request flag | |
1313 rcall cavemode_waypoint_in_check ; check if command is allowed to execute | |
1314 tstfsz WREG ; command allowed? | |
1315 return ; NO - no further in possible, abort | |
1316 goto backtrack_waypoint_go_in ; YES - execute command (and return) | |
1074 | 1317 |
1075 ENDIF | 1318 ENDIF |
1076 | 1319 |
1077 ;============================================================================= | 1320 ;============================================================================= |
1078 | 1321 |
1099 ; calculate velocity in m/min | 1342 ; calculate velocity in m/min |
1100 MOVII sub_c,xA ; copy pressure differential to xA | 1343 MOVII sub_c,xA ; copy pressure differential to xA |
1101 MOVLI .39,xB ; put scale coefficient into xB (use 77 when called every second) | 1344 MOVLI .39,xB ; put scale coefficient into xB (use 77 when called every second) |
1102 call mult16x16 ; compute differential pressure in mbar * scale coefficient | 1345 call mult16x16 ; compute differential pressure in mbar * scale coefficient |
1103 MOVII xC,divA ; copy result to divA | 1346 MOVII xC,divA ; copy result to divA |
1104 ADDLI .64,divA ; add some round-up TODO: too sensitive with this? | 1347 ADDLI .64,divA ; add some round-up |
1105 movlw .7 ; divide by 2^7 | 1348 movlw .7 ; divide by 2^7 |
1106 call div16 ; divA = divA / 2^WREG, yields velocity in m/min | 1349 call div16 ; divA = divA / 2^WREG, yields velocity in m/min |
1107 | 1350 |
1108 movlw .99 ; load a 99 | 1351 movlw .99 ; load a 99 |
1109 cpfslt divA+0 ; velocity < 99 m/min ? | 1352 cpfslt divA+0 ; velocity < 99 m/min ? |
1123 | 1366 |
1124 check_deco_states: | 1367 check_deco_states: |
1125 btfsc deco_region ; been within the deco stops region before? | 1368 btfsc deco_region ; been within the deco stops region before? |
1126 return ; YES - been in deco then before too, done | 1369 return ; YES - been in deco then before too, done |
1127 movff char_O_deco_info,WREG ; NO - get deco info vector | 1370 movff char_O_deco_info,WREG ; NO - get deco info vector |
1128 btfss WREG,deco_stops ; do we have a deco obligation right now? | 1371 btfss WREG,deco_stops_norm ; do we have a deco obligation right now? |
1129 return ; NO - done | 1372 return ; NO - done |
1130 bsf deco_locked ; YES - memorize dive was in deco | 1373 bsf deco_locked ; YES - memorize dive was in deco |
1131 movff char_O_deco_depth+0,WREG ; - get depth of first stop in meters into WREG | 1374 movff char_O_deco_depth+0,WREG ; - get depth of first stop in meters into WREG |
1132 addlw deco_region_distance+.1 ; - add deco region start distance + 1 meter for the negative test to work | 1375 addlw deco_region_distance+.1 ; - add deco region start distance + 1 meter for the negative test to work |
1133 subwf depth_meter,W ; - compute current depth - (first stop depth + deco distance) | 1376 subwf depth_meter,W ; - compute current depth - (first stop depth + deco region distance) |
1134 btfss STATUS,C ; - result negative? | 1377 btfss STATUS,C ; - result negative? |
1135 bsf deco_region ; YES - memorize to have entered the deco stops region | 1378 bsf deco_region ; YES - memorize to have entered the deco stops region |
1136 return ; - done | 1379 return ; - done |
1137 | 1380 |
1138 ;============================================================================= | 1381 ;============================================================================= |
1139 | 1382 |
1140 safety_stop_control: | 1383 safety_stop_control: |
1141 TSTOSS opt_enable_safetystop ; safety stop enabled? (=1: show safety stop) | 1384 TSTOSS opt_safetystop ; safety stop enabled? (=1: show safety stop) |
1142 return ; NO - done | 1385 return ; NO - done |
1143 | 1386 |
1144 btfsc FLAG_gauge_mode ; in gauge mode? | 1387 btfsc FLAG_gauge_mode ; in gauge mode? |
1145 return ; YES - omit (well, else fix collision of safety stop output with avg depth label) | 1388 return ; YES - omit (well, else fix collision of safety stop output with avg depth label) |
1146 | 1389 |
1150 ; check for deco | 1393 ; check for deco |
1151 btfsc decostop_active ; in deco mode? | 1394 btfsc decostop_active ; in deco mode? |
1152 bra safety_stop_finish ; YES - shut down safety stop | 1395 bra safety_stop_finish ; YES - shut down safety stop |
1153 | 1396 |
1154 ; below "opt_safety_stop_reset"? | 1397 ; below "opt_safety_stop_reset"? |
1155 MOVII pressure_rel_cur_cached,mpr ; get current depth into hi:lo | 1398 MOVII pressure_rel_cur_cached,mpr ; get current pressure into MPR |
1156 call adjust_depth_with_salinity ; compute salinity setting into hi:lo [mbar] | 1399 call convert_pres_to_depth ; convert pressure in [mbar] to depth in [cm] |
1157 MOVII mpr,sub_a ; move adjusted depth to sub_a | 1400 MOVII mpr,sub_a ; move depth in [cm] to sub_a |
1158 movff opt_safety_stop_reset,WREG ; load safety stop reset threshold [cbar] | 1401 movff opt_safety_stop_reset,WREG ; load safety stop reset threshold [dm] |
1159 mullw .10 ; convert threshold from [cbar] to [mbar] | 1402 mullw .10 ; convert threshold from [dm] to [cm] |
1160 MOVII PROD,sub_b ; move threshold to sub_b | 1403 MOVII PROD,sub_b ; move threshold in [cm] to sub_b |
1161 call cmpU16 ; sub_a - sub_b | 1404 call cmpU16 ; sub_a - sub_b |
1162 btfss neg_flag ; below threshold depth? | 1405 btfss neg_flag ; below threshold depth? |
1163 bra safety_stop_reset ; YES - arm safety stop and delete it from display if still shown | 1406 bra safety_stop_reset ; YES - arm safety stop and delete it from display if still shown |
1164 | 1407 ;bra safety_stop_control_1 ; NO - check if above end threshold |
1408 | |
1409 safety_stop_control_1: | |
1165 ; above "opt_safety_stop_end"? | 1410 ; above "opt_safety_stop_end"? |
1166 movff opt_safety_stop_end,WREG ; load safety stop end threshold [cbar] | 1411 movff opt_safety_stop_end,WREG ; load safety stop end threshold [dm] |
1167 mullw .10 ; convert threshold from [cbar] to [mbar] | 1412 mullw .10 ; convert threshold from [dm] to [cm] |
1168 MOVII PROD,sub_b ; move threshold to sub_b | 1413 MOVII PROD,sub_b ; move threshold in [cm] to sub_b |
1169 call cmpU16 ; sub_a - sub_b | 1414 call cmpU16 ; sub_a - sub_b |
1170 btfsc neg_flag ; above or at threshold depth? | 1415 btfsc neg_flag ; above or at threshold depth? |
1171 bra safety_stop_finish ; YES - finish with safety stop | 1416 bra safety_stop_finish ; YES - finish with safety stop |
1172 | 1417 ;bra safety_stop_control_2 ; NO - check if above start threshold |
1418 | |
1419 safety_stop_control_2: | |
1173 ; above "opt_safety_stop_start"? | 1420 ; above "opt_safety_stop_start"? |
1174 movff opt_safety_stop_start,WREG ; load safety stop start threshold [cbar] | 1421 movff opt_safety_stop_start,WREG ; load safety stop start threshold [dm] |
1175 mullw .10 ; convert threshold from [cbar] to [mbar] | 1422 mullw .10 ; convert threshold from [dm] to [cm] |
1176 MOVII PROD,sub_b ; move threshold to sub_b | 1423 MOVII PROD,sub_b ; move threshold in [cm] to sub_b |
1177 call cmpU16 ; sub_a - sub_b | 1424 call cmpU16 ; sub_a - sub_b |
1178 btfss neg_flag ; above or at threshold depth? | 1425 btfss neg_flag ; above or at threshold depth? |
1179 return ; NO - pause safety stop | 1426 return ; NO - pause safety stop |
1180 tstfsz safety_stop_countdown ; YES - safety stop armed? | 1427 tstfsz safety_stop_countdown ; YES - safety stop armed? |
1181 bsf safety_stop_enabled ; YES - enable safety stop | 1428 bsf safety_stop_enabled ; YES - enable safety stop |
1182 return ; NO - done | 1429 return ; NO - done |
1430 | |
1183 | 1431 |
1184 safety_stop_show: | 1432 safety_stop_show: |
1185 btfss safety_stop_enabled ; safety stop enabled? | 1433 btfss safety_stop_enabled ; safety stop enabled? |
1186 return ; NO - done | 1434 return ; NO - done |
1187 dcfsnz safety_stop_countdown,F ; YES - decrement remaining stop time, reached zero? | 1435 dcfsnz safety_stop_countdown,F ; YES - decrement remaining stop time, reached zero? |
1213 btfss trigger_timeout ; timeout occurred? | 1461 btfss trigger_timeout ; timeout occurred? |
1214 return ; NO - done | 1462 return ; NO - done |
1215 ;bra timeout_divemode_menu2 ; YES - clean up main menu and restore dive data | 1463 ;bra timeout_divemode_menu2 ; YES - clean up main menu and restore dive data |
1216 | 1464 |
1217 global timeout_divemode_menu2 | 1465 global timeout_divemode_menu2 |
1218 timeout_divemode_menu2: ; called from divemenu_tree.asm | 1466 timeout_divemode_menu2: ; jump-in point from divemenu_tree.asm |
1219 bcf dive_main_menu ; timeout, clear flag for dive mode menu shown | 1467 bcf dive_main_menu ; clear flag for dive mode menu shown |
1220 call TFT_clear_divemode_menu ; clear menu | 1468 call TFT_clear_divemode_menu ; clear menu area |
1469 | |
1470 btfss custom_view_locked ; was the custom view locked by the menu system? | |
1471 bra timeout_divemode_menu3 ; NO - continue with redrawing the lower display | |
1472 bcf custom_view_locked ; YES - clear flag for custom view locked by menu | |
1473 movf backup_customview,W ; - get previous custom view into WREG | |
1474 cpfseq active_customview ; - compare with current custom view, equal? | |
1475 call dive_customview_recall ; NO - redraw previous custom view | |
1476 | |
1477 timeout_divemode_menu3: | |
1221 bsf FLAG_TFT_active_gas_divemode; redraw gas/setpoint/diluent | 1478 bsf FLAG_TFT_active_gas_divemode; redraw gas/setpoint/diluent |
1222 bcf better_gas_blinking ; clear flag to have temperature updated once | |
1223 bcf better_dil_blinking ; clear flag to have temperature updated once | |
1224 bsf FLAG_TFT_temperature ; display temperature (or resettable dive time when in compass view) | 1479 bsf FLAG_TFT_temperature ; display temperature (or resettable dive time when in compass view) |
1480 bcf better_gas_blinking ; stop better gas cue | |
1481 bcf better_dil_blinking ; stop better dil cue | |
1225 | 1482 |
1226 request_redraw_NDL_deco_data: | 1483 request_redraw_NDL_deco_data: |
1227 btfsc FLAG_gauge_mode ; in gauge mode? | 1484 btfsc FLAG_gauge_mode ; in gauge mode? |
1228 return ; YES - done | 1485 return ; YES - done |
1229 btfss decostop_active ; NO - in deco mode? | 1486 btfss decostop_active ; NO - in deco mode? |
1284 bra timeout_divemode_com_sec ; continue with common part for seconds | 1541 bra timeout_divemode_com_sec ; continue with common part for seconds |
1285 | 1542 |
1286 | 1543 |
1287 update_divemode60: ; tasks every full minute | 1544 update_divemode60: ; tasks every full minute |
1288 bcf trigger_full_minute ; clear flag | 1545 bcf trigger_full_minute ; clear flag |
1546 | |
1289 call get_battery_voltage ; get battery voltage | 1547 call get_battery_voltage ; get battery voltage |
1290 rcall set_powersafe ; check if battery is low | 1548 btfsc battery_low_condition ; battery low condition detected? |
1291 IFDEF _cave_mode | 1549 rcall set_powersafe ; YES - record an alarm and reduce display brightness |
1292 movlw .1 ; prepare to add backtrack data for 1 minute | 1550 |
1293 btfsc cave_mode ; cave mode switched on? | 1551 ; max allowed runtime in simulator is 254 minutes in |
1294 rcall update_backtrack ; YES - store backtracking data | 1552 ; order for the tissue calculation catch-up to work! |
1295 ENDIF | 1553 |
1296 btfss sensor_override_active ; in simulator mode? | 1554 btfss sensor_override_active ; in simulator mode? |
1297 return ; NO - done | 1555 return ; NO - done |
1298 movlw .20 ; YES - quite dive mode simulation after 21 * 256 sec = 89 min : 36 sec | 1556 movlw simulator_timeout_normal ; YES - set simulation timeout |
1299 cpfsgt total_divetime_secs+1 ; - timeout? | 1557 IFDEF _cave_mode |
1558 TSTOSC opt_cave_mode ; - cave mode switched on? | |
1559 movlw simulator_timeout_cave ; YES - update simulation timeout | |
1560 ENDIF | |
1561 cpfsgt counted_divetime_mins+0 ; - timeout? | |
1300 return ; NO - done | 1562 return ; NO - done |
1301 IFDEF _DEBUG | 1563 IFDEF _DEBUG |
1302 return ; YES - but no timeout in debug mode | 1564 return ; YES - but we do not care in debug mode... |
1303 ENDIF | 1565 ELSE |
1304 bra divemode_option1 ; YES - set depth to 0 m and "return" | 1566 bra divemode_option_sim_quit ; YES - set depth to 0 m and return |
1567 ENDIF | |
1305 | 1568 |
1306 ;============================================================================= | 1569 ;============================================================================= |
1307 | 1570 |
1308 IFDEF _cave_mode | 1571 IFDEF _cave_mode |
1309 | 1572 |
1310 update_backtrack: | 1573 ; ** jump-in functions ** |
1311 btfsc dive_turned ; dive turned? | 1574 |
1312 return ; YES - done | 1575 write_backtrack_deltatime: |
1313 btfsc FLAG_backtrack_full ; NO - backtracking storage full? | 1576 rcall setup_backtrack_index ; setup writing position |
1314 return ; YES - done | 1577 bra write_backtrack_datum_deltatime ; store the current delta time (and return) |
1315 movwf lo ; NO - store minutes to add in lo | 1578 |
1316 lfsr FSR1,char_I_backtrack_depth ; - load FSR1 with base address of backtrack storage | 1579 write_backtrack_1min_depth: |
1317 movff char_I_backtrack_time,FSR1L ; - adjust FSR1 to last index | 1580 rcall setup_backtrack_index ; setup writing position |
1318 update_backtrack_loop: | 1581 rcall write_backtrack_datum_depth ; store depth |
1319 movff depth_meter,PREINC1 ; increment index and write current depth to backtrack storage | 1582 rcall write_backtrack_datum_zerotime ; reset the time elapsed since last depth recording and store it |
1320 incfsz FSR1L,W ; increment index once more and dump to WREG, did a wrap-around occur (backtrack storage full)? | 1583 bra write_backtrack_datum_check ; store new writing position, check remaining storage capacity ()and return) |
1321 bra update_backtrack_loop_1 ; NO - continue loop | 1584 |
1322 bsf FLAG_backtrack_full ; YES - flag backtracking storage is full | 1585 write_backtrack_waypoint: |
1323 return ; - done | 1586 rcall setup_backtrack_index ; setup writing position |
1324 update_backtrack_loop_1: | 1587 rcall write_backtrack_datum_deltatime ; store the time elapsed since last depth recording |
1325 decfsz lo,F ; decrement loop counter, did it became zero? | 1588 movf POSTINC1,W ; dummy read to increment the writing position index |
1326 bra update_backtrack_loop ; NO - loop | 1589 rcall write_backtrack_datum_depth ; store depth |
1327 movff FSR1L,char_I_backtrack_time ; YES - store updated index | 1590 rcall write_backtrack_datum_gas ; store gas availability vector |
1328 return ; - done | 1591 rcall write_backtrack_datum_waypoint ; store waypoint number |
1329 | 1592 rcall write_backtrack_datum_zerotime ; reset the time elapsed since last depth recording and store it |
1330 ENDIF | 1593 bra write_backtrack_datum_check ; store new writing position, check remaining storage capacity (and return) |
1594 | |
1595 write_backtrack_turnpoint: | |
1596 rcall write_backtrack_waypoint ; write a waypoint (see above) | |
1597 movf POSTDEC1,W ; dummy read to decrement the position index to the waypoint number datum | |
1598 movff FSR1L,char_I_backtrack_index ; store updated writing position | |
1599 movff backtrack_waypoint_num,backtrack_waypoint_turn; memorize this waypoint as turn point | |
1600 return ; done | |
1601 | |
1602 resume_backtrack_recording: | |
1603 clrf backtrack_waypoint_turn ; clear turn point reference | |
1604 bsf waypoint_reached_last ; declare to be at last waypoint now | |
1605 rcall setup_backtrack_index ; setup index position | |
1606 movf POSTINC1,W ; dummy read to increment the position index to the delta time datum | |
1607 rcall write_backtrack_datum_zerotime ; reset the time elapsed since last depth recording and store it | |
1608 bra write_backtrack_datum_check ; store new writing position, check remaining storage capacity (and return) | |
1609 | |
1610 backtrack_waypoint_go_out: | |
1611 bcf waypoint_reached_last ; not at last waypoint (or turn point) any more | |
1612 rcall setup_backtrack_index ; setup index position | |
1613 movlw b'11100000'-.1 ; a waypoint datum has bits 5-7 set, -1 because of cpfsgt | |
1614 backtrack_waypoint_go_out_loop: | |
1615 movff POSTDEC1,lo ; dummy read current datum and go to previous datum (there is no PREDEC) | |
1616 cpfsgt INDF1 ; read datum, is it a waypoint datum? | |
1617 bra backtrack_waypoint_go_out_loop ; NO - try next datum | |
1618 movff FSR1L,char_I_backtrack_index ; store new index position | |
1619 movf INDF1,W ; copy waypoint datum to WREG | |
1620 andlw b'00011111' ; remove waypoint tag | |
1621 movwf backtrack_waypoint_num ; store new waypoint number | |
1622 movlw .1 ; number of first waypoint | |
1623 cpfsgt backtrack_waypoint_num ; current waypoint number > number of first waypoint ? | |
1624 bsf waypoint_reached_first ; NO - reached first waypoint | |
1625 goto restart_deco_engine_wo_norm ; invalidate all alternative plan data and restart deco engine | |
1626 | |
1627 backtrack_waypoint_go_in: | |
1628 bcf waypoint_reached_first ; not at first waypoint any more | |
1629 rcall setup_backtrack_index ; setup index position | |
1630 movlw b'11100000'-.1 ; a waypoint datum has bits 5-7 set, -1 because of cpfsgt | |
1631 backtrack_waypoint_go_in_loop: | |
1632 cpfsgt PREINC1 ; go to next datum, read it, is it a waypoint datum? | |
1633 bra backtrack_waypoint_go_in_loop ; NO - try next datum | |
1634 movff FSR1L,char_I_backtrack_index ; store new index position | |
1635 movf INDF1,W ; copy waypoint datum to WREG | |
1636 andlw b'00011111' ; remove waypoint tag | |
1637 movwf backtrack_waypoint_num ; store new waypoint number | |
1638 movf backtrack_waypoint_turn,W ; load WREG with waypoint number of turn point | |
1639 cpfslt backtrack_waypoint_num ; new waypoint number < number of turn point ? | |
1640 bsf waypoint_reached_last ; NO - reached last waypoint | |
1641 goto restart_deco_engine_wo_norm ; invalidate all alternative plan data and restart deco engine | |
1642 | |
1643 | |
1644 ; ** helper functions ** | |
1645 | |
1646 setup_backtrack_index: | |
1647 lfsr FSR1,char_I_backtrack_storage ; load FSR1 with base address of the backtracking storage | |
1648 movff char_I_backtrack_index,FSR1L ; adjust FSR1 to the current index position | |
1649 return | |
1650 | |
1651 write_backtrack_datum_zerotime: | |
1652 clrf backtrack_deltatime ; reset the time elapsed since last depth recording | |
1653 write_backtrack_datum_deltatime: | |
1654 movf backtrack_deltatime,W ; get the time elapsed since last depth recording | |
1655 bsf WREG,7 ; add the time marker (bit 7 set) to the time stored in WREG | |
1656 movwf INDF1 ; write the time and keep the writing position index pointing on it | |
1657 return ; done | |
1658 | |
1659 write_backtrack_datum_depth: | |
1660 movf depth_meter,W ; get current depth in meters into WREG | |
1661 btfsc WREG,7 ; current depth < 128 m ? | |
1662 movlw .127 ; NO - clip depth to 127 meters | |
1663 movwf POSTINC1 ; write the depth entry and increment the writing position index | |
1664 return ; done | |
1665 | |
1666 write_backtrack_datum_gas: | |
1667 ; Cave mode is currently only available with gas needs calculation enabled, | |
1668 ; so deco mode is either OC anyhow or CCR/pSCR in bailout mode. Hence it is | |
1669 ; always the OC (bailout) gases whose staging status needs to be stored. | |
1670 lfsr FSR2,opt_gas_type ; load base address of the OC/bailout gas types | |
1671 movlw NUM_GAS ; load number of gases | |
1672 movwf lo ; initialize loop counter | |
1673 movlw b'00000001' ; load gas bit pattern for the first gas | |
1674 movwf hi ; store gas bit pattern in hi | |
1675 movlw b'11000000' ; initialize WREG with the gas staging status tag | |
1676 write_backtrack_datum_gas_loop: | |
1677 movff POSTINC2,up ; get gas type and increment index | |
1678 btfsc up,gas_staged ; gas staged? | |
1679 iorwf hi,W ; YES - set respective gas bit | |
1680 rlncf hi,F ; rotate gas bit pattern to match the next gas | |
1681 decfsz lo,F ; decrement loop counter, did it became zero? | |
1682 bra write_backtrack_datum_gas_loop ; NO - loop | |
1683 movwf POSTINC1 ; YES - write the gas staging status entry and increment the writing position index | |
1684 return ; - done | |
1685 | |
1686 write_backtrack_datum_waypoint: | |
1687 incf backtrack_waypoint_num,F ; increment the waypoint number | |
1688 movf backtrack_waypoint_num,W ; copy waypoint number to WREG | |
1689 iorlw b'11100000' ; add the waypoint marker (bit 7-5 set) to the number stored in WREG | |
1690 movwf POSTINC1 ; write the waypoint datum and increment the writing position index | |
1691 movlw .2 ; load a 2 into WREG | |
1692 cpfslt backtrack_waypoint_num ; new waypoint number >= 2 ? | |
1693 bcf waypoint_reached_first ; YES - not at first waypoint any more | |
1694 return ; done | |
1695 | |
1696 write_backtrack_datum_check: | |
1697 movff FSR1L,char_I_backtrack_index ; store new index position | |
1698 movlw backtrack_almost_full_threshold ; load threshold for backtracking storage almost full | |
1699 bcf backtrack_almost_full ; clear almost full state | |
1700 cpfslt FSR1L ; index < threshold ? | |
1701 bsf backtrack_almost_full ; NO - flag backtracking storage is almost full | |
1702 movlw backtrack_entire_full_threshold ; load threshold for backtracking storage entirely full | |
1703 bcf backtrack_entire_full ; clear entirely full state | |
1704 cpfslt FSR1L ; index < threshold ? | |
1705 bsf backtrack_entire_full ; NO - flag backtracking storage is entirely full | |
1706 return ; done | |
1707 | |
1708 ENDIF ; _cave_mode | |
1331 | 1709 |
1332 ;============================================================================= | 1710 ;============================================================================= |
1333 | 1711 |
1334 global set_dive_modes | 1712 global set_dive_modes |
1335 set_dive_modes: | 1713 set_dive_modes: |
1387 bcf divemode ; NO - quit dive mode as this was no real dive | 1765 bcf divemode ; NO - quit dive mode as this was no real dive |
1388 return ; done | 1766 return ; done |
1389 | 1767 |
1390 | 1768 |
1391 set_powersafe: | 1769 set_powersafe: |
1392 movlw battery_warn_level_36+1 ; get threshold for 3.6 Volt battery warning, incremented by 1 | 1770 movlw d'7' ; set type of alarm = battery low |
1393 btfss battery_is_36v ; actually a 3.6 Volt battery detected? | 1771 movwf alarm_type ; copy to alarm register |
1394 movlw battery_warn_level_15+1 ; NO - replace with 1.5 Volt battery warning, incremented by 1 | 1772 bsf event_occured ; set event flag |
1395 cpfslt batt_percent ; current battery level > warning threshold ? | 1773 movlw .0 ; coding of brightness level ECO |
1396 return ; YES - ok, done | 1774 movff WREG,opt_brightness ; set brightness to ECO |
1397 movlw d'7' ; NO - set type of alarm = battery low | 1775 return ; done |
1398 movwf alarm_type ; - copy to alarm register | |
1399 bsf event_occured ; - set event flag | |
1400 movlw .0 ; - coding of brightness level ECO | |
1401 movff WREG,opt_brightness ; - set brightness to ECO | |
1402 return ; - done | |
1403 | 1776 |
1404 | 1777 |
1405 clear_resettable_average_depth: | 1778 clear_resettable_average_depth: |
1406 ; prime the resettable average depth with 0 | 1779 ; prime the resettable average depth with 0 |
1407 CLRI pressure_rel_avg_trip | 1780 CLRI pressure_rel_avg_trip |
1549 test_switches_divemode1: | 1922 test_switches_divemode1: |
1550 movlw divemode_timeout_premenu ; get timeout for pre-menu | 1923 movlw divemode_timeout_premenu ; get timeout for pre-menu |
1551 call reset_timeout_time ; reset timeout | 1924 call reset_timeout_time ; reset timeout |
1552 movff active_premenu,WREG ; get number of active pre-menu | 1925 movff active_premenu,WREG ; get number of active pre-menu |
1553 dcfsnz WREG,F | 1926 dcfsnz WREG,F |
1554 bra divemode_option_gaschange ; switch to the the "better gas" / "better diluent" | 1927 bra divemode_option_gaschange ; 1: switch to the the "better gas" / "better diluent" |
1555 dcfsnz WREG,F | 1928 dcfsnz WREG,F |
1556 bra divemode_option0 ; start/setup dive mode menu | 1929 bra divemode_option_divemenu ; 2: enter dive mode menu |
1557 dcfsnz WREG,F | 1930 dcfsnz WREG,F |
1558 bra divemode_option1 ; quit simulation? | 1931 IFDEF _cave_mode |
1932 bra divemode_option_cavemenu ; 3: enter cave mode menu | |
1933 ELSE | |
1934 return ; 3: (no cave mode compiled in) | |
1935 ENDIF | |
1559 dcfsnz WREG,F | 1936 dcfsnz WREG,F |
1560 bra divemode_option2 ; descent 1m | 1937 bra divemode_option_sim_quit ; 4: simulation - quit |
1561 dcfsnz WREG,F | 1938 dcfsnz WREG,F |
1562 bra divemode_option3 ; ascend 1m | 1939 bra divemode_option_sim_down ; 5: simulation - descent |
1563 dcfsnz WREG,F | 1940 dcfsnz WREG,F |
1564 bra divemode_option4 ; quit apnoe mode | 1941 bra divemode_option_sim_up ; 6: simulation - ascend |
1565 dcfsnz WREG,F | 1942 dcfsnz WREG,F |
1566 bra divemode_option5 ; reset stopwatch (gauge mode only) | 1943 bra divemode_option_sim_time ; 7: simulation - +5 min |
1567 dcfsnz WREG,F | 1944 dcfsnz WREG,F |
1568 bra divemode_option6 ; +5 min simulation | 1945 bra divemode_option_apnoe_quit ; 8: apnoe - quit |
1946 dcfsnz WREG,F | |
1947 bra divemode_option_gauge_reset ; 9: gauge - reset stopwatch and avg depth | |
1569 dcfsnz WREG,F | 1948 dcfsnz WREG,F |
1570 IFDEF _compass | 1949 IFDEF _compass |
1571 bra divemode_option7 ; store heading | 1950 bra divemode_option_course ; 10: store heading |
1572 ELSE | 1951 ELSE |
1573 return ; should never happen without compass | 1952 return ; 10: (no compass compiled in) |
1574 ENDIF | 1953 ENDIF |
1575 dcfsnz WREG,F | 1954 dcfsnz WREG,F |
1576 bra divemode_option8 ; switch layout | 1955 bra divemode_option_layout ; 11: switch layout |
1577 return | 1956 return |
1578 | 1957 |
1579 | 1958 |
1580 gas_switched_common: | 1959 gas_switch_common: |
1581 bcf request_gaschange ; clear request flag | 1960 bcf request_gas_change ; clear request flag |
1582 IFDEF _ccr_pscr | 1961 IFDEF _ccr_pscr |
1583 btfss request_back_to_loop ; is a switchback from OC bailout to loop requested? | 1962 btfss request_back_to_loop ; is a switchback from OC bailout to loop requested? |
1584 bra gas_switched_common0 ; NO - continue with checking if selected gas is valid | 1963 bra gas_switched_common0 ; NO - continue with checking if selected gas is valid |
1585 bcf request_back_to_loop ; YES - clear flag | 1964 bcf request_back_to_loop ; YES - clear flag |
1586 movff active_dil,menu_pos_cur ; - reload last diluent | 1965 movff active_dil,menu_pos_cur ; - reload last diluent |
1589 gas_switched_common0: | 1968 gas_switched_common0: |
1590 tstfsz menu_pos_cur ; menu_pos_cur = 0 ? | 1969 tstfsz menu_pos_cur ; menu_pos_cur = 0 ? |
1591 bra gas_switched_common1 ; NO - valid gas | 1970 bra gas_switched_common1 ; NO - valid gas |
1592 return ; YES - something went wrong, invalid gas, abort | 1971 return ; YES - something went wrong, invalid gas, abort |
1593 gas_switched_common1: | 1972 gas_switched_common1: |
1594 movf menu_pos_cur,W ; get selected gas into WREG (1-6) | 1973 movf menu_pos_cur,W ; get selected gas into WREG (1-5) |
1595 IFDEF _ccr_pscr | 1974 IFDEF _ccr_pscr |
1596 btfsc FLAG_oc_mode ; in OC mode? | 1975 btfsc FLAG_oc_mode ; in OC mode? |
1597 bra gas_switched_common_OC ; YES | 1976 bra gas_switched_common_OC ; YES |
1598 btfsc bailout_mode ; in bailout? | 1977 btfsc bailout_mode ; in bailout? |
1599 bra gas_switched_common_OC ; YES | 1978 bra gas_switched_common_OC ; YES |
1600 gas_switched_common_loop: ; NO to both - must be loop mode then | 1979 gas_switched_common_loop: ; NO to both - must be loop mode then |
1601 rcall setup_dil_registers ; with WREG = diluent 1-6 | 1980 rcall setup_dil_registers ; set up real tissues with WREG = diluent 1-6 |
1602 rcall deco_setup_cc_diluents ; with WREG = diluent 1-6 | 1981 rcall deco_setup_cc_diluents ; set up deco planning with WREG = diluent 1-6 |
1603 bra gas_switched_common3 | 1982 bra gas_switched_common3 ; continue with common part |
1604 ENDIF | 1983 ENDIF ; _ccr_pscr |
1605 gas_switched_common_OC: | 1984 gas_switched_common_OC: |
1606 rcall setup_gas_registers ; with WREG = Gas 1-6 | 1985 rcall setup_gas_registers ; set up real tissues with WREG = gas 1-6 |
1607 rcall deco_setup_oc_gases ; with WREG = Gas 1-6 | 1986 rcall deco_setup_oc_gases ; set up deco planning with WREG = gas 1-6 |
1987 ;bra gas_switched_common3 ; continue with common part | |
1608 gas_switched_common3: | 1988 gas_switched_common3: |
1609 banksel int_O_breathed_ppO2 | 1989 banksel int_O_breathed_ppO2 |
1610 bcf int_O_breathed_ppO2+1,int_low_flag ; | clear all flags that control color-coding | 1990 bcf int_O_breathed_ppO2+1,int_low_flag ; | clear all flags that control color-coding |
1611 bcf int_O_breathed_ppO2+1,int_high_flag ; | to have the new gas initially displayed in | 1991 bcf int_O_breathed_ppO2+1,int_high_flag ; | to have the new gas initially displayed in |
1612 bcf int_O_breathed_ppO2+1,int_attention_flag ; | memo color instead of a warning or attention | 1992 bcf int_O_breathed_ppO2+1,int_attention_flag ; | memo color instead of a warning or attention |
1613 bcf int_O_breathed_ppO2+1,int_warning_flag ; | color that belonged to the previous gas | 1993 bcf int_O_breathed_ppO2+1,int_warning_flag ; | color that belonged to the previous gas |
1614 banksel common | 1994 banksel common |
1615 bsf FLAG_TFT_active_gas_divemode ; redraw gas/setpoint/diluent | 1995 bsf FLAG_TFT_active_gas_divemode ; redraw gas/setpoint/diluent |
1616 call restart_deco_engine_wo_ceiling ; abort any running deco calculations and restart the deco engine | 1996 bsf FLAG_TFT_temperature ; redraw temperature |
1617 ; set flags for profile recording | 1997 bsf event_occured ; set global event flag |
1618 bsf event_occured ; set global event flag | |
1619 IFDEF _ccr_pscr | 1998 IFDEF _ccr_pscr |
1620 btfsc bailout_mode ; in bailout mode? | 1999 btfsc bailout_mode ; in bailout mode? |
1621 bsf event_bailout ; YES - set gas change event due to bailout | 2000 bsf event_bailout ; YES - set bailout event |
1622 btfss bailout_mode ; in bailout mode? | 2001 btfss bailout_mode ; in bailout mode? |
1623 ENDIF | 2002 ENDIF |
1624 bsf event_gas_change ; NO - set gas change event (normal change) | 2003 bsf event_gas_change ; (NO) - set gas change event (normal change) |
1625 return | 2004 goto restart_deco_engine_wo_ceiling ; abort running deco calculations and restart (and return) |
1626 | 2005 |
2006 | |
2007 gas_update_common: | |
2008 bcf request_gas_update ; reset the request flag | |
2009 movf active_gas,W ; load WREG with currently used gas | |
2010 IFDEF _ccr_pscr | |
2011 btfsc FLAG_oc_mode ; in OC mode? | |
2012 bra gas_switched_common_OC ; YES - reload OC gases | |
2013 btfsc bailout_mode ; NO - in bailout? | |
2014 bra gas_switched_common_OC ; YES - reload OC gases | |
2015 movf active_dil,W ; NO - load WREG with currently used diluent | |
2016 bra gas_switched_common_loop ; - set up diluent gases | |
2017 ELSE | |
2018 bra gas_switched_common_OC ; reload OC gases | |
2019 ENDIF | |
1627 | 2020 |
1628 ; Code to pass all parameters to the C code | 2021 ; Code to pass all parameters to the C code |
1629 | 2022 |
1630 global get_first_gas_to_WREG | 2023 global get_first_gas_to_WREG |
1631 get_first_gas_to_WREG: ; gets first gas (1-5) into WREG | 2024 get_first_gas_to_WREG: ; gets first gas (1-5) into WREG |
1702 rcall deco_setup_copy ; copy all OC He ratios | 2095 rcall deco_setup_copy ; copy all OC He ratios |
1703 lfsr FSR1,opt_gas_type ; load FSR1 with base address of opt_gas_type | 2096 lfsr FSR1,opt_gas_type ; load FSR1 with base address of opt_gas_type |
1704 rcall deco_setup_copy ; copy all gas types | 2097 rcall deco_setup_copy ; copy all gas types |
1705 lfsr FSR1,opt_gas_change ; load FSR1 with base address of opt_gas_change | 2098 lfsr FSR1,opt_gas_change ; load FSR1 with base address of opt_gas_change |
1706 rcall deco_setup_copy ; copy all gas change depths | 2099 rcall deco_setup_copy ; copy all gas change depths |
1707 ; switch to oc mode | 2100 ; switch deco engine to oc mode: |
1708 bcf lo,DECO_MODE_PSCR_FLAG ; clear the pSCR-mode flag (may not be set, but never mind) | 2101 bcf lo,DECO_MODE_PSCR_FLAG ; - clear the pSCR-mode flag (may not be set, but never mind) |
1709 bcf lo,DECO_MODE_LOOP_FLAG ; clear the loop/CCR-mode flag | 2102 bcf lo,DECO_MODE_LOOP_FLAG ; - clear the loop/CCR-mode flag |
1710 movff lo,char_O_deco_status ; bank safe write-back of char_O_deco_status | 2103 movff lo,char_O_deco_status ; - bank safe write-back of char_O_deco_status |
1711 return | 2104 return ; done |
1712 | 2105 |
1713 ;============================================================================= | 2106 ;============================================================================= |
1714 | 2107 |
1715 IFDEF _ccr_pscr | 2108 IFDEF _ccr_pscr |
1716 | 2109 |
1741 rcall deco_setup_copy ; copy all dil He ratios | 2134 rcall deco_setup_copy ; copy all dil He ratios |
1742 lfsr FSR1,opt_dil_type ; load FSR1 with base address of opt_dil_type | 2135 lfsr FSR1,opt_dil_type ; load FSR1 with base address of opt_dil_type |
1743 rcall deco_setup_copy ; copy all dil types | 2136 rcall deco_setup_copy ; copy all dil types |
1744 lfsr FSR1,opt_dil_change ; load FSR1 with base address of opt_dil_change | 2137 lfsr FSR1,opt_dil_change ; load FSR1 with base address of opt_dil_change |
1745 rcall deco_setup_copy ; copy all dil change depths | 2138 rcall deco_setup_copy ; copy all dil change depths |
1746 ; switch to CCR / pSCR mode | 2139 ; switch to CCR / pSCR mode: |
1747 bsf lo,DECO_MODE_LOOP_FLAG ; loop flag is set in both, CCR and pSCR mode | 2140 bsf lo,DECO_MODE_LOOP_FLAG ; - loop flag is set in both, CCR and pSCR mode |
1748 bcf lo,DECO_MODE_PSCR_FLAG ; clear pSCR mode flag by default | 2141 bcf lo,DECO_MODE_PSCR_FLAG ; - clear pSCR mode flag by default |
1749 btfsc FLAG_pscr_mode ; check if we are in pSCR mode | 2142 btfsc FLAG_pscr_mode ; - check if we are in pSCR mode |
1750 bsf lo,DECO_MODE_PSCR_FLAG ; YES - set additional flag for pSCR mode | 2143 bsf lo,DECO_MODE_PSCR_FLAG ; YES - set additional flag for pSCR mode |
1751 movff lo,char_O_deco_status ; bank safe write-back of char_O_deco_status | 2144 movff lo,char_O_deco_status ; - bank safe write-back of char_O_deco_status |
1752 return | 2145 return ; done |
1753 | 2146 |
1754 ENDIF | 2147 ENDIF |
1755 | 2148 |
1756 ;============================================================================= | 2149 ;============================================================================= |
1757 | 2150 |
1788 ENDIF | 2181 ENDIF |
1789 addlw .10 ; advance index from He ratio to gas type | 2182 addlw .10 ; advance index from He ratio to gas type |
1790 movff PLUSW1,char_I_current_gas_type ; copy gas type (0=Disabled, 1=First, 2=Travel, 3=Deco) | 2183 movff PLUSW1,char_I_current_gas_type ; copy gas type (0=Disabled, 1=First, 2=Travel, 3=Deco) |
1791 setup_gas_registers_com: | 2184 setup_gas_registers_com: |
1792 movff char_O_main_status,lo ; working copy of char_O_main_status in bank common | 2185 movff char_O_main_status,lo ; working copy of char_O_main_status in bank common |
1793 bcf lo,DECO_MODE_PSCR_FLAG ; clear the pSCR-mode flag (may not be set, but never mind) | 2186 bcf lo,DECO_MODE_PSCR_FLAG ; clear the pSCR-mode flag (if applicable) |
1794 bcf lo,DECO_MODE_LOOP_FLAG ; clear the loop/CCR-mode flag | 2187 bcf lo,DECO_MODE_LOOP_FLAG ; clear the loop/CCR-mode flag |
1795 movff lo,char_O_main_status ; bank safe write-back of char_O_main_status | 2188 movff lo,char_O_main_status ; bank safe write-back of char_O_main_status |
1796 movf active_gas,W ; reload WREG with gas 1-5 or 6 (important!) | 2189 movf active_gas,W ; reload WREG with gas 1-5 or 6 (important!) |
1797 return | 2190 return |
1798 | 2191 |
1853 ENDIF | 2246 ENDIF |
1854 divemode_option_gaschange_oc: ; in OC or bailout | 2247 divemode_option_gaschange_oc: ; in OC or bailout |
1855 movff best_gas_number,menu_pos_cur; select best gas | 2248 movff best_gas_number,menu_pos_cur; select best gas |
1856 bcf better_gas_available ; clear flag immediately | 2249 bcf better_gas_available ; clear flag immediately |
1857 divemode_option_gaschange3 ; common part | 2250 divemode_option_gaschange3 ; common part |
1858 bsf request_gaschange ; request a gas/diluent change | 2251 bsf request_gas_change ; request a gas/diluent change |
1859 call menuview_toggle_reset ; terminate the pre-menu | 2252 goto menuview_toggle_reset ; terminate the pre-menu (and return) |
1860 return | 2253 |
1861 | 2254 divemode_option_divemenu: ; start/setup dive mode menu |
1862 global divemode_option0_return | 2255 btfss divemode ; in dive mode? |
1863 divemode_option0: ; start/setup dive mode menu | 2256 goto menuview_toggle_reset ; NO - block menu, terminate the pre-menu |
1864 call TFT_clear_divemode_menu ; clear menu area | 2257 call TFT_clear_divemode_menu ; YES - clear menu area |
1865 bcf dive_options_menu ; dive options menu is not shown anymore | 2258 bcf dive_options_menu ; - set dive options menu as not shown anymore |
1866 call do_main_divemenu ; hand over to menu processor | 2259 goto do_main_divemenu ; - hand over to menu processor |
1867 divemode_option0_return: ; return point for menu processor | 2260 |
2261 IFDEF _cave_mode | |
2262 divemode_option_cavemenu: ; start/setup cave mode menu | |
2263 btfss divemode ; in dive mode? | |
2264 goto menuview_toggle_reset ; NO - block menu, terminate the pre-menu | |
2265 call TFT_clear_divemode_menu ; YES - clear menu area | |
2266 bcf dive_options_menu ; - set dive options menu as not shown anymore | |
2267 goto do_main_cavemenu ; - hand over to menu processor | |
2268 ENDIF | |
2269 | |
2270 global divemode_option_divemenu_return | |
2271 divemode_option_divemenu_return: ; return point for menu processor | |
1868 call TFT_show_menu_cursor_divemode ; show the cursor | 2272 call TFT_show_menu_cursor_divemode ; show the cursor |
1869 clrf active_premenu ; set pre-menu is not shown any more | 2273 clrf active_premenu ; set pre-menu is not shown any more |
1870 bcf safety_stop_active ; set safety stop is not shown any more | 2274 bcf safety_stop_active ; set safety stop is not shown any more |
1871 bsf dive_main_menu ; set main menu is shown now | 2275 bsf dive_main_menu ; set main menu is shown now |
1872 movlw divemode_timeout_mainmenu ; get timeout for main menu | 2276 movlw divemode_timeout_mainmenu ; get timeout for main menu |
1873 call reset_timeout_time ; reload timeout | 2277 call reset_timeout_time ; reload timeout |
1874 goto diveloop_menu_exit ; go back to dive loop (menu processor resets STKPTR!) | 2278 goto diveloop_menu_exit ; go back to dive loop (menu processor resets STKPTR!) |
1875 | 2279 |
1876 divemode_option1: ; quit simulation mode | 2280 divemode_option_sim_quit: ; quit simulation mode |
1877 clrf simulatormode_depth ; set target depth to zero | 2281 clrf simulatormode_depth ; set target depth to zero |
1878 bsf quit_simulatormode ; request ISR to end simulator mode | 2282 bsf quit_simulatormode ; request ISR to end simulator mode |
1879 call menuview_toggle_reset ; terminate the pre-menu | 2283 call menuview_toggle_reset ; terminate the pre-menu |
1880 btfsc FLAG_apnoe_mode ; in apnoe mode? | 2284 btfsc FLAG_apnoe_mode ; in apnoe mode? |
1881 bcf divemode ; YES - force end of dive mode | 2285 bcf divemode ; YES - force end of dive mode |
1882 return ; done | 2286 return ; done |
1883 | 2287 |
1884 divemode_option2: ; plus 1 meter | 2288 divemode_option_sim_down: ; plus 1 meter |
1885 movlw ostc_depth_max-1 ; load depth limit into WREG | 2289 movlw ostc_depth_max-1 ; load depth limit into WREG |
1886 cpfsgt simulatormode_depth ; simulated depth <= limit ? | 2290 cpfsgt simulatormode_depth ; simulated depth <= limit ? |
1887 incf simulatormode_depth,F ; YES - increment simulated depth | 2291 incf simulatormode_depth,F ; YES - increment simulated depth |
1888 return ; done | 2292 return ; done |
1889 | 2293 |
1890 divemode_option3: ; minus 1 meter | 2294 divemode_option_sim_up: ; minus 1 meter |
1891 tstfsz simulatormode_depth ; simulated depth > 0 ? | 2295 tstfsz simulatormode_depth ; simulated depth > 0 ? |
1892 decf simulatormode_depth,F ; YES - decrement simulated depth | 2296 decf simulatormode_depth,F ; YES - decrement simulated depth |
1893 return ; done | 2297 return ; done |
1894 | 2298 |
1895 divemode_option4: ; quit apnoe mode (available while at the surface only) | 2299 divemode_option_sim_time: |
1896 btfsc sensor_override_active ; in simulator mode? | 2300 ; check for pending +5' request on deco engine |
1897 bra divemode_option1 ; YES - use simulator quit procedure | |
1898 bcf divemode ; NO - force end of dive mode | |
1899 return ; - done | |
1900 | |
1901 | |
1902 divemode_option5: | |
1903 bsf request_reset_avg ; request reset of average depth | |
1904 goto menuview_toggle_reset ; terminate pre-menu and return | |
1905 | |
1906 divemode_option6: | |
1907 ; check for pending +5 request | |
1908 movff char_I_sim_advance_time,WREG; get mailbox content | 2301 movff char_I_sim_advance_time,WREG; get mailbox content |
1909 tstfsz WREG ; mailbox clear (=0) ? | 2302 tstfsz WREG ; mailbox clear (=0) ? |
1910 return ; NO - still having a pending +5' request, refuse new request | 2303 return ; NO - still having a pending +5' request, refuse new request |
1911 | 2304 |
1912 ; advance tissues pressures and deco obligation by 5 minutes | 2305 ; advance tissues pressures and deco obligation by 5 minutes |
1946 addwfc pressure_rel_accu_trip+2,F | 2339 addwfc pressure_rel_accu_trip+2,F |
1947 movf xC+3,W | 2340 movf xC+3,W |
1948 addwfc pressure_rel_accu_trip+3,F | 2341 addwfc pressure_rel_accu_trip+3,F |
1949 | 2342 |
1950 ; add to the total depth accumulator | 2343 ; add to the total depth accumulator |
1951 movf xC+0,w | 2344 movf xC+0,W |
1952 addwf pressure_rel_accu_total+0,F | 2345 addwf pressure_rel_accu_total+0,F |
1953 movf xC+1,w | 2346 movf xC+1,W |
1954 addwfc pressure_rel_accu_total+1,F | 2347 addwfc pressure_rel_accu_total+1,F |
1955 movf xC+2,w | 2348 movf xC+2,W |
1956 addwfc pressure_rel_accu_total+2,F | 2349 addwfc pressure_rel_accu_total+2,F |
1957 movf xC+3,w | 2350 movf xC+3,W |
1958 addwfc pressure_rel_accu_total+3,F | 2351 addwfc pressure_rel_accu_total+3,F |
1959 | 2352 |
1960 IFDEF _cave_mode | 2353 IFDEF _cave_mode |
1961 ; update backtracking data | 2354 ; update backtracking data |
1962 movlw .5 ; configure 5 minutes | 2355 btfss cave_mode ; cave mode switched on? |
1963 call update_backtrack ; add backtrack data for 5 minutes | 2356 bra divemode_option_sim_time_exit ; NO - skip backtracking depth recording |
1964 ENDIF | 2357 btfsc dive_turned ; YES - dive turned? |
1965 | 2358 bra divemode_option_sim_time_exit ; YES - skip backtracking depth recording |
2359 ;bra divemode_option_sim_time_exec ; NO - update backtracking depth recording | |
2360 divemode_option_sim_time_exec: | |
2361 movff backtrack_deltatime,hi ; backup time elapsed since last depth recording | |
2362 movlw .5 ; configure 5 minutes | |
2363 movwf lo ; use lo as loop counter | |
2364 divemode_option_sim_time_loop: | |
2365 call write_backtrack_1min_depth ; store a backtracking depth data set | |
2366 btfsc backtrack_entire_full ; backtracking storage entirely used up? | |
2367 bra divemode_option_sim_time_exit ; YES - abort backtracking depth recording | |
2368 decfsz lo,F ; NO - decrement loop counter, did it became zero? | |
2369 bra divemode_option_sim_time_loop ; NO - loop | |
2370 ;bra divemode_option_sim_time_done ; YES - done | |
2371 divemode_option_sim_time_done: | |
2372 movff hi,backtrack_deltatime ; restore time elapsed since last depth recording | |
2373 ;bra divemode_option_sim_time_exit ; finish backtracking depth recording | |
2374 ENDIF ; _cave_mode | |
2375 | |
2376 divemode_option_sim_time_exit: | |
1966 ; goto menuview_toggle_reset ; terminate the pre-menu and return | 2377 ; goto menuview_toggle_reset ; terminate the pre-menu and return |
1967 return ; just return, leaving option avail for repeated selection | 2378 return ; just return, leaving option avail for repeated selection |
1968 | 2379 |
2380 divemode_option_apnoe_quit: ; quit apnoe mode (available while at the surface only) | |
2381 btfsc sensor_override_active ; in simulator mode? | |
2382 bra divemode_option_sim_quit ; YES - use simulator quit procedure | |
2383 bcf divemode ; NO - force end of dive mode | |
2384 return ; - done | |
2385 | |
2386 divemode_option_gauge_reset: | |
2387 bsf request_reset_avg ; request reset of average depth | |
2388 goto menuview_toggle_reset ; terminate pre-menu and return | |
2389 | |
1969 IFDEF _compass | 2390 IFDEF _compass |
1970 divemode_option7: | 2391 divemode_option_course: |
1971 ; store heading for compass view | 2392 ; store heading for compass view |
1972 MOVII compass_heading_shown,compass_bearing | 2393 MOVII compass_heading_shown,compass_bearing |
1973 bsf compass_bearing_set ; set flag to show heading | 2394 bsf compass_bearing_set ; set flag to show heading |
1974 goto menuview_toggle_reset ; terminate the pre-menu and return | 2395 goto menuview_toggle_reset ; terminate the pre-menu and return |
1975 ENDIF | 2396 ENDIF |
1976 | 2397 |
1977 | 2398 divemode_option_layout: ; switch layout |
1978 divemode_option8: | |
1979 call menuview_toggle_reset ; terminate the pre-menu | 2399 call menuview_toggle_reset ; terminate the pre-menu |
1980 call TFT_ClearScreen ; clear the whole screen | 2400 call TFT_ClearScreen ; clear the whole screen |
1981 btg alt_layout_active ; toggle layout | 2401 btg alt_layout_active ; toggle layout |
1982 | 2402 |
1983 bcf depth_warn_att_last ; set warning or attention on the depth not shown | 2403 bcf depth_warn_att_last ; set warning or attention on the depth not shown |
1990 bsf FLAG_TFT_divemode_mask ; request redraw of dive screen mask | 2410 bsf FLAG_TFT_divemode_mask ; request redraw of dive screen mask |
1991 bsf FLAG_TFT_divetime ; request redraw of dive time | 2411 bsf FLAG_TFT_divetime ; request redraw of dive time |
1992 bsf FLAG_TFT_depth_current ; request redraw of current depth | 2412 bsf FLAG_TFT_depth_current ; request redraw of current depth |
1993 bsf FLAG_TFT_depth_maximum ; request redraw of maximum depth | 2413 bsf FLAG_TFT_depth_maximum ; request redraw of maximum depth |
1994 bsf FLAG_TFT_active_gas_divemode; request redraw of gas and setpoint | 2414 bsf FLAG_TFT_active_gas_divemode; request redraw of gas and setpoint |
1995 bsf FLAG_TFT_customview_mask ; request redraw of custom view mask | |
1996 bsf FLAG_TFT_temperature ; request redraw of temperature | 2415 bsf FLAG_TFT_temperature ; request redraw of temperature |
2416 bsf FLAG_TFT_customview_callup ; request redraw of custom view | |
1997 | 2417 |
1998 goto request_redraw_NDL_deco_data; request redraw of NDL/deco data and return | 2418 goto request_redraw_NDL_deco_data; request redraw of NDL/deco data and return |
1999 | 2419 |
2000 | 2420 |
2001 ;============================================================================= | 2421 ;============================================================================= |
2042 MOVII PROD,ppO2_max_default ; store as default ppO2 max | 2462 MOVII PROD,ppO2_max_default ; store as default ppO2 max |
2043 | 2463 |
2044 check_gas_best_2: | 2464 check_gas_best_2: |
2045 | 2465 |
2046 IFDEF _ccr_pscr | 2466 IFDEF _ccr_pscr |
2047 | |
2048 ; check dive mode | 2467 ; check dive mode |
2049 btfsc FLAG_oc_mode ; in OC mode? | 2468 btfsc FLAG_oc_mode ; in OC mode? |
2050 bra check_gas_best_gas ; YES - skip diluents, check for best gas only | 2469 bra check_gas_best_gas ; YES - skip diluents, check for best gas only |
2051 | 2470 |
2052 check_gas_best_dil: | 2471 check_gas_best_dil: |
2054 movff char_I_ppO2_min,WREG ; min ppO2 for pure diluent in CCR mode (default) | 2473 movff char_I_ppO2_min,WREG ; min ppO2 for pure diluent in CCR mode (default) |
2055 btfsc FLAG_pscr_mode ; in pSCR mode? | 2474 btfsc FLAG_pscr_mode ; in pSCR mode? |
2056 movff char_I_ppO2_min_loop,WREG ; YES - replace by min ppO2 for pure diluent in pSCR mode | 2475 movff char_I_ppO2_min_loop,WREG ; YES - replace by min ppO2 for pure diluent in pSCR mode |
2057 mullw .100 ; min ppO2 * 100, result in 0.1 mbar | 2476 mullw .100 ; min ppO2 * 100, result in 0.1 mbar |
2058 MOVII PROD,ppO2_min ; store in ppO2_min | 2477 MOVII PROD,ppO2_min ; store in ppO2_min |
2059 ; preset results to nothing found | 2478 ; check diluents |
2060 clrf best_gas_num ; initialize best diluent as 0 = nothing found yet | |
2061 bcf better_dil_available ; =1: a better diluent is available and a gas change is advised in dive mode | |
2062 ; ; current diluent = 'gas6' ? | |
2063 ; movlw .6 ; | |
2064 ; cpfseq active_dil ; using 'gas6' as current diluent? | |
2065 ; bra check_gas_best_dil0 ; NO - continue | |
2066 ; bra check_gas_best_dil3 ; YES - suppress better diluent search in this case | |
2067 ;check_gas_best_dil0: | |
2068 ; check all diluents | |
2069 lfsr FSR1,opt_dil_O2_ratio ; set base address for diluent arrays | 2479 lfsr FSR1,opt_dil_O2_ratio ; set base address for diluent arrays |
2070 movff active_dil,lo ; number of currently used diluent | 2480 movff active_dil,lo ; set number of currently used diluent |
2071 setf best_gas_depth ; initialize change depth of best dil found so far to 255 meter | 2481 ; preset result to nothing found |
2072 ; original code | 2482 clrf best_gas_num ; initialize best diluent to 0 = none found yet |
2073 clrf check_gas_num | 2483 setf best_gas_depth ; initialize change depth to 255 = any one will be better |
2074 incf check_gas_num,F | 2484 ; check if current diluent is usable |
2075 rcall check_gas_best_common ; check diluent 1 | 2485 movff lo,check_gas_num ; check if the current diluent is usable |
2076 incf check_gas_num,F | 2486 rcall check_gas_best_common ; if yes, the current diluent will become the best diluent found so far |
2077 rcall check_gas_best_common ; check diluent 2 | 2487 rcall check_gas_best_all ; check if any other diluent is better |
2078 incf check_gas_num,F | |
2079 rcall check_gas_best_common ; check diluent 3 | |
2080 incf check_gas_num,F | |
2081 rcall check_gas_best_common ; check diluent 4 | |
2082 incf check_gas_num,F | |
2083 rcall check_gas_best_common ; check diluent 5 | |
2084 ; alternative code | |
2085 ; movlw .5 | |
2086 ; movwf check_gas_num | |
2087 ;check_gas_best_dil_loop: | |
2088 ; rcall check_gas_best_common | |
2089 ; decfsz check_gas_num | |
2090 ; bra check_gas_best_dil_loop | |
2091 ; | |
2092 ; store result | 2488 ; store result |
2093 movff best_gas_num,best_dil_number ; store new best diluent found (1-5 or 0 of no usable diluent available) | 2489 movff best_gas_num,best_dil_number ; store new best diluent found (1-5 or 0 of no usable diluent available) |
2094 ; check if change advices shall be given in general | 2490 ; check if change advices shall be given in general |
2095 btfsc bailout_mode ; in bailout? | 2491 btfsc bailout_mode ; in bailout? |
2096 bra check_gas_best_gas ; YES - no better diluent advice when in bailout | 2492 bra check_gas_best_gas ; YES - no better diluent advice when in bailout |
2097 check_gas_best_dil1: | 2493 check_gas_best_dil1: |
2098 ; check if a change advice shall be given right now | 2494 ; check if a change advice shall be given right now |
2495 bcf better_dil_available ; default to no better diluent found | |
2099 movf best_dil_number,W ; load number of best diluent into WREG (1-5) | 2496 movf best_dil_number,W ; load number of best diluent into WREG (1-5) |
2100 bz check_gas_best_dil3 ; has a best diluent been found at all? NO - nothing to signal for | 2497 bz check_gas_best_dil3 ; has a best diluent been found at all? NO - nothing to signal for |
2101 cpfseq active_dil ; is this the currently used diluent? | 2498 cpfseq active_dil ; is this the currently used diluent? |
2102 bra check_gas_best_dil2 ; NO | 2499 bra check_gas_best_dil2 ; NO - a better diluent has been found |
2103 bra check_gas_best_dil3 ; YES - no need to signal a better diluent if this diluent is already in use | 2500 bra check_gas_best_dil3 ; YES - no need to signal a better diluent if this diluent is already in use |
2104 check_gas_best_dil2: | 2501 check_gas_best_dil2: |
2105 btfsc sp_fallback ; in fallback condition? | 2502 btfsc sp_fallback ; in fallback condition? |
2106 bra check_gas_best_dil3 ; YES - suppress better diluent prompt in this case | 2503 bra check_gas_best_dil3 ; YES - suppress better diluent prompt in this case |
2107 ; not using the best gas - show better diluent hint whenever a better diluent is available | 2504 ; not using the best gas - show better diluent hint whenever a better diluent is available |
2108 bsf better_dil_available ; signal that a better diluent is available | 2505 bsf better_dil_available ; signal that a better diluent is available |
2109 bsf FLAG_TFT_active_gas_divemode ; redraw gas/setpoint/diluent | 2506 bsf FLAG_TFT_active_gas_divemode ; redraw gas/setpoint/diluent |
2110 check_gas_best_dil3: | 2507 check_gas_best_dil3: |
2111 btfss better_dil_available ; shall a better diluent be signaled for? | 2508 btfss better_dil_available ; shall a better diluent be signaled for? |
2112 bcf better_dil_blinking ; NO - clear blinking flag | 2509 bcf better_dil_blinking ; NO - clear blinking flag |
2113 ; continue with checking for best bailout gas | 2510 ;bra check_gas_best_gas ; ; continue with checking for best bailout gas |
2114 | |
2115 ENDIF ; _ccr_pscr | 2511 ENDIF ; _ccr_pscr |
2512 | |
2116 | 2513 |
2117 check_gas_best_gas: | 2514 check_gas_best_gas: |
2118 ; set minimum ppO2 required | 2515 ; set minimum ppO2 required |
2119 movff char_I_ppO2_min,WREG ; min ppO2 for OC and bailout | 2516 movff char_I_ppO2_min,WREG ; min ppO2 for OC and bailout |
2120 mullw .100 ; min ppO2 * 100, result in 0.1 mbar | 2517 mullw .100 ; min ppO2 * 100, result in 0.1 mbar |
2121 MOVII PROD,ppO2_min ; store in ppO2_min | 2518 MOVII PROD,ppO2_min ; store in ppO2_min |
2122 ; preset results to nothing found | 2519 ; check gases |
2123 clrf best_gas_num ; initialize best gas as 0 = nothing found yet | |
2124 bcf better_gas_available ; =1: a better gas is available and a gas change is advised in dive mode | |
2125 ; ; current gas = 'gas6' ? | |
2126 ; movlw .6 ; | |
2127 ; cpfseq active_gas ; using 'gas6' as current gas? | |
2128 ; bra check_gas_best_gas0 ; NO - continue | |
2129 ; bra check_gas_best_gas3 ; YES - suppress better gas search in this case | |
2130 ;check_gas_best_gas0: | |
2131 ; check all gases | |
2132 lfsr FSR1,opt_gas_O2_ratio ; set base address for gas arrays | 2520 lfsr FSR1,opt_gas_O2_ratio ; set base address for gas arrays |
2133 movff active_gas,lo ; number of currently used gas | 2521 movff active_gas,lo ; set number of currently used gas |
2134 setf best_gas_depth ; initialize change depth of best gas found so far to 255 meter | 2522 ; preset result to nothing found |
2135 ; original code | 2523 clrf best_gas_num ; initialize best gas to 0 = none found yet |
2136 clrf check_gas_num | 2524 setf best_gas_depth ; initialize change depth to 255 = any one will be better |
2137 incf check_gas_num,F | 2525 ; check if current gas is usable |
2138 rcall check_gas_best_common ; check gas 1 | 2526 movff lo,check_gas_num ; check if the current gas is usable |
2139 incf check_gas_num,F | 2527 rcall check_gas_best_common ; if yes, the current gas will become the best gas found so far |
2140 rcall check_gas_best_common ; check gas 2 | 2528 rcall check_gas_best_all ; check if any other gas is better |
2141 incf check_gas_num,F | |
2142 rcall check_gas_best_common ; check gas 3 | |
2143 incf check_gas_num,F | |
2144 rcall check_gas_best_common ; check gas 4 | |
2145 incf check_gas_num,F | |
2146 rcall check_gas_best_common ; check gas 5 | |
2147 ; alternative code | |
2148 ; movlw .5 | |
2149 ; movwf check_gas_num | |
2150 ;check_gas_best_gas_loop: | |
2151 ; rcall check_gas_best_common | |
2152 ; decfsz check_gas_num | |
2153 ; bra check_gas_best_gas_loop | |
2154 ; | |
2155 ; store result | 2529 ; store result |
2156 movff best_gas_num,best_gas_number ; store new best gas found (1-5 or 0 of no usable gas available) | 2530 movff best_gas_num,best_gas_number ; store new best gas found (1-5 or 0 of no usable gas available) |
2531 IFDEF _ccr_pscr | |
2157 ; check if change advices shall be given in general | 2532 ; check if change advices shall be given in general |
2158 btfsc FLAG_oc_mode ; in OC mode? | 2533 btfsc FLAG_oc_mode ; in OC mode? |
2159 bra check_gas_best_gas1 ; YES | 2534 bra check_gas_best_gas1 ; YES - give advice |
2160 btfsc bailout_mode ; in bailout? | 2535 btfsc bailout_mode ; NO - in bailout? |
2161 bra check_gas_best_gas1 ; YES | 2536 bra check_gas_best_gas1 ; YES - give advice |
2162 return ; NO - no better (OC) gas advice when not in OC or bailout mode | 2537 return ; NO - no better (OC) gas advice when not in OC or bailout mode |
2538 ENDIF ; _ccr_pscr | |
2163 check_gas_best_gas1: ; check if we are already on the best gas | 2539 check_gas_best_gas1: ; check if we are already on the best gas |
2164 ; check if a change advice shall be given right now | 2540 ; check if a change advice shall be given right now |
2541 bcf better_gas_available ; default to no better gas found | |
2165 movf best_gas_number,W ; load number of best gas into WREG (1-5) | 2542 movf best_gas_number,W ; load number of best gas into WREG (1-5) |
2166 bz check_gas_best_gas3 ; has a best gas been found at all? NO - nothing to signal for | 2543 bz check_gas_best_gas3 ; has a best gas been found at all? NO - nothing to signal for |
2167 cpfseq active_gas ; is this the currently used gas? | 2544 cpfseq active_gas ; is this the currently used gas? |
2168 bra check_gas_best_gas2 ; NO | 2545 bra check_gas_best_gas2 ; NO - a better gas has been found |
2169 bra check_gas_best_gas3 ; YES - no need to signal a better gas if this gas is already in use | 2546 bra check_gas_best_gas3 ; YES - no need to signal a better gas if this gas is already in use |
2170 check_gas_best_gas2: | 2547 check_gas_best_gas2: |
2171 ; not using the best gas - show better gas hint whenever a better gas is available | 2548 ; not using the best gas - show better gas hint whenever a better gas is available |
2172 bsf better_gas_available ; YES - signal that a better gas is available | 2549 bsf better_gas_available ; YES - signal that a better gas is available |
2173 bsf FLAG_TFT_active_gas_divemode ; YES - redraw gas/setpoint/diluent | 2550 bsf FLAG_TFT_active_gas_divemode ; YES - redraw gas/setpoint/diluent |
2174 check_gas_best_gas3: | 2551 check_gas_best_gas3: |
2175 btfss better_gas_available ; shall a better gas be signaled for? | 2552 btfss better_gas_available ; shall a better gas be signaled for? |
2176 bcf better_gas_blinking ; NO - clear blinking flag | 2553 bcf better_gas_blinking ; NO - clear blinking flag |
2177 return | 2554 return |
2555 | |
2556 | |
2557 check_gas_best_all: | |
2558 clrf check_gas_num ; increment comes first, so initialize with zero | |
2559 check_gas_best_loop: | |
2560 incf check_gas_num,F ; increment number of gas to check | |
2561 movf lo,W ; copy number of currently used gas to WREG | |
2562 cpfseq check_gas_num ; gas to be checked = currently used gas ? | |
2563 rcall check_gas_best_common ; NO - check the gas | |
2564 movlw NUM_GAS ; get total number of gases | |
2565 cpfseq check_gas_num ; reached last gas? | |
2566 bra check_gas_best_loop ; NO - loop | |
2567 return ; YES - done | |
2568 | |
2178 | 2569 |
2179 check_gas_best_common: ; with gas to be checked in check_gas_num (1-5) | 2570 check_gas_best_common: ; with gas to be checked in check_gas_num (1-5) |
2180 ; ; and current gas in lo (1-5) | 2571 ; ; and current gas in lo (1-5) |
2181 ; | 2572 ; |
2182 ; Memory Map: | 2573 ; Memory Map: |
2203 cpfseq lo ; is this the currently used gas? | 2594 cpfseq lo ; is this the currently used gas? |
2204 bra check_gas_best_common0 ; NO - do the disabled & deco gas checks | 2595 bra check_gas_best_common0 ; NO - do the disabled & deco gas checks |
2205 bra check_gas_best_common3 ; YES - a gas in use overrides disabled and deco status | 2596 bra check_gas_best_common3 ; YES - a gas in use overrides disabled and deco status |
2206 check_gas_best_common0: | 2597 check_gas_best_common0: |
2207 ; check if gas is available (i.e. not disabled) | 2598 ; check if gas is available (i.e. not disabled) |
2599 btfsc check_gas_type,gas_lost ; gas/dil lost? | |
2600 return ; YES - skip as not available any more | |
2601 btfsc check_gas_type,gas_staged ; gas/dil staged? | |
2602 return ; YES - skip as currently not available | |
2208 tstfsz check_gas_type ; type = disabled (0) ? | 2603 tstfsz check_gas_type ; type = disabled (0) ? |
2209 bra check_gas_best_common1 ; NO - continue checks | 2604 bra check_gas_best_common1 ; NO - continue checks |
2210 return ; YES - skip disabled gases | 2605 return ; YES - skip as not available at all |
2211 check_gas_best_common1: | 2606 check_gas_best_common1: |
2212 ; skip deco gases (type=3) if there are no stops, but include them when in bailout mode | 2607 ; skip deco gases (type=3) if there are no stops, but include them when in bailout mode |
2213 movlw .3 ; coding for deco gas | 2608 movlw .3 ; coding for deco gas |
2214 cpfseq check_gas_type ; type = deco (3) ? | 2609 cpfseq check_gas_type ; type = deco (3) ? |
2215 bra check_gas_best_common3 ; NO - first or travel/normal then, ok to use | 2610 bra check_gas_best_common3 ; NO - first or travel/normal then, ok to use |
2611 IFDEF _ccr_pscr | |
2216 btfsc bailout_mode ; YES - in bailout? | 2612 btfsc bailout_mode ; YES - in bailout? |
2217 bra check_gas_best_common2 ; YES - ok to use (using deco gases is always allowed when in bailout) | 2613 bra check_gas_best_common2 ; YES - ok to use (using deco gases is always allowed when in bailout) |
2218 TSTOSS opt_extended_stops ; NO - extended stops enables? | 2614 ENDIF |
2219 bra check_gas_best_common1b ; NO | 2615 TSTOSS opt_ext_stops ; NO - extended stops enabled? |
2220 ;bra check_gas_best_common1a ; YES | 2616 bra check_gas_best_common1b ; NO - only ok if in deco region |
2617 ;bra check_gas_best_common1a ; YES - only ok if in deco mode | |
2221 check_gas_best_common1a: | 2618 check_gas_best_common1a: |
2222 movff char_O_deco_info,WREG ; get deco info vector | 2619 movff char_O_deco_info,WREG ; get deco info vector |
2223 btfss WREG,deco_mode ; are we in deco mode? | 2620 btfss WREG,deco_mode ; are we in deco mode? |
2224 return ; NO - skip deco gas while not in deco mode | 2621 return ; NO - skip deco gas while not in deco mode |
2225 bra check_gas_best_common2 ; YES - deco gases allowed | 2622 bra check_gas_best_common2 ; YES - deco gases allowed |
2240 movf best_gas_num,W ; get best gas found so far (1-5) or 0 if none found yet | 2637 movf best_gas_num,W ; get best gas found so far (1-5) or 0 if none found yet |
2241 tstfsz WREG ; has a best gas candidate been found yet? | 2638 tstfsz WREG ; has a best gas candidate been found yet? |
2242 bra check_gas_best_common5 ; YES - check if the new one is better than the one we have so far | 2639 bra check_gas_best_common5 ; YES - check if the new one is better than the one we have so far |
2243 bra check_gas_best_common6 ; NO - no need to do the above mentioned check | 2640 bra check_gas_best_common6 ; NO - no need to do the above mentioned check |
2244 check_gas_best_common5: | 2641 check_gas_best_common5: |
2245 ; check if the change depth of the checked gas is <= (shallower or equal) the change depth of the best gas found so far | 2642 ; check if the change depth of the checked gas is < (shallower) than the change depth of the best gas found so far |
2246 movf best_gas_depth,W ; load change depth of best gas so far into WREG | 2643 movf best_gas_depth,W ; load change depth of best gas so far into WREG |
2247 cpfsgt check_gas_depth ; change depth of checked gas > (deeper than) change depth of best gas so far? | 2644 cpfslt check_gas_depth ; change depth of checked gas < (shallower than) change depth of best gas so far? |
2248 bra check_gas_best_common6 ; NO - this gas is better or equal, continue | 2645 return ; NO - this gas is not better than the best already found |
2249 return ; YES - this gas is not better than the best already found | 2646 ;bra check_gas_best_common6 ; YES - this gas is better, continue |
2250 check_gas_best_common6: | 2647 check_gas_best_common6: |
2251 ; check if the gas fits into the ppO2 limits | 2648 ; check if the gas fits into the ppO2 limits |
2252 movff check_gas_O2_ratio,xB+0 ; xB = O2 ratio, xA is still loaded with (absolute pressure / 10) | 2649 movff check_gas_O2_ratio,xB+0 ; xB = O2 ratio, xA is still loaded with (absolute pressure / 10) |
2253 clrf xB+1 | 2650 clrf xB+1 |
2254 call mult16x16 ; xC = O2 ratio * (absolute pressure / 10), result in 0.1 mbar | 2651 call mult16x16 ; xC = O2 ratio * (absolute pressure / 10), result in 0.1 mbar |
2266 MOVII ppO2_min,sub_b ; copy minimum ppO2 to sub_b | 2663 MOVII ppO2_min,sub_b ; copy minimum ppO2 to sub_b |
2267 call cmpU16 ; sub_a - sub_b | 2664 call cmpU16 ; sub_a - sub_b |
2268 btfsc neg_flag ; within limit? | 2665 btfsc neg_flag ; within limit? |
2269 return ; NO - too low, gas is not usable | 2666 return ; NO - too low, gas is not usable |
2270 ; we have a (new) best gas | 2667 ; we have a (new) best gas |
2271 movff check_gas_num, best_gas_num ; set checked gas (1-5) as best gas | 2668 movff check_gas_num, best_gas_num ; YES - set checked gas (1-5) as best gas |
2272 movff check_gas_depth,best_gas_depth ; memorize its change depth | 2669 movff check_gas_depth,best_gas_depth ; - memorize its change depth |
2273 return | 2670 return ; - done |
2274 | 2671 |
2275 | 2672 |
2276 ;============================================================================= | 2673 ;============================================================================= |
2277 ; Check for Auto-SP | 2674 ; Check for Auto-SP |
2278 ; | 2675 ; |
2282 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP | 2679 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP |
2283 sublw .2 ; opt_ccr_mode = 2 (Auto SP)? | 2680 sublw .2 ; opt_ccr_mode = 2 (Auto SP)? |
2284 bz check_dive_autosp2 ; YES - check | 2681 bz check_dive_autosp2 ; YES - check |
2285 return ; NO - return for sensor or fixed mode | 2682 return ; NO - return for sensor or fixed mode |
2286 check_dive_autosp2: | 2683 check_dive_autosp2: |
2287 ; Check SP2 | 2684 ; check SP2 |
2288 btfsc FLAG_SP2_used ; SP 2 used so far? | 2685 btfsc FLAG_SP2_used ; SP 2 used so far? |
2289 bra check_dive_autosp3 ; YES - continue with SP 3 | 2686 bra check_dive_autosp3 ; YES - continue with SP 3 |
2290 movff opt_setpoint_change+1,lo ; NO - get depth in m | 2687 movff opt_setpoint_change+1,lo ; NO - get depth in m |
2291 tstfsz lo ; - SP change depth = 0 ? | 2688 tstfsz lo ; - SP change depth = 0 ? |
2292 bra check_dive_autosp2a ; NO - continue | 2689 bra check_dive_autosp2a ; NO - continue |
2298 ; auto switch to SP2 | 2695 ; auto switch to SP2 |
2299 movff opt_setpoint_cbar+1,char_I_const_ppO2 ; YES - use SP | 2696 movff opt_setpoint_cbar+1,char_I_const_ppO2 ; YES - use SP |
2300 rcall xmit_sp_set_flag ; - send SP to external devices | 2697 rcall xmit_sp_set_flag ; - send SP to external devices |
2301 bsf FLAG_SP2_used ; - set SP 2 used flag | 2698 bsf FLAG_SP2_used ; - set SP 2 used flag |
2302 check_dive_autosp3: | 2699 check_dive_autosp3: |
2303 ; Check SP3 | 2700 ; check SP3 |
2304 btfsc FLAG_SP3_used ; SP 3 used so far? | 2701 btfsc FLAG_SP3_used ; SP 3 used so far? |
2305 bra check_dive_autosp4 ; YES - continue with SP 4 | 2702 bra check_dive_autosp4 ; YES - continue with SP 4 |
2306 movff opt_setpoint_change+2,lo ; NO - get depth in m | 2703 movff opt_setpoint_change+2,lo ; NO - get depth in m |
2307 tstfsz lo ; - SP change depth = 0 ? | 2704 tstfsz lo ; - SP change depth = 0 ? |
2308 bra check_dive_autosp3a ; NO - continue | 2705 bra check_dive_autosp3a ; NO - continue |
2314 ; auto switch to SP3 | 2711 ; auto switch to SP3 |
2315 movff opt_setpoint_cbar+2,char_I_const_ppO2 ; YES - use SP | 2712 movff opt_setpoint_cbar+2,char_I_const_ppO2 ; YES - use SP |
2316 rcall xmit_sp_set_flag ; - send SP to external devices | 2713 rcall xmit_sp_set_flag ; - send SP to external devices |
2317 bsf FLAG_SP3_used ; - set SP 3 used flag | 2714 bsf FLAG_SP3_used ; - set SP 3 used flag |
2318 check_dive_autosp4: | 2715 check_dive_autosp4: |
2319 ; Check SP4 | 2716 ; check SP4 |
2320 btfsc FLAG_SP4_used ; SP 4 used so far? | 2717 btfsc FLAG_SP4_used ; SP 4 used so far? |
2321 bra check_dive_autosp5 ; YES - continue with SP 5 | 2718 bra check_dive_autosp5 ; YES - continue with SP 5 |
2322 movff opt_setpoint_change+3,lo ; NO - get depth in m | 2719 movff opt_setpoint_change+3,lo ; NO - get depth in m |
2323 tstfsz lo ; - SP change depth = 0 ? | 2720 tstfsz lo ; - SP change depth = 0 ? |
2324 bra check_dive_autosp4a ; NO - continue | 2721 bra check_dive_autosp4a ; NO - continue |
2330 ; auto switch to SP4 | 2727 ; auto switch to SP4 |
2331 movff opt_setpoint_cbar+3,char_I_const_ppO2 ; YES - use SP | 2728 movff opt_setpoint_cbar+3,char_I_const_ppO2 ; YES - use SP |
2332 rcall xmit_sp_set_flag ; - send SP to external devices | 2729 rcall xmit_sp_set_flag ; - send SP to external devices |
2333 bsf FLAG_SP4_used ; - set SP 4 used flag | 2730 bsf FLAG_SP4_used ; - set SP 4 used flag |
2334 check_dive_autosp5: | 2731 check_dive_autosp5: |
2335 ; Check SP5 | 2732 ; check SP5 |
2336 btfsc FLAG_SP5_used ; SP 5 used so far? | 2733 btfsc FLAG_SP5_used ; SP 5 used so far? |
2337 bra check_dive_autosp6 ; YES - done | 2734 bra check_dive_autosp6 ; YES - done |
2338 movff opt_setpoint_change+4,lo ; NO - get depth in m | 2735 movff opt_setpoint_change+4,lo ; NO - get depth in m |
2339 tstfsz lo ; - SP change depth = 0 ? | 2736 tstfsz lo ; - SP change depth = 0 ? |
2340 bra check_dive_autosp5a ; NO - continue | 2737 bra check_dive_autosp5a ; NO - continue |
2370 return | 2767 return |
2371 | 2768 |
2372 ;============================================================================= | 2769 ;============================================================================= |
2373 ; Setup everything to enter dive mode | 2770 ; Setup everything to enter dive mode |
2374 ; | 2771 ; |
2375 global dive_boot_oc_bail | |
2376 dive_boot_oc_bail: | |
2377 ; copy opt_gas_types into backup (for "lost gas" feature) | |
2378 movff opt_gas_type+0,opt_gas_type_backup+0 ; 0=Disabled, 1=First, 2=Travel, 3=Deco | |
2379 movff opt_gas_type+1,opt_gas_type_backup+1 ; 0=Disabled, 1=First, 2=Travel, 3=Deco | |
2380 movff opt_gas_type+2,opt_gas_type_backup+2 ; 0=Disabled, 1=First, 2=Travel, 3=Deco | |
2381 movff opt_gas_type+3,opt_gas_type_backup+3 ; 0=Disabled, 1=First, 2=Travel, 3=Deco | |
2382 movff opt_gas_type+4,opt_gas_type_backup+4 ; 0=Disabled, 1=First, 2=Travel, 3=Deco | |
2383 return | |
2384 | |
2385 global dive_boot_oc | 2772 global dive_boot_oc |
2386 dive_boot_oc: | 2773 dive_boot_oc: |
2387 ; set-up registers | 2774 ; set-up registers |
2388 rcall get_first_gas_to_WREG ; get first gas (1-5) into WREG | 2775 rcall get_first_gas_to_WREG ; get first gas (1-5) into WREG |
2389 rcall setup_gas_registers ; set-up of gas parameters of currently breathed gas (with WREG = gas 1-5) | 2776 rcall setup_gas_registers ; set-up of gas parameters of currently breathed gas (with WREG = gas 1-5) |
2390 rcall deco_setup_oc_gases ; set-up of gas list for deco calculations (with WREG = gas 1-5) | 2777 rcall deco_setup_oc_gases ; set-up of gas list for deco calculations (with WREG = gas 1-5) |
2391 return | 2778 return |
2392 | 2779 |
2393 ;============================================================================= | |
2394 | 2780 |
2395 IFDEF _ccr_pscr | 2781 IFDEF _ccr_pscr |
2396 | 2782 |
2397 global dive_boot_cc | 2783 global dive_boot_cc |
2398 dive_boot_cc: | 2784 dive_boot_cc: |
2399 ; copy opt_dil_types into backup (for "lost diluent" feature) | |
2400 movff opt_dil_type+0,opt_dil_type_backup+0 ; 0=Disabled, 1=First, 2=Normal | |
2401 movff opt_dil_type+1,opt_dil_type_backup+1 ; 0=Disabled, 1=First, 2=Normal | |
2402 movff opt_dil_type+2,opt_dil_type_backup+2 ; 0=Disabled, 1=First, 2=Normal | |
2403 movff opt_dil_type+3,opt_dil_type_backup+3 ; 0=Disabled, 1=First, 2=Normal | |
2404 movff opt_dil_type+4,opt_dil_type_backup+4 ; 0=Disabled, 1=First, 2=Normal | |
2405 ; set-up registers | 2785 ; set-up registers |
2406 rcall get_first_dil_to_WREG ; get first diluent (1-5) into WREG | 2786 rcall get_first_dil_to_WREG ; get first diluent (1-5) into WREG |
2407 rcall setup_dil_registers ; set-up of diluent parameters for currently breathed diluent (with WREG = current diluent 1-5) | 2787 rcall setup_dil_registers ; set-up of diluent parameters for currently breathed diluent (with WREG = current diluent 1-5) |
2408 rcall deco_setup_cc_diluents ; set-up of diluent list for deco calculations (with WREG = current diluent 1-5) | 2788 rcall deco_setup_cc_diluents ; set-up of diluent list for deco calculations (with WREG = current diluent 1-5) |
2409 ; done | |
2410 return | 2789 return |
2411 | 2790 |
2412 | 2791 |
2413 dive_boot_cc_part2: | 2792 dive_boot_cc_part2: |
2414 ; revoke sensors from usage if they do not have a valid calibration | 2793 ; revoke sensors from usage if they do not have a valid calibration |
2485 bsf reset_trip_pressure ; request ISR to reset the resettable min/max pressure | 2864 bsf reset_trip_pressure ; request ISR to reset the resettable min/max pressure |
2486 ENDIF | 2865 ENDIF |
2487 | 2866 |
2488 IFDEF _cave_mode | 2867 IFDEF _cave_mode |
2489 ; initialize the cave mode | 2868 ; initialize the cave mode |
2490 bsf cave_mode ; enable cave mode by default | 2869 bcf cave_mode ; disable cave mode by default |
2491 movff opt_calc_asc_gasvolume,WREG ; get gas needs calculation mode (0= off, 1= on, 2= cave mode) | 2870 TSTOSC opt_cave_mode ; cave mode switched on? |
2492 xorlw .2 ; coding for cave mode | 2871 bsf cave_mode ; YES - enable cave mode |
2493 tstfsz WREG ; cave mode enabled? | 2872 |
2494 bcf cave_mode ; NO - disable cave mode again | 2873 bcf dive_turned ; dive is not turned yet |
2495 ENDIF | 2874 bcf backtrack_almost_full ; backtracking storage is not almost full yet |
2496 | 2875 bcf backtrack_entire_full ; backtracking storage is not entirely full yet |
2497 ; configure the deco engine | 2876 bsf waypoint_reached_first ; current waypoint is the first recorded waypoint |
2877 bsf waypoint_reached_last ; current waypoint is the last recorded waypoint | |
2878 | |
2879 clrf backtrack_waypoint_num ; initialize the waypoint number | |
2880 clrf backtrack_waypoint_turn ; no turn point yet | |
2881 | |
2882 movlw .0 ; initialize backtracking index to first position in storage | |
2883 movff WREG,char_I_backtrack_index ; ... | |
2884 | |
2885 clrf depth_meter ; store initial depth data set with depth = surface | |
2886 call write_backtrack_1min_depth ; ... | |
2887 ENDIF ; _cave_mode | |
2888 | |
2889 ; base configuration of the deco engine | |
2498 clrf hi ; start with everything disabled | 2890 clrf hi ; start with everything disabled |
2499 | 2891 TSTOSC opt_ext_stops ; shall make extended stops? |
2500 TSTOSC opt_ZfactorUse ; shall use Z factors? | |
2501 bsf hi,DECO_Z_FACTOR_FLAG ; YES - enable Z factors | |
2502 | |
2503 TSTOSC opt_extended_stops ; shall make extended stops? | |
2504 bsf hi,DECO_EXTENDED_STOPS ; YES - enable extended stops | 2892 bsf hi,DECO_EXTENDED_STOPS ; YES - enable extended stops |
2505 | |
2506 IFDEF _rx_functions | 2893 IFDEF _rx_functions |
2507 btfsc tr_functions_activated ; TR functions activated? | 2894 btfsc tr_functions_activated ; TR functions activated? |
2508 bsf hi,DECO_TR_FUNCTIONS ; YES - enable TR functions | 2895 bsf hi,DECO_TR_FUNCTIONS ; YES - enable TR functions |
2509 ENDIF | 2896 ENDIF |
2510 | 2897 IFDEF _gas_contingency |
2898 ; set contingency mode on/off | |
2899 TSTOSC opt_gas_contingency_dive ; gas contingency for dive mode switched on? | |
2900 bsf hi,DECO_GAS_CONTINGENCY ; YES - activate gas contingency mode | |
2901 ENDIF ; _gas_contingency | |
2511 movff hi,char_O_main_status ; bank-safe copy to deco engine | 2902 movff hi,char_O_main_status ; bank-safe copy to deco engine |
2512 | 2903 |
2513 movff char_O_deco_status,lo ; bank-safe read | 2904 clrf lo ; start with everything disabled |
2514 bsf lo,DECO_START_NORM ; set flag for doing a normal plan, | 2905 bsf lo,DECO_START_NORM ; set flag for doing a normal plan |
2515 bcf lo,DECO_START_ALT ; clear flag for doing an alternative plan, | 2906 bsf lo,DECO_INITIALIZE ; set flag for initializing the deco engine |
2516 bsf lo,DECO_INITIALIZE ; set flag for initializing the deco engine | |
2517 bcf lo,DECO_ASCENT_FLAG ; disable delayed ascent calculation | |
2518 bcf lo,DECO_CALCULATOR_MODE ; deco engine not run from the deco calculator | |
2519 movff lo,char_O_deco_status ; bank-safe copy back to deco engine | 2907 movff lo,char_O_deco_status ; bank-safe copy back to deco engine |
2520 | 2908 |
2521 ; disable "fast forward" function | 2909 ; disable "fast forward" function |
2522 movlw .0 | 2910 movlw .0 |
2523 movff WREG,char_I_sim_advance_time | 2911 movff WREG,char_I_sim_advance_time |
2524 | 2912 |
2525 ; write last stop depth to deco engine | 2913 ; write last stop depth to deco engine |
2526 movff opt_last_stop,char_I_depth_last_deco | 2914 movff opt_last_stop,char_I_last_stop_depth |
2527 | 2915 |
2528 ; initialize max depth for apnoe mode | 2916 ; initialize max depth for apnoe mode |
2529 CLRI apnoe_max_pressure | 2917 CLRI apnoe_max_pressure |
2530 | 2918 |
2531 ; reset minimum temperature, ISR-safe 2 byte copy | 2919 ; reset minimum temperature, ISR-safe 2 byte copy |
2539 bcf CNS_start+1,int_attention_flag ; without attention flag | 2927 bcf CNS_start+1,int_attention_flag ; without attention flag |
2540 | 2928 |
2541 ; save supersaturation at beginning of dive (only lower byte is used for value) | 2929 ; save supersaturation at beginning of dive (only lower byte is used for value) |
2542 movff int_O_lead_supersat+0,supersat_start | 2930 movff int_O_lead_supersat+0,supersat_start |
2543 | 2931 |
2544 clrf menu_pos_cur | 2932 clrf menu_pos_cur ; reset current menu position |
2545 clrf active_premenu ; reset to zero (0= no pre-menu task) | 2933 clrf active_premenu ; no pre-menu task active |
2546 bsf o2_sensors_agree ; initialize sensors disagree warning system | 2934 bsf o2_sensors_agree ; initialize sensors disagree warning system |
2547 | 2935 |
2548 clrf safety_stop_countdown ; clear safety stop count-down | 2936 clrf safety_stop_countdown ; clear safety stop count-down |
2549 | 2937 |
2550 CLRI last_pressure_velocity ; initialize last pressure for velocity calculation | 2938 CLRI last_pressure_velocity ; initialize last pressure for velocity calculation |
2558 | 2946 |
2559 ; clear the total dive average depth | 2947 ; clear the total dive average depth |
2560 CLRI pressure_rel_avg_total ; average depth | 2948 CLRI pressure_rel_avg_total ; average depth |
2561 CLRI divesecs_avg_total ; time accumulator | 2949 CLRI divesecs_avg_total ; time accumulator |
2562 clrf pressure_rel_accu_total+0 ; depth accumulator | 2950 clrf pressure_rel_accu_total+0 ; depth accumulator |
2563 clrf pressure_rel_accu_total+1 | 2951 clrf pressure_rel_accu_total+1 ; ... |
2564 clrf pressure_rel_accu_total+2 | 2952 clrf pressure_rel_accu_total+2 ; ... |
2565 clrf pressure_rel_accu_total+3 | 2953 clrf pressure_rel_accu_total+3 ; ... |
2566 | 2954 |
2567 IFDEF _rx_functions | 2955 IFDEF _rx_functions |
2568 | 2956 |
2569 btfss tr_functions_activated ; TR functions activated? | 2957 btfss tr_functions_activated ; TR functions activated? |
2570 bra diveloop_boot_0 ; NO - skip TR function initialization | 2958 bra diveloop_boot_0 ; NO - skip TR function initialization |
2571 ; YES - initialize TR function variables | |
2572 | 2959 |
2573 banksel int_IO_pressure_value | 2960 banksel int_IO_pressure_value |
2574 clrf WREG ; clear WREG | 2961 clrf WREG ; clear WREG |
2575 bsf WREG,int_not_avail_flag ; set WREG to coding for integer numbers -> data not available | 2962 bsf WREG,int_not_avail_flag ; set WREG to coding for integer numbers -> data not available |
2576 clrf int_IO_pressure_value+0 ; clear low byte of 1st pressure reading value | 2963 clrf int_IO_pressure_value+0 ; clear low byte of 1st pressure reading value |
2601 setf best_gas_number ; initialize best gas as not computed yet (255) | 2988 setf best_gas_number ; initialize best gas as not computed yet (255) |
2602 IFDEF _ccr_pscr | 2989 IFDEF _ccr_pscr |
2603 setf best_dil_number ; initialize best diluent as not computed yet (255) | 2990 setf best_dil_number ; initialize best diluent as not computed yet (255) |
2604 ENDIF | 2991 ENDIF |
2605 | 2992 |
2606 rcall dive_boot_oc_bail ; basic settings required for all modes | |
2607 | |
2608 btfsc FLAG_oc_mode ; in OC mode? | 2993 btfsc FLAG_oc_mode ; in OC mode? |
2609 rcall dive_boot_oc ; YES - add OC mode settings | 2994 rcall dive_boot_oc ; YES - add OC mode settings |
2610 | 2995 |
2611 IFDEF _ccr_pscr | 2996 IFDEF _ccr_pscr |
2612 btfsc FLAG_ccr_mode ; in CCR mode? | 2997 btfsc FLAG_ccr_mode ; in CCR mode? |
2617 btfsc FLAG_pscr_mode ; in pSCR mode? | 3002 btfsc FLAG_pscr_mode ; in pSCR mode? |
2618 rcall dive_boot_cc ; YES - add CC mode settings | 3003 rcall dive_boot_cc ; YES - add CC mode settings |
2619 btfsc FLAG_pscr_mode ; in pSCR mode? | 3004 btfsc FLAG_pscr_mode ; in pSCR mode? |
2620 rcall dive_boot_cc_part2 ; YES - add CC sensor and SP settings | 3005 rcall dive_boot_cc_part2 ; YES - add CC sensor and SP settings |
2621 ENDIF | 3006 ENDIF |
3007 | |
3008 bcf bailout_mode ; not in bailout mode | |
2622 | 3009 |
2623 call ghostwriter_short_header ; write short header with dive number into profile memory | 3010 call ghostwriter_short_header ; write short header with dive number into profile memory |
2624 call init_recording_params ; set up all the divisors for dive data recording | 3011 call init_recording_params ; set up all the divisors for dive data recording |
2625 | 3012 |
2626 ; setup gas selector flag (required to have better gas working) | 3013 ; setup gas selector flag (required to have better gas working) |
2659 movlw .2 ; NO - two messages at a time in normal layout | 3046 movlw .2 ; NO - two messages at a time in normal layout |
2660 cpfsgt message_counter ; more than one (alt layout) / 2 (normal layout) messages currently active? | 3047 cpfsgt message_counter ; more than one (alt layout) / 2 (normal layout) messages currently active? |
2661 bra divemode_check_warnings1 ; NO - update messages every second | 3048 bra divemode_check_warnings1 ; NO - update messages every second |
2662 | 3049 |
2663 ; ; YES - update every 4 seconds: | 3050 ; ; YES - update every 4 seconds: |
2664 ; btfss timebase_1sec - on second 1 or 3 ? | 3051 ; btfss timebase_1sec ; - on second 1 or 3 ? |
2665 ; return ; NO - no update in this cycle | 3052 ; return ; NO - no update in this cycle |
2666 ; btfss timebase_2sec ; YES - on second 3 ? | 3053 ; btfss timebase_2sec ; YES - on second 3 ? |
2667 ; return ; NO - no update in this cycle | 3054 ; return ; NO - no update in this cycle |
2668 ; ;bra divemode_check_warnings1 ; YES - update messages | 3055 ; ;bra divemode_check_warnings1 ; YES - update messages |
2669 | 3056 |
2691 | 3078 |
2692 btfsc FLAG_gauge_mode ; in gauge mode? | 3079 btfsc FLAG_gauge_mode ; in gauge mode? |
2693 bra divemode_check_warnings2 ; YES | 3080 bra divemode_check_warnings2 ; YES |
2694 | 3081 |
2695 ; warnings applicable only in deco modes | 3082 ; warnings applicable only in deco modes |
3083 | |
3084 IFDEF _cave_mode | |
3085 rcall check_cavemode ; check cave mode status | |
3086 ENDIF | |
3087 | |
3088 rcall check_display_ftts ; show @+x time (or cave mode cTTS) | |
3089 | |
2696 rcall check_ppO2 ; check ppO2 and displays warning, if required | 3090 rcall check_ppO2 ; check ppO2 and displays warning, if required |
2697 | 3091 |
2698 IFDEF _external_sensor | 3092 IFDEF _external_sensor |
2699 btfss o2_sensors_agree ; are the sensor values within the threshold range? | 3093 btfss o2_sensors_agree ; are the sensor values within the threshold range? |
2700 rcall check_warn_sensors_disagree ; NO - do further evaluation | 3094 rcall check_warn_sensors_disagree ; NO - do further evaluation |
2716 btfsc decostop_active ; in deco mode? | 3110 btfsc decostop_active ; in deco mode? |
2717 rcall check_and_store_sat_violation; YES - sets warnings, if required | 3111 rcall check_and_store_sat_violation; YES - sets warnings, if required |
2718 | 3112 |
2719 rcall check_mbubbles ; check for micro bubbles | 3113 rcall check_mbubbles ; check for micro bubbles |
2720 rcall check_cns_violation ; check CNS value and display it, if required | 3114 rcall check_cns_violation ; check CNS value and display it, if required |
2721 rcall check_gas_needs_ascent ; show gas needs warning if any gas need for ascent is > threshold | 3115 rcall check_gas_needs ; show gas needs warning if any gas need for ascent is > threshold |
2722 rcall check_eod_cns_violation ; check CNS values for end-of-dive and display warning, if required | 3116 rcall check_eod_cns_violation ; check CNS values for end-of-dive and display warning, if required |
2723 rcall check_display_ftts ; show @+x time | |
2724 | |
2725 IFDEF _cave_mode | |
2726 btfsc cave_mode ; cave mode switched on? | |
2727 rcall check_cavemode ; YES - check cave mode status | |
2728 ENDIF | |
2729 | 3117 |
2730 btfsc use_aGF ; using alternative GF factors? | 3118 btfsc use_aGF ; using alternative GF factors? |
2731 rcall warn_agf ; YES - show memo | 3119 rcall warn_agf ; YES - show memo |
2732 | 3120 |
2733 btfsc sp_fallback ; in fallback condition due to O2 sensor failure? | 3121 btfsc sp_fallback ; in fallback condition due to O2 sensor failure? |
2734 rcall warn_fallback ; YES - show a warning | 3122 rcall warn_fallback ; YES - show a warning |
2735 | 3123 |
2736 btfsc better_dil_available ; is a better diluent available? | 3124 btfsc better_dil_available ; is a better diluent available? |
2737 rcall advice_gas_change ; YES - display an advice | 3125 rcall advice_gas_change ; YES - display a gas change advice |
2738 | 3126 |
2739 btfsc better_gas_available ; is a better gas available? | 3127 btfsc better_gas_available ; is a better gas available? |
2740 rcall advice_gas_change ; YES - display an advice | 3128 rcall advice_gas_change ; YES - display a gas change advice |
2741 | 3129 |
2742 divemode_check_warnings2: | 3130 divemode_check_warnings2: |
2743 IFDEF _rx_functions | 3131 IFDEF _rx_functions |
2744 btfss tr_functions_activated ; TR functions activated? | 3132 btfss tr_functions_activated ; TR functions activated? |
2745 bra divemode_check_warnings3 ; NO - skip | 3133 bra divemode_check_warnings3 ; NO - skip |
2785 check_warn_battery: | 3173 check_warn_battery: |
2786 movlw battery_show_level+1 ; get threshold for showing battery level, incremented by 1 | 3174 movlw battery_show_level+1 ; get threshold for showing battery level, incremented by 1 |
2787 cpfslt batt_percent ; battery percentage ok? | 3175 cpfslt batt_percent ; battery percentage ok? |
2788 return ; YES - no display, no warning | 3176 return ; YES - no display, no warning |
2789 ; Display Battery, but warn? | 3177 ; Display Battery, but warn? |
2790 movlw battery_warn_level_36+1 ; get threshold for 3.6 Volt battery warning, incremented by 1 | 3178 btfsc battery_low_condition ; battery low condition detected? |
2791 btfss battery_is_36v ; actually a 3.6 Volt battery detected? | 3179 bsf message_warning ; YES - set warning flag for battery low |
2792 movlw battery_warn_level_15+1 ; NO - replace with 1.5 Volt battery warning, incremented by 1 | |
2793 cpfsgt batt_percent ; battery percent below warning threshold? | |
2794 bsf message_warning ; YES - set warning flag | |
2795 movlw index_clock_batt_surfpress ; index of custom view clock, battery and surface pressure | 3180 movlw index_clock_batt_surfpress ; index of custom view clock, battery and surface pressure |
2796 cpfseq active_customview ; battery shown in custom view? | 3181 cpfseq active_customview ; battery shown in custom view? |
2797 bra check_warn_battery2 ; NO - show warning | 3182 bra check_warn_battery2 ; NO - show warning |
2798 return ; YES - do not show twice (in custom view and in message area) | 3183 return ; YES - do not show twice (in custom view and in message area) |
2799 check_warn_battery2: | 3184 check_warn_battery2: |
2800 incf message_counter,F ; increase counter | 3185 incf message_counter,F ; increase counter |
2801 goto TFT_msg_batt_percent_divemode ; show percent (and return) | 3186 goto TFT_msg_batt_percent_divemode ; show warning message for battery low (battery percent) and return |
2802 | 3187 |
2803 | 3188 |
2804 check_divetimeout: | 3189 check_divetimeout: |
2805 btfsc count_divetime ; is dive time counted? | 3190 btfsc count_divetime ; is dive time counted? |
2806 return ; YES - do nothing | 3191 return ; YES - do nothing |
2839 check_ppO2_high: | 3224 check_ppO2_high: |
2840 movlw d'5' ; set type of alarm (ppO2 high) | 3225 movlw d'5' ; set type of alarm (ppO2 high) |
2841 check_ppO2_common: | 3226 check_ppO2_common: |
2842 movwf alarm_type ; copy alarm type to alarm register | 3227 movwf alarm_type ; copy alarm type to alarm register |
2843 bsf event_occured ; set event flag | 3228 bsf event_occured ; set event flag |
2844 bsf message_warning ; show warning sign | 3229 bsf message_warning ; show warning sign for breathed ppO2 |
2845 check_ppO2_common_2: | 3230 check_ppO2_common_2: |
2846 btfsc FLAG_oc_mode ; are we in OC mode? | 3231 btfsc FLAG_oc_mode ; are we in OC mode? |
2847 bra check_ppo2_display ; YES - show | 3232 bra check_ppo2_display ; YES - show |
3233 IFDEF _ccr_pscr | |
2848 btfsc bailout_mode ; are we in bailout mode? | 3234 btfsc bailout_mode ; are we in bailout mode? |
2849 bra check_ppo2_display ; YES - show | 3235 bra check_ppo2_display ; YES - show |
3236 ENDIF | |
2850 return ; NO - in loop mode, ppO2 is already shown via setpoint display | 3237 return ; NO - in loop mode, ppO2 is already shown via setpoint display |
2851 check_ppo2_display_a: | 3238 check_ppo2_display_a: |
2852 bsf message_attention ; show attention sign | 3239 bsf message_attention ; show attention sign for breathed ppO2 |
2853 check_ppo2_display: | 3240 check_ppo2_display: |
2854 movlw index_ppo2_ead_end_cns ; index of custom view ppO2, EAD/END and CNS (without He) or gas density (with He) | 3241 movlw index_ppo2_ead_end_cns ; index of custom view ppO2, EAD/END and CNS (without He) or gas density (with He) |
2855 cpfseq active_customview ; ppO2 shown? | 3242 cpfseq active_customview ; ppO2 shown? |
2856 bra check_ppO2_b ; NO | 3243 bra check_ppO2_b ; NO |
2857 return ; YES - do not show twice (in custom view and in warning area) | 3244 return ; YES - do not show twice (in custom view and in warning area) |
2859 movlw index_pscr_info ; index of custom view with pSCR data | 3246 movlw index_pscr_info ; index of custom view with pSCR data |
2860 cpfseq active_customview ; ppO2 shown? | 3247 cpfseq active_customview ; ppO2 shown? |
2861 bra check_ppO2_d ; NO - show ppO2 | 3248 bra check_ppO2_d ; NO - show ppO2 |
2862 return ; YES - do not show twice (in custom view and in warning area) | 3249 return ; YES - do not show twice (in custom view and in warning area) |
2863 check_ppO2_dw: | 3250 check_ppO2_dw: |
2864 bsf message_warning ; show warning sign | 3251 bsf message_warning ; show warning sign for diluent ppO2 |
2865 check_ppO2_da: | 3252 check_ppO2_da: |
2866 bsf message_attention ; show attention sign (no problem if a warning sign is set as well, as it will take priority) | 3253 bsf message_attention ; show attention sign for diluent ppO2 (no problem if a warning sign is set as well, as it will take priority) |
2867 check_ppO2_d: | 3254 check_ppO2_d: |
2868 incf message_counter,F ; increase counter | 3255 incf message_counter,F ; increase counter |
2869 goto TFT_show_ppo2_warning ; show breathed gas or diluent ppO2 warning (and return) | 3256 goto TFT_show_ppo2_warning ; show warning message for breathed gas or diluent ppO2 and return |
2870 | 3257 |
2871 | 3258 |
2872 check_display_ftts: | 3259 check_display_ftts: |
3260 IFDEF _ccr_pscr | |
3261 btfsc bailout_mode ; in bailout mode? | |
3262 return ; YES - in bailout no fTTS is computed, done | |
3263 ENDIF | |
2873 btfss count_divetime ; is dive time counted? | 3264 btfss count_divetime ; is dive time counted? |
2874 return ; NO - omit | 3265 return ; NO - omit, done |
2875 movff char_I_extra_time,lo ; YES - get extra time | 3266 movff char_I_extra_time,lo ; YES - get extra time |
2876 tstfsz lo ; - extra time > 0 ? | 3267 tstfsz lo ; - extra time > 0 ? |
2877 bra check_display_ftts_1 ; YES - continue checking bailout condition | 3268 bra check_display_ftts_1 ; YES - continue checking bailout condition |
2878 return ; NO - done | 3269 return ; NO - no fTTS computed, done |
2879 check_display_ftts_1: | 3270 check_display_ftts_1: |
2880 btfsc bailout_mode ; in bailout mode? | 3271 incf message_counter,F ; increase counter |
2881 return ; YES - in bailout no fTTS will be computed, so nothing to display | 3272 goto TFT_show_ftts ; show @+x time |
2882 incf message_counter,F ; NO - increase counter | |
2883 goto TFT_show_ftts ; - show @+x time | |
2884 | 3273 |
2885 | 3274 |
2886 global check_cns_violation | 3275 global check_cns_violation |
2887 check_cns_violation: | 3276 check_cns_violation: |
2888 ; Check if CNS should be displayed | 3277 ; Check if CNS should be displayed |
2891 bra check_cns_violation_1 ; YES - issue warning | 3280 bra check_cns_violation_1 ; YES - issue warning |
2892 btfsc WREG,int_attention_flag ; NO - attention flag set? | 3281 btfsc WREG,int_attention_flag ; NO - attention flag set? |
2893 bra check_cns_violation_2 ; YES - issue attention | 3282 bra check_cns_violation_2 ; YES - issue attention |
2894 return ; NO - done | 3283 return ; NO - done |
2895 check_cns_violation_1: | 3284 check_cns_violation_1: |
2896 bsf message_warning ; show warning sign | 3285 bsf message_warning ; show warning sign for CNS |
2897 check_cns_violation_2: | 3286 check_cns_violation_2: |
2898 bsf message_attention ; show attention sign | 3287 bsf message_attention ; show attention sign for CNS |
2899 IFNDEF _helium | 3288 IFNDEF _helium |
2900 movlw index_ppo2_ead_end_cns ; index of custom view ppO2, EAD/END and CNS (without He) or gas density (with He) | 3289 movlw index_ppo2_ead_end_cns ; index of custom view ppO2, EAD/END and CNS (without He) or gas density (with He) |
2901 cpfseq active_customview ; CNS shown? | 3290 cpfseq active_customview ; CNS shown? |
2902 bra check_cns_violation_3 ; NO | 3291 bra check_cns_violation_3 ; NO |
2903 return ; YES - do not show twice (in custom view and in warning area) | 3292 return ; YES - do not show twice (in custom view and in warning area) |
2907 cpfseq active_customview ; CNS shown? | 3296 cpfseq active_customview ; CNS shown? |
2908 bra check_cns_violation_4 ; NO | 3297 bra check_cns_violation_4 ; NO |
2909 return ; YES - do not show twice (in custom view and in warning area) | 3298 return ; YES - do not show twice (in custom view and in warning area) |
2910 check_cns_violation_4: | 3299 check_cns_violation_4: |
2911 incf message_counter,F ; increase counter | 3300 incf message_counter,F ; increase counter |
2912 goto TFT_show_cns ; show CNS (and return) | 3301 goto TFT_show_cns ; show attention/warning message for CNS and return |
2913 | 3302 |
2914 | 3303 |
2915 global check_eod_cns_violation ; check end-of-dive CNS values | 3304 global check_eod_cns_violation ; check end-of-dive CNS values |
2916 check_eod_cns_violation: | 3305 check_eod_cns_violation: |
2917 movff int_O_CNS_current+1,WREG ; get current CNS, high byte | 3306 movff int_O_CNS_current+1,WREG ; get current CNS, high byte |
2928 return ; YES - done with CNS checking | 3317 return ; YES - done with CNS checking |
2929 btfsc WREG,int_warning_flag ; NO - flag for warning set? | 3318 btfsc WREG,int_warning_flag ; NO - flag for warning set? |
2930 bra check_eod_cns_violation2 ; YES - issue warning | 3319 bra check_eod_cns_violation2 ; YES - issue warning |
2931 return ; NO - done with CNS checking | 3320 return ; NO - done with CNS checking |
2932 check_eod_cns_violation2: ; issue warning (actually only on attention level) | 3321 check_eod_cns_violation2: ; issue warning (actually only on attention level) |
2933 bsf message_attention ; show attention sign | 3322 bsf message_attention ; show attention sign for end-of-dive CNS |
2934 movlw index_CNS ; index of custom view with CNS values | 3323 movlw index_CNS ; index of custom view with CNS values |
2935 cpfseq active_customview ; CNS values shown? | 3324 cpfseq active_customview ; CNS values shown? |
2936 bra display_eod_cns_violation ; NO - issue textual warning | 3325 bra display_eod_cns_violation ; NO - issue textual warning |
2937 return ; YES - do not show twice (in custom view and in warning area) | 3326 return ; YES - do not show twice (in custom view and in warning area) |
2938 display_eod_cns_violation: | 3327 display_eod_cns_violation: |
2939 incf message_counter,F ; increase counter | 3328 incf message_counter,F ; increase counter |
2940 goto TFT_warning_eod_cns ; issue CNS at end-of-dive warning (and return) | 3329 goto TFT_warning_eod_cns ; show warning message for end-of-dive CNS and return |
2941 | 3330 |
2942 | 3331 |
2943 global check_and_store_sat_violation | 3332 global check_and_store_sat_violation |
2944 check_and_store_sat_violation: | 3333 check_and_store_sat_violation: |
2945 movff int_O_lead_supersat+1,WREG ; get upper byte of leading tissue's supersaturation | 3334 movff int_O_lead_supersat+1,WREG ; get upper byte of leading tissue's supersaturation |
2946 btfss WREG,int_warning_flag ; check if the warning flag is set | 3335 btfss WREG,int_warning_flag ; check if the warning flag is set |
2947 bra check_and_store_sat_violation2 ; NO - continue with checking for attention flag | 3336 bra check_and_store_sat_violation2 ; NO - continue with checking for attention flag |
2948 movlw d'2' ; YES - set type of alarm | 3337 movlw d'2' ; YES - set type of alarm |
2949 movwf alarm_type ; - copy to alarm register | 3338 movwf alarm_type ; - copy to alarm register |
2950 bsf event_occured ; - set event flag | 3339 bsf event_occured ; - set event flag |
2951 bsf message_warning ; - set warning flag | 3340 bsf message_warning ; - show warning sign for saturation |
2952 bra check_and_store_sat_violation3 ; - show GF warning | 3341 bra check_and_store_sat_violation3 ; - show saturation |
2953 check_and_store_sat_violation2: | 3342 check_and_store_sat_violation2: |
2954 btfsc WREG,int_attention_flag ; check if the attention flag is set | 3343 btfsc WREG,int_attention_flag ; check if the attention flag is set |
2955 bra check_and_store_sat_violation3 ; YES - show gf | 3344 bra check_and_store_sat_violation3 ; YES - show saturation |
2956 TSTOSS opt_enable_IBCD ; NO - IBCD warning activated? | 3345 TSTOSS opt_enable_IBCD ; NO - IBCD warning activated? |
2957 bra check_and_store_sat_violation4 ; NO - continue checking of deco info | 3346 bra check_and_store_sat_violation4 ; NO - continue checking of deco info |
2958 movff char_O_deco_warnings,WREG ; YES - get the deco warnings vector | 3347 movff char_O_deco_warnings,WREG ; YES - get the deco warnings vector |
2959 btfss WREG,IBCD_warning ; - is the IBCD warning flag set? | 3348 btfss WREG,IBCD_warning ; - is the IBCD warning flag set? |
2960 bra check_and_store_sat_violation4 ; NO - continue checking for deco info | 3349 bra check_and_store_sat_violation4 ; NO - continue checking for deco info |
2961 check_and_store_sat_violation3: ; YES - show GF | 3350 check_and_store_sat_violation3: ; YES - show saturation |
2962 bsf message_attention ; show attention sign | 3351 bsf message_attention ; show attention sign for saturation |
2963 incf message_counter,F ; increase counter | 3352 incf message_counter,F ; increase counter |
2964 goto TFT_warning_sat ; show saturation (and return) | 3353 goto TFT_warning_saturation ; show attention/warning message for saturation and return |
2965 check_and_store_sat_violation4: ; check for deco info | 3354 check_and_store_sat_violation4: ; check for deco info |
2966 btfss divemode ; in dive mode? | 3355 btfss divemode ; in dive mode? |
2967 return ; NO - done, return | 3356 return ; NO - done, return |
3357 IFDEF _ccr_pscr | |
2968 btfsc bailout_mode ; YES - in bailout mode? | 3358 btfsc bailout_mode ; YES - in bailout mode? |
2969 return ; YES - done, return (deco zone flag is not updated when in bailout mode) | 3359 return ; YES - done, return (deco zone flag is not updated when in bailout mode) |
3360 ENDIF | |
2970 movff char_O_deco_info,WREG ; NO - get the deco info vector | 3361 movff char_O_deco_info,WREG ; NO - get the deco info vector |
2971 btfss WREG,deco_zone ; check if the deco zone flag is set | 3362 btfss WREG,deco_zone ; check if the deco zone flag is set |
2972 return ; NO - done, return | 3363 return ; NO - done, return |
2973 btfsc use_aGF ; YES - using alternative GF factors? | 3364 btfsc use_aGF ; YES - using alternative GF factors? |
2974 return ; YES - suppress deco zone info | 3365 return ; YES - suppress deco zone info |
2981 check_depth_limit: | 3372 check_depth_limit: |
2982 bcf depth_limit_exceeded ; clear warning flag by default | 3373 bcf depth_limit_exceeded ; clear warning flag by default |
2983 movff opt_max_depth,WREG ; get depth limit | 3374 movff opt_max_depth,WREG ; get depth limit |
2984 cpfsgt depth_meter ; current depth > depth limit? | 3375 cpfsgt depth_meter ; current depth > depth limit? |
2985 return ; NO | 3376 return ; NO |
2986 bsf depth_limit_exceeded ; YES - set warning flag | 3377 bsf depth_limit_exceeded ; YES - set flag for depth limit exceeded |
2987 incf message_counter,F ; - increase counter | 3378 incf message_counter,F ; - increase counter |
2988 bsf message_warning ; - set warning flag | 3379 bsf message_warning ; - show warning sign for depth |
2989 goto TFT_warning_depth ; - show warning | 3380 goto TFT_warning_depth ; - show warning message for depth |
2990 | 3381 |
2991 | 3382 |
2992 check_outside: | 3383 check_outside: |
2993 movff char_O_deco_warnings,WREG ; bank-safe copy of deco warnings | 3384 movff char_O_deco_warnings,WREG ; bank-safe copy of deco warnings |
2994 btfss WREG,outside_warning_lock ; are we outside of the ZH-L16 model? | 3385 btfss WREG,outside_warning_lock ; are we outside of the ZH-L16 model? |
2995 return ; NO - done | 3386 return ; NO - done |
2996 incf message_counter,F ; YES - increase counter | 3387 incf message_counter,F ; YES - increase counter |
2997 bsf message_attention ; - show attention sign | 3388 bsf message_attention ; - show attention sign for outside |
2998 btfsc WREG,outside_warning ; - are we outside the ZH-L16 model right now (-> warning)? | 3389 btfsc WREG,outside_warning ; - are we outside the ZH-L16 model right now (-> warning)? |
2999 bsf message_warning ; - set warning flag | 3390 bsf message_warning ; - show warning sign for outside |
3000 goto TFT_warning_outside ; - show outside-ZHL-model warning/attention (and return) | 3391 goto TFT_warning_outside ; - show warning/attention message for outside and return |
3001 | 3392 |
3002 | 3393 |
3003 global check_mbubbles | 3394 global check_mbubbles |
3004 check_mbubbles: | 3395 check_mbubbles: |
3005 movff char_O_deco_warnings,WREG ; bank-safe copy for deco warnings | 3396 movff char_O_deco_warnings,WREG ; bank-safe copy for deco warnings |
3007 bra check_mbubbles_warn ; YES | 3398 bra check_mbubbles_warn ; YES |
3008 btfss WREG,mbubble_warning_lock ; were we in micro bubbling zone? | 3399 btfss WREG,mbubble_warning_lock ; were we in micro bubbling zone? |
3009 return ; NO - done | 3400 return ; NO - done |
3010 check_mbubble_att ; YES - attention level | 3401 check_mbubble_att ; YES - attention level |
3011 incf message_counter,F ; increase counter | 3402 incf message_counter,F ; increase counter |
3012 bsf message_attention ; show attention sign | 3403 bsf message_attention ; show attention sign for micro bubbles |
3013 goto TFT_warning_mbubbles ; show micro bubble attention (and return) - TFT_warning_mbubbles switches by itself between attention and warning | 3404 goto TFT_warning_mbubbles ; show micro bubble attention (and return) - TFT_warning_mbubbles switches by itself between attention and warning |
3014 check_mbubbles_warn: ; locked micro bubbles - warning level if at issue, attention level if locked | 3405 check_mbubbles_warn: ; locked micro bubbles - warning level if at issue, attention level if locked |
3015 incf message_counter,F ; increase counter | 3406 incf message_counter,F ; increase counter |
3016 bsf message_warning ; set warning flag | 3407 bsf message_warning ; show warning sign for micro bubbles |
3017 goto TFT_warning_mbubbles ; show micro bubbles warning (and return) | 3408 goto TFT_warning_mbubbles ; show warning message for micro bubbles (and return) |
3409 | |
3018 | 3410 |
3019 IFDEF _cave_mode | 3411 IFDEF _cave_mode |
3412 | |
3020 check_cavemode: | 3413 check_cavemode: |
3414 btfsc backtrack_entire_full ; is the backtracking storage entirely used up? | |
3415 bra check_cavemode_full ; YES - turn dive, switch off cave mode and show warning message | |
3416 btfsc backtrack_almost_full ; NO - backtracking storage almost full? | |
3417 bra check_cavemode_almost_full ; YES - show attention message that cave mode will stop soon | |
3418 btfss alt_layout_active ; NO - alternative layout active? | |
3419 bra check_cavemode_info ; NO - show cave mode active info | |
3420 return ; YES - suppress info message | |
3421 | |
3422 check_cavemode_full: | |
3423 btfss backtrack_shutdown ; backtracking shut down already? | |
3424 bsf request_cave_off_turned ; NO - request to switch cave mode off and to set the dive as turned | |
3425 bsf backtrack_shutdown ; remember shut down as been executed (anyhow) | |
3021 incf message_counter,F ; increase counter | 3426 incf message_counter,F ; increase counter |
3022 btfsc dive_turned ; dive turned? | 3427 btfsc cave_mode ; has the cave mode been switched on again meanwhile? |
3023 goto TFT_info_dive_turned ; YES - show info that dive is turned | 3428 goto TFT_cave_shutdown_attention ; YES - show attention message for cave mode shutdown ands return |
3024 btfsc FLAG_backtrack_full ; NO - is the backtracking storage full? | 3429 bsf message_warning ; NO - show warning sign for cave mode shutdown |
3025 goto TFT_warn_cave_shutdown ; YES - show that cave mode has shut down | 3430 goto TFT_cave_shutdown_warning ; - show warning message for cave mode shutdown and return |
3026 goto TFT_info_cave_mode ; NO - show that cave mode is active | 3431 |
3027 ENDIF | 3432 check_cavemode_almost_full: |
3433 btfss cave_mode ; cave mode switched on? | |
3434 return ; NO - suppress message | |
3435 incf message_counter,F ; YES - increase counter | |
3436 goto TFT_cave_shutdown_attention ; - show attention message that cave mode will shut down soon | |
3437 | |
3438 check_cavemode_info: | |
3439 btfss cave_mode ; cave mode switched on? | |
3440 return ; NO - do not show info | |
3441 incf message_counter,F ; YES - increase counter | |
3442 goto TFT_info_cave_mode ; - show cave mode active info | |
3443 | |
3444 ENDIF ; _cave_mode | |
3445 | |
3028 | 3446 |
3029 warn_agf: | 3447 warn_agf: |
3030 incf message_counter,F ; increase counter | 3448 incf message_counter,F ; increase counter |
3031 goto TFT_warning_agf ; show aGF reminder (and return) | 3449 goto TFT_warning_agf ; show aGF reminder (and return) |
3032 | 3450 |
3033 warn_fallback: | 3451 warn_fallback: |
3034 incf message_counter,F ; increase counter | 3452 incf message_counter,F ; increase counter |
3035 bsf message_warning ; set warning flag | 3453 bsf message_warning ; show warning sign for fallback |
3036 goto TFT_warning_fallback ; show fallback warning (and return) | 3454 goto TFT_warning_fallback ; show warning message for fallback and return |
3037 | 3455 |
3038 ;============================================================================= | 3456 ;============================================================================= |
3039 | 3457 |
3040 IFDEF _rx_functions | 3458 IFDEF _rx_functions |
3041 | 3459 |
3045 movff int_O_SAC_measured+1,WREG ; YES - bank-safe copy of measured SAC rate | 3463 movff int_O_SAC_measured+1,WREG ; YES - bank-safe copy of measured SAC rate |
3046 btfss WREG,int_attention_flag ; - attention flag set? | 3464 btfss WREG,int_attention_flag ; - attention flag set? |
3047 bra check_tr_messages2 ; NO - skip | 3465 bra check_tr_messages2 ; NO - skip |
3048 btfsc WREG,int_not_avail_flag ; SAC rate available? | 3466 btfsc WREG,int_not_avail_flag ; SAC rate available? |
3049 bra check_tr_messages2 ; NO - continue with swap advice | 3467 bra check_tr_messages2 ; NO - continue with swap advice |
3050 bsf message_attention ; YES - show attention sign | 3468 bsf message_attention ; YES - show attention sign for SAC rate |
3051 movlw index_pressures_SAC ; - index of custom view with SAC rate | 3469 movlw index_pressures_SAC ; - index of custom view with SAC rate |
3052 cpfseq active_customview ; - SAC rate shown right now? | 3470 cpfseq active_customview ; - SAC rate shown right now? |
3053 bra check_tr_messages1 ; NO - show attention message | 3471 bra check_tr_messages1 ; NO - show attention message |
3054 bra check_tr_messages2 ; YES - do not show twice, continue with swap advice | 3472 bra check_tr_messages2 ; YES - do not show twice, continue with swap advice |
3055 check_tr_messages1: | 3473 check_tr_messages1: |
3056 incf message_counter,F ; increase counter | 3474 incf message_counter,F ; increase counter |
3057 call TFT_attention_sac ; show SAC attention | 3475 call TFT_attention_sac ; show attention message for SAC rate |
3058 check_tr_messages2: | 3476 check_tr_messages2: |
3059 movff char_O_deco_info,WREG ; bank-safe copy of deco info vector | 3477 movff char_O_deco_info,WREG ; bank-safe copy of deco info vector |
3060 btfss WREG,ind_double_switch ; swap tank flag set? | 3478 btfss WREG,ind_double_switch ; swap tank flag set? |
3061 return ; NO | 3479 return ; NO |
3062 incf message_counter,F ; YES - increase counter | 3480 incf message_counter,F ; YES - increase counter |
3063 bsf message_advice ; - show advice sign | 3481 bsf message_advice ; - show advice sign for switching tanks |
3064 goto TFT_advice_switch ; - show swap advice | 3482 goto TFT_advice_switch ; - show advice message for switching tanks and return |
3065 | |
3066 | 3483 |
3067 check_tr_functions: | 3484 check_tr_functions: |
3068 clrf xmitter_flags_mesg ; set all messages as not shown yet | 3485 clrf xmitter_flags_mesg ; set all messages as not shown yet |
3069 movlw index_pressures_SAC ; index of custom view pressure readings | 3486 movlw index_pressures_SAC ; index of custom view pressure readings |
3070 cpfseq active_customview ; pressure readings shown? | 3487 cpfseq active_customview ; pressure readings shown? |
3085 rcall check_tr_functions_helper7 ; check for transmitter 2 pressure warning | 3502 rcall check_tr_functions_helper7 ; check for transmitter 2 pressure warning |
3086 rcall check_tr_functions_helper8 ; check for transmitter 2 pressure attention | 3503 rcall check_tr_functions_helper8 ; check for transmitter 2 pressure attention |
3087 check_tr_functions_show_xmtr: | 3504 check_tr_functions_show_xmtr: |
3088 btfss show_transmitter_attention ; shall show transmitter attention message? | 3505 btfss show_transmitter_attention ; shall show transmitter attention message? |
3089 bra check_tr_functions_show_warn ; NO - continue with pressure warning | 3506 bra check_tr_functions_show_warn ; NO - continue with pressure warning |
3090 bsf message_attention ; YES - set flag for attention | 3507 bsf message_attention ; YES - show attention sign for transmitter |
3091 incf message_counter,F ; - increase counter | 3508 incf message_counter,F ; - increase counter |
3092 call TFT_attention_transmitter ; - show transmitter attention message | 3509 call TFT_attention_transmitter ; - show transmitter attention message |
3093 check_tr_functions_show_warn: | 3510 check_tr_functions_show_warn: |
3094 btfss show_pres_warning ; shall show pressure warning? | 3511 btfss show_pres_warning ; shall show pressure warning? |
3095 bra check_tr_functions_show_att ; NO - continue with pressure attention | 3512 bra check_tr_functions_show_att ; NO - continue with pressure attention |
3096 bsf message_warning ; YES - set flag for warning | 3513 bsf message_warning ; YES - show warning sign for pressure |
3097 incf message_counter,F ; - increase counter | 3514 incf message_counter,F ; - increase counter |
3098 goto TFT_warning_pres_reading ; - pressure reading warning message and done then | 3515 goto TFT_warning_pres_reading ; - show warning message for pressure reading and return |
3099 check_tr_functions_show_att: | 3516 check_tr_functions_show_att: |
3100 btfss show_pres_attention ; shall show pressure attention? | 3517 btfss show_pres_attention ; shall show pressure attention? |
3101 return ; NO - done | 3518 return ; NO - done |
3102 bsf message_attention ; YES - set flag for attention | 3519 bsf message_attention ; YES - show attention sign for pressure |
3103 incf message_counter,F ; - increase counter | 3520 incf message_counter,F ; - increase counter |
3104 goto TFT_attention_pres_reading ; - pressure reading warning message and done then | 3521 goto TFT_attention_pres_reading ; - show attention message for pressure reading and return |
3105 | 3522 |
3106 check_tr_functions_helper1: | 3523 check_tr_functions_helper1: |
3107 btfsc WREG,char_transmitter_lost ; transmitter 1 lost? | 3524 btfsc WREG,char_transmitter_lost ; transmitter 1 lost? |
3108 bra check_tr_functions_helper1a ; YES - show transmitter attention message | 3525 bra check_tr_functions_helper1a ; YES - show transmitter attention message |
3109 bcf transmitter1_lost ; NO - clear flag for old lost attention | 3526 bcf transmitter1_lost ; NO - clear flag for old lost attention |
3200 ;bra check_tr_functions_show_cv ; - show custom view | 3617 ;bra check_tr_functions_show_cv ; - show custom view |
3201 | 3618 |
3202 check_tr_functions_show_cv: | 3619 check_tr_functions_show_cv: |
3203 btfsc pres_customview_shown ; is the pressure readings custom view not shown yet? | 3620 btfsc pres_customview_shown ; is the pressure readings custom view not shown yet? |
3204 return ; NO - already shown, done | 3621 return ; NO - already shown, done |
3205 bsf pres_customview_shown ; YES - mark as shown | 3622 btfsc custom_view_locked ; YES - custom view locked? |
3206 movlw index_pressures_SAC-1 ; - custom view number one below pressure readings | 3623 return ; YES - done |
3207 movwf active_customview ; - set custom view number | 3624 bsf pres_customview_shown ; NO - mark as shown now |
3208 bsf request_next_custview ; - initiate toggle to desired custom view -> pressure readings view will be shown | 3625 movlw index_pressures_SAC ; - get custom view number of pressure readings |
3209 return ; - done | 3626 goto dive_customview_show ; - draw custom view and return |
3210 | 3627 |
3211 ENDIF | 3628 ENDIF |
3212 | 3629 |
3213 ;============================================================================= | 3630 ;============================================================================= |
3214 | 3631 |
3215 check_gas_needs_ascent: | 3632 check_gas_needs: |
3216 banksel int_O_gas_need_pres | 3633 banksel int_O_gas_need_pres |
3217 movf int_O_gas_need_pres+1,W ; get high byte from pres need of 1st tank | 3634 movf int_O_gas_need_pres+1,W ; get high byte from pres need of 1st tank |
3218 iorwf int_O_gas_need_pres+3,W ; inclusive or with high byte from pres need of 2nd tank | 3635 iorwf int_O_gas_need_pres+3,W ; inclusive or with high byte from pres need of 2nd tank |
3219 iorwf int_O_gas_need_pres+5,W ; inclusive or with high byte from pres need of 3rd tank | 3636 iorwf int_O_gas_need_pres+5,W ; inclusive or with high byte from pres need of 3rd tank |
3220 iorwf int_O_gas_need_pres+7,W ; inclusive or with high byte from pres need of 4th tank | 3637 iorwf int_O_gas_need_pres+7,W ; inclusive or with high byte from pres need of 4th tank |
3221 iorwf int_O_gas_need_pres+9,W ; inclusive or with high byte from pres need of 5th tank | 3638 iorwf int_O_gas_need_pres+9,W ; inclusive or with high byte from pres need of 5th tank |
3222 banksel common | 3639 banksel common |
3223 btfsc WREG,int_invalid_flag ; check if invalid flag is set | 3640 btfsc WREG,int_invalid_flag ; check if invalid flag is set |
3224 return ; YES - no further checking required | 3641 return ; YES - no further checking required |
3225 btfsc WREG,int_warning_flag ; NO - check if any gas has a pres_need >= pres_fill | 3642 btfsc WREG,int_warning_flag ; NO - check if any gas has a pres_need >= pres_fill |
3226 bra check_gas_needs_ascent_warn ; YES - generate a warning | 3643 bra check_gas_needs_warn ; YES - generate a warning |
3227 btfsc WREG,int_attention_flag ; NO - check if any gas has a pres_need >= pres_fill * threshold | 3644 btfsc WREG,int_attention_flag ; NO - check if any gas has a pres_need >= pres_fill * threshold |
3228 bra check_gas_needs_ascent_att ; YES - generate an attention | 3645 bra check_gas_needs_att ; YES - generate an attention |
3229 bcf gas_needs_attention ; NO - clear flag for a new attention | 3646 bcf gas_needs_attention ; NO - clear flag for a new attention |
3230 bcf gas_needs_warning ; - clear flag for a new warning | 3647 bcf gas_needs_warning ; - clear flag for a new warning |
3231 return ; - done | 3648 return ; - done |
3232 | 3649 |
3233 check_gas_needs_ascent_warn: | 3650 check_gas_needs_warn: |
3234 bsf message_warning ; set warning flag | 3651 bsf message_warning ; show warning sign for gas needs |
3235 incf message_counter,F ; increase counter | 3652 incf message_counter,F ; increase counter |
3236 btfsc gas_needs_warning ; is it a new warning? | 3653 btfsc gas_needs_warning ; is it a new warning? |
3237 goto TFT_warning_gas_needs_warn ; NO - do not show the gas needs custom view again | 3654 bra check_gas_needs_warn_1 ; NO - do not show the gas needs custom view again |
3238 bsf gas_needs_warning ; YES - memorize it's an old now | 3655 btfsc custom_view_locked ; YES - custom view locked? |
3239 movlw index_gas_needs_ascent-1 ; - custom view number one below gas needs view | 3656 bra check_gas_needs_warn_1 ; YES - done |
3240 movwf active_customview ; - set custom view number | 3657 bsf gas_needs_warning ; NO - memorize it's an old now |
3241 bsf request_next_custview ; - initiate toggle to desired custom view -> gas needs view will be shown | 3658 movlw index_gas_needs_ascent ; - get custom view number of gas needs |
3242 goto TFT_warning_gas_needs_warn ; - show warning message | 3659 call dive_customview_show ; - draw custom view |
3243 | 3660 check_gas_needs_warn_1: |
3244 check_gas_needs_ascent_att: | 3661 goto TFT_warning_gas_needs ; - show warning message for gas needs and return |
3245 bsf message_attention ; set attention flag | 3662 |
3663 check_gas_needs_att: | |
3664 bsf message_attention ; show attention sign for gas needs | |
3246 incf message_counter,F ; increase counter | 3665 incf message_counter,F ; increase counter |
3247 btfsc gas_needs_attention ; is it a new attention? | 3666 btfsc gas_needs_attention ; is it a new attention? |
3248 goto TFT_warning_gas_needs_att ; NO - do not show the gas needs custom view again | 3667 bra check_gas_needs_att_1 ; NO - do not show the gas needs custom view again |
3249 bsf gas_needs_attention ; YES - memorize it's an old now | 3668 btfsc custom_view_locked ; YES - custom view locked? |
3250 movlw index_gas_needs_ascent-1 ; - custom view number one below gas needs view | 3669 bra check_gas_needs_att_1 ; YES - done |
3251 movwf active_customview ; - set custom view number | 3670 bsf gas_needs_attention ; NO - memorize it's an old now |
3252 bsf request_next_custview ; - initiate toggle to desired custom view -> gas needs view will be shown | 3671 movlw index_gas_needs_ascent ; - get custom view number of gas needs |
3253 goto TFT_warning_gas_needs_att ; - show attention message | 3672 call dive_customview_show ; - draw custom view |
3673 check_gas_needs_att_1: | |
3674 goto TFT_attention_gas_needs ; - show attention message for gas needs and return | |
3254 | 3675 |
3255 ;============================================================================= | 3676 ;============================================================================= |
3256 | 3677 |
3257 IFDEF _external_sensor | 3678 IFDEF _external_sensor |
3258 | 3679 |
3259 check_warn_sensors_disagree: | 3680 check_warn_sensors_disagree: |
3260 incf message_counter,F ; increase counter | 3681 incf message_counter,F ; increase counter |
3261 bsf message_warning ; set warning flag | 3682 bsf message_warning ; show warning sign for sensor disagree |
3262 btfsc o2_sensors_warning ; is it a new warning? | 3683 btfsc o2_sensors_warning ; is it a new warning? |
3263 goto TFT_warning_sensor_disagree ; NO - don't show sensor custom view again, just show sensor disagree warning and return | 3684 goto TFT_warning_sensor_disagree ; NO - don't show sensor custom view again, just show sensor disagree warning and return |
3264 bsf o2_sensors_warning ; YES - memorize it's an old warning now | 3685 bsf o2_sensors_warning ; YES - memorize it's an old warning now |
3265 call show_sensors_custview ; - show sensors custom view | 3686 call show_sensors_custview ; - show sensors custom view |
3266 goto TFT_warning_sensor_disagree ; - show sensor disagree warning and return | 3687 goto TFT_warning_sensor_disagree ; - show warning message for sensor disagree and return |
3267 | 3688 |
3268 ENDIF | 3689 ENDIF |
3269 | 3690 |
3270 ;============================================================================= | 3691 ;============================================================================= |
3271 | 3692 |
3285 ;============================================================================= | 3706 ;============================================================================= |
3286 | 3707 |
3287 check_OC_gas_avail: | 3708 check_OC_gas_avail: |
3288 tstfsz best_gas_number ; is a breathable OC (bailout) gas available? | 3709 tstfsz best_gas_number ; is a breathable OC (bailout) gas available? |
3289 return ; YES (>0) - a breathable gas is available | 3710 return ; YES (>0) - a breathable gas is available |
3290 btfsc bailout_mode ; NO (=0) - in bailout? | 3711 IFDEF _ccr_pscr |
3291 return ; YES - suppress warning | 3712 btfsc bailout_mode ; in bailout? |
3292 incf message_counter,F ; NO - increase counter | 3713 return ; YES - suppress warning |
3293 bsf message_warning ; - set attention flag | 3714 ENDIF |
3294 goto TFT_warning_no_BO_gas ; - show waring (and return) | 3715 incf message_counter,F ; increase counter |
3716 bsf message_warning ; show warning sign for no bailout gas | |
3717 goto TFT_warning_no_BO_gas ; show warning message for no bailout gas and return | |
3295 | 3718 |
3296 | 3719 |
3297 advice_gas_change: | 3720 advice_gas_change: |
3298 bsf message_advice ; show advice sign | 3721 bsf message_advice ; show advice sign |
3299 incf message_counter,F ; increase counter | 3722 incf message_counter,F ; increase counter |
3300 goto TFT_advice_gas_change | 3723 goto TFT_advice_gas_change ; show advice (and return) |
3301 | 3724 |
3302 | 3725 |
3303 global restart_deco_engine | 3726 global restart_deco_engine |
3304 global restart_deco_engine_wo_ceiling | 3727 global restart_deco_engine_wo_ceiling |
3305 restart_deco_engine: | 3728 restart_deco_engine: |
3307 bsf int_O_ceiling+1,char_invalid_flag ; invalidate ceiling (int_O_ceiling has its invalid flag on a char's position!) | 3730 bsf int_O_ceiling+1,char_invalid_flag ; invalidate ceiling (int_O_ceiling has its invalid flag on a char's position!) |
3308 | 3731 |
3309 restart_deco_engine_wo_ceiling: | 3732 restart_deco_engine_wo_ceiling: |
3310 banksel char_O_deco_gas ; switch to bank where the shared "_O_" variables are stored | 3733 banksel char_O_deco_gas ; switch to bank where the shared "_O_" variables are stored |
3311 bsf char_O_deco_gas+0,char_invalid_flag ; invalidate deco data (stop table data) | 3734 bsf char_O_deco_gas+0,char_invalid_flag ; invalidate deco data (stop table data) |
3312 bsf int_O_TTS_norm+1,int_invalid_flag ; invalidate ascent time (normal plan) | 3735 bsf int_O_NDL_norm+1,int_invalid_flag ; invalidate NDL time (normal plan) |
3736 bsf int_O_TTS_norm+1,int_invalid_flag ; invalidate TTS time (normal plan) | |
3737 bsf int_O_TST_norm+1,int_invalid_flag ; invalidate TST time (normal plan) | |
3313 bsf int_O_CNS_norm+1,int_invalid_flag ; invalidate CNS at end of dive in normal plan | 3738 bsf int_O_CNS_norm+1,int_invalid_flag ; invalidate CNS at end of dive in normal plan |
3314 ; restart deco engine: | 3739 |
3315 bcf char_O_deco_status,DECO_COMPLETED_NORM ; eventually clear flag stating completion of normal plan | 3740 restart_deco_engine_wo_norm: |
3316 bsf char_O_deco_status,DECO_COMPLETED_ALT ; fake we came from alternative plan to force normal plan to be done next | 3741 banksel common ; bank to bank common |
3742 bsf request_restart_engine ; request restart of the deco engine | |
3317 | 3743 |
3318 inval_alternative_plan_data: | 3744 inval_alternative_plan_data: |
3319 banksel int_O_TTS_alt ; switch to bank where the shared "_O_" variables are stored | 3745 banksel int_O_TTS_alt ; switch to bank where the shared "_O_" variables are stored |
3320 bsf int_O_TTS_alt+1,int_invalid_flag ; invalidate ascent time (alternative plan) | 3746 bsf int_O_NDL_alt+1,int_invalid_flag ; invalidate NDL time (alternative plan) |
3747 bsf int_O_TTS_alt+1,int_invalid_flag ; invalidate TTS time (alternative plan) | |
3748 bsf int_O_TST_alt+1,int_invalid_flag ; invalidate TST time (alternative plan) | |
3321 bsf int_O_CNS_alt+1,int_invalid_flag ; invalidate CNS at end of dive in alternative plan | 3749 bsf int_O_CNS_alt+1,int_invalid_flag ; invalidate CNS at end of dive in alternative plan |
3322 bsf int_O_gas_need_pres+1,int_invalid_flag ; invalidate ascent gas needs | 3750 bsf int_O_gas_need_pres+1,int_invalid_flag ; invalidate ascent gas needs |
3323 | 3751 |
3324 IFDEF _rx_functions | 3752 IFDEF _rx_functions |
3325 bsf int_O_pressure_need+1,int_not_avail_flag ; invalidate pressure needs to reading 1 (TR functions) | 3753 bsf int_O_pressure_need+1,int_not_avail_flag ; invalidate pressure needs to reading 1 (TR functions) |
3334 ;============================================================================= | 3762 ;============================================================================= |
3335 ; Simulator Mode | 3763 ; Simulator Mode |
3336 ; | 3764 ; |
3337 global do_demo_divemode | 3765 global do_demo_divemode |
3338 do_demo_divemode: | 3766 do_demo_divemode: |
3767 call TFT_ClearScreen ; blank screen | |
3768 | |
3769 ; leaving menu mode, so have option values in EEPROM up-to-date | |
3770 btfsc options_changed ; do the options need to be stored to EEPROM ? | |
3771 call option_check_and_store_all ; YES - check and store all option values in EEPROM | |
3772 bcf options_changed ; clear flag | |
3339 | 3773 |
3340 ; +++ COMMENT OUT FOR TESTING PURPOSE ONLY !!! +++ | 3774 ; +++ COMMENT OUT FOR TESTING PURPOSE ONLY !!! +++ |
3341 bsf simulatormode ; will restore tissue pressures and CNS value after simulator use | 3775 bsf simulatormode ; restore tissue pressures and CNS value after finishing simulator use |
3342 ; +++ DO NOT COMMENT OUT IN OPERATIONAL USE !!! +++ | 3776 ; +++ DO NOT COMMENT OUT IN OPERATIONAL USE !!! +++ |
3343 | 3777 |
3344 call TFT_ClearScreen ; blank screen | |
3345 call option_save_all ; save all settings into EEPROM before starting simulation | |
3346 call deco_push_tissues_to_vault ; back-up the tissue pressures (C-code) | 3778 call deco_push_tissues_to_vault ; back-up the tissue pressures (C-code) |
3347 banksel common ; back to bank common | 3779 banksel common ; back to bank common |
3348 | 3780 |
3349 ; set simulated target depth | 3781 ; set simulated target depth |
3350 movff char_I_bottom_depth,simulatormode_depth | 3782 movff char_I_bottom_depth,simulatormode_depth |