Mercurial > public > hwos_code
comparison src/divemode.asm @ 634:4050675965ea
3.10 stable release
author | heinrichsweikamp |
---|---|
date | Tue, 28 Apr 2020 17:34:31 +0200 |
parents | 185ba2f91f59 |
children | 9a64914a8fca |
comparison
equal
deleted
inserted
replaced
633:690c48db7b5b | 634:4050675965ea |
---|---|
1 ;============================================================================= | 1 ;============================================================================= |
2 ; | 2 ; |
3 ; File divemode.asm combined next generation V3.08.8 | 3 ; File divemode.asm * combined next generation V3.09.5 |
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 menu_draw_cursor_dive | |
34 extern init_recording_params | 35 extern init_recording_params |
35 extern option_check_and_store_all | 36 extern option_check_and_store_all |
36 | 37 |
37 IFDEF _compass | 38 IFDEF _compass |
38 extern TFT_dive_compass_heading | 39 extern TFT_dive_compass_heading |
39 ENDIF | 40 ENDIF |
40 | 41 |
41 IFDEF _cave_mode | 42 IFDEF _cave_mode |
42 extern do_main_cavemenu | 43 extern do_main_cavemenu |
43 ENDIF | 44 ENDIF |
45 | |
44 | 46 |
45 ;---- Private local Variables ------------------------------------------------- | 47 ;---- Private local Variables ------------------------------------------------- |
46 | 48 |
47 CBLOCK local1 ; max size is 16 Byte !!! | 49 CBLOCK local1 ; max size is 16 Byte !!! |
48 sensor_setpoint ; sensor ppo2 in 0.01bar for deco routine | 50 sensor_setpoint ; sensor ppo2 in 0.01bar for deco routine |
61 ENDC ; used: 14 byte, remaining: 2 byte | 63 ENDC ; used: 14 byte, remaining: 2 byte |
62 | 64 |
63 CBLOCK local2 ; max size is 16 Byte !!! | 65 CBLOCK local2 ; max size is 16 Byte !!! |
64 pressure_rel_accu_trip:4 ; pressure accumulator for calculating the resettable average depth | 66 pressure_rel_accu_trip:4 ; pressure accumulator for calculating the resettable average depth |
65 pressure_rel_accu_total:4 ; pressure accumulator for calculating the total dive average depth | 67 pressure_rel_accu_total:4 ; pressure accumulator for calculating the total dive average depth |
66 xmitter_flags_stat ; pressure transmitter flags for status | |
67 xmitter_flags_mesg ; pressure transmitter flags for messages | |
68 ppO2_min:2 ; used in search for best gas/dil: minimum ppO2 required | 68 ppO2_min:2 ; used in search for best gas/dil: minimum ppO2 required |
69 ppO2_max_default:2 ; used in search for best gas/dil: default maximum ppO2 | 69 ppO2_max_default:2 ; used in search for best gas/dil: default maximum ppO2 |
70 ppO2_max_deco:2 ; used in search for best gas/dil: deco maximum ppO2 | 70 ppO2_max_deco:2 ; used in search for best gas/dil: deco maximum ppO2 |
71 ENDC ; used: 16 byte, remaining: 0 byte ==> FULL | 71 ENDC ; used: 14 byte, remaining: 2 byte |
72 | 72 |
73 | 73 |
74 ;---- Private local Flags ---------------------------------------------------- | 74 ;---- Private local Flags ---------------------------------------------------- |
75 | 75 |
76 ; TFT_output_flags_1 - phase 1: every second - before deco calculations, all modes | 76 ; TFT_output_flags_1 - phase 1: every second - before deco calculations, all modes |
112 #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 |
113 #DEFINE FLAG_TFT_velocity_clear TFT_output_flags_4,6 ; =1: clear vertical velocity | 113 #DEFINE FLAG_TFT_velocity_clear TFT_output_flags_4,6 ; =1: clear vertical velocity |
114 ; TFT_output_flags_4,7 ; --- unused | 114 ; TFT_output_flags_4,7 ; --- unused |
115 | 115 |
116 | 116 |
117 ; Pressure Transmitter Status | |
118 #DEFINE transmitter1_lost xmitter_flags_stat,0 ; =1: transmitter 1 lost is an old message | |
119 #DEFINE transmitter1_battery xmitter_flags_stat,1 ; =1: transmitter 1 battery low is an old message | |
120 #DEFINE transmitter1_pres_warn xmitter_flags_stat,2 ; =1: transmitter 1 pressure warning is an old message | |
121 #DEFINE transmitter1_pres_att xmitter_flags_stat,3 ; =1: transmitter 1 pressure attention is an old message | |
122 #DEFINE transmitter2_lost xmitter_flags_stat,4 ; =1: transmitter 2 lost is an old message | |
123 #DEFINE transmitter2_battery xmitter_flags_stat,5 ; =1: transmitter 2 battery low is an old message | |
124 #DEFINE transmitter2_pres_warn xmitter_flags_stat,6 ; =1: transmitter 2 pressure warning is an old message | |
125 #DEFINE transmitter2_pres_att xmitter_flags_stat,7 ; =1: transmitter 2 pressure attention is an old message | |
126 | |
127 ; Pressure Transmitter Messages | |
128 #DEFINE pres_customview_shown xmitter_flags_mesg,0 ; =1: pressure readings custom view has been shown before | |
129 #DEFINE show_transmitter_attention xmitter_flags_mesg,1 ; =1: show transmitter attention | |
130 #DEFINE show_pres_warning xmitter_flags_mesg,2 ; =1: show transmitter pressure warning | |
131 #DEFINE show_pres_attention xmitter_flags_mesg,3 ; =1: show transmitter pressure attention | |
132 ; xmitter_flags_mesg,4 ; --- unused | |
133 ; xmitter_flags_mesg,5 ; --- unused | |
134 ; xmitter_flags_mesg,6 ; --- unused | |
135 ; xmitter_flags_mesg,7 ; --- unused | |
136 | |
137 ; various Flags | 117 ; various Flags |
138 #DEFINE new_deco_data_avail DM_flags_local,0 ; =1: new NDL or deco data available | 118 #DEFINE new_deco_data_avail DM_flags_local,0 ; =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 | 119 #DEFINE update_menu DM_flags_local,1 ; =1: redraw the dive menu |
140 #DEFINE update_menu DM_flags_local,2 ; =1: redraw the dive menu | 120 #DEFINE FLAG_SP2_used DM_flags_local,2 ; =1: setpoint 2 has been auto-selected already |
141 #DEFINE FLAG_SP2_used DM_flags_local,3 ; =1: setpoint 2 has been auto-selected already | 121 #DEFINE FLAG_SP3_used DM_flags_local,3 ; =1: setpoint 3 has been auto-selected already |
142 #DEFINE FLAG_SP3_used DM_flags_local,4 ; =1: setpoint 3 has been auto-selected already | 122 #DEFINE FLAG_SP4_used DM_flags_local,4 ; =1: setpoint 4 has been auto-selected already |
143 #DEFINE FLAG_SP4_used DM_flags_local,5 ; =1: setpoint 4 has been auto-selected already | 123 #DEFINE FLAG_SP5_used DM_flags_local,5 ; =1: setpoint 5 has been auto-selected already |
144 #DEFINE FLAG_SP5_used DM_flags_local,6 ; =1: setpoint 5 has been auto-selected already | 124 ; DM_flags_local,6 ; --- unused |
145 ; DM_flags_local,7 ; --- unused | 125 ; DM_flags_local,7 ; --- unused |
146 | 126 |
147 | 127 |
148 dmode CODE | |
149 | |
150 ;============================================================================= | 128 ;============================================================================= |
151 | 129 dmode1 CODE |
130 ;============================================================================= | |
131 | |
132 | |
133 ;----------------------------------------------------------------------------- | |
134 ; Entry Point for Dive Mode | |
135 ; | |
152 global diveloop | 136 global diveloop |
153 diveloop: | 137 diveloop: |
154 clrf STKPTR ; clear return addresses stack | 138 clrf STKPTR ; clear return addresses stack |
155 | 139 |
156 ; start with a clean time base | 140 ; start with a clean time base |
168 clrf DM_flags_layout2 ; clear all flags for display control / layout (2) | 152 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) | 153 clrf DM_flags_layout3 ; clear all flags for display control / layout (3) |
170 clrf DM_flags_message ; clear all flags for display control / messages | 154 clrf DM_flags_message ; clear all flags for display control / messages |
171 clrf DM_flags_gas_dil ; clear all flags for display control / gases, diluents, depth | 155 clrf DM_flags_gas_dil ; clear all flags for display control / gases, diluents, depth |
172 | 156 |
173 bcf dive_main_menu ; clear dive main menu flag | 157 clrf DM_flags_advc_det ; clear all flags for advices detection |
174 bcf dive_options_menu ; clear dive options menu flag | 158 clrf DM_flags_advc_ack ; clear all flags for advices acknowledged |
159 | |
160 clrf DM_flags_att1_det ; clear all flags for attentions detection | |
161 clrf DM_flags_att2_det ; ... | |
162 clrf DM_flags_att3_det ; ... | |
163 | |
164 clrf DM_flags_att1_ack ; clear all flags for attentions acknowledged | |
165 clrf DM_flags_att2_ack ; ... | |
166 clrf DM_flags_att3_ack ; ... | |
167 | |
168 clrf DM_flags_war1_det ; clear all flags for warnings detection | |
169 clrf DM_flags_war2_det ; ... | |
170 | |
171 clrf DM_flags_war1_ack ; clear all flags for warnings acknowledged | |
172 clrf DM_flags_war2_ack ; ... | |
173 | |
174 clrf DM_flags_shown1 ; arm auto show-up of custom views | |
175 clrf DM_flags_shown2 ; ... | |
176 clrf DM_flags_shown3 ; ... | |
177 | |
178 bcf dive_main_menu ; clear dive main menu flag | |
179 bcf dive_pre_menu ; clear dive pre-menu flag | |
175 | 180 |
176 ; reset local flags | 181 ; reset local flags |
177 clrf TFT_output_flags_1 ; clear all flags for TFT output phase 1 | 182 clrf TFT_output_flags_1 ; clear all flags for TFT output phase 1 |
178 clrf TFT_output_flags_2 ; clear all flags for TFT output phase 2 | 183 clrf TFT_output_flags_2 ; clear all flags for TFT output phase 2 |
179 clrf TFT_output_flags_3 ; clear all flags for TFT output phase 3 | 184 clrf TFT_output_flags_3 ; clear all flags for TFT output phase 3 |
180 clrf TFT_output_flags_4 ; clear all flags for TFT output phase 4 | 185 clrf TFT_output_flags_4 ; clear all flags for TFT output phase 4 |
181 clrf xmitter_flags_stat ; clear all pressure transmitter status flags | |
182 clrf xmitter_flags_mesg ; clear all pressure transmitter message flags | |
183 clrf DM_flags_local ; clear all the various other flags, too | 186 clrf DM_flags_local ; clear all the various other flags, too |
184 | 187 |
185 ; configure screen layout (all flags were cleared above) | |
186 TSTOSC opt_layout ; alternative layout enabled? | |
187 bsf alt_layout_active ; YES - start with alternative layout | |
188 | |
189 ; configure tissue graphics (all flags were cleared above) | |
190 TSTOSS opt_tissue_graphics ; shall show: 0= pres+sat, 1= N2+He | |
191 bsf tissue_graphic_layout ; YES - show press+sat | |
192 | |
193 TSTOSC char_I_model ; GF factors enabled? | |
194 bsf tissue_graphic_gf ; YES - show GF lines | |
195 | |
196 | |
197 ; boot tasks for all modes | 188 ; boot tasks for all modes |
198 call diveloop_boot | 189 call diveloop_boot ; initialize dive mode |
199 | 190 |
200 ; startup tasks for all modes | 191 ; startup tasks for all modes |
201 ; clrf CCP1CON ; stop PWM | |
202 ; bcf PORTC,2 ; pull PWM output to GND | |
203 ; clrf CCPR1L ; backlight off | |
204 call TFT_boot ; initialize TFT (includes clear screen) | 192 call TFT_boot ; initialize TFT (includes clear screen) |
193 call TFT_load_dive_color_pallet ; load dive color pallet | |
205 call TFT_show_divemode_mask ; display static dive mode mask | 194 call TFT_show_divemode_mask ; display static dive mode mask |
206 call TFT_Display_FadeIn ; dim up the display | 195 call TFT_Display_FadeIn ; dim up the display |
207 | 196 |
208 ; reload and redraw last custom view | 197 ; arm dive start timer |
209 movff customview_divemode,active_customview | |
210 bsf FLAG_TFT_customview_callup | |
211 | |
212 bcf divetime_longer_1min ; the dive has just begun | 198 bcf divetime_longer_1min ; the dive has just begun |
213 btfsc FLAG_apnoe_mode ; in apnea mode? | 199 btfsc FLAG_apnoe_mode ; in apnea mode? |
214 bsf divetime_longer_1min ; YES - force dive to have lasted for longer than 1 minute already | 200 bsf divetime_longer_1min ; YES - force dive to have lasted for longer than 1 minute already |
215 btfsc sensor_override_active ; in simulator mode? | 201 btfsc sensor_override_active ; in simulator mode? |
216 bsf divetime_longer_1min ; YES - force dive to have lasted for longer than 1 minute already | 202 bsf divetime_longer_1min ; YES - force dive to have lasted for longer than 1 minute already |
217 | 203 |
204 ; initiate initial display outputs | |
218 bsf trigger_pres_cur_changed ; flag that the pressures have changed to have all data... | 205 bsf trigger_pres_cur_changed ; flag that the pressures have changed to have all data... |
219 bsf trigger_pres_max_changed ; ... written to the display on the first output round | 206 bsf trigger_pres_max_changed ; ... written to the display on the first output round |
220 | |
221 bsf trigger_temp_changed ; flag that the temperature has changed to have the temperature ... | 207 bsf trigger_temp_changed ; flag that the temperature has changed to have the temperature ... |
222 ; ... written to the display on the first output round | 208 ; ... written to the display on the first output round |
223 | |
224 bsf new_deco_data_avail ; flag that new deco engine results are available to have the initial data ... | 209 bsf new_deco_data_avail ; flag that new deco engine results are available to have the initial data ... |
225 ; ... written to the display on the first output round | 210 ; ... written to the display on the first output round |
226 | 211 |
227 ; clear the resettable average depth | 212 ; initialize the resettable average depth |
228 call clear_resettable_average_depth | 213 call resettable_average_depth_init |
229 | 214 |
230 ; ; initial caching of new absolute and relative pressure, ISR-safe 2 byte copies | 215 ; reload and redraw last custom view |
231 ; SMOVII pressure_abs, pressure_abs_cached | 216 movff customview_divemode,active_customview |
232 ; SMOVII pressure_rel_cur,pressure_rel_cur_cached | 217 bsf FLAG_TFT_customview_callup |
233 | |
234 ; ; initial transfer of absolute pressure to deco engine | |
235 ; MOVII pressure_abs_cached,int_I_pres_respiration | |
236 | 218 |
237 btfsc FLAG_apnoe_mode ; in apnoe mode? | 219 btfsc FLAG_apnoe_mode ; in apnoe mode? |
238 bra diveloop_1 ; YES - done with initialization | 220 bra diveloop_1 ; YES - done with initialization |
239 btfsc FLAG_gauge_mode ; NO - in gauge mode? | 221 btfsc FLAG_gauge_mode ; NO - in gauge mode? |
240 bra diveloop_1 ; YES - done with initialization | 222 bra diveloop_1 ; YES - done with initialization |
241 bsf FLAG_TFT_display_ndl_mask ; NO - in deco mode then, display NDL mask | 223 bsf FLAG_TFT_display_ndl_mask ; NO - request initial display of NDL mask |
242 bsf FLAG_TFT_active_gas_divemode; - request initial display of gas and setpoint | 224 bsf FLAG_TFT_active_gas_divemode; - request initial display of gas and setpoint |
243 | 225 |
244 diveloop_1: | 226 diveloop_1: |
245 btfsc reset_timebase ; has the ISR confirmed reset of the timebase meanwhile? | 227 btfsc reset_timebase ; has the ISR confirmed reset of the timebase meanwhile? |
246 bra $-2 ; NO - not yet, loop waiting for confirmation before entering the dive loop | 228 bra $-2 ; NO - not yet, loop waiting for confirmation before entering the dive loop |
247 | 229 ;bra diveloop_loop ; YES - enter the dive loop |
230 | |
231 | |
232 ;----------------------------------------------------------------------------- | |
233 ; Dive Mode Mail Loop | |
234 ; | |
248 diveloop_loop: | 235 diveloop_loop: |
249 ; ### the dive loop starts here ### | |
250 btfsc trigger_full_second ; new 1/1 second? | 236 btfsc trigger_full_second ; new 1/1 second? |
251 bra diveloop_loop_2 ; YES - continue with tasks every 1/1 second | 237 bra diveloop_loop_2 ; YES - continue with tasks every 1/1 second |
252 btfsc trigger_half_second ; NO - new 1/2 second? | 238 btfsc trigger_half_second ; NO - new 1/2 second? |
253 bra diveloop_loop_1 ; YES - continue with tasks every 1/2 second | 239 bra diveloop_loop_1 ; YES - continue with tasks every 1/2 second |
254 | 240 |
341 diveloop_loop_4: | 327 diveloop_loop_4: |
342 ; continue tasks every 1/1 second | 328 ; continue tasks every 1/1 second |
343 | 329 |
344 IFDEF _external_sensor | 330 IFDEF _external_sensor |
345 btfsc FLAG_ccr_mode ; in CCR mode? | 331 btfsc FLAG_ccr_mode ; in CCR mode? |
346 rcall calc_deko_divemode_sensor ; YES - do sensor data acquisition if applicable | 332 rcall calc_deko_divemode_sensor ; YES - process sensor readings |
347 btfsc FLAG_pscr_mode ; in pSCR mode? | 333 btfsc FLAG_pscr_mode ; in pSCR mode? |
348 rcall calc_deko_divemode_sensor ; YES - do sensor data acquisition if applicable | 334 rcall calc_deko_divemode_sensor ; YES - process sensor readings |
349 ENDIF | 335 ENDIF |
350 | 336 |
351 IFDEF _cave_mode | 337 IFDEF _cave_mode |
352 btfss cave_mode ; cave mode switched on? | 338 btfss cave_mode ; cave mode switched on? |
353 bra diveloop_loop_4a ; NO - no backtracking depth recording | 339 bra diveloop_loop_4a ; NO - no backtracking depth recording |
405 bra diveloop_loop_7 ; YES - skip deco calculations | 391 bra diveloop_loop_7 ; YES - skip deco calculations |
406 | 392 |
407 call callup_deco_engine ; ##### manage and invoke the deco calculation engine ##### | 393 call callup_deco_engine ; ##### manage and invoke the deco calculation engine ##### |
408 | 394 |
409 btfsc new_deco_data_avail ; new NDL or deco data available? | 395 btfsc new_deco_data_avail ; new NDL or deco data available? |
410 call show_new_deco_data ; YES - update the display and update the decostop_active flag | 396 call show_new_deco_data ; YES - set-up display update requests |
411 | 397 |
412 btfsc decostop_active ; in deco mode? | 398 btfsc decostop_active ; in deco mode? |
413 bsf FLAG_TFT_display_deco ; YES - update deco stop depth & time every second because of depth-dependent color-coding | 399 bsf FLAG_TFT_display_deco ; YES - update deco stop depth & time every second because of depth-dependent color-coding |
414 | 400 |
415 bsf FLAG_TFT_depth_current ; set flag to display depth (in next round, needed in deco modes irrespectively of a pressure change for color-coding and blinking effects) | 401 bsf FLAG_TFT_depth_current ; set flag to display depth (in next round, needed in deco modes irrespectively of a pressure change for color-coding and blinking effects) |
433 rcall check_deco_states ; check and lock if in deco and in the deco stops region | 419 rcall check_deco_states ; check and lock if in deco and in the deco stops region |
434 rcall TFT_output_3 ; do display updates | 420 rcall TFT_output_3 ; do display updates |
435 | 421 |
436 diveloop_loop_10: | 422 diveloop_loop_10: |
437 ; common tasks every 1/1 second | 423 ; common tasks every 1/1 second |
438 rcall timeout_divemode ; check for timeout condition | 424 rcall timeout_divemode ; check for timeout conditions |
439 call check_dive_modes ; test if depth still deeper than threshold | 425 call check_dive_modes_dive ; test if depth still deeper than threshold |
440 | 426 |
441 btfsc trigger_full_minute ; has next minute begun? | 427 btfsc trigger_full_minute ; has next minute begun? |
442 rcall update_divemode60 ; YES - update clock, etc. | 428 rcall update_divemode60 ; YES - update clock, etc. |
443 | 429 |
444 btfss FLAG_oc_mode ; are we in OC mode? | 430 btfss FLAG_oc_mode ; are we in OC mode? |
449 | 435 |
450 rcall TFT_output_4 ; do display updates | 436 rcall TFT_output_4 ; do display updates |
451 | 437 |
452 ; tasks every round, every mode | 438 ; tasks every round, every mode |
453 diveloop_loop_11: | 439 diveloop_loop_11: |
454 call test_switches_divemode ; check switches in dive mode | 440 call test_switches_divemode ; check switches, in case branch into menu processor |
455 bra diveloop_loop_12 | 441 bra diveloop_loop_12 ; continue the dive loop |
456 | 442 |
443 | |
444 ; **** jump-in when returning from menu processor **** | |
445 ; | |
446 global divemode_option_divemenu_return | |
447 divemode_option_divemenu_return: | |
448 clrf STKPTR ; reset the stack | |
449 call menu_draw_cursor_dive ; show the cursor | |
450 bsf dive_main_menu ; set main menu is shown now | |
451 clrf active_premenu ; set pre-menu is not shown any more | |
452 bcf safety_stop_active ; set safety stop is not shown any more | |
453 movlw divemode_timeout_mainmenu ; get timeout for main menu | |
454 call restart_timeout_time ; restart the timeout | |
455 bra diveloop_loop_12 ; continue the dive loop | |
456 | |
457 | |
458 ; **** jump-in when returning from dive mode menu **** | |
459 ; | |
457 global diveloop_menu_exit | 460 global diveloop_menu_exit |
458 diveloop_menu_exit: ; jump-in from menu exit | 461 diveloop_menu_exit: |
459 bsf FLAG_TFT_temperature ; restore temperature display or resettable dive time (was overwritten by menu) | 462 clrf STKPTR ; reset the stack |
463 call divemenu_cleanup ; clean up menu area and restore dive data | |
464 ;bra diveloop_loop_12 ; continue the dive loop | |
465 | |
460 | 466 |
461 diveloop_loop_12: | 467 diveloop_loop_12: |
462 bsf FLAG_TFT_active_gas_divemode; redraw gas and setpoint (eventually needed to restore the "Bailout" text) | 468 bsf FLAG_TFT_active_gas_divemode; redraw gas and setpoint (eventually needed to restore the "Bailout" text) |
463 | 469 |
464 btfsc request_next_custview ; shall show next custom view? | 470 btfsc request_next_custview ; shall show next custom view? |
465 call dive_customview_toggle ; YES - show next custom view (and delete this flag) | 471 call dive_customview_toggle ; YES - show next custom view |
466 | 472 |
467 btfsc request_gas_change ; shall change gas? | 473 btfsc request_gas_change ; shall change gas? |
468 call gas_switch_common ; YES | 474 call gas_switch_common ; YES |
469 | 475 |
470 btfsc request_gas_update ; shall update the gases? | 476 btfsc request_gas_update ; shall update the gases? |
471 call gas_update_common ; YES | 477 call gas_update_common ; YES |
472 | 478 |
473 btfsc request_toggle_GF ; shall toggle GF/aGF? | 479 btfsc request_toggle_GF ; shall toggle GF/aGF? |
474 rcall divemodemode_togglegf ; YES | 480 call divemodemode_togglegf ; YES |
475 | 481 |
476 IFDEF _cave_mode | 482 IFDEF _cave_mode |
477 btfsc request_cave_off_turned ; shall switch cave mode off and set the dive as turned? | 483 btfsc request_cave_off_turned ; shall switch cave mode off and set the dive as turned? |
478 rcall cavemode_switch_off_turned ; YES | 484 rcall cavemode_switch_off_turned ; YES |
479 | 485 |
508 IFDEF _screendump | 514 IFDEF _screendump |
509 btfsc screen_dump_avail ; screen dump function enabled? | 515 btfsc screen_dump_avail ; screen dump function enabled? |
510 call TFT_dump_screen_check ; YES - check if requested and do it | 516 call TFT_dump_screen_check ; YES - check if requested and do it |
511 ENDIF | 517 ENDIF |
512 | 518 |
513 bra diveloop_loop ; loop in dive mode | 519 bra diveloop_loop ; do next loop in dive mode |
514 | 520 |
515 ;-------------------------------------------------------------------------------------------------------- | 521 |
516 | 522 ;----------------------------------------------------------------------------- |
523 ; Dive Mode Tasks every 1/1 Minute | |
524 ; | |
525 update_divemode60: | |
526 bcf trigger_full_minute ; clear flag | |
527 | |
528 call get_battery_voltage ; get battery voltage | |
529 btfss battery_low_condition ; battery low condition detected? | |
530 bra update_divemode60_1 ; NO - skip next | |
531 movlw d'7' ; YES - set type of alarm = battery low | |
532 movwf alarm_type ; - copy to alarm register | |
533 bsf event_occured ; - set event flag | |
534 movlw .0 ; - coding of brightness level ECO | |
535 movff WREG,opt_brightness ; - set brightness to ECO | |
536 | |
537 update_divemode60_1: | |
538 ; max allowed runtime in simulator is 254 minutes in | |
539 ; order for the tissue calculation catch-up to work! | |
540 | |
541 btfss sensor_override_active ; in simulator mode? | |
542 return ; NO - done | |
543 movlw simulator_timeout_normal ; YES - set simulation timeout | |
544 IFDEF _cave_mode | |
545 TSTOSC opt_cave_mode ; - cave mode switched on? | |
546 movlw simulator_timeout_cave ; YES - replace with cave mode simulation timeout | |
547 ENDIF | |
548 cpfsgt counted_divetime_mins+0 ; - timeout? | |
549 return ; NO - done | |
550 IFDEF _DEBUG | |
551 return ; YES - but we do not care in debug mode... | |
552 ELSE | |
553 goto divemode_option_sim_quit ; YES - set depth to 0 m and return | |
554 ENDIF | |
555 | |
556 | |
557 ;----------------------------------------------------------------------------- | |
558 ; Helper Function - set-up Display Update Requests | |
559 ; | |
560 show_new_deco_data: | |
561 bcf new_deco_data_avail ; reset flag for new NDL or deco data available | |
562 movff char_O_deco_info,WREG ; get the deco info vector | |
563 btfsc WREG,deco_stops_norm ; deco stops found? | |
564 bra show_new_deco_data_deco ; YES - in deco | |
565 ;bra show_new_deco_data_ndl ; NO - within NDL | |
566 | |
567 show_new_deco_data_ndl: ; within NDL | |
568 btfsc decostop_active ; been in deco mode before? | |
569 bsf FLAG_TFT_clear_deco_data ; YES - clear old deco data | |
570 btfsc decostop_active ; been in deco mode before? | |
571 bsf FLAG_TFT_display_ndl_mask ; YES - display NDL data mask | |
572 bcf decostop_active ; clear flag for been in deco mode before | |
573 bsf FLAG_TFT_display_ndl ; display NDL time | |
574 return ; done | |
575 | |
576 show_new_deco_data_deco: ; in deco | |
577 btfss decostop_active ; been in deco mode before? | |
578 bsf FLAG_TFT_clear_deco_data ; NO - clear old NDL data | |
579 btfss decostop_active ; been in deco mode before? | |
580 bsf FLAG_TFT_display_deco_mask ; NO - display deco data mask | |
581 bsf decostop_active ; set flag for being in deco mode | |
582 bsf FLAG_TFT_display_tts ; display TTS time (display of stop data is managed separately) | |
583 return ; done | |
584 | |
585 | |
586 ;----------------------------------------------------------------------------- | |
587 ; Helper Function - do all Phase 1 Display Outputs | |
588 ; | |
517 TFT_output_1: ; every second - before deco calculations, all mode | 589 TFT_output_1: ; every second - before deco calculations, all mode |
518 btfsc FLAG_TFT_clear_apnoe_surface ; shall clear apnoe mode surface data from screen? | 590 btfsc FLAG_TFT_clear_apnoe_surface ; shall clear apnoe mode surface data from screen? |
519 call TFT_clear_apnoe_surface ; YES - clear apnoe mode surface data from screen | 591 call TFT_clear_apnoe_surface ; YES - clear apnoe mode surface data from screen |
520 | 592 |
521 btfsc FLAG_TFT_depth_current ; shall show depth? | 593 btfsc FLAG_TFT_depth_current ; shall show depth? |
535 call TFT_show_apnoe_times ; YES - show apnoe dive time? | 607 call TFT_show_apnoe_times ; YES - show apnoe dive time? |
536 | 608 |
537 clrf TFT_output_flags_1 ; mark all TFT updates done | 609 clrf TFT_output_flags_1 ; mark all TFT updates done |
538 return ; done | 610 return ; done |
539 | 611 |
612 | |
613 ;----------------------------------------------------------------------------- | |
614 ; Helper Function - do all Phase 2 Display Outputs | |
615 ; | |
540 TFT_output_2: ; every second - before deco calculations, deco modes only | 616 TFT_output_2: ; every second - before deco calculations, deco modes only |
541 btfsc FLAG_TFT_divemode_mask ; shall re-draw mask? | 617 btfsc FLAG_TFT_divemode_mask ; shall re-draw mask? |
542 call TFT_show_divemode_mask ; YES - re-draw mask | 618 call TFT_show_divemode_mask ; YES - re-draw mask |
543 btfsc FLAG_TFT_divetime ; shall show dive time? | 619 btfsc FLAG_TFT_divetime ; shall show dive time? |
544 call TFT_show_divetime ; YES - show dive time | 620 call TFT_show_divetime ; YES - show dive time |
547 btfsc FLAG_TFT_safety_stop_clear ; shall clear safety stop? | 623 btfsc FLAG_TFT_safety_stop_clear ; shall clear safety stop? |
548 call TFT_safety_stop_clear ; YES - clear safety stop | 624 call TFT_safety_stop_clear ; YES - clear safety stop |
549 clrf TFT_output_flags_2 ; mark all TFT updates done | 625 clrf TFT_output_flags_2 ; mark all TFT updates done |
550 goto dive_customview_second ; do every-second tasks for the custom view area (in sync with the dive time) and return | 626 goto dive_customview_second ; do every-second tasks for the custom view area (in sync with the dive time) and return |
551 | 627 |
628 | |
629 ;----------------------------------------------------------------------------- | |
630 ; Helper Function - do all Phase 3 Display Outputs | |
631 ; | |
552 TFT_output_3: ; every second - after deco calculations, deco modes only | 632 TFT_output_3: ; every second - after deco calculations, deco modes only |
553 btfsc FLAG_TFT_clear_deco_data ; shall clear deco data (NDL or stop & TTS)? | 633 btfsc FLAG_TFT_clear_deco_data ; shall clear deco data (NDL or stop & TTS)? |
554 call TFT_clear_deco_data ; YES - clear deco data (NDL or stop & TTS) | 634 call TFT_clear_deco_data ; YES - clear deco data (NDL or stop & TTS) |
555 btfsc FLAG_TFT_display_ndl_mask ; shall show NDL mask? | 635 btfsc FLAG_TFT_display_ndl_mask ; shall show NDL mask? |
556 call TFT_show_ndl_mask ; YES - show NDL mask | 636 call TFT_show_ndl_mask ; YES - show NDL mask |
563 btfsc FLAG_TFT_display_tts ; shall show deco TTS? | 643 btfsc FLAG_TFT_display_tts ; shall show deco TTS? |
564 call TFT_show_tts ; YES - show deco TTS | 644 call TFT_show_tts ; YES - show deco TTS |
565 clrf TFT_output_flags_3 ; mark all TFT updates done | 645 clrf TFT_output_flags_3 ; mark all TFT updates done |
566 return ; done | 646 return ; done |
567 | 647 |
648 | |
649 ;----------------------------------------------------------------------------- | |
650 ; Helper Function - do all Phase 4 Display Outputs | |
651 ; | |
568 TFT_output_4: ; every second - after deco calculations, all modes | 652 TFT_output_4: ; every second - after deco calculations, all modes |
569 btfsc FLAG_TFT_customview_callup ; shall show a custom view? | 653 btfsc FLAG_TFT_customview_callup ; shall show a custom view? |
570 call dive_customview_callup ; YES - show a custom view | 654 call dive_customview_callup ; YES - show a custom view |
571 btfsc FLAG_TFT_velocity_show ; shall show vertical velocity? | 655 btfsc FLAG_TFT_velocity_show ; shall show vertical velocity? |
572 call TFT_velocity_show ; YES - show vertical velocity | 656 call TFT_velocity_show ; YES - show vertical velocity |
581 btfsc FLAG_TFT_message_clear_2nd ; shall clear 2nd row of message area? | 665 btfsc FLAG_TFT_message_clear_2nd ; shall clear 2nd row of message area? |
582 call TFT_clear_message_window_row2 ; YES - clear 2nd row of message area | 666 call TFT_clear_message_window_row2 ; YES - clear 2nd row of message area |
583 clrf TFT_output_flags_4 ; mark all TFT updates done | 667 clrf TFT_output_flags_4 ; mark all TFT updates done |
584 return ; done | 668 return ; done |
585 | 669 |
586 ;-------------------------------------------------------------------------------------------------------- | 670 |
587 | 671 ;----------------------------------------------------------------------------- |
672 ; Apnoe Mode Tasks | |
673 ; | |
588 divemode_apnoe_tasks: ; 1 sec. apnoe tasks | 674 divemode_apnoe_tasks: ; 1 sec. apnoe tasks |
589 bsf FLAG_TFT_apnoe_divetime ; show apnoe dive times (current/last dive and total) | 675 bsf FLAG_TFT_apnoe_divetime ; show apnoe dive times (current/last dive and total) |
590 btfsc apnoe_at_surface ; at the surface? | 676 btfsc apnoe_at_surface ; at the surface? |
591 bra divemode_apnoe_tasks_surf ; YES - at the surface | 677 bra divemode_apnoe_tasks_surf ; YES - at the surface |
592 ;bra divemode_apnoe_tasks_dive ; NO - in dive phase | 678 ;bra divemode_apnoe_tasks_dive ; NO - in dive phase |
604 bsf FLAG_TFT_depth_maximum_apnoe ; show max. depth of last dive | 690 bsf FLAG_TFT_depth_maximum_apnoe ; show max. depth of last dive |
605 bsf FLAG_TFT_depth_maximum ; show max. depth of all dives | 691 bsf FLAG_TFT_depth_maximum ; show max. depth of all dives |
606 ;bra apnoe_calc_maxdepth ; calculate overall max. depth and return | 692 ;bra apnoe_calc_maxdepth ; calculate overall max. depth and return |
607 | 693 |
608 | 694 |
695 ;----------------------------------------------------------------------------- | |
696 ; Helper Function - calculate Apnoe Mode overall maximum Depth | |
697 ; | |
609 global apnoe_calc_maxdepth | 698 global apnoe_calc_maxdepth |
610 apnoe_calc_maxdepth: | 699 apnoe_calc_maxdepth: |
611 MOVII apnoe_max_pressure, sub_a ; get max depth from all dives to far | 700 MOVII apnoe_max_pressure, sub_a ; get max depth from all dives to far |
612 MOVII pressure_rel_max_cached,sub_b ; get max depth of last dive | 701 MOVII pressure_rel_max_cached,sub_b ; get max depth of last dive |
613 call cmpU16 ; sub_a - sub_b = apnoe_max_pressure - pressure_rel_max_cached | 702 call cmpU16 ; sub_a - sub_b = apnoe_max_pressure - pressure_rel_max_cached |
614 btfss neg_flag ; last dive deeper than all the others before? | 703 btfss neg_flag ; last dive deeper than all the others before? |
615 return ; NO - done | 704 return ; NO - done |
616 MOVII pressure_rel_max_cached,apnoe_max_pressure ; YES - store new overall max depth | 705 MOVII pressure_rel_max_cached,apnoe_max_pressure ; YES - store new overall max depth |
617 return ; - done | 706 return ; - done |
618 | 707 |
619 ; -------------------------------------------------------------------------------------- | 708 |
620 | 709 ;----------------------------------------------------------------------------- |
621 ; Manage and invoke the Deco Calculation Engine | 710 ; Manage and invoke the Deco Calculation Engine |
622 ; ============================================= | 711 ; |
712 callup_deco_engine: | |
713 | |
623 ; Any reconfiguration done here only affects the deco calculation (prediction), not the | 714 ; 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 | 715 ; 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 | 716 ; in case of a gas change, in case of a real bailout, or in case a switchback to setpoint |
626 ; or sensor is done. | 717 ; or sensor is done. |
627 ; On event of a gas change, a diluent change, a real bailout, or a switchback, the settings | 718 ; On event of a gas change, a diluent change, a real bailout, or a switchback, the settings |
629 ; real tissues. This is all done in the function 'gas_switch_common' which is triggered by | 720 ; real tissues. This is all done in the function 'gas_switch_common' which is triggered by |
630 ; the flag 'request_gas_change'. | 721 ; the flag 'request_gas_change'. |
631 | 722 |
632 ; Deco Engine Calculation Schedules: | 723 ; Deco Engine Calculation Schedules: |
633 ; | 724 ; |
634 ; Schedule Dive Mode Bailout fTTS Gas Needs Plan Deco Mode Planning Modes | 725 ; Schedule Dive Mode Bailout fTTS Gas Needs Plan Deco Mode calculated Functions |
635 ; --------------------------------------------------------------------------------------------- | 726 ; ----------------------------------------------------------------------------------------------------- |
636 ; | 727 ; |
637 ; 1a) OC no no (yes) norm OC (gas needs) | 728 ; 1a) OC no no (yes) norm OC TTS, CNS, deco plan, (gas needs) |
638 ; alt -- -- | 729 ; no alt plan |
639 ; | 730 ; |
640 ; 1b) OC no YES (yes) norm OC -- | 731 ; 1b) OC no YES (yes) norm OC TTS, CNS, deco plan |
641 ; alt OC fTTS, (gas needs) | 732 ; alt OC fTTS, fCNS, (gas needs) |
642 ; | 733 ; |
643 ; 2a) Loop no no no norm Loop -- | 734 ; 2a) Loop no no no norm Loop TTS, CNS, deco plan |
644 ; alt -- -- | 735 ; no alt plan |
645 ; | 736 ; |
646 ; 2b) Loop no yes no norm Loop -- | 737 ; 2b) Loop no yes no norm Loop TTS, CNS, deco plan |
647 ; alt Loop fTTS | 738 ; alt Loop fTTS, fCNS |
648 ; | 739 ; |
649 ; 2c) Loop no (yes) YES norm Loop -- | 740 ; 2c) Loop no (yes) YES norm Loop TTS, CNS, deco plan |
650 ; alt OC gas needs, (fTTS*) | 741 ; alt OC fTTS*, fCNS*, gas needs <- "what if" BAILOUT |
651 ; | 742 ; |
652 ; 3) Loop YES n/a (yes) norm OC bailout, (gas needs) | 743 ; 3) Loop YES n/a (yes) norm OC TTS, deco plan, (gas needs) <- real BAILOUT |
653 ; alt -- -- | 744 ; no alt plan |
654 ; _____________________________________________________________________________________________ | 745 ; _____________________________________________________________________________________________________ |
655 ; norm: normal plan, alt: alternative plan, -- none, (): optional, n/a: not applicable | 746 ; norm: normal plan, alt: alternative plan, (): optional, n/a: not applicable |
656 ; * suppressed when in cave mode and dive is turned | 747 ; * the fTTS time is set to zero when in cave mode and the dive is in turned state |
657 | 748 |
658 | |
659 callup_deco_engine: | |
660 | 749 |
661 ; get working copies of char_O_main_status and char_O_deco_status | 750 ; get working copies of char_O_main_status and char_O_deco_status |
662 movff char_O_main_status,hi ; get char_O_main_status into hi | 751 movff char_O_main_status,hi ; get char_O_main_status into hi |
663 movff char_O_deco_status,lo ; get char_O_deco_status into lo | 752 movff char_O_deco_status,lo ; get char_O_deco_status into lo |
664 | 753 |
674 calc_deco_engine_restart: | 763 calc_deco_engine_restart: |
675 bcf request_restart_engine ; clear request flag | 764 bcf request_restart_engine ; clear request flag |
676 bcf lo,DECO_COMPLETED_NORM ; clear completion flag from normal plan if applicable | 765 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 | 766 ;bra calc_deco_engine_norm ; continue with calculating a normal plan |
678 | 767 |
768 | |
679 ; ---- normal plans ---- | 769 ; ---- normal plans ---- |
680 | 770 ; |
681 calc_deco_engine_norm: | 771 calc_deco_engine_norm: |
682 bcf lo,DECO_COMPLETED_ALT ; clear completion flag from alternative plan | 772 bcf lo,DECO_COMPLETED_ALT ; clear completion flag from alternative plan |
683 IFDEF _ccr_pscr | 773 IFDEF _ccr_pscr |
684 btfsc bailout_mode ; in real bailout? | 774 btfsc bailout_mode ; in real bailout? |
685 bra calc_deco_engine_norm_3 ; YES - configure real bailout schedule | 775 bra calc_deco_engine_norm_3 ; YES - configure real bailout schedule |
747 | 837 |
748 calc_deco_engine_norm_start: | 838 calc_deco_engine_norm_start: |
749 bsf lo,DECO_START_NORM ; calculate a normal plan | 839 bsf lo,DECO_START_NORM ; calculate a normal plan |
750 bra calc_deco_engine_start ; start deco engine | 840 bra calc_deco_engine_start ; start deco engine |
751 | 841 |
842 | |
752 ; ---- alternative plans ---- | 843 ; ---- alternative plans ---- |
753 | 844 ; |
754 calc_deco_engine_alt: | 845 calc_deco_engine_alt: |
755 bcf lo,DECO_COMPLETED_NORM ; clear completion flag from normal plan | 846 bcf lo,DECO_COMPLETED_NORM ; clear completion flag from normal plan |
756 IFDEF _ccr_pscr | 847 IFDEF _ccr_pscr |
757 btfsc bailout_mode ; in real bailout? | 848 btfsc bailout_mode ; in real bailout? |
758 bra calc_deco_engine_norm_3 ; YES - schedule 3 has no alternative plan | 849 bra calc_deco_engine_norm_3 ; YES - schedule 3 has no alternative plan |
820 | 911 |
821 calc_deco_engine_alt_start: | 912 calc_deco_engine_alt_start: |
822 bsf lo,DECO_START_ALT ; calculate an alternative plan | 913 bsf lo,DECO_START_ALT ; calculate an alternative plan |
823 ;bra calc_deco_engine_start ; start deco engine | 914 ;bra calc_deco_engine_start ; start deco engine |
824 | 915 |
916 | |
825 ; ---- start deco engine ---- | 917 ; ---- start deco engine ---- |
826 | 918 ; |
827 calc_deco_engine_start: | 919 calc_deco_engine_start: |
828 IFDEF _cave_mode | 920 IFDEF _cave_mode |
829 bcf hi,DECO_CAVE_MODE ; deactivate cave mode by default | 921 bcf hi,DECO_CAVE_MODE ; deactivate cave mode by default |
830 btfss cave_mode ; cave mode switched on? | 922 btfss cave_mode ; cave mode switched on? |
831 bra calc_deco_engine_start_1 ; NO - keep deactivated, no backtracking depth recording | 923 bra calc_deco_engine_start_1 ; NO - keep deactivated, no backtracking depth recording |
837 movff hi,char_O_main_status ; write-back char_O_main_status to deco engine interface | 929 movff hi,char_O_main_status ; write-back char_O_main_status to deco engine interface |
838 movff lo,char_O_deco_status ; write-back char_O_deco_status to deco engine interface | 930 movff lo,char_O_deco_status ; write-back char_O_deco_status to deco engine interface |
839 | 931 |
840 calc_deco_engine_exec: | 932 calc_deco_engine_exec: |
841 ; +++++++++++++++++++++++++++++++++++++ | 933 ; +++++++++++++++++++++++++++++++++++++ |
934 bsf tmr5_preemtion_allowed ; grant preemption allowance for timer 5 (deco engine) | |
842 call deco_calc_hauptroutine ; invoke the deco engine (C-code) | 935 call deco_calc_hauptroutine ; invoke the deco engine (C-code) |
843 banksel common ; back to bank common | 936 banksel common ; back to bank common |
937 bcf tmr5_preemtion_allowed ; revoke preemption allowance | |
844 ; +++++++++++++++++++++++++++++++++++++ | 938 ; +++++++++++++++++++++++++++++++++++++ |
845 | 939 |
846 ifdef _debug_output | 940 ifdef _debug_output |
847 call TFT_debug_output ; debug output of scheduling performance data | 941 call TFT_debug_output ; debug output of scheduling performance data |
848 endif | 942 endif |
850 ; check if new calculation results for normal plan mode are available | 944 ; check if new calculation results for normal plan mode are available |
851 movff char_O_deco_status,WREG ; get deco status of deco engine | 945 movff char_O_deco_status,WREG ; get deco status of deco engine |
852 btfsc WREG,DECO_COMPLETED_NORM ; new calculation results for normal plan available? | 946 btfsc WREG,DECO_COMPLETED_NORM ; new calculation results for normal plan available? |
853 bsf new_deco_data_avail ; YES - set flag for new NDL or deco data available | 947 bsf new_deco_data_avail ; YES - set flag for new NDL or deco data available |
854 | 948 |
855 ; done | 949 return ; done |
856 return | 950 |
857 | |
858 ; ------------------------------------------------------------------------------------------------- | |
859 | |
860 show_new_deco_data: | |
861 bcf new_deco_data_avail ; reset flag for new NDL or deco data available | |
862 movff char_O_deco_info,WREG ; get the deco info vector | |
863 btfsc WREG,deco_stops_norm ; deco stops found? | |
864 bra show_new_deco_data_deco ; YES - in deco | |
865 ;bra show_new_deco_data_ndl ; NO - within NDL | |
866 | |
867 show_new_deco_data_ndl: ; within NDL | |
868 btfsc decostop_active ; been in deco mode before? | |
869 bsf FLAG_TFT_clear_deco_data ; YES - clear old deco data | |
870 btfsc decostop_active ; been in deco mode before? | |
871 bsf FLAG_TFT_display_ndl_mask ; YES - display NDL data mask | |
872 bcf decostop_active ; clear flag for been in deco mode before | |
873 bsf FLAG_TFT_display_ndl ; display NDL time | |
874 return | |
875 | |
876 show_new_deco_data_deco: ; in deco | |
877 btfss decostop_active ; been in deco mode before? | |
878 bsf FLAG_TFT_clear_deco_data ; NO - clear old deco data | |
879 btfss decostop_active ; been in deco mode before? | |
880 bsf FLAG_TFT_display_deco_mask ; NO - display deco data mask | |
881 bsf decostop_active ; set flag for being in deco mode | |
882 bsf FLAG_TFT_display_tts ; display TTS time (display or stop data is managed somewhere else) | |
883 return | |
884 | |
885 ;============================================================================= | |
886 | 951 |
887 IFDEF _ccr_pscr | 952 IFDEF _ccr_pscr |
888 IFDEF _external_sensor | 953 IFDEF _external_sensor |
889 | 954 |
955 ;----------------------------------------------------------------------------- | |
956 ; Process Sensor Readings | |
957 ; | |
890 global calc_deko_divemode_sensor | 958 global calc_deko_divemode_sensor |
891 calc_deko_divemode_sensor: | 959 calc_deko_divemode_sensor: |
892 ; sensor acquisition code | 960 btfsc ext_input_optical ; do we have an optical interface? |
893 btfss s8_digital_avail ; do we have a digital S8 interface? | 961 bra calc_deko_divemode_sensor_opt ; YES - process received data |
894 bra calc_deko_divemode_sensor_analog ; NO - check if we have an analog interface | 962 btfss ext_input_s8_ana ; NO - do we have a S8/analog interface? |
895 btfss trigger_S8_data_update ; YES - check if a new data frame was received | 963 return ; NO - nothing to do, done |
896 bra calc_deko_divemode_sensor_common ; NO - use old values | 964 TSTOSS opt_s8_mode ; YES - shall use S8 interface? |
897 bcf trigger_S8_data_update ; YES - clear update flag | 965 bra calc_deko_divemode_sensor_ana ; - NO - use analog interface |
898 call compute_mvolts_for_all_sensors ; - compute mV values from digital data | 966 ;bra calc_deko_divemode_sensor_s8 ; YES - use S8 interface |
899 bra calc_deko_divemode_sensor_common | 967 |
900 calc_deko_divemode_sensor_analog: | 968 calc_deko_divemode_sensor_s8: |
901 btfss analog_o2_input ; do we have an analog input? | 969 btfss trigger_S8_data_update ; new data frame available? |
902 bra calc_deko_divemode_sensor_opt ; NO - check if we have an optical interface | 970 bra calc_deko_divemode_sensor_common; NO - use old values |
903 call get_analog_inputs ; YES - get the analog voltages and continue with the common part | 971 bcf trigger_S8_data_update ; YES - clear update flag |
904 bra calc_deko_divemode_sensor_common | 972 call compute_mvolts_from_rawdata ; - compute mV values from digital data |
973 bra calc_deko_divemode_sensor_common; - continue with common part | |
974 | |
905 calc_deko_divemode_sensor_opt: | 975 calc_deko_divemode_sensor_opt: |
906 btfss optical_input ; do we have an optical input? | 976 ; sensor1_ppO2, sensor2_ppO2 and sensor3_ppO2 are already filled in ISR |
907 return ; NO - return (we have no sensors at all: not analog, not S8 and not optical) | 977 btfss sensor1_active ; check HUD status data and eventually clear use_O2_sensorX |
908 btfss sensor1_active ; YES - sensor1_ppO2, sensor2_ppO2 and sensor3_ppO2 are already filled in ISR | 978 bcf use_O2_sensor1 ; ... |
909 bcf use_O2_sensor1 ; check HUD status data and eventually clear use_O2_sensorX | 979 btfss sensor2_active ; ... |
910 btfss sensor2_active | 980 bcf use_O2_sensor2 ; ... |
911 bcf use_O2_sensor2 | 981 btfss sensor3_active ; ... |
912 btfss sensor3_active | 982 bcf use_O2_sensor3 ; ... |
913 bcf use_O2_sensor3 | 983 bra check_sensor_avg ; continue with calculating sensor average |
914 bra calc_deko_divemode_sensor_A ; continue with calculating sensor average | 984 |
985 calc_deko_divemode_sensor_ana: | |
986 call get_analog_inputs ; get the analog voltages and continue with the common part | |
987 ;bra calc_deko_divemode_sensor_common; continue with common part | |
915 | 988 |
916 calc_deko_divemode_sensor_common: | 989 calc_deko_divemode_sensor_common: |
990 | |
917 ; Check each sensor if it is calibrated and if its mV value is within min_mv and max_mv limits. | 991 ; Check each sensor if it is calibrated and if its mV value is within min_mv and max_mv limits. |
918 ; If ok: compute o2_ppo2_sensorX = o2_mv_sensorX * opt_x_sX / 1000 | 992 ; If ok: compute o2_ppo2_sensorX = o2_mv_sensorX * opt_x_sX / 1000 |
919 ; If not ok: reset o2_ppo2_sensorX, reset use_O2_sensorX and show the customview 1 in case the sensor was ok before | 993 ; If not ok: reset o2_ppo2_sensorX, reset use_O2_sensorX and show the customview 1 in case the sensor was ok before |
920 | 994 |
921 ; check sensor 1 | 995 ; check sensor 1 |
922 btfss sensor1_calibrated_ok ; check if sensor is usable at all | 996 btfss sensor1_calibrated_ok ; check if sensor is usable at all |
923 bra check_sensor_1_fail ; NO - handle it as failed | 997 bra check_sensor_1_fail ; NO - handle it as failed |
998 SMOVII sensor1_mv,sub_a ; YES - load sensor mV value | |
999 | |
924 ; check min threshold | 1000 ; check min threshold |
925 SMOVII sensor1_mv,sub_a ; load sensor mV value | 1001 rcall check_min_threshold ; check if sensor mV is outside minimum |
926 rcall check_min_threshold | |
927 btfsc neg_flag ; check if result is negative, i.e. sensor_mv < min_mv | 1002 btfsc neg_flag ; check if result is negative, i.e. sensor_mv < min_mv |
928 bra check_sensor_1_fail ; YES - declare sensor as failed | 1003 bra check_sensor_1_fail ; YES - declare sensor as failed |
1004 | |
929 ; check max_threshold | 1005 ; check max_threshold |
930 rcall check_max_threshold | 1006 rcall check_max_threshold ; check if sensor mV is outside maximum |
931 btfss neg_flag ; check if result is negative, i.e. sensor_mv < max_mv | 1007 btfss neg_flag ; check if result is negative, i.e. sensor_mv < max_mv |
932 bra check_sensor_1_fail ; NO - declare sensor as failed | 1008 bra check_sensor_1_fail ; NO - declare sensor as failed |
1009 | |
933 ; check HUD data, if available | 1010 ; check HUD data, if available |
934 btfss hud_connection_ok ; check if there is a HUD connected | 1011 btfss hud_connection_ok ; check if there is a HUD connected |
935 bra check_sensor_1_ok ; NO - all checks done then and positive | 1012 bra check_sensor_1_ok ; NO - all checks done then and positive |
936 btfss sensor1_active ; YES - HUD status ok? | 1013 btfss sensor1_active ; YES - HUD status ok? |
937 bra check_sensor_1_fail ; NO - HUD reports a fail | 1014 bra check_sensor_1_fail ; NO - HUD reports a fail |
1015 | |
938 check_sensor_1_ok: | 1016 check_sensor_1_ok: |
939 ; sensor1_ppO2 = sensor1_mv:2 * opt_x_s1:2 / 1000 | 1017 ; sensor1_ppO2 = sensor1_mv:2 * opt_x_s1:2 / 1000 |
940 SMOVII sensor1_mv,xA | 1018 SMOVII sensor1_mv,xA ; get sensor mV into xA |
941 MOVII opt_x_s1, xB | 1019 MOVII opt_x_s1, xB ; get calibration factor into xB |
942 rcall compute_ppo2_helper | 1020 rcall compute_ppo2_helper ; compute ppO2 |
943 movff xC+0,sensor1_ppO2 ; result in 0.01 bar | 1021 movff xC+0,sensor1_ppO2 ; result in 0.01 bar |
1022 bcf attn_det_sensor1_lost ; clear attention | |
1023 bcf shown_sensor1_fail ; re-arm custom-view show-up | |
944 bra check_sensor_2 ; continue with next sensor | 1024 bra check_sensor_2 ; continue with next sensor |
1025 | |
945 check_sensor_1_fail: | 1026 check_sensor_1_fail: |
946 clrf WREG | 1027 clrf WREG ; set ppO2 reading to zero |
947 movff WREG,sensor1_ppO2 ; set ppO2 reading to zero | 1028 movff WREG,sensor1_ppO2 ; ... |
948 btfss use_O2_sensor1 ; check if sensor was in use before | 1029 btfsc use_O2_sensor1 ; check if sensor is in use |
949 bra check_sensor_1_fail_1 ; NO - no new news then | 1030 bsf attn_det_sensor1_lost ; YES - set an attention |
950 call check_sensor_custview_helper; YES - show sensors custom view on further conditions met | |
951 check_sensor_1_fail_1: | |
952 bcf use_O2_sensor1 ; revoke sensor from usage | 1031 bcf use_O2_sensor1 ; revoke sensor from usage |
953 | 1032 |
954 check_sensor_2: ; check min_mv of sensor 2 | 1033 check_sensor_2: |
1034 ; check sensor 2 | |
955 btfss sensor2_calibrated_ok ; check if sensor is usable at all | 1035 btfss sensor2_calibrated_ok ; check if sensor is usable at all |
956 bra check_sensor_2_fail ; NO - handle it as failed | 1036 bra check_sensor_2_fail ; NO - handle it as failed |
1037 SMOVII sensor2_mv,sub_a ; YES - load sensor mV value | |
1038 | |
957 ; check min threshold | 1039 ; check min threshold |
958 SMOVII sensor2_mv,sub_a ; load sensor mV value | 1040 rcall check_min_threshold ; check if sensor mV is outside minimum |
959 rcall check_min_threshold | |
960 btfsc neg_flag ; check if result is negative, i.e. sensor_mv < min_mv | 1041 btfsc neg_flag ; check if result is negative, i.e. sensor_mv < min_mv |
961 bra check_sensor_2_fail ; YES - declare sensor as failed | 1042 bra check_sensor_2_fail ; YES - declare sensor as failed |
1043 | |
962 ; check max_threshold | 1044 ; check max_threshold |
963 rcall check_max_threshold | 1045 rcall check_max_threshold ; check if sensor mV is outside maximum |
964 btfss neg_flag ; check if result is nagative, i.e. sensor_mv < max_mv | 1046 btfss neg_flag ; check if result is nagative, i.e. sensor_mv < max_mv |
965 bra check_sensor_2_fail ; NO - declare sensor as failed | 1047 bra check_sensor_2_fail ; NO - declare sensor as failed |
1048 | |
966 ; check HUD data, if available | 1049 ; check HUD data, if available |
967 btfss hud_connection_ok ; check if there is a HUD connected | 1050 btfss hud_connection_ok ; check if there is a HUD connected |
968 bra check_sensor_2_ok ; NO - all checks done then and positive | 1051 bra check_sensor_2_ok ; NO - all checks done then and positive |
969 btfss sensor2_active ; YES - HUD status ok? | 1052 btfss sensor2_active ; YES - HUD status ok? |
970 bra check_sensor_2_fail ; NO - HUD reports a fail | 1053 bra check_sensor_2_fail ; NO - HUD reports a fail |
1054 | |
971 check_sensor_2_ok: | 1055 check_sensor_2_ok: |
972 ; sensor2_ppO2 = sensor2_mv:2 * opt_x_s2:2 / 1000 | 1056 ; sensor2_ppO2 = sensor2_mv:2 * opt_x_s2:2 / 1000 |
973 SMOVII sensor2_mv,xA | 1057 SMOVII sensor2_mv,xA ; get sensor mV into xA |
974 MOVII opt_x_s2, xB | 1058 MOVII opt_x_s2, xB ; get calibration factor into xB |
975 rcall compute_ppo2_helper | 1059 rcall compute_ppo2_helper ; compute ppO2 |
976 movff xC+0,sensor2_ppO2 ; result in 0.01 bar | 1060 movff xC+0,sensor2_ppO2 ; result in 0.01 bar |
1061 bcf attn_det_sensor2_lost ; clear attention | |
1062 bcf shown_sensor2_fail ; re-arm custom-view show-up | |
977 bra check_sensor_3 ; continue with next sensor | 1063 bra check_sensor_3 ; continue with next sensor |
1064 | |
978 check_sensor_2_fail: | 1065 check_sensor_2_fail: |
979 clrf WREG | 1066 clrf WREG ; set ppO2 reading to zero |
980 movff WREG,sensor2_ppO2 ; set ppO2 reading to zero | 1067 movff WREG,sensor2_ppO2 ; ... |
981 btfss use_O2_sensor2 ; check if sensor was in use before | 1068 btfsc use_O2_sensor2 ; check if sensor is in use |
982 bra check_sensor_2_fail_1 ; NO - no new news then | 1069 bsf attn_det_sensor2_lost ; YES - set an attention |
983 call check_sensor_custview_helper; YES - show sensors custom view on further conditions met | |
984 check_sensor_2_fail_1: | |
985 bcf use_O2_sensor2 ; revoke sensor from usage | 1070 bcf use_O2_sensor2 ; revoke sensor from usage |
986 | 1071 |
987 check_sensor_3: ; check min_mv of sensor 2 | 1072 check_sensor_3: |
1073 ; check sensor 3 | |
988 btfss sensor3_calibrated_ok ; check if sensor is usable at all | 1074 btfss sensor3_calibrated_ok ; check if sensor is usable at all |
989 bra check_sensor_3_fail ; NO - handle it as failed | 1075 bra check_sensor_3_fail ; NO - handle it as failed |
1076 SMOVII sensor3_mv,sub_a ; YES - load sensor mV value | |
1077 | |
990 ; check min threshold | 1078 ; check min threshold |
991 SMOVII sensor3_mv,sub_a ; load sensor mV value | 1079 rcall check_min_threshold ; check if sensor mV is outside minimum |
992 rcall check_min_threshold | |
993 btfsc neg_flag ; check if result is negative, i.e. sensor_mv < min_mv | 1080 btfsc neg_flag ; check if result is negative, i.e. sensor_mv < min_mv |
994 bra check_sensor_3_fail ; YES - declare sensor as failed | 1081 bra check_sensor_3_fail ; YES - declare sensor as failed |
1082 | |
995 ; check max threshold | 1083 ; check max threshold |
996 rcall check_max_threshold | 1084 rcall check_max_threshold ; check if sensor mV is outside maximum |
997 btfss neg_flag ; check if result is negative, i.e. sensor_mv < max_mv | 1085 btfss neg_flag ; check if result is negative, i.e. sensor_mv < max_mv |
998 bra check_sensor_3_fail ; NO - declare sensor as failed | 1086 bra check_sensor_3_fail ; NO - declare sensor as failed |
1087 | |
999 ; check HUD data, if available | 1088 ; check HUD data, if available |
1000 btfss hud_connection_ok ; check if there is a HUD connected | 1089 btfss hud_connection_ok ; check if there is a HUD connected |
1001 bra check_sensor_3_ok ; NO - all checks done then and positive | 1090 bra check_sensor_3_ok ; NO - all checks done then and positive |
1002 btfss sensor3_active ; YES - HUD status ok? | 1091 btfss sensor3_active ; YES - HUD status ok? |
1003 bra check_sensor_3_fail ; NO - HUD reports a fail | 1092 bra check_sensor_3_fail ; NO - HUD reports a fail |
1093 | |
1004 check_sensor_3_ok: | 1094 check_sensor_3_ok: |
1005 ; sensor3_ppO2 = sensor3_mv:2 * opt_x_s1:2 / 1000 | 1095 ; sensor3_ppO2 = sensor3_mv:2 * opt_x_s1:2 / 1000 |
1006 SMOVII sensor3_mv,xA | 1096 SMOVII sensor3_mv,xA ; get sensor mV into xA |
1007 MOVII opt_x_s3, xB | 1097 MOVII opt_x_s3, xB ; get calibration factor into xB |
1008 rcall compute_ppo2_helper | 1098 rcall compute_ppo2_helper ; compute ppO2 |
1009 movff xC+0,sensor3_ppO2 ; result in 0.01 bar | 1099 movff xC+0,sensor3_ppO2 ; result in 0.01 bar |
1010 bra calc_deko_divemode_sensor_A ; continue with calculating sensor average | 1100 bcf attn_det_sensor3_lost ; clear attention |
1101 bcf shown_sensor3_fail ; re-arm custom-view show-up | |
1102 bra check_sensor_avg ; continue with calculating sensor average | |
1103 | |
1011 check_sensor_3_fail: | 1104 check_sensor_3_fail: |
1012 clrf WREG | 1105 clrf WREG ; set ppO2 reading to zero |
1013 movff WREG,sensor3_ppO2 ; set ppO2 reading to zero | 1106 movff WREG,sensor3_ppO2 ; ... |
1014 btfss use_O2_sensor3 ; check if sensor was in use before | 1107 btfsc use_O2_sensor3 ; check if sensor is in use |
1015 bra check_sensor_3_fail_1 ; NO - no new news then | 1108 bsf attn_det_sensor3_lost ; YES - set an attention |
1016 call check_sensor_custview_helper; YES - show sensors custom view on further conditions met | |
1017 check_sensor_3_fail_1: | |
1018 bcf use_O2_sensor3 ; revoke sensor from usage | 1109 bcf use_O2_sensor3 ; revoke sensor from usage |
1019 | 1110 |
1020 calc_deko_divemode_sensor_A: ; calculate sensor average | 1111 check_sensor_avg: |
1112 ; calculate sensor average | |
1021 btfss divemode ; in dive mode? | 1113 btfss divemode ; in dive mode? |
1022 return ; NO - done here if not in dive mode | 1114 return ; NO - done here if not in dive mode |
1023 | 1115 |
1024 ; compute sensor_setpoint = average of all o2_ppo2_sensorX of those sensors that have use_O2_sensorX == true | 1116 ; compute sensor_setpoint = average of all o2_ppo2_sensorX of |
1025 ; sum up sensor values (in xA:2) and active sensors in (xB:2) | 1117 ; those sensors that have use_O2_sensorX == true |
1026 CLRI xA | 1118 |
1027 CLRI xB | 1119 CLRI xA ; clear sum of sensor values |
1028 divemode_setup_sensor_1_value: | 1120 CLRI xB ; clear number of active sensors found |
1029 btfss use_O2_sensor1 ; sensor 1 active? | 1121 |
1030 bra divemode_setup_sensor_2_value ; NO | 1122 check_sensor_avg_1: |
1031 movff sensor1_ppO2,WREG | 1123 btfss use_O2_sensor1 ; sensor 1 active? |
1032 addwf xA+0,F | 1124 bra check_sensor_avg_2 ; NO |
1033 movlw .0 | 1125 movff sensor1_ppO2,WREG ; YES - get ppO2 |
1034 addwfc xA+1,F ; add into xA:2 | 1126 addwf xA+0,F ; - add into xA:2 |
1035 incf xB+0,F ; add a sensor | 1127 movlw .0 ; - ... |
1036 divemode_setup_sensor_2_value: | 1128 addwfc xA+1,F ; - ... |
1037 btfss use_O2_sensor2 ; sensor 2 active? | 1129 incf xB+0,F ; - add a sensor |
1038 bra divemode_setup_sensor_3_value ; NO | 1130 |
1039 movff sensor2_ppO2,WREG | 1131 check_sensor_avg_2: |
1040 addwf xA+0,F | 1132 btfss use_O2_sensor2 ; sensor 2 active? |
1041 movlw .0 | 1133 bra check_sensor_avg_3 ; NO |
1042 addwfc xA+1,F ; add into xA:2 | 1134 movff sensor2_ppO2,WREG ; YES - get ppO2 |
1043 incf xB+0,F ; add a sensor | 1135 addwf xA+0,F ; - add into xA:2 |
1044 divemode_setup_sensor_3_value: | 1136 movlw .0 ; - ... |
1045 btfss use_O2_sensor3 ; sensor 3 active? | 1137 addwfc xA+1,F ; - ... |
1046 bra divemode_setup_sensor_mean ; NO | 1138 incf xB+0,F ; - add a sensor |
1047 movff sensor3_ppO2,WREG | 1139 |
1048 addwf xA+0,F | 1140 check_sensor_avg_3: |
1049 movlw .0 | 1141 btfss use_O2_sensor3 ; sensor 3 active? |
1050 addwfc xA+1,F ; add into xA:2 | 1142 bra check_sensor_avg_compute ; NO |
1051 incf xB+0,F ; add a sensor | 1143 movff sensor3_ppO2,WREG ; YES - get ppO2 |
1052 | 1144 addwf xA+0,F ; - add into xA:2 |
1145 movlw .0 ; - ... | |
1146 addwfc xA+1,F ; - ... | |
1147 incf xB+0,F ; add a sensor | |
1148 | |
1149 check_sensor_avg_compute: | |
1053 ; divide sum of sensor values by number of active sensors found | 1150 ; divide sum of sensor values by number of active sensors found |
1054 divemode_setup_sensor_mean: | 1151 clrf xC+0 ; set zero as default result |
1055 clrf xC+0 ; set zero as default result | 1152 tstfsz xB+0 ; pending div/0 ? |
1056 tstfsz xB+0 ; pending div/0 ? | 1153 call div16x16 ; NO - execute xC = xA / xB = summed ppO2 / number of sensors |
1057 call div16x16 ; NO - execute xC = xA / xB = summed ppO2 / number of sensors | 1154 movff xC+0,sensor_setpoint ; copy result (or its default) |
1058 movff xC+0,sensor_setpoint ; copy result (or its default) | |
1059 | 1155 |
1060 ; set default value for pSCR mode: 0 => let p2_deco.c compute the ppO2 based on current dil gas and depth | 1156 ; set default value for pSCR mode: 0 => let p2_deco.c compute the ppO2 based on current dil gas and depth |
1061 ; will be overwritten later in case we are in sensor mode and have at least one usable sensor | 1157 ; will be overwritten later in case we are in sensor mode and have at least one usable sensor |
1062 clrf WREG ; pre-load a zero | 1158 clrf WREG ; pre-load a zero |
1063 btfsc FLAG_pscr_mode ; check if we are in pSCR mode | 1159 btfsc FLAG_pscr_mode ; check if we are in pSCR mode |
1064 movff WREG,char_I_const_ppO2 ; YES - write 0 to char_I_const_ppo2, | 1160 movff WREG,char_I_const_ppO2 ; YES - write 0 to char_I_const_ppo2, |
1065 ; it will be overwritten if we have a usable sensor reading | 1161 ; it will be overwritten if we have a usable sensor reading |
1066 btfsc bailout_mode ; check if we are in bailout | 1162 btfsc bailout_mode ; check if we are in bailout |
1067 bra calc_deko_divemode_sensor_V ; YES - no sensor data transfer to char_I_const_ppO2 in this case | 1163 bra check_sensor_vote ; YES - no sensor data transfer to char_I_const_ppO2 in this case |
1068 movff opt_ccr_mode,WREG ; NO - get mode (0: Fixed SP, 1: Sensor, 2: Auto SP) | 1164 movff opt_ccr_mode,WREG ; NO - get mode (0: Fixed SP, 1: Sensor, 2: Auto SP) |
1069 sublw .1 ; - in sensor mode? | 1165 sublw .1 ; - in sensor mode? |
1070 bnz calc_deko_divemode_sensor_V ; NO - not in sensor mode - no transfer of sensor data to char_I_const_ppO2 | 1166 bnz check_sensor_vote ; NO - not in sensor mode - no transfer of sensor data to char_I_const_ppO2 |
1071 tstfsz xB+0 ; YES - check if we have found at least one usable sensor | 1167 tstfsz xB+0 ; YES - check if we have found at least one usable sensor |
1072 bra divemode_setup_sensor_mean1 ; YES - we have at least one usable sensor | 1168 bra check_sensor_avg_use ; YES - we have at least one usable sensor |
1073 bsf sp_fallback ; NO - we have NO usable sensors -> initiate fallback | 1169 bsf warn_det_sensors_lost ; NO - we have NO usable sensors |
1074 btfss FLAG_ccr_mode ; - check if we are in CCR mode | 1170 btfsc FLAG_ccr_mode ; - check if we are in CCR mode |
1075 bra calc_deko_divemode_sensor_V ; NO - continue with voting logic flags | 1171 movff opt_setpoint_cbar+0,char_I_const_ppO2 ; YES - select fixed setpoint no. 1 for fallback |
1076 movff opt_setpoint_cbar+0,char_I_const_ppO2 ; YES - select fixed setpoint no. 1 for fallback | 1172 bra check_sensor_vote ; - continue with voting logic flags |
1077 bra calc_deko_divemode_sensor_V ; - continue with voting logic flags | 1173 |
1174 check_sensor_avg_use: | |
1078 ; we have at least one usable sensor with a ppO2 value > 0 | 1175 ; we have at least one usable sensor with a ppO2 value > 0 |
1079 divemode_setup_sensor_mean1: | 1176 bcf warn_det_sensors_lost ; clear warning |
1080 bcf sp_fallback ; clear fallback condition | 1177 bcf shown_sensors_lost ; re-arm custom view show-up |
1081 movff sensor_setpoint,char_I_const_ppO2 ; transfer average sensor value to p2_deco.c code | 1178 movff sensor_setpoint,char_I_const_ppO2 ; transfer average sensor value to p2_deco.c code |
1082 ; vote sensors | 1179 |
1083 calc_deko_divemode_sensor_V: | 1180 check_sensor_vote: |
1084 bsf voting_logic_sensor1 | 1181 ; check if individual sensors agree with their average |
1085 movff sensor1_ppO2,lo | 1182 bsf voting_logic_sensor1 ; default sensor to be within voting |
1086 rcall check_sensor_voting_helper | 1183 movff sensor1_ppO2,WREG ; get sensor's ppO2 |
1184 rcall check_sensor_voting_helper ; check if sensor is within +/- range around setpoint | |
1087 tstfsz WREG ; sensor within range (WREG = 0)? | 1185 tstfsz WREG ; sensor within range (WREG = 0)? |
1088 bcf voting_logic_sensor1 ; NO - vote out this sensor | 1186 bcf voting_logic_sensor1 ; NO - vote out this sensor |
1089 | 1187 |
1090 bsf voting_logic_sensor2 | 1188 bsf voting_logic_sensor2 ; default sensor to be within voting |
1091 movff sensor2_ppO2,lo | 1189 movff sensor2_ppO2,WREG ; get sensor's ppO2 |
1092 rcall check_sensor_voting_helper | 1190 rcall check_sensor_voting_helper ; check if sensor is within +/- range around setpoint |
1093 tstfsz WREG ; sensor within range (WREG = 0)? | 1191 tstfsz WREG ; sensor within range (WREG = 0)? |
1094 bcf voting_logic_sensor2 ; NO - vote out this sensor | 1192 bcf voting_logic_sensor2 ; NO - vote out this sensor |
1095 | 1193 |
1096 bsf voting_logic_sensor3 | 1194 bsf voting_logic_sensor3 ; default sensor to be within voting |
1097 movff sensor3_ppO2,lo | 1195 movff sensor3_ppO2,WREG ; get sensor's ppO2 |
1098 rcall check_sensor_voting_helper | 1196 rcall check_sensor_voting_helper ; check if sensor is within +/- range around setpoint |
1099 tstfsz WREG ; sensor within range (WREG = 0)? | 1197 tstfsz WREG ; sensor within range (WREG = 0)? |
1100 bcf voting_logic_sensor3 ; NO - vote out this sensor | 1198 bcf voting_logic_sensor3 ; NO - vote out this sensor |
1101 | 1199 |
1102 ; check if a warning shall be issued on sensor disagreement | 1200 ; check if a warning shall be issued on sensor disagreement |
1103 btfsc FLAG_ccr_mode ; check if we are in CCR mode | 1201 btfsc FLAG_ccr_mode ; check if we are in CCR mode |
1104 bra check_warn_sensor_0 ; YES - continue with further checks | 1202 bra check_warn_sensor_0 ; YES - continue with further checks |
1105 btfsc FLAG_pscr_mode ; check if we are in pSCR mode | 1203 btfsc FLAG_pscr_mode ; check if we are in pSCR mode |
1106 bra check_warn_sensor_0 ; YES - continue with further checks | 1204 bra check_warn_sensor_0 ; YES - continue with further checks |
1107 bra check_warn_sensor_done ; not in CCR and not in pSCR, so no warning | 1205 bra check_warn_sensor_done ; not in CCR and not in pSCR, so no warning |
1206 | |
1108 check_warn_sensor_0: ; we are in CCR or pSCR mode | 1207 check_warn_sensor_0: ; we are in CCR or pSCR mode |
1109 btfsc bailout_mode ; check if we are in bailout | 1208 btfsc bailout_mode ; check if we are in bailout |
1110 bra check_warn_sensor_done ; YES - no warning in this case | 1209 bra check_warn_sensor_done ; YES - no warning in this case |
1111 movff opt_ccr_mode,WREG ; get mode (0: Fixed SP, 1: Sensor, 2: Auto SP) | 1210 movff opt_ccr_mode,WREG ; get mode (0: Fixed SP, 1: Sensor, 2: Auto SP) |
1112 sublw .1 ; in sensor mode? | 1211 sublw .1 ; in sensor mode? |
1113 bnz check_warn_sensor_done ; NO - not in sensor mode - no warning in this case | 1212 bnz check_warn_sensor_done ; NO - not in sensor mode - no warning in this case |
1114 ; check sensor 1 | 1213 |
1115 check_warn_sensor_1: | 1214 check_warn_sensor_1: |
1116 btfss sensor1_calibrated_ok ; check if sensor has a valid calibration | 1215 btfss sensor1_calibrated_ok ; check if sensor has a valid calibration |
1117 bra check_warn_sensor_2 ; NO - sensor can not cause a warning then | 1216 bra check_warn_sensor_2 ; NO - sensor can not cause a warning then |
1118 btfss use_O2_sensor1 ; YES - check if sensor is in use | 1217 btfss use_O2_sensor1 ; YES - check if sensor is in use |
1119 bra check_warn_sensor_2 ; NO - sensor can not cause a warning then | 1218 bra check_warn_sensor_2 ; NO - sensor can not cause a warning then |
1120 btfsc voting_logic_sensor1 ; YES - check if sensor value is within agreement range | 1219 btfsc voting_logic_sensor1 ; YES - check if sensor value is within agreement range |
1121 bra check_warn_sensor_2 ; YES - continue with next sensor | 1220 bra check_warn_sensor_2 ; YES - continue with next sensor |
1122 bcf o2_sensors_agree ; NO - issue a warning | 1221 bsf warn_det_sensors_div ; NO - sensors divergence |
1123 return | 1222 return ; - done |
1124 ; check sensor 2 | 1223 |
1125 check_warn_sensor_2: | 1224 check_warn_sensor_2: |
1126 btfss sensor2_calibrated_ok ; check if sensor has a valid calibration | 1225 btfss sensor2_calibrated_ok ; check if sensor has a valid calibration |
1127 bra check_warn_sensor_3 ; NO - sensor can not cause a warning then | 1226 bra check_warn_sensor_3 ; NO - sensor can not cause a warning then |
1128 btfss use_O2_sensor2 ; YES - check if sensor is in use | 1227 btfss use_O2_sensor2 ; YES - check if sensor is in use |
1129 bra check_warn_sensor_3 ; NO - sensor can not cause a warning then | 1228 bra check_warn_sensor_3 ; NO - sensor can not cause a warning then |
1130 btfsc voting_logic_sensor2 ; YES - check if sensor value is within agreement range | 1229 btfsc voting_logic_sensor2 ; YES - check if sensor value is within agreement range |
1131 bra check_warn_sensor_3 ; YES - continue with next sensor | 1230 bra check_warn_sensor_3 ; YES - continue with next sensor |
1132 bcf o2_sensors_agree ; NO - issue a warning | 1231 bsf warn_det_sensors_div ; NO - sensors divergence |
1133 return | 1232 return ; - done |
1134 ; check sensor 3 | 1233 |
1135 check_warn_sensor_3: | 1234 check_warn_sensor_3: |
1136 btfss sensor3_calibrated_ok ; check if sensor has a valid calibration | 1235 btfss sensor3_calibrated_ok ; check if sensor has a valid calibration |
1137 bra check_warn_sensor_agree ; NO - sensor can not cause a warning then | 1236 bra check_warn_sensor_agree ; NO - sensor can not cause a warning then |
1138 btfss use_O2_sensor3 ; YES - check if sensor is in use | 1237 btfss use_O2_sensor3 ; YES - check if sensor is in use |
1139 bra check_warn_sensor_agree ; NO - sensor can not cause a warning then | 1238 bra check_warn_sensor_agree ; NO - sensor can not cause a warning then |
1140 btfsc voting_logic_sensor3 ; YES - check if sensor value is within agreement range | 1239 btfsc voting_logic_sensor3 ; YES - check if sensor value is within agreement range |
1141 bra check_warn_sensor_agree ; YES - continue with next sensor | 1240 bra check_warn_sensor_agree ; YES - continue with next sensor |
1142 bcf o2_sensors_agree ; NO - issue a warning | 1241 bsf warn_det_sensors_div ; NO - set warning |
1143 return | 1242 return ; - done |
1144 ; no need for a warning | 1243 |
1145 check_warn_sensor_done: | 1244 check_warn_sensor_done: |
1146 check_warn_sensor_agree: | 1245 check_warn_sensor_agree: |
1147 bsf o2_sensors_agree | 1246 bcf warn_det_sensors_div ; clear warning |
1148 return | 1247 bcf shown_sensors_diverg ; re-arm custom view show-up |
1149 | 1248 return ; done |
1249 | |
1250 | |
1251 ;----------------------------------------------------------------------------- | |
1252 ; Helper Function - check if sensor mV is outside minimum | |
1253 ; | |
1150 check_min_threshold: | 1254 check_min_threshold: |
1151 MOVLI min_mv,sub_b ; load minimum mV value | 1255 MOVLI min_mv,sub_b ; load minimum mV value |
1152 goto sub16 ; sub_c = sensor_mv - min_mv (and return) | 1256 goto sub16 ; sub_c = sensor_mv - min_mv (and return) |
1153 | 1257 |
1258 | |
1259 ;----------------------------------------------------------------------------- | |
1260 ; Helper Function - check if sensor mV is outside maximum | |
1261 ; | |
1154 check_max_threshold: | 1262 check_max_threshold: |
1155 MOVLI max_mv,sub_b ; load maximum mV value | 1263 MOVLI max_mv,sub_b ; load maximum mV value |
1156 goto sub16 ; sub_c = sensor_mv - max_mv (and return) | 1264 goto sub16 ; sub_c = sensor_mv - max_mv (and return) |
1157 | 1265 |
1266 | |
1267 ;----------------------------------------------------------------------------- | |
1268 ; Helper Function - compute ppO2 from sensor mV and calibration factor | |
1269 ; | |
1158 compute_ppo2_helper: | 1270 compute_ppo2_helper: |
1159 call mult16x16 ; xC:4 = xA:2 * xB:2 | 1271 call mult16x16 ; xC:4 = xA:2 * xB:2 |
1160 MOVLI .1000,xB | 1272 MOVLI .1000,xB ; load scaling factor |
1161 call div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder | 1273 call div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder |
1162 tstfsz xC+1 ; is the ppO2 higher than 2.55 bar? | 1274 tstfsz xC+1 ; is the ppO2 higher than 2.55 bar? |
1163 setf xC+0 ; YES - set result to 255 aka 2.55 bar | 1275 setf xC+0 ; YES - set result to 255 aka 2.55 bar |
1164 return | 1276 return ; done |
1165 | 1277 |
1166 check_sensor_custview_helper: | 1278 |
1167 btfss divemode ; check if we are in dive mode | 1279 ;----------------------------------------------------------------------------- |
1168 return ; NO - not in dive mode, return | 1280 ; Helper Function - check if sensor is within +/- range around setpoint |
1169 movff opt_ccr_mode,WREG ; YES - =0: Fixed SP, =1: Sensor, =2: Auto SP | 1281 ; |
1170 decfsz WREG,W ; - opt_ccr_mode = 1 (sensors)? | |
1171 return ; NO - not using the sensors in the moment | |
1172 show_sensors_custview: | |
1173 btfsc custom_view_locked ; YES - custom view locked? | |
1174 return ; YES - done | |
1175 movlw index_ppo2_sensors ; NO - get custom view number of ppO2 sensors | |
1176 goto dive_customview_show ; - draw custom view and return | |
1177 | |
1178 check_sensor_voting_helper: | 1282 check_sensor_voting_helper: |
1179 movf lo,W | 1283 subwf sensor_setpoint,W ; deviation = setpoint - sensor ppO2 |
1180 cpfsgt sensor_setpoint | 1284 btfsc STATUS,N ; result negative? |
1181 bra check_sensor_voting_helper2 ; lo < sensor_setpoint | 1285 negf WREG,W ; YES - negate deviation |
1182 ; lo > sensor_setpoint | 1286 sublw sensor_voting_logic_threshold ; WREG = threshold - deviation |
1183 movf lo,W | 1287 btfss STATUS,N ; result negative? |
1184 subwf sensor_setpoint,W | 1288 retlw .0 ; NO - within range |
1185 movwf lo | 1289 retlw .1 ; YES - out of range |
1186 check_sensor_voting_helper1: | 1290 |
1187 movlw sensor_voting_logic_threshold ; threshold in 0.01 bar | 1291 ; cpfsgt sensor_setpoint ; sensor ppO2 > setpoint? |
1188 cpfsgt lo | 1292 ; bra check_sensor_voting_helper_2 ; NO |
1189 retlw .0 ; within range | 1293 ; ;bra check_sensor_voting_helper_1 ; YES |
1190 retlw .1 ; out of range | 1294 ; |
1191 check_sensor_voting_helper2: | 1295 ;check_sensor_voting_helper_1: |
1192 ; lo < sensor_setpoint | 1296 ; subwf sensor_setpoint,W ; WREG = setpoint - sensor ppO2 |
1193 movf sensor_setpoint,W | 1297 ; bra check_sensor_voting_helper_com ; continue with common part |
1194 subwf lo,F | 1298 ; |
1195 bra check_sensor_voting_helper1 | 1299 ;check_sensor_voting_helper_2: |
1300 ; movwf lo ; copy sensor ppO2 to lo | |
1301 ; movf sensor_setpoint,W ; copy setpoint to WREG | |
1302 ; subwf lo,W ; WREG = sensor ppO2 - setpoint | |
1303 ; ;bra check_sensor_voting_helper_com ; continue with common part | |
1304 ; | |
1305 ;check_sensor_voting_helper_com: | |
1306 ; movwf lo ; copy deviation to lo | |
1307 ; movlw sensor_voting_logic_threshold ; load threshold in 0.01 bar | |
1308 ; cpfsgt lo ; deviation > threshold ? | |
1309 ; retlw .0 ; NO - within range | |
1310 ; retlw .1 ; YES - out of range | |
1196 | 1311 |
1197 ENDIF ; _external_sensor | 1312 ENDIF ; _external_sensor |
1198 ENDIF ; _ccr_pscr | 1313 ENDIF ; _ccr_pscr |
1199 | 1314 |
1200 ;============================================================================= | |
1201 | |
1202 divemodemode_togglegf: | |
1203 bcf request_toggle_GF ; clear request flag | |
1204 goto restart_deco_engine ; restart the deco engine and return | |
1205 | |
1206 ;============================================================================= | |
1207 | 1315 |
1208 IFDEF _cave_mode | 1316 IFDEF _cave_mode |
1209 | 1317 |
1318 ;----------------------------------------------------------------------------- | |
1319 ; Cave Mode - on/off Switching | |
1320 ; | |
1210 cavemode_toggle_onoff: | 1321 cavemode_toggle_onoff: |
1211 bcf request_cave_toggle ; clear request flag | 1322 bcf request_cave_toggle ; clear request flag |
1212 btg cave_mode ; toggle the on/off state | 1323 btg cave_mode ; toggle the on/off state |
1213 return ; done | 1324 return ; done |
1214 | 1325 |
1326 | |
1327 ;----------------------------------------------------------------------------- | |
1328 ; Cave Mode - switch off and set Dive as turned | |
1329 ; | |
1215 cavemode_switch_off_turned: | 1330 cavemode_switch_off_turned: |
1216 bcf request_cave_off_turned ; clear request flag | 1331 bcf request_cave_off_turned ; clear request flag |
1217 bcf cave_mode ; switch cave mode off | 1332 bcf cave_mode ; switch cave mode off |
1218 bra cavemode_turndive_turn_exec ; set dive as turned (and return) | 1333 bra cavemode_turndive_turn_exec ; set dive as turned (and return) |
1219 | 1334 |
1220 | 1335 |
1336 ;----------------------------------------------------------------------------- | |
1337 ; Cave Mode - check if 'turn dive' is allowed | |
1338 ; | |
1221 global cavemode_turndive_check | 1339 global cavemode_turndive_check |
1222 cavemode_turndive_check: | 1340 cavemode_turndive_check: |
1223 btfss cave_mode ; cave mode switched on? | 1341 btfss cave_mode ; cave mode switched on? |
1224 retlw 1 ; NO - signal not allowed | 1342 retlw 1 ; NO - signal not allowed |
1225 btfss dive_turned ; YES - is the dive currently turned? | 1343 btfss dive_turned ; YES - is the dive currently turned? |
1227 movf backtrack_waypoint_turn,W ; YES - copy turn point number to WREG | 1345 movf backtrack_waypoint_turn,W ; YES - copy turn point number to WREG |
1228 cpfslt backtrack_waypoint_num ; - current waypoint number < turn point number ? | 1346 cpfslt backtrack_waypoint_num ; - current waypoint number < turn point number ? |
1229 retlw 1 ; NO - signal not allowed | 1347 retlw 1 ; NO - signal not allowed |
1230 retlw 0 ; YES - command is allowed | 1348 retlw 0 ; YES - command is allowed |
1231 | 1349 |
1350 | |
1351 ;----------------------------------------------------------------------------- | |
1352 ; Cave Mode - execute 'turn dive' toggle | |
1353 ; | |
1232 cavemode_turndive_toggle: | 1354 cavemode_turndive_toggle: |
1233 bcf request_turn_toggle ; clear request flag | 1355 bcf request_turn_toggle ; clear request flag |
1234 rcall cavemode_turndive_check ; check if command is allowed | 1356 rcall cavemode_turndive_check ; check if command is allowed |
1235 tstfsz WREG ; command allowed? | 1357 tstfsz WREG ; command allowed? |
1236 return ; NO - abort | 1358 return ; NO - abort |
1237 btfss dive_turned ; YES - is the dive currently turned? | 1359 btfss dive_turned ; YES - is the dive currently turned? |
1238 bra cavemode_turndive_turn_exec ; NO - turn the dive | 1360 bra cavemode_turndive_turn_exec ; NO - turn the dive |
1239 bra request_turndive_cont_exec ; YES - continue the dive | 1361 bcf dive_turned ; YES - set dive as not turned any more |
1240 | 1362 bcf backtrack_shutdown ; - set backtracking as not shut down any more |
1363 call set_logbook_marker ; - set a logbook marker | |
1364 goto resume_backtrack_recording ; - append further logging after current waypoint and return | |
1365 | |
1366 | |
1367 ;----------------------------------------------------------------------------- | |
1368 ; Cave Mode - set the dive as turned | |
1369 ; | |
1241 cavemode_turndive_turn: | 1370 cavemode_turndive_turn: |
1242 bcf request_turn_turn ; clear request flag | 1371 bcf request_turn_turn ; clear request flag |
1243 btfss cave_mode ; cave mode switched on? | 1372 btfss cave_mode ; cave mode switched on? |
1244 return ; NO - abort | 1373 return ; NO - abort |
1245 btfsc dive_turned ; YES - is the dive already turned? | 1374 btfsc dive_turned ; YES - is the dive already turned? |
1246 return ; YES - nothing to do any more | 1375 return ; YES - nothing to do any more |
1247 ;bra cavemode_turndive_turn_exec ; NO - turn the dive | |
1248 | |
1249 cavemode_turndive_turn_exec: | 1376 cavemode_turndive_turn_exec: |
1250 bsf dive_turned ; set dive as turned | 1377 bsf dive_turned ; NO - set dive as turned |
1251 call set_logbook_marker ; set a logbook marker | 1378 call set_logbook_marker ; - set a logbook marker |
1252 goto write_backtrack_turnpoint ; write a turn-point waypoint (and return) | 1379 goto write_backtrack_turnpoint ; - write a turn-point waypoint and return |
1253 | 1380 |
1254 request_turndive_cont_exec: | 1381 |
1255 bcf dive_turned ; set dive as not turned any more | 1382 ;----------------------------------------------------------------------------- |
1256 bcf backtrack_shutdown ; set backtracking as not shut down any more | 1383 ; Cave Mode - check if setting a Waypoint is allowed |
1257 call set_logbook_marker ; set a logbook marker | 1384 ; |
1258 goto resume_backtrack_recording ; append further logging after current waypoint (and return) | |
1259 | |
1260 | |
1261 global cavemode_waypoint_set_check | 1385 global cavemode_waypoint_set_check |
1262 cavemode_waypoint_set_check: | 1386 cavemode_waypoint_set_check: |
1263 btfss cave_mode ; cave mode switched on? | 1387 btfss cave_mode ; cave mode switched on? |
1264 retlw 1 ; NO - command not allowed | 1388 retlw 1 ; NO - command not allowed |
1265 btfsc dive_turned ; YES - is the dive turned? | 1389 btfsc dive_turned ; YES - is the dive turned? |
1269 movlw backtrack_waypoint_max ; NO - get highest allowed waypoint number | 1393 movlw backtrack_waypoint_max ; NO - get highest allowed waypoint number |
1270 cpfslt backtrack_waypoint_num ; - current waypoint number < max allowed number? | 1394 cpfslt backtrack_waypoint_num ; - current waypoint number < max allowed number? |
1271 retlw 1 ; NO - command not allowed | 1395 retlw 1 ; NO - command not allowed |
1272 retlw 0 ; YES - command is allowed | 1396 retlw 0 ; YES - command is allowed |
1273 | 1397 |
1398 | |
1399 ;----------------------------------------------------------------------------- | |
1400 ; Cave Mode - set a Waypoint | |
1401 ; | |
1274 cavemode_waypoint_set: | 1402 cavemode_waypoint_set: |
1275 bcf request_waypoint_set ; clear request flag | 1403 bcf request_waypoint_set ; clear request flag |
1276 rcall cavemode_waypoint_set_check ; check if command is allowed to execute | 1404 rcall cavemode_waypoint_set_check ; check if command is allowed to execute |
1277 tstfsz WREG ; command allowed? | 1405 tstfsz WREG ; command allowed? |
1278 return ; NO - no waypoint setting possible, abort | 1406 return ; NO - no waypoint setting possible, abort |
1279 call set_logbook_marker ; YES - set a logbook marker | 1407 call set_logbook_marker ; YES - set a logbook marker |
1280 goto write_backtrack_waypoint ; - execute command (and return) | 1408 goto write_backtrack_waypoint ; - execute command (and return) |
1281 | 1409 |
1282 | 1410 |
1411 ;----------------------------------------------------------------------------- | |
1412 ; Cave Mode - check if stepping one Waypoint outwards is allowed | |
1413 ; | |
1283 global cavemode_waypoint_out_check | 1414 global cavemode_waypoint_out_check |
1284 cavemode_waypoint_out_check: | 1415 cavemode_waypoint_out_check: |
1285 btfss cave_mode ; cave mode switched on? | 1416 btfss cave_mode ; cave mode switched on? |
1286 retlw 1 ; NO - command not allowed | 1417 retlw 1 ; NO - command not allowed |
1287 btfss dive_turned ; YES - is the dive turned? | 1418 btfss dive_turned ; YES - is the dive turned? |
1288 retlw 1 ; NO - no stepping back on way in, command not allowed | 1419 retlw 1 ; NO - no stepping back on way in, command not allowed |
1289 btfsc waypoint_reached_first ; YES - already at first waypoint? | 1420 btfsc waypoint_reached_first ; YES - already at first waypoint? |
1290 retlw 1 ; YES - command not allowed | 1421 retlw 1 ; YES - command not allowed |
1291 retlw 0 ; NO - command is allowed | 1422 retlw 0 ; NO - command is allowed |
1292 | 1423 |
1424 | |
1425 ;----------------------------------------------------------------------------- | |
1426 ; Cave Mode - step one Waypoint outwards | |
1427 ; | |
1293 cavemode_waypoint_out: | 1428 cavemode_waypoint_out: |
1294 bcf request_waypoint_out ; clear request flag | 1429 bcf request_waypoint_out ; clear request flag |
1295 rcall cavemode_waypoint_out_check ; check if command is allowed to execute | 1430 rcall cavemode_waypoint_out_check ; check if command is allowed to execute |
1296 tstfsz WREG ; command allowed? | 1431 tstfsz WREG ; command allowed? |
1297 return ; NO - no further out possible, abort | 1432 return ; NO - no further out possible, abort |
1298 goto backtrack_waypoint_go_out ; YES - execute the command (and return) | 1433 goto backtrack_waypoint_go_out ; YES - execute the command (and return) |
1299 | 1434 |
1300 | 1435 |
1436 ;----------------------------------------------------------------------------- | |
1437 ; Cave Mode - check if stepping one Waypoint inwards is allowed | |
1438 ; | |
1301 global cavemode_waypoint_in_check | 1439 global cavemode_waypoint_in_check |
1302 cavemode_waypoint_in_check: | 1440 cavemode_waypoint_in_check: |
1303 btfss cave_mode ; cave mode switched on? | 1441 btfss cave_mode ; cave mode switched on? |
1304 retlw 1 ; NO - command not allowed | 1442 retlw 1 ; NO - command not allowed |
1305 btfss dive_turned ; YES - is the dive turned? | 1443 btfss dive_turned ; YES - is the dive turned? |
1306 retlw 1 ; NO - no stepping forward on way in, command not allowed | 1444 retlw 1 ; NO - no stepping forward on way in, command not allowed |
1307 btfsc waypoint_reached_last ; YES - already at last waypoint? | 1445 btfsc waypoint_reached_last ; YES - already at last waypoint? |
1308 retlw 1 ; YES - command not allowed | 1446 retlw 1 ; YES - command not allowed |
1309 retlw 0 ; NO - command is allowed | 1447 retlw 0 ; NO - command is allowed |
1310 | 1448 |
1449 | |
1450 ;----------------------------------------------------------------------------- | |
1451 ; Cave Mode - step one Waypoint inwards | |
1452 ; | |
1311 cavemode_waypoint_in: | 1453 cavemode_waypoint_in: |
1312 bcf request_waypoint_in ; clear request flag | 1454 bcf request_waypoint_in ; clear request flag |
1313 rcall cavemode_waypoint_in_check ; check if command is allowed to execute | 1455 rcall cavemode_waypoint_in_check ; check if command is allowed to execute |
1314 tstfsz WREG ; command allowed? | 1456 tstfsz WREG ; command allowed? |
1315 return ; NO - no further in possible, abort | 1457 return ; NO - no further in possible, abort |
1316 goto backtrack_waypoint_go_in ; YES - execute command (and return) | 1458 goto backtrack_waypoint_go_in ; YES - execute command (and return) |
1317 | 1459 |
1318 ENDIF | 1460 |
1319 | 1461 ;----------------------------------------------------------------------------- |
1320 ;============================================================================= | 1462 ; Cave Mode - store current Delta Time |
1321 | 1463 ; |
1322 calc_velocity: ; called every two seconds | |
1323 btfsc velocity_active_num ; was velocity shown in last cycle? | |
1324 bra calc_velocity_1 ; YES - always update if shown before | |
1325 btfss count_divetime ; NO - is the dive time counted, i.e. deeper than dive threshold? | |
1326 return ; NO - display velocity only if deeper than 1m, | |
1327 ; i.e. not at the surface after the dive | |
1328 calc_velocity_1: | |
1329 ; calculate pressure difference | |
1330 MOVII pressure_abs_cached, sub_a; current pressure | |
1331 MOVII last_pressure_velocity,sub_b; last pressure | |
1332 call subU16 ; do an unsigned subtraction | |
1333 | |
1334 ; decide if ascending or descending | |
1335 bcf neg_flag_velocity ; set to ascending by default | |
1336 btfsc neg_flag ; pressure differential negative? | |
1337 bsf neg_flag_velocity ; YES - descending | |
1338 | |
1339 ; store current pressure as last pressure for next round | |
1340 MOVII pressure_abs_cached,last_pressure_velocity | |
1341 | |
1342 ; calculate velocity in m/min | |
1343 MOVII sub_c,xA ; copy pressure differential to xA | |
1344 MOVLI .39,xB ; put scale coefficient into xB (use 77 when called every second) | |
1345 call mult16x16 ; compute differential pressure in mbar * scale coefficient | |
1346 MOVII xC,divA ; copy result to divA | |
1347 ADDLI .64,divA ; add some round-up | |
1348 movlw .7 ; divide by 2^7 | |
1349 call div16 ; divA = divA / 2^WREG, yields velocity in m/min | |
1350 | |
1351 movlw .99 ; load a 99 | |
1352 cpfslt divA+0 ; velocity < 99 m/min ? | |
1353 movwf divA+0 ; NO - limit to 99 m/min | |
1354 | |
1355 bcf STATUS,C ; clear carry flag | |
1356 movlw velocity_display_threshold ; get threshold for displaying vertical velocity | |
1357 subwf divA+0,W ; subtract threshold from velocity | |
1358 btfss STATUS,C ; above threshold? | |
1359 bsf FLAG_TFT_velocity_clear ; NO - don't show / request to clear | |
1360 btfsc STATUS,C ; above threshold? | |
1361 bsf FLAG_TFT_velocity_show ; YES - request to show | |
1362 return ; done | |
1363 | |
1364 | |
1365 ;============================================================================= | |
1366 | |
1367 check_deco_states: | |
1368 btfsc deco_region ; been within the deco stops region before? | |
1369 return ; YES - been in deco then before too, done | |
1370 movff char_O_deco_info,WREG ; NO - get deco info vector | |
1371 btfss WREG,deco_stops_norm ; do we have a deco obligation right now? | |
1372 return ; NO - done | |
1373 bsf deco_locked ; YES - memorize dive was in deco | |
1374 movff char_O_deco_depth+0,WREG ; - get depth of first stop in meters into WREG | |
1375 addlw deco_region_distance+.1 ; - add deco region start distance + 1 meter for the negative test to work | |
1376 subwf depth_meter,W ; - compute current depth - (first stop depth + deco region distance) | |
1377 btfss STATUS,C ; - result negative? | |
1378 bsf deco_region ; YES - memorize to have entered the deco stops region | |
1379 return ; - done | |
1380 | |
1381 ;============================================================================= | |
1382 | |
1383 safety_stop_control: | |
1384 TSTOSS opt_safetystop ; safety stop enabled? (=1: show safety stop) | |
1385 return ; NO - done | |
1386 | |
1387 btfsc FLAG_gauge_mode ; in gauge mode? | |
1388 return ; YES - omit (well, else fix collision of safety stop output with avg depth label) | |
1389 | |
1390 ; setup | |
1391 bcf safety_stop_enabled ; disable safety stop by default | |
1392 | |
1393 ; check for deco | |
1394 btfsc decostop_active ; in deco mode? | |
1395 bra safety_stop_finish ; YES - shut down safety stop | |
1396 | |
1397 ; below "opt_safety_stop_reset"? | |
1398 MOVII pressure_rel_cur_cached,mpr ; get current pressure into MPR | |
1399 call convert_pres_to_depth ; convert pressure in [mbar] to depth in [cm] | |
1400 MOVII mpr,sub_a ; move depth in [cm] to sub_a | |
1401 movff opt_safety_stop_reset,WREG ; load safety stop reset threshold [dm] | |
1402 mullw .10 ; convert threshold from [dm] to [cm] | |
1403 MOVII PROD,sub_b ; move threshold in [cm] to sub_b | |
1404 call cmpU16 ; sub_a - sub_b | |
1405 btfss neg_flag ; below threshold depth? | |
1406 bra safety_stop_reset ; YES - arm safety stop and delete it from display if still shown | |
1407 ;bra safety_stop_control_1 ; NO - check if above end threshold | |
1408 | |
1409 safety_stop_control_1: | |
1410 ; above "opt_safety_stop_end"? | |
1411 movff opt_safety_stop_end,WREG ; load safety stop end threshold [dm] | |
1412 mullw .10 ; convert threshold from [dm] to [cm] | |
1413 MOVII PROD,sub_b ; move threshold in [cm] to sub_b | |
1414 call cmpU16 ; sub_a - sub_b | |
1415 btfsc neg_flag ; above or at threshold depth? | |
1416 bra safety_stop_finish ; YES - finish with safety stop | |
1417 ;bra safety_stop_control_2 ; NO - check if above start threshold | |
1418 | |
1419 safety_stop_control_2: | |
1420 ; above "opt_safety_stop_start"? | |
1421 movff opt_safety_stop_start,WREG ; load safety stop start threshold [dm] | |
1422 mullw .10 ; convert threshold from [dm] to [cm] | |
1423 MOVII PROD,sub_b ; move threshold in [cm] to sub_b | |
1424 call cmpU16 ; sub_a - sub_b | |
1425 btfss neg_flag ; above or at threshold depth? | |
1426 return ; NO - pause safety stop | |
1427 tstfsz safety_stop_countdown ; YES - safety stop armed? | |
1428 bsf safety_stop_enabled ; YES - enable safety stop | |
1429 return ; NO - done | |
1430 | |
1431 | |
1432 safety_stop_show: | |
1433 btfss safety_stop_enabled ; safety stop enabled? | |
1434 return ; NO - done | |
1435 dcfsnz safety_stop_countdown,F ; YES - decrement remaining stop time, reached zero? | |
1436 bra safety_stop_finish ; YES - finished with safety stop | |
1437 bsf FLAG_TFT_safety_stop_show ; NO - request to show safety stop | |
1438 return ; - done | |
1439 | |
1440 safety_stop_finish: | |
1441 clrf safety_stop_countdown ; disarm safety stop | |
1442 bcf safety_stop_enabled ; disable safety stop | |
1443 bsf FLAG_TFT_safety_stop_clear ; request to clear safety stop | |
1444 return ; done | |
1445 | |
1446 safety_stop_reset: | |
1447 movff opt_safety_stop_length,safety_stop_countdown ; arm safety stop (load timer) | |
1448 incf safety_stop_countdown,F ; +1 because safety_stop_show does decrement first | |
1449 bsf FLAG_TFT_safety_stop_clear ; request to clear safety stop | |
1450 return ; done | |
1451 | |
1452 | |
1453 ;============================================================================= | |
1454 | |
1455 timeout_menuview: | |
1456 btfss trigger_timeout ; timeout occurred? | |
1457 return ; NO - done | |
1458 goto menuview_toggle_reset ; YES - terminate the pre-menu and return | |
1459 | |
1460 timeout_divemode_menu: | |
1461 btfss trigger_timeout ; timeout occurred? | |
1462 return ; NO - done | |
1463 ;bra timeout_divemode_menu2 ; YES - clean up main menu and restore dive data | |
1464 | |
1465 global timeout_divemode_menu2 | |
1466 timeout_divemode_menu2: ; jump-in point from divemenu_tree.asm | |
1467 bcf dive_main_menu ; clear flag for dive mode menu shown | |
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: | |
1478 bsf FLAG_TFT_active_gas_divemode; redraw gas/setpoint/diluent | |
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 | |
1482 | |
1483 request_redraw_NDL_deco_data: | |
1484 btfsc FLAG_gauge_mode ; in gauge mode? | |
1485 return ; YES - done | |
1486 btfss decostop_active ; NO - in deco mode? | |
1487 bra timeout_divemode_menu_ndl ; NO - show NDL again | |
1488 ;bra timeout_divemode_menu_deco ; YES - show deco again | |
1489 | |
1490 timeout_divemode_menu_deco: | |
1491 bsf FLAG_TFT_display_deco_mask ; show deco mask | |
1492 bsf FLAG_TFT_display_deco ; show deco stop | |
1493 bsf FLAG_TFT_display_tts ; show TTS time | |
1494 return ; done | |
1495 | |
1496 timeout_divemode_menu_ndl: | |
1497 bsf FLAG_TFT_display_ndl_mask ; show NDL mask | |
1498 bsf FLAG_TFT_display_ndl ; show NDL time | |
1499 return ; done | |
1500 | |
1501 timeout_divemode: | |
1502 btfsc dive_main_menu ; main dive menu shown? | |
1503 rcall timeout_divemode_menu ; YES - check the timeout for it | |
1504 | |
1505 btfsc dive_options_menu ; pre-menu shown? | |
1506 rcall timeout_menuview ; YES - check the timeout for it | |
1507 | |
1508 btfss divetime_longer_1min ; does dive already last for longer than one minute? | |
1509 return ; NO - suspend timeout | |
1510 | |
1511 btfsc FLAG_apnoe_mode ; in apnoe mode? | |
1512 bra timeout_divemode_apnoe ; YES - use apnoe timeout | |
1513 | |
1514 IFNDEF _DEBUG | |
1515 btfsc sensor_override_active ; in simulator mode? | |
1516 bra timeout_divemode_sim ; YES - use simulator timeout | |
1517 ;bra timeout_divemode_dive ; NO - use normal dive timeout | |
1518 ENDIF | |
1519 | |
1520 timeout_divemode_dive: | |
1521 movff opt_diveTimeout,WREG ; get dive timeout in minutes into WREG | |
1522 ;bra timeout_divemode_com_min | |
1523 | |
1524 timeout_divemode_com_min: | |
1525 mullw .60 ; multiply with 60 to convert minutes in WREG to seconds | |
1526 MOVII PRODL,sub_a ; copy resulting seconds to sub_a | |
1527 timeout_divemode_com_sec: | |
1528 MOVII dive_timeout_timer,sub_b ; copy current timeout timer value to sub_b | |
1529 INCI dive_timeout_timer ; increment timeout timer | |
1530 call cmpU16 ; check sub_a - sub_b | |
1531 btfsc neg_flag ; result negative, i.e. timeout? | |
1532 bcf divemode ; YES - terminate dive mode | |
1533 return ; done | |
1534 | |
1535 timeout_divemode_apnoe: | |
1536 movlw apnoe_timeout ; get apnoe timeout in minutes into WREG | |
1537 bra timeout_divemode_com_min ; continue with common part for minutes | |
1538 | |
1539 timeout_divemode_sim: | |
1540 MOVLI simulator_timeout,sub_a ; get simulator timeout in seconds directly into sub_a | |
1541 bra timeout_divemode_com_sec ; continue with common part for seconds | |
1542 | |
1543 | |
1544 update_divemode60: ; tasks every full minute | |
1545 bcf trigger_full_minute ; clear flag | |
1546 | |
1547 call get_battery_voltage ; get battery voltage | |
1548 btfsc battery_low_condition ; battery low condition detected? | |
1549 rcall set_powersafe ; YES - record an alarm and reduce display brightness | |
1550 | |
1551 ; max allowed runtime in simulator is 254 minutes in | |
1552 ; order for the tissue calculation catch-up to work! | |
1553 | |
1554 btfss sensor_override_active ; in simulator mode? | |
1555 return ; NO - done | |
1556 movlw simulator_timeout_normal ; YES - set simulation 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? | |
1562 return ; NO - done | |
1563 IFDEF _DEBUG | |
1564 return ; YES - but we do not care in debug mode... | |
1565 ELSE | |
1566 bra divemode_option_sim_quit ; YES - set depth to 0 m and return | |
1567 ENDIF | |
1568 | |
1569 ;============================================================================= | |
1570 | |
1571 IFDEF _cave_mode | |
1572 | |
1573 ; ** jump-in functions ** | |
1574 | |
1575 write_backtrack_deltatime: | 1464 write_backtrack_deltatime: |
1576 rcall setup_backtrack_index ; setup writing position | 1465 rcall setup_backtrack_index ; setup writing position |
1577 bra write_backtrack_datum_deltatime ; store the current delta time (and return) | 1466 bra write_backtrack_datum_deltatime ; store the current delta time (and return) |
1578 | 1467 |
1468 | |
1469 ;----------------------------------------------------------------------------- | |
1470 ; Cave Mode - store a Backtracking Depth Data Set | |
1471 ; | |
1579 write_backtrack_1min_depth: | 1472 write_backtrack_1min_depth: |
1580 rcall setup_backtrack_index ; setup writing position | 1473 rcall setup_backtrack_index ; setup writing position |
1581 rcall write_backtrack_datum_depth ; store depth | 1474 rcall write_backtrack_datum_depth ; store depth |
1582 rcall write_backtrack_datum_zerotime ; reset the time elapsed since last depth recording and store it | 1475 rcall write_backtrack_datum_zerotime ; reset the time elapsed since last depth recording and store it |
1583 bra write_backtrack_datum_check ; store new writing position, check remaining storage capacity ()and return) | 1476 bra write_backtrack_datum_check ; store new writing position, check remaining storage capacity ()and return) |
1584 | 1477 |
1478 | |
1479 ;----------------------------------------------------------------------------- | |
1480 ; Cave Mode - store a Waypoint | |
1481 ; | |
1585 write_backtrack_waypoint: | 1482 write_backtrack_waypoint: |
1586 rcall setup_backtrack_index ; setup writing position | 1483 rcall setup_backtrack_index ; setup writing position |
1587 rcall write_backtrack_datum_deltatime ; store the time elapsed since last depth recording | 1484 rcall write_backtrack_datum_deltatime ; store the time elapsed since last depth recording |
1588 movf POSTINC1,W ; dummy read to increment the writing position index | 1485 movf POSTINC1,W ; dummy read to increment the writing position index |
1589 rcall write_backtrack_datum_depth ; store depth | 1486 rcall write_backtrack_datum_depth ; store depth |
1590 rcall write_backtrack_datum_gas ; store gas availability vector | 1487 rcall write_backtrack_datum_gas ; store gas availability vector |
1591 rcall write_backtrack_datum_waypoint ; store waypoint number | 1488 rcall write_backtrack_datum_waypoint ; store waypoint number |
1592 rcall write_backtrack_datum_zerotime ; reset the time elapsed since last depth recording and store it | 1489 rcall write_backtrack_datum_zerotime ; reset the time elapsed since last depth recording and store it |
1593 bra write_backtrack_datum_check ; store new writing position, check remaining storage capacity (and return) | 1490 bra write_backtrack_datum_check ; store new writing position, check remaining storage capacity (and return) |
1594 | 1491 |
1492 | |
1493 ;----------------------------------------------------------------------------- | |
1494 ; Cave Mode - store a Turn Point | |
1595 write_backtrack_turnpoint: | 1495 write_backtrack_turnpoint: |
1596 rcall write_backtrack_waypoint ; write a waypoint (see above) | 1496 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 | 1497 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 | 1498 movff FSR1L,char_I_backtrack_index ; store updated writing position |
1599 movff backtrack_waypoint_num,backtrack_waypoint_turn; memorize this waypoint as turn point | 1499 movff backtrack_waypoint_num,backtrack_waypoint_turn; memorize this waypoint as turn point |
1600 return ; done | 1500 return ; done |
1601 | 1501 |
1502 | |
1503 ;----------------------------------------------------------------------------- | |
1504 ; Cave Mode - append further Logging after current Waypoint | |
1505 ; | |
1602 resume_backtrack_recording: | 1506 resume_backtrack_recording: |
1603 clrf backtrack_waypoint_turn ; clear turn point reference | 1507 clrf backtrack_waypoint_turn ; clear turn point reference |
1604 bsf waypoint_reached_last ; declare to be at last waypoint now | 1508 bsf waypoint_reached_last ; declare to be at last waypoint now |
1605 rcall setup_backtrack_index ; setup index position | 1509 rcall setup_backtrack_index ; setup index position |
1606 movf POSTINC1,W ; dummy read to increment the position index to the delta time datum | 1510 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 | 1511 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) | 1512 bra write_backtrack_datum_check ; store new writing position, check remaining storage capacity (and return) |
1609 | 1513 |
1514 | |
1515 ;----------------------------------------------------------------------------- | |
1516 ; Cave Mode - execute stepping one Waypoint outwards | |
1517 ; | |
1610 backtrack_waypoint_go_out: | 1518 backtrack_waypoint_go_out: |
1611 bcf waypoint_reached_last ; not at last waypoint (or turn point) any more | 1519 bcf waypoint_reached_last ; not at last waypoint (or turn point) any more |
1612 rcall setup_backtrack_index ; setup index position | 1520 rcall setup_backtrack_index ; setup index position |
1613 movlw b'11100000'-.1 ; a waypoint datum has bits 5-7 set, -1 because of cpfsgt | 1521 movlw b'11100000'-.1 ; a waypoint datum has bits 5-7 set, -1 because of cpfsgt |
1614 backtrack_waypoint_go_out_loop: | 1522 backtrack_waypoint_go_out_loop: |
1622 movlw .1 ; number of first waypoint | 1530 movlw .1 ; number of first waypoint |
1623 cpfsgt backtrack_waypoint_num ; current waypoint number > number of first waypoint ? | 1531 cpfsgt backtrack_waypoint_num ; current waypoint number > number of first waypoint ? |
1624 bsf waypoint_reached_first ; NO - reached first waypoint | 1532 bsf waypoint_reached_first ; NO - reached first waypoint |
1625 goto restart_deco_engine_wo_norm ; invalidate all alternative plan data and restart deco engine | 1533 goto restart_deco_engine_wo_norm ; invalidate all alternative plan data and restart deco engine |
1626 | 1534 |
1535 | |
1536 ;----------------------------------------------------------------------------- | |
1537 ; Cave Mode - execute stepping one Waypoint inwards | |
1538 ; | |
1627 backtrack_waypoint_go_in: | 1539 backtrack_waypoint_go_in: |
1628 bcf waypoint_reached_first ; not at first waypoint any more | 1540 bcf waypoint_reached_first ; not at first waypoint any more |
1629 rcall setup_backtrack_index ; setup index position | 1541 rcall setup_backtrack_index ; setup index position |
1630 movlw b'11100000'-.1 ; a waypoint datum has bits 5-7 set, -1 because of cpfsgt | 1542 movlw b'11100000'-.1 ; a waypoint datum has bits 5-7 set, -1 because of cpfsgt |
1631 backtrack_waypoint_go_in_loop: | 1543 backtrack_waypoint_go_in_loop: |
1639 cpfslt backtrack_waypoint_num ; new waypoint number < number of turn point ? | 1551 cpfslt backtrack_waypoint_num ; new waypoint number < number of turn point ? |
1640 bsf waypoint_reached_last ; NO - reached last waypoint | 1552 bsf waypoint_reached_last ; NO - reached last waypoint |
1641 goto restart_deco_engine_wo_norm ; invalidate all alternative plan data and restart deco engine | 1553 goto restart_deco_engine_wo_norm ; invalidate all alternative plan data and restart deco engine |
1642 | 1554 |
1643 | 1555 |
1644 ; ** helper functions ** | 1556 ;----------------------------------------------------------------------------- |
1645 | 1557 ; Cave Mode Helper Function - set up Index Position |
1558 ; | |
1646 setup_backtrack_index: | 1559 setup_backtrack_index: |
1647 lfsr FSR1,char_I_backtrack_storage ; load FSR1 with base address of the backtracking storage | 1560 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 | 1561 movff char_I_backtrack_index,FSR1L ; adjust FSR1 to the current index position |
1649 return | 1562 return |
1650 | 1563 |
1564 | |
1565 ;----------------------------------------------------------------------------- | |
1566 ; Cave Mode Helper Function - reset Time since last Depth Recording and store it | |
1567 ; | |
1651 write_backtrack_datum_zerotime: | 1568 write_backtrack_datum_zerotime: |
1652 clrf backtrack_deltatime ; reset the time elapsed since last depth recording | 1569 clrf backtrack_deltatime ; reset the time elapsed since last depth recording |
1570 ;bra write_backtrack_datum_deltatime ; store the time | |
1571 | |
1572 | |
1573 ;----------------------------------------------------------------------------- | |
1574 ; Cave Mode Helper Function - store Time elapsed since last Depth Recording | |
1575 ; | |
1653 write_backtrack_datum_deltatime: | 1576 write_backtrack_datum_deltatime: |
1654 movf backtrack_deltatime,W ; get the time elapsed since last depth recording | 1577 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 | 1578 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 | 1579 movwf INDF1 ; write the time and keep the writing position index pointing on it |
1657 return ; done | 1580 return ; done |
1658 | 1581 |
1582 | |
1583 ;----------------------------------------------------------------------------- | |
1584 ; Cave Mode Helper Function - store Depth | |
1585 ; | |
1659 write_backtrack_datum_depth: | 1586 write_backtrack_datum_depth: |
1660 movf depth_meter,W ; get current depth in meters into WREG | 1587 movf depth_meter,W ; get current depth in meters into WREG |
1661 btfsc WREG,7 ; current depth < 128 m ? | 1588 btfsc WREG,7 ; current depth < 128 m ? |
1662 movlw .127 ; NO - clip depth to 127 meters | 1589 movlw .127 ; NO - clip depth to 127 meters (protect time marker bit) |
1663 movwf POSTINC1 ; write the depth entry and increment the writing position index | 1590 movwf POSTINC1 ; write the depth entry and increment the writing position index |
1664 return ; done | 1591 return ; done |
1665 | 1592 |
1593 | |
1594 ;----------------------------------------------------------------------------- | |
1595 ; Cave Mode Helper Function - store Gas Availability Vector | |
1596 ; | |
1666 write_backtrack_datum_gas: | 1597 write_backtrack_datum_gas: |
1667 ; Cave mode is currently only available with gas needs calculation enabled, | 1598 ; 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 | 1599 ; 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. | 1600 ; 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 | 1601 lfsr FSR2,opt_gas_type ; load base address of the OC/bailout gas types |
1681 decfsz lo,F ; decrement loop counter, did it became zero? | 1612 decfsz lo,F ; decrement loop counter, did it became zero? |
1682 bra write_backtrack_datum_gas_loop ; NO - loop | 1613 bra write_backtrack_datum_gas_loop ; NO - loop |
1683 movwf POSTINC1 ; YES - write the gas staging status entry and increment the writing position index | 1614 movwf POSTINC1 ; YES - write the gas staging status entry and increment the writing position index |
1684 return ; - done | 1615 return ; - done |
1685 | 1616 |
1617 | |
1618 ;----------------------------------------------------------------------------- | |
1619 ; Cave Mode Helper Function - store a Waypoint Number | |
1620 ; | |
1686 write_backtrack_datum_waypoint: | 1621 write_backtrack_datum_waypoint: |
1687 incf backtrack_waypoint_num,F ; increment the waypoint number | 1622 incf backtrack_waypoint_num,F ; increment the waypoint number |
1688 movf backtrack_waypoint_num,W ; copy waypoint number to WREG | 1623 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 | 1624 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 | 1625 movwf POSTINC1 ; write the waypoint datum and increment the writing position index |
1691 movlw .2 ; load a 2 into WREG | 1626 movlw .2 ; load a 2 into WREG |
1692 cpfslt backtrack_waypoint_num ; new waypoint number >= 2 ? | 1627 cpfslt backtrack_waypoint_num ; new waypoint number >= 2 ? |
1693 bcf waypoint_reached_first ; YES - not at first waypoint any more | 1628 bcf waypoint_reached_first ; YES - not at first waypoint any more |
1694 return ; done | 1629 return ; done |
1695 | 1630 |
1631 | |
1632 ;----------------------------------------------------------------------------- | |
1633 ; Cave Mode Helper Function - store new writing position and check remaining storage capacity | |
1634 ; | |
1696 write_backtrack_datum_check: | 1635 write_backtrack_datum_check: |
1697 movff FSR1L,char_I_backtrack_index ; store new index position | 1636 movff FSR1L,char_I_backtrack_index ; store new index position |
1698 movlw backtrack_almost_full_threshold ; load threshold for backtracking storage almost full | 1637 movlw backtrack_almost_full_threshold ; load threshold for backtracking storage almost full |
1699 bcf backtrack_almost_full ; clear almost full state | 1638 bcf backtrack_almost_full ; clear almost full state |
1700 cpfslt FSR1L ; index < threshold ? | 1639 cpfslt FSR1L ; index < threshold ? |
1705 bsf backtrack_entire_full ; NO - flag backtracking storage is entirely full | 1644 bsf backtrack_entire_full ; NO - flag backtracking storage is entirely full |
1706 return ; done | 1645 return ; done |
1707 | 1646 |
1708 ENDIF ; _cave_mode | 1647 ENDIF ; _cave_mode |
1709 | 1648 |
1710 ;============================================================================= | 1649 |
1711 | 1650 ;----------------------------------------------------------------------------- |
1712 global set_dive_modes | 1651 ; Calculate vertical Velocity |
1713 set_dive_modes: | 1652 ; |
1714 SMOVII pressure_rel_cur,sub_a ; ISR-safe 2 byte copy of current relative pressure to sub_a | 1653 calc_velocity: ; called every two seconds |
1715 bra set_dive_modes_1 | 1654 btfsc velocity_active_num ; was velocity shown in last cycle? |
1655 bra calc_velocity_1 ; YES - always update if shown before | |
1656 btfss count_divetime ; NO - is the dive time counted, i.e. deeper than dive threshold? | |
1657 return ; NO - display velocity only if deeper than 1m, | |
1658 ; i.e. not at the surface after the dive | |
1659 calc_velocity_1: | |
1660 ; calculate pressure difference | |
1661 MOVII pressure_abs_cached, sub_a; current pressure | |
1662 MOVII last_pressure_velocity,sub_b; last pressure | |
1663 call subU16 ; do an unsigned subtraction | |
1664 | |
1665 ; decide if ascending or descending | |
1666 bcf neg_flag_velocity ; set to ascending by default | |
1667 btfsc neg_flag ; pressure differential negative? | |
1668 bsf neg_flag_velocity ; YES - descending | |
1669 | |
1670 ; store current pressure as last pressure for next round | |
1671 MOVII pressure_abs_cached,last_pressure_velocity | |
1672 | |
1673 ; calculate velocity in m/min | |
1674 MOVII sub_c,xA ; copy pressure differential to xA | |
1675 MOVLI .39,xB ; put scale coefficient into xB (use 77 when called every second) | |
1676 call mult16x16 ; compute differential pressure in mbar * scale coefficient | |
1677 MOVII xC,divA ; copy result to divA | |
1678 ADDLI .64,divA ; add some round-up | |
1679 movlw .7 ; divide by 2^7 | |
1680 call div16 ; divA = divA / 2^WREG, yields velocity in m/min | |
1681 | |
1682 movlw .99 ; load a 99 | |
1683 cpfslt divA+0 ; velocity < 99 m/min ? | |
1684 movwf divA+0 ; NO - limit to 99 m/min | |
1685 | |
1686 bcf STATUS,C ; clear carry flag | |
1687 movlw velocity_display_threshold ; get threshold for displaying vertical velocity | |
1688 subwf divA+0,W ; subtract threshold from velocity | |
1689 btfss STATUS,C ; above threshold? | |
1690 bsf FLAG_TFT_velocity_clear ; NO - don't show / request to clear | |
1691 btfsc STATUS,C ; above threshold? | |
1692 bsf FLAG_TFT_velocity_show ; YES - request to show | |
1693 return ; done | |
1694 | |
1695 | |
1696 ;----------------------------------------------------------------------------- | |
1697 ; Check and Memorize if Dive went into Deco & Deco Region | |
1698 ; | |
1699 check_deco_states: | |
1700 btfsc deco_region ; been within the deco stops region before? | |
1701 return ; YES - been in deco then before too, done | |
1702 movff char_O_deco_info,WREG ; NO - get deco info vector | |
1703 btfss WREG,deco_stops_norm ; do we have a deco obligation right now? | |
1704 return ; NO - done | |
1705 bsf deco_locked ; YES - memorize dive was in deco | |
1706 movff char_O_deco_depth+0,WREG ; - get depth of first stop in meters into WREG | |
1707 addlw deco_region_distance+.1 ; - add deco region start distance + 1 meter for the negative test to work | |
1708 subwf depth_meter,W ; - compute current depth - (first stop depth + deco region distance) | |
1709 btfss STATUS,C ; - result negative? | |
1710 bsf deco_region ; YES - memorize to have entered the deco stops region | |
1711 return ; - done | |
1712 | |
1713 | |
1714 ;----------------------------------------------------------------------------- | |
1715 ; Exercise Safety Stop Control | |
1716 ; | |
1717 safety_stop_control: | |
1718 TSTOSS opt_safetystop ; safety stop enabled? (=1: show safety stop) | |
1719 return ; NO - done | |
1720 | |
1721 btfsc FLAG_gauge_mode ; in gauge mode? | |
1722 return ; YES - omit (well, else fix collision of safety stop output with avg depth label) | |
1723 | |
1724 ; setup | |
1725 bcf safety_stop_enabled ; disable safety stop by default | |
1726 | |
1727 ; check for deco | |
1728 btfsc decostop_active ; in deco mode? | |
1729 bra safety_stop_finish ; YES - shut down safety stop | |
1730 | |
1731 ; below "opt_safety_stop_reset"? | |
1732 MOVII pressure_rel_cur_cached,mpr ; get current pressure into MPR | |
1733 call convert_pres_to_depth ; convert pressure in [mbar] to depth in [cm] | |
1734 MOVII mpr,sub_a ; move depth in [cm] to sub_a | |
1735 movff opt_safety_stop_reset,WREG ; load safety stop reset threshold [dm] | |
1736 mullw .10 ; convert threshold from [dm] to [cm] | |
1737 MOVII PROD,sub_b ; move threshold in [cm] to sub_b | |
1738 call cmpU16 ; sub_a - sub_b | |
1739 btfsc neg_flag ; below threshold depth? | |
1740 bra safety_stop_control_chk ; NO - check if above end threshold | |
1741 ;bra safety_stop_reset ; YES - reset safety stop | |
1742 | |
1743 safety_stop_reset: | |
1744 movff opt_safety_stop_length,safety_stop_countdown ; rearm safety stop (load timer) | |
1745 incf safety_stop_countdown,F ; +1 because safety_stop_show decrements first | |
1746 bsf FLAG_TFT_safety_stop_clear ; request to clear safety stop | |
1747 return ; done | |
1748 | |
1749 safety_stop_control_chk: | |
1750 ; above "opt_safety_stop_end"? | |
1751 movff opt_safety_stop_end,WREG ; load safety stop end threshold [dm] | |
1752 mullw .10 ; convert threshold from [dm] to [cm] | |
1753 MOVII PROD,sub_b ; move threshold in [cm] to sub_b | |
1754 call cmpU16 ; sub_a - sub_b | |
1755 btfsc neg_flag ; above or at threshold depth? | |
1756 bra safety_stop_finish ; YES - finish with safety stop and return | |
1757 | |
1758 ; above "opt_safety_stop_start"? | |
1759 movff opt_safety_stop_start,WREG ; load safety stop start threshold [dm] | |
1760 mullw .10 ; convert threshold from [dm] to [cm] | |
1761 MOVII PROD,sub_b ; move threshold in [cm] to sub_b | |
1762 call cmpU16 ; sub_a - sub_b | |
1763 btfss neg_flag ; above or at threshold depth? | |
1764 return ; NO - pause safety stop | |
1765 tstfsz safety_stop_countdown ; YES - safety stop armed? | |
1766 bsf safety_stop_enabled ; YES - enable safety stop | |
1767 return ; - done | |
1768 | |
1769 | |
1770 ;----------------------------------------------------------------------------- | |
1771 ; Show Safety Stop | |
1772 ; | |
1773 safety_stop_show: | |
1774 btfss safety_stop_enabled ; safety stop enabled? | |
1775 return ; NO - done | |
1776 dcfsnz safety_stop_countdown,F ; YES - decrement remaining stop time, reached zero? | |
1777 bra safety_stop_finish ; YES - finished with safety stop and return | |
1778 bsf FLAG_TFT_safety_stop_show ; NO - request to show safety stop | |
1779 return ; - done | |
1780 | |
1781 | |
1782 ;----------------------------------------------------------------------------- | |
1783 ; Finish Safety Stop | |
1784 ; | |
1785 safety_stop_finish: | |
1786 clrf safety_stop_countdown ; disarm safety stop | |
1787 bcf safety_stop_enabled ; disable safety stop | |
1788 bsf FLAG_TFT_safety_stop_clear ; request to clear safety stop | |
1789 return ; done | |
1790 | |
1791 | |
1792 ;----------------------------------------------------------------------------- | |
1793 ; Check for Timeouts (called by tasks every 1/1 second) | |
1794 ; | |
1795 timeout_divemode: | |
1796 btfss dive_main_menu ; main dive menu shown? | |
1797 bra timeout_divemode_1 ; NO - skip | |
1798 btfsc trigger_timeout ; YES - timeout occurred? | |
1799 rcall divemenu_cleanup ; YES - clean up main menu and restore dive data | |
1800 | |
1801 timeout_divemode_1: | |
1802 btfss dive_pre_menu ; pre-menu shown? | |
1803 bra timeout_divemode_2 ; NO - skip | |
1804 btfsc trigger_timeout ; YES - timeout occurred? | |
1805 call menuview_toggle_reset ; YES - terminate the pre-menu | |
1806 | |
1807 timeout_divemode_2: | |
1808 btfss divetime_longer_1min ; does the dive already last for longer than one minute? | |
1809 return ; NO - suspend timeout | |
1810 | |
1811 INCI dive_timeout_timer ; increment timeout timer | |
1812 | |
1813 btfsc FLAG_apnoe_mode ; in apnoe mode? | |
1814 bra timeout_divemode_apnoe ; YES - use apnoe timeout | |
1815 | |
1816 IFNDEF _DEBUG | |
1817 btfsc sensor_override_active ; in simulator mode? | |
1818 bra timeout_divemode_sim ; YES - use simulator timeout | |
1819 ENDIF | |
1820 | |
1821 movff opt_diveTimeout,WREG ; get dive timeout in minutes into WREG | |
1822 bra timeout_divemode_com_min ; continue with common part for minutes | |
1823 | |
1824 timeout_divemode_apnoe: | |
1825 movlw apnoe_timeout ; get apnoe timeout in minutes into WREG | |
1826 bra timeout_divemode_com_min ; continue with common part for minutes | |
1827 | |
1828 timeout_divemode_sim: | |
1829 MOVLI simulator_timeout,sub_a ; get simulator timeout in seconds directly into sub_a | |
1830 bra timeout_divemode_com_sec ; continue with common part for seconds | |
1831 | |
1832 timeout_divemode_com_min: | |
1833 mullw .60 ; multiply with 60 to convert minutes in WREG to seconds | |
1834 MOVII PRODL,sub_a ; copy resulting seconds to sub_a | |
1835 | |
1836 timeout_divemode_com_sec: | |
1837 MOVII dive_timeout_timer,sub_b ; copy current timeout timer value to sub_b | |
1838 call cmpU16 ; check sub_a - sub_b | |
1839 btfsc neg_flag ; result negative, i.e. timeout? | |
1840 bcf divemode ; YES - terminate dive mode | |
1841 return ; done | |
1842 | |
1843 | |
1844 ;----------------------------------------------------------------------------- | |
1845 ; Clean up Dive Menu Area and restore Dive Data | |
1846 ; | |
1847 divemenu_cleanup: | |
1848 bcf dive_main_menu ; clear flag for dive mode menu shown | |
1849 call TFT_clear_divemode_menu ; clear menu area | |
1850 | |
1851 btfss custom_view_locked ; was the custom view locked by the menu system? | |
1852 bra divemenu_cleanup_1 ; NO - continue with redrawing the lower display | |
1853 bcf custom_view_locked ; YES - release locked | |
1854 movf backup_customview,W ; - get previous custom view into WREG | |
1855 cpfseq active_customview ; - compare with current custom view, equal? | |
1856 call dive_customview_recall ; NO - redraw previous custom view | |
1857 | |
1858 divemenu_cleanup_1: | |
1859 bsf FLAG_TFT_active_gas_divemode; request redraw of gas/setpoint/diluent | |
1860 bsf FLAG_TFT_temperature ; request redraw of temperature (or resettable dive) | |
1861 bcf better_gas_blinking ; stop better gas cue | |
1862 bcf better_dil_blinking ; stop better dil cue | |
1863 ;bra request_redraw_NDL_deco_data; request redraw of NDL/deco data and return | |
1864 | |
1865 | |
1866 ;----------------------------------------------------------------------------- | |
1867 ; Request redraw of NDL/Deco Data | |
1868 ; | |
1869 request_redraw_NDL_deco_data: | |
1870 btfsc FLAG_gauge_mode ; in gauge mode? | |
1871 return ; YES - done | |
1872 btfss decostop_active ; NO - in deco mode? | |
1873 bra timeout_divemode_menu_ndl ; NO - show NDL again | |
1874 ;bra timeout_divemode_menu_deco ; YES - show deco again | |
1875 | |
1876 timeout_divemode_menu_deco: | |
1877 bsf FLAG_TFT_display_deco_mask ; show deco mask | |
1878 bsf FLAG_TFT_display_deco ; show deco stop | |
1879 bsf FLAG_TFT_display_tts ; show TTS time | |
1880 return ; done | |
1881 | |
1882 timeout_divemode_menu_ndl: | |
1883 bsf FLAG_TFT_display_ndl_mask ; show NDL mask | |
1884 bsf FLAG_TFT_display_ndl ; show NDL time | |
1885 return ; done | |
1886 | |
1887 | |
1888 ;----------------------------------------------------------------------------- | |
1889 ; Check if Dive Mode needs to be started (called from Surface Mode) | |
1890 ; | |
1891 global check_dive_modes_surf | |
1892 check_dive_modes_surf: | |
1893 SMOVII pressure_rel_cur,sub_a ; ISR-safe 2 byte copy of current relative pressure to sub_a | |
1894 bcf divetime_longer_1min ; not diving when in surface mode | |
1895 bra check_dive_modes ; continue with common part | |
1896 | |
1897 | |
1898 ;----------------------------------------------------------------------------- | |
1899 ; Check if Dive Mode needs to be finished (called from Dive Loop) | |
1900 ; | |
1901 check_dive_modes_dive: | |
1902 MOVII pressure_rel_cur_cached,sub_a ; copy cached relative pressure to sub_a | |
1903 ;bra check_dive_modes ; continue with common part | |
1904 | |
1905 | |
1906 ;----------------------------------------------------------------------------- | |
1907 ; Check for Dive Mode Start/Finish - common Part | |
1908 ; | |
1716 check_dive_modes: | 1909 check_dive_modes: |
1717 MOVII pressure_rel_cur_cached,sub_a; copy cached relative pressure to sub_a | 1910 btfss high_altitude_mode ; in high altitude mode? |
1718 set_dive_modes_1: | 1911 bra check_dive_modes_norm ; NO - use normal start-dive threshold |
1719 btfss high_altitude_mode ; in high altitude mode? | 1912 btfsc divetime_longer_1min ; YES - diving since > one minute? |
1720 bra set_dive_modes_norm ; NO - use normal start-dive threshold | 1913 bra check_dive_modes_norm ; YES - this is a real dive -> use normal start-dive threshold |
1721 btfsc divetime_longer_1min ; YES - dive lasted longer than one minute? | 1914 ;bra check_dive_modes_high ; NO - use hight-altitude start-dive threshold |
1722 bra set_dive_modes_norm ; YES - this is a real dive -> use normal start-dive threshold | 1915 |
1723 ;bra set_dive_modes_high ; NO - use hight-altitude start-dive threshold | 1916 check_dive_modes_high: |
1724 | |
1725 ; high altitude start/end dive thresholds | 1917 ; high altitude start/end dive thresholds |
1726 set_dive_modes_high: | 1918 btfss count_divetime ; dive time counting, i.e. already in the dive? |
1727 btfss count_divetime ; dive time counting, i.e. already in the dive? | 1919 bra check_dive_modes_high_start ; NO - select start threshold |
1728 bra set_dive_modes_high_start ; NO - select start threshold | 1920 ;bra check_dive_modes_high_end ; YES - select end threshold |
1729 ;bra set_dive_modes_high_end ; YES - select end threshold | 1921 |
1730 | 1922 check_dive_modes_high_end: |
1731 set_dive_modes_high_end: | 1923 MOVLI dive_threshold_high_alt_end,sub_b ; load high altitude end threshold |
1732 MOVLI dive_threshold_high_alt_end,sub_b | 1924 bra check_dive_modes_comm ; continue with common part |
1733 bra set_dive_modes_comm | 1925 |
1734 | 1926 check_dive_modes_high_start: |
1735 set_dive_modes_high_start: | 1927 MOVLI dive_threshold_high_alt_start,sub_b ; load high altitude start threshold |
1736 MOVLI dive_threshold_high_alt_start,sub_b | 1928 bra check_dive_modes_comm ; continue with common part |
1737 bra set_dive_modes_comm | 1929 |
1738 | 1930 check_dive_modes_norm: |
1739 ; normal altitude start/end dive thresholds | 1931 ; normal altitude start/end dive thresholds |
1740 set_dive_modes_norm: | 1932 btfss count_divetime ; dive time counting, i.e. already in the dive? |
1741 btfss count_divetime ; dive time counting, i.e. already in the dive? | 1933 bra check_dive_modes_norm_start ; NO - select start threshold |
1742 bra set_dive_modes_norm_start ; NO - select start threshold | 1934 ;bra check_dive_modes_norm_end ; YES - select end threshold |
1743 ;bra set_dive_modes_norm_end ; YES - select end threshold | 1935 |
1744 | 1936 check_dive_modes_norm_end: |
1745 set_dive_modes_norm_end: | 1937 MOVLI dive_threshold_norm_alt_end,sub_b ; load normal altitude end threshold |
1746 MOVLI dive_threshold_norm_alt_end,sub_b | 1938 bra check_dive_modes_comm ; continue with common part |
1747 bra set_dive_modes_comm | 1939 |
1748 | 1940 check_dive_modes_norm_start |
1749 set_dive_modes_norm_start | 1941 MOVLI dive_threshold_norm_alt_start,sub_b ; load normal altitude start threshold |
1750 MOVLI dive_threshold_norm_alt_start,sub_b | 1942 ;bra check_dive_modes_comm ; continue with common part |
1751 ;bra set_dive_modes_comm | 1943 |
1752 | 1944 check_dive_modes_comm: |
1753 set_dive_modes_comm: | 1945 call cmpU16 ; sub_a - sub_b = pressure_rel_cur - start-dive threshold |
1754 call cmpU16 ; sub_a - sub_b = pressure_rel_cur - start-dive threshold | 1946 btfsc neg_flag ; pressure_rel_cur > dive_threshold, i.e. deeper than threshold? |
1755 btfsc neg_flag ; pressure_rel_cur > dive_threshold, i.e. deeper than threshold? | 1947 bra check_dive_modes_shallow ; NO - shallower than threshold |
1756 bra set_dive_modes_shallow ; NO - shallower than threshold | 1948 btfsc divetime_longer_1min ; YES - diving > one minute? |
1757 btfsc divetime_longer_1min ; YES - dive lasted longer than one minute? | 1949 CLRI dive_timeout_timer ; YES - reset timeout counter |
1758 CLRI dive_timeout_timer ; YES - reset timeout counter | 1950 bsf divemode ; - set dive mode flag |
1759 bsf divemode ; - set dive mode flag | 1951 bsf count_divetime ; - count dive time |
1760 bsf count_divetime ; - count dive time | 1952 return ; - done |
1761 return ; - done | 1953 |
1762 set_dive_modes_shallow: | 1954 check_dive_modes_shallow: |
1763 bcf count_divetime ; NO - stop counting dive time | 1955 bcf count_divetime ; stop counting dive time |
1764 btfss divetime_longer_1min ; - dive lasted longer than one minute? | 1956 btfss divetime_longer_1min ; diving > one minute? |
1765 bcf divemode ; NO - quit dive mode as this was no real dive | 1957 bcf divemode ; NO - quit dive mode as this was no real dive |
1766 return ; done | 1958 return ; done |
1767 | 1959 |
1768 | 1960 |
1769 set_powersafe: | 1961 ;----------------------------------------------------------------------------- |
1770 movlw d'7' ; set type of alarm = battery low | 1962 ; Initialize the resettable Depth and Timer |
1771 movwf alarm_type ; copy to alarm register | 1963 ; |
1772 bsf event_occured ; set event flag | 1964 resettable_average_depth_init: |
1773 movlw .0 ; coding of brightness level ECO | 1965 CLRI pressure_rel_avg_trip ; prime the resettable average depth with 0 |
1774 movff WREG,opt_brightness ; set brightness to ECO | 1966 bra resettable_average_depth_common ; clear pressure accumulator and timer |
1775 return ; done | 1967 |
1776 | 1968 |
1777 | 1969 ;----------------------------------------------------------------------------- |
1778 clear_resettable_average_depth: | 1970 ; Reset the resettable Depth and Timer |
1779 ; prime the resettable average depth with 0 | 1971 ; |
1780 CLRI pressure_rel_avg_trip | 1972 resettable_average_depth_reset: |
1781 bra reset_resettable_average_depth1 | 1973 bcf request_reset_avg ; clear request |
1782 | 1974 MOVII pressure_rel_cur_cached,pressure_rel_avg_trip ; prime the resettable average depth |
1783 reset_resettable_average_depth: | 1975 ; with the current relative pressure (depth) |
1784 ; clear reset-average request | 1976 ;bra resettable_average_depth_common ; clear pressure accumulator and timer |
1785 bcf request_reset_avg | 1977 |
1786 | 1978 |
1787 ; prime the resettable average depth with the current relative pressure (depth) | 1979 ;----------------------------------------------------------------------------- |
1788 MOVII pressure_rel_cur_cached,pressure_rel_avg_trip | 1980 ; Helper Function - common Part for resettable Depth and Timer init/reset |
1789 | 1981 ; |
1790 reset_resettable_average_depth1: | 1982 resettable_average_depth_common: |
1791 ; clear the resettable depth accumulator | 1983 clrf pressure_rel_accu_trip+0 ; clear the resettable depth accumulator |
1792 clrf pressure_rel_accu_trip+0 | 1984 clrf pressure_rel_accu_trip+1 ; .... |
1793 clrf pressure_rel_accu_trip+1 | 1985 clrf pressure_rel_accu_trip+2 ; .... |
1794 clrf pressure_rel_accu_trip+2 | 1986 clrf pressure_rel_accu_trip+3 ; .... |
1795 clrf pressure_rel_accu_trip+3 | 1987 CLRI divesecs_avg_trip ; clear the resettable time accumulator |
1796 | 1988 return ; done |
1797 ; clear the resettable time accumulator | 1989 |
1798 CLRI divesecs_avg_trip | 1990 |
1799 return | 1991 ;----------------------------------------------------------------------------- |
1800 | 1992 ; Calculate Average Depth |
1801 | 1993 ; |
1802 calc_average_depth: | 1994 calc_average_depth: |
1803 ; 1. compute pressure_rel_cur_cached x 2, because this routine is called every 2nd second only | 1995 ; 1. compute pressure_rel_cur_cached x 2, because this routine is called every 2nd second only |
1804 | 1996 MOVII pressure_rel_cur_cached,xB ; copy current rel pressure to xB |
1805 ; copy current rel pressure to xB | 1997 bcf STATUS,C ; multiply rel pressure x 2 (via shift left) |
1806 MOVII pressure_rel_cur_cached,xB | 1998 rlcf xB+0,F ; ... |
1807 | 1999 rlcf xB+1,F ; ... |
1808 ; multiply rel pressure x 2 (via shift left) | |
1809 bcf STATUS,C | |
1810 rlcf xB+0,F | |
1811 rlcf xB+1,F | |
1812 | 2000 |
1813 ; 2a add (pressure_rel_cur_cached x 2) to the resettable depth accumulator | 2001 ; 2a add (pressure_rel_cur_cached x 2) to the resettable depth accumulator |
1814 ; will work up to 9999 mbar * 60 * 60 * 24 = 863913600 mbar (24h @ 90 m depth) | 2002 ; will work up to 9999 mbar * 60 * 60 * 24 = 863913600 mbar (24h @ 90 m depth) |
1815 movf xB+0,W | 2003 movf xB+0,W ; pressure_rel_accu_trip += xB |
1816 addwf pressure_rel_accu_trip+0,F | 2004 addwf pressure_rel_accu_trip+0,F ; ... |
1817 movf xB+1,W | 2005 movf xB+1,W ; ... |
1818 addwfc pressure_rel_accu_trip+1,F | 2006 addwfc pressure_rel_accu_trip+1,F ; ... |
1819 movlw .0 | 2007 movlw .0 ; ... |
1820 addwfc pressure_rel_accu_trip+2,F | 2008 addwfc pressure_rel_accu_trip+2,F ; ... |
1821 addwfc pressure_rel_accu_trip+3,F | 2009 addwfc pressure_rel_accu_trip+3,F ; ... |
1822 | 2010 |
1823 ; 2b add (pressure_rel_cur_cached x 2) to the total depth accumulator | 2011 ; 2b add (pressure_rel_cur_cached x 2) to the total depth accumulator |
1824 ; will work up to 9999 mbar * 60 * 60 * 24 = 863913600 mbar (24h @ 90 m depth) | 2012 ; will work up to 9999 mbar * 60 * 60 * 24 = 863913600 mbar (24h @ 90 m depth) |
1825 movf xB+0,W | 2013 movf xB+0,W ; pressure_rel_accu_total += xB |
1826 addwf pressure_rel_accu_total+0,F | 2014 addwf pressure_rel_accu_total+0,F ; ... |
1827 movf xB+1,W | 2015 movf xB+1,W ; ... |
1828 addwfc pressure_rel_accu_total+1,F | 2016 addwfc pressure_rel_accu_total+1,F ; ... |
1829 movlw .0 | 2017 movlw .0 ; ... |
1830 addwfc pressure_rel_accu_total+2,F | 2018 addwfc pressure_rel_accu_total+2,F ; ... |
1831 addwfc pressure_rel_accu_total+3,F | 2019 addwfc pressure_rel_accu_total+3,F ; ... |
1832 | 2020 |
1833 ; 3a compute the resettable average depth | 2021 ; 3a compute the resettable average depth |
1834 | 2022 movff pressure_rel_accu_trip+0,xC+0 ; get the accumulated depth |
1835 ; get the accumulated depth | 2023 movff pressure_rel_accu_trip+1,xC+1 ; ... |
1836 movff pressure_rel_accu_trip+0,xC+0 | 2024 movff pressure_rel_accu_trip+2,xC+2 ; ... |
1837 movff pressure_rel_accu_trip+1,xC+1 | 2025 movff pressure_rel_accu_trip+3,xC+3 ; ... |
1838 movff pressure_rel_accu_trip+2,xC+2 | 2026 MOVII divesecs_avg_trip,xB ; get the accumulated time |
1839 movff pressure_rel_accu_trip+3,xC+3 | |
1840 | |
1841 ; get the accumulated time | |
1842 MOVII divesecs_avg_trip,xB | |
1843 | 2027 |
1844 ; divide accumulated depth by accumulated time | 2028 ; divide accumulated depth by accumulated time |
1845 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | 2029 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder |
1846 | 2030 |
1847 ; store result | 2031 ; store result |
1848 MOVII xC,pressure_rel_avg_trip ; resettable average depth | 2032 MOVII xC,pressure_rel_avg_trip ; resettable average depth |
1849 btfss count_divetime ; is dive time counted? | 2033 btfss count_divetime ; is dive time counted? |
1850 return ; NO (e.g. too shallow) | 2034 return ; NO (e.g. too shallow) |
1851 | 2035 |
1852 ; 3b compute the dive total average depth | 2036 ; 3b compute the dive total average depth |
1853 | 2037 movff pressure_rel_accu_total+0,xC+0 ; get accumulated depth |
1854 ; get accumulated depth | 2038 movff pressure_rel_accu_total+1,xC+1 ; ... |
1855 movff pressure_rel_accu_total+0,xC+0 | 2039 movff pressure_rel_accu_total+2,xC+2 ; ... |
1856 movff pressure_rel_accu_total+1,xC+1 | 2040 movff pressure_rel_accu_total+3,xC+3 ; ... |
1857 movff pressure_rel_accu_total+2,xC+2 | 2041 MOVII divesecs_avg_total,xB ; get accumulated time |
1858 movff pressure_rel_accu_total+3,xC+3 | |
1859 | |
1860 ; get accumulated time | |
1861 MOVII divesecs_avg_total,xB | |
1862 | 2042 |
1863 ; divide accumulated depth by accumulated time | 2043 ; divide accumulated depth by accumulated time |
1864 call div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder | 2044 call div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder |
1865 | 2045 |
1866 ; store result | 2046 ; store result |
1867 MOVII xC,pressure_rel_avg_total ; total dive average depth | 2047 MOVII xC,pressure_rel_avg_total ; total dive average depth |
1868 | 2048 |
1869 btfsc request_reset_avg ; shall reset the resettable average depth? | 2049 btfsc request_reset_avg ; shall reset the resettable average depth? |
1870 rcall reset_resettable_average_depth ; YES - reset the resettable average depth | 2050 rcall resettable_average_depth_reset ; YES - reset the resettable average depth |
1871 | 2051 |
1872 TSTOSC opt_2ndDepthDisp ; drawing average depth instead of max depth? | 2052 TSTOSC opt_2ndDepthDisp ; drawing average depth instead of max depth? |
1873 bsf FLAG_TFT_depth_maximum ; YES - flag to update display | 2053 bsf FLAG_TFT_depth_maximum ; YES - flag to update display |
1874 | 2054 |
1875 btfsc FLAG_gauge_mode ; in gauge mode? | 2055 btfsc FLAG_gauge_mode ; in gauge mode? |
1876 bsf FLAG_TFT_depth_maximum ; YES - flag to update display (needed for alternative layout) | 2056 bsf FLAG_TFT_depth_maximum ; YES - flag to update display (needed for alternative layout) |
1877 | 2057 |
1878 return ; done | 2058 return ; done |
1879 | 2059 |
1880 | 2060 |
1881 test_switches_divemode: ; checks switches in dive mode, called every second | 2061 ;----------------------------------------------------------------------------- |
2062 ; Check Switches, execute Pre-Menu Items (called every second) | |
2063 ; | |
2064 test_switches_divemode: | |
1882 btfsc dive_main_menu ; dive mode menu shown? | 2065 btfsc dive_main_menu ; dive mode menu shown? |
1883 bra test_switches_divemode_menu ; YES - use menu processor | 2066 bra test_switches_divemode_menu ; YES - use menu processor |
1884 btfsc switch_left ; NO - left button pressed? | 2067 btfsc switch_left ; NO - left button pressed? |
1885 goto menuview_toggle ; YES - menu or simulator tasks; and return... | 2068 goto menuview_toggle ; YES - step through pre-menu |
1886 btfss switch_right ; NO - right button pressed? | 2069 btfss switch_right ; NO - right button pressed? |
1887 return ; NO - done | 2070 return ; NO - done |
1888 bcf switch_right ; YES - clear button event | 2071 bcf switch_right ; YES - clear button event |
1889 tstfsz active_premenu ; - any pre-menu task selected? | 2072 tstfsz active_premenu ; - any pre-menu task selected? |
1890 bra test_switches_divemode1 ; YES - do option or menu tasks | 2073 bra test_switches_divemode1 ; YES - execute a pre-menu item |
1891 bsf request_next_custview ; NO - request next custom view | 2074 bsf request_next_custview ; NO - request next custom view |
1892 return ; - done | 2075 return ; - done |
1893 | 2076 |
1894 test_switches_divemode_menu: | 2077 test_switches_divemode_menu: |
1895 btfsc switch_left ; left button pressed? | 2078 btfsc switch_left ; left button pressed? |
1896 bra test_switches_divemode_menu2 ; YES - move cursor | 2079 bra test_switches_divemode_menu2 ; YES - move cursor |
1897 btfsc switch_right ; NO - right button pressed? | 2080 btfsc switch_right ; NO - right button pressed? |
1898 bra test_switches_divemode_menu3 ; YES - enter sub-menu or do something | 2081 bra test_switches_divemode_menu3 ; YES - do a menu operation |
1899 btfss update_menu ; NO - shall update the menu? | 2082 btfss update_menu ; NO - shall update the menu? |
1900 return ; NO - done | 2083 return ; NO - done |
1901 bcf update_menu ; YES - clear request | 2084 bcf update_menu ; YES - clear request |
1902 goto menu_draw_lines_divemode ; - redraw the menu (to update color coding) and return | 2085 goto menu_draw_lines_divemode ; - redraw the menu (to update color coding) and return |
1903 | 2086 |
1904 test_switches_divemode_menu1: | 2087 test_switches_divemode_menu1: |
1905 clrf menu_pos_cur | 2088 clrf menu_pos_cur ; reset menu item number to zero |
1906 test_switches_divemode_menu2: | 2089 test_switches_divemode_menu2: |
1907 bcf switch_left | 2090 bcf switch_left ; clear left button event |
1908 incf menu_pos_cur,F | 2091 incf menu_pos_cur,F ; increment menu item number |
1909 incf menu_pos_max,W ; menu_pos_max + 1 -> WREG | 2092 incf menu_pos_max,W ; get number of items + 1 into WREG |
1910 cpfslt menu_pos_cur ; > menu_pos_max ? | 2093 cpfslt menu_pos_cur ; incremented item number > number of items ? |
1911 bra test_switches_divemode_menu1 ; YES - set to 1 | 2094 bra test_switches_divemode_menu1 ; YES - restart from first item |
1912 call TFT_show_menu_cursor_divemode ; update the cursor | 2095 call menu_draw_cursor_dive ; draw cursor at new position |
1913 movlw divemode_timeout_mainmenu ; get timeout for main menu | 2096 movlw divemode_timeout_mainmenu ; get timeout for main menu |
1914 call reset_timeout_time ; reset timeout | 2097 call restart_timeout_time ; restart the timeout |
1915 return | 2098 return ; done |
1916 | 2099 |
1917 test_switches_divemode_menu3: ; enter sub-menu or do something | 2100 test_switches_divemode_menu3: |
1918 bcf switch_right | 2101 bcf switch_right ; clear right button event |
1919 ; decf menu_pos_cur,F ; menu_processor needs 0-5... | 2102 goto do_line_menu ; Warning! trashes STKPTR and returns to |
1920 goto do_line_menu ; Warning! trashes STKPTR and returns to diveloop_menu_exit | 2103 ; divemode_option_divemenu_return |
1921 | 2104 |
1922 test_switches_divemode1: | 2105 test_switches_divemode1: |
1923 movlw divemode_timeout_premenu ; get timeout for pre-menu | 2106 movlw divemode_timeout_premenu ; get timeout for pre-menu |
1924 call reset_timeout_time ; reset timeout | 2107 call restart_timeout_time ; restart the timeout |
1925 movff active_premenu,WREG ; get number of active pre-menu | 2108 movf active_premenu,W ; get active pre-menu item |
1926 dcfsnz WREG,F | 2109 dcfsnz WREG,F |
1927 bra divemode_option_gaschange ; 1: switch to the the "better gas" / "better diluent" | 2110 bra divemode_option_gaschange ; 1: switch to the the "better gas" / "better diluent" |
1928 dcfsnz WREG,F | 2111 dcfsnz WREG,F |
1929 bra divemode_option_divemenu ; 2: enter dive mode menu | 2112 bra divemode_option_ackn ; 2: acknowledge current advice, attention, or warning |
2113 dcfsnz WREG,F | |
2114 bra divemode_option_divemenu ; 3: enter dive mode menu | |
1930 dcfsnz WREG,F | 2115 dcfsnz WREG,F |
1931 IFDEF _cave_mode | 2116 IFDEF _cave_mode |
1932 bra divemode_option_cavemenu ; 3: enter cave mode menu | 2117 bra divemode_option_cavemenu ; 4: enter cave mode menu |
1933 ELSE | 2118 ELSE |
1934 return ; 3: (no cave mode compiled in) | 2119 return ; 4: (no cave mode compiled in) |
1935 ENDIF | 2120 ENDIF |
1936 dcfsnz WREG,F | 2121 dcfsnz WREG,F |
1937 bra divemode_option_sim_quit ; 4: simulation - quit | 2122 bra divemode_option_sim_quit ; 5: quit simulator mode |
1938 dcfsnz WREG,F | 2123 dcfsnz WREG,F |
1939 bra divemode_option_sim_down ; 5: simulation - descent | 2124 bra divemode_option_sim_down ; 6: simulator mode - descent |
1940 dcfsnz WREG,F | 2125 dcfsnz WREG,F |
1941 bra divemode_option_sim_up ; 6: simulation - ascend | 2126 bra divemode_option_sim_up ; 7: simulator mode - ascend |
1942 dcfsnz WREG,F | 2127 dcfsnz WREG,F |
1943 bra divemode_option_sim_time ; 7: simulation - +5 min | 2128 bra divemode_option_sim_time ; 8: simulator mode - +5 min |
1944 dcfsnz WREG,F | 2129 dcfsnz WREG,F |
1945 bra divemode_option_apnoe_quit ; 8: apnoe - quit | 2130 bra divemode_option_apnoe_quit ; 9: quit apnoe dive |
1946 dcfsnz WREG,F | 2131 dcfsnz WREG,F |
1947 bra divemode_option_gauge_reset ; 9: gauge - reset stopwatch and avg depth | 2132 bra divemode_option_gauge_reset ; 10: reset stopwatch and avg depth (gauge mode) |
1948 dcfsnz WREG,F | 2133 dcfsnz WREG,F |
1949 IFDEF _compass | 2134 IFDEF _compass |
1950 bra divemode_option_course ; 10: store heading | 2135 bra divemode_option_course ; 11: set bearing |
1951 ELSE | 2136 ELSE |
1952 return ; 10: (no compass compiled in) | 2137 return ; 11: (no compass compiled in) |
1953 ENDIF | 2138 ENDIF |
1954 dcfsnz WREG,F | 2139 dcfsnz WREG,F |
1955 bra divemode_option_layout ; 11: switch layout | 2140 bra divemode_option_layout ; 12: switch layout |
1956 return | 2141 return ; catch illegal item number |
1957 | 2142 |
1958 | 2143 |
2144 ; item 1: switch to the the "better gas" / "better diluent" | |
2145 ; | |
2146 divemode_option_gaschange: | |
2147 IFDEF _ccr_pscr | |
2148 btfsc FLAG_oc_mode ; in OC mode? | |
2149 bra divemode_option_gaschange_oc ; YES | |
2150 btfsc bailout_mode ; in bailout? | |
2151 bra divemode_option_gaschange_oc ; YES | |
2152 | |
2153 ; in CCR/pSCR mode and not in bailout | |
2154 movff best_dil_number,menu_pos_cur ; select best diluent | |
2155 bcf better_dil_available ; clear flag immediately | |
2156 bra divemode_option_gaschange3 ; continue with common part | |
2157 ENDIF | |
2158 divemode_option_gaschange_oc: | |
2159 movff best_gas_number,menu_pos_cur ; select best gas | |
2160 bcf better_gas_available ; clear better gas cue | |
2161 | |
2162 divemode_option_gaschange3 | |
2163 bsf request_gas_change ; request a gas/diluent change | |
2164 goto menuview_toggle_reset ; terminate the pre-menu (and return) | |
2165 | |
2166 | |
2167 ; item 2: acknowledge current advice, attention, or warning | |
2168 ; | |
2169 divemode_option_ackn: | |
2170 btfss sign_warning ; any warning active? | |
2171 bra divemode_option_ackn_attn ; NO - check for active attentions | |
2172 movff DM_flags_war1_det,DM_flags_war1_ack ; YES - memorize active warnings as acknowledged | |
2173 movff DM_flags_war2_det,DM_flags_war2_ack ; - ... | |
2174 bra divemode_option_ackn_common ; - update screen | |
2175 | |
2176 divemode_option_ackn_attn: | |
2177 btfss sign_attention ; any attention active? | |
2178 bra divemode_option_ackn_advc ; NO - must be active advice then | |
2179 movff DM_flags_att1_det,DM_flags_att1_ack ; YES - memorize active attentions as acknowledged | |
2180 movff DM_flags_att2_det,DM_flags_att2_ack ; - ... | |
2181 movff DM_flags_att3_det,DM_flags_att3_ack ; - ... | |
2182 bra divemode_option_ackn_common ; - update screen | |
2183 | |
2184 divemode_option_ackn_advc: | |
2185 movff DM_flags_advc_det,DM_flags_advc_ack ; memorize active advices as acknowledged | |
2186 ;bra divemode_option_ackn_common ; update screen | |
2187 | |
2188 divemode_option_ackn_common: | |
2189 call menuview_toggle_reset ; terminate pre-menu | |
2190 call divemode_check_sign ; compute if the advice / attention / warning sign shall be shown | |
2191 btfsc FLAG_TFT_sign_show ; shall show the advice / attention / warning sign? | |
2192 goto TFT_divemode_sign_show ; YES - show sign and return | |
2193 goto TFT_divemode_sign_clear ; NO - clear sign and return | |
2194 | |
2195 | |
2196 ; item 3: enter dive mode menu | |
2197 ; | |
2198 divemode_option_divemenu: | |
2199 btfss divemode ; in dive mode? | |
2200 goto menuview_toggle_reset ; NO - block menu, terminate the pre-menu | |
2201 call TFT_clear_divemode_menu ; YES - clear menu area | |
2202 bcf dive_pre_menu ; - set pre-menu as not shown anymore | |
2203 goto do_main_divemenu ; - hand over to menu processor | |
2204 | |
2205 | |
2206 ; item 4: enter cave mode menu | |
2207 ; | |
2208 IFDEF _cave_mode | |
2209 divemode_option_cavemenu: | |
2210 btfss divemode ; in dive mode? | |
2211 goto menuview_toggle_reset ; NO - block menu, terminate the pre-menu | |
2212 call TFT_clear_divemode_menu ; YES - clear menu area | |
2213 bcf dive_pre_menu ; - set pre-menu as not shown anymore | |
2214 goto do_main_cavemenu ; - hand over to menu processor | |
2215 ENDIF | |
2216 | |
2217 | |
2218 ; item 5: quit simulator mode | |
2219 ; | |
2220 divemode_option_sim_quit: | |
2221 clrf simulatormode_depth ; set target depth to zero | |
2222 bsf quit_simulatormode ; request ISR to end simulator mode | |
2223 call menuview_toggle_reset ; terminate the pre-menu | |
2224 btfsc FLAG_apnoe_mode ; in apnoe mode? | |
2225 bcf divemode ; YES - force end of dive mode | |
2226 return ; done | |
2227 | |
2228 | |
2229 ; item 6: simulator mode - descent 1 meter | |
2230 ; | |
2231 divemode_option_sim_down: | |
2232 movlw ostc_depth_max-1 ; load depth limit into WREG | |
2233 cpfsgt simulatormode_depth ; simulated depth < limit ? | |
2234 incf simulatormode_depth,F ; YES - increment simulated depth | |
2235 return ; done | |
2236 | |
2237 | |
2238 ; item 7: simulator mode - ascent 1 meter | |
2239 ; | |
2240 divemode_option_sim_up: | |
2241 tstfsz simulatormode_depth ; simulated depth > 0 ? | |
2242 decf simulatormode_depth,F ; YES - decrement simulated depth | |
2243 return ; done | |
2244 | |
2245 | |
2246 ; item 8: simulator mode - +5 min | |
2247 ; | |
2248 divemode_option_sim_time: | |
2249 movff char_I_sim_advance_time,WREG ; get mailbox content | |
2250 tstfsz WREG ; mailbox clear (=0) ? | |
2251 return ; NO - still having a pending +5' request, refuse new request | |
2252 bra advance_time ; YES - advance time and return | |
2253 | |
2254 | |
2255 ; item 9: quit apnoe dive | |
2256 ; | |
2257 divemode_option_apnoe_quit: | |
2258 btfsc sensor_override_active ; in simulator mode? | |
2259 bra divemode_option_sim_quit ; YES - use simulator quit procedure | |
2260 bcf divemode ; NO - force end of dive mode | |
2261 return ; - done | |
2262 | |
2263 | |
2264 ; item 10: reset stopwatch and avg depth (gauge mode only) | |
2265 ; | |
2266 divemode_option_gauge_reset: | |
2267 bsf request_reset_avg ; request reset of average depth | |
2268 goto menuview_toggle_reset ; terminate pre-menu and return | |
2269 | |
2270 | |
2271 ; item 11: set bearing | |
2272 ; | |
2273 IFDEF _compass | |
2274 divemode_option_course: | |
2275 MOVII compass_heading_shown,compass_bearing | |
2276 bsf compass_bearing_set ; set flag to show heading | |
2277 goto menuview_toggle_reset ; terminate the pre-menu and return | |
2278 ENDIF | |
2279 | |
2280 | |
2281 ; item 12: switch layout | |
2282 ; | |
2283 divemode_option_layout: | |
2284 call menuview_toggle_reset ; terminate the pre-menu | |
2285 call TFT_ClearScreen ; clear the whole screen | |
2286 btg alt_layout_active ; toggle layout | |
2287 | |
2288 bcf depth_color_last ; set warning or attention on the depth not shown | |
2289 bcf depth_inverse_last ; set depth displayed in inverse as not shown | |
2290 bcf sign_shown ; set warning/attention/advice sign not shown | |
2291 bcf velocity_active_num ; set numerical vertical velocity display not shown | |
2292 bcf velocity_active_vsi ; set vertical vertical velocity display not shown | |
2293 bcf safety_stop_active ; set safety stop not shown | |
2294 | |
2295 bsf FLAG_TFT_divemode_mask ; request redraw of dive screen mask | |
2296 bsf FLAG_TFT_divetime ; request redraw of dive time | |
2297 bsf FLAG_TFT_depth_current ; request redraw of current depth | |
2298 bsf FLAG_TFT_depth_maximum ; request redraw of maximum depth | |
2299 bsf FLAG_TFT_active_gas_divemode; request redraw of gas and setpoint | |
2300 bsf FLAG_TFT_temperature ; request redraw of temperature | |
2301 bsf FLAG_TFT_customview_callup ; request redraw of custom view | |
2302 | |
2303 goto request_redraw_NDL_deco_data; request redraw of NDL/deco data and return | |
2304 | |
2305 | |
2306 ;----------------------------------------------------------------------------- | |
2307 ; Helper Function - advance Time by 5 Minutes (Simulator Mode) | |
2308 ; | |
2309 advance_time: | |
2310 ; advance tissues pressures and deco obligation by 5 minutes | |
2311 movlw .5 ; + 5 minutes | |
2312 movff WREG,char_I_sim_advance_time ; copy to mailbox | |
2313 call restart_deco_engine ; condition deco engine to execute the +5 minutes | |
2314 | |
2315 bcf count_divetime ; stop dive time incrementing in ISR | |
2316 ADDLI .5,counted_divetime_mins ; add 5 minutes to counted_divetime_mins | |
2317 ADDLI .300,total_divetime_secs ; add 5 minutes (300 seconds) to total_divetime_secs | |
2318 bsf count_divetime ; continue dive time incrementing in ISR | |
2319 | |
2320 ADDLI .300,divesecs_avg_trip ; add 5 minutes (300 seconds) to resettable time accumulator | |
2321 ADDLI .300,divesecs_avg_total ; add 5 minutes (300 seconds) to total time accumulator | |
2322 | |
2323 MOVII pressure_rel_cur_cached,xB ; calculate 300 x depth in mbar (300 = 5 min * 60 sec/min) | |
2324 MOVLI .300,xA ; ... | |
2325 call mult16x16 ; xC = xA * xB | |
2326 | |
2327 movf xC+0,W ; add to the resettable depth accumulator | |
2328 addwf pressure_rel_accu_trip+0,F ; ... | |
2329 movf xC+1,W ; ... | |
2330 addwfc pressure_rel_accu_trip+1,F ; ... | |
2331 movf xC+2,W ; ... | |
2332 addwfc pressure_rel_accu_trip+2,F ; ... | |
2333 movf xC+3,W ; ... | |
2334 addwfc pressure_rel_accu_trip+3,F ; ... | |
2335 | |
2336 movf xC+0,W ; add to the total depth accumulator | |
2337 addwf pressure_rel_accu_total+0,F ; ... | |
2338 movf xC+1,W ; ... | |
2339 addwfc pressure_rel_accu_total+1,F ; ... | |
2340 movf xC+2,W ; ... | |
2341 addwfc pressure_rel_accu_total+2,F ; ... | |
2342 movf xC+3,W ; ... | |
2343 addwfc pressure_rel_accu_total+3,F ; ... | |
2344 | |
2345 IFDEF _cave_mode | |
2346 ; update backtracking data | |
2347 btfss cave_mode ; cave mode switched on? | |
2348 bra divemode_option_sim_time_exit ; NO - skip backtracking depth recording | |
2349 btfsc dive_turned ; YES - dive turned? | |
2350 bra divemode_option_sim_time_exit ; YES - skip backtracking depth recording | |
2351 ;bra divemode_option_sim_time_exec ; NO - update backtracking depth recording | |
2352 | |
2353 divemode_option_sim_time_exec: | |
2354 movff backtrack_deltatime,hi ; backup time elapsed since last depth recording | |
2355 movlw .5 ; configure 5 minutes | |
2356 movwf lo ; use lo as loop counter | |
2357 | |
2358 divemode_option_sim_time_loop: | |
2359 call write_backtrack_1min_depth ; store a backtracking depth data set | |
2360 btfsc backtrack_entire_full ; backtracking storage entirely used up? | |
2361 bra divemode_option_sim_time_exit ; YES - abort backtracking depth recording | |
2362 decfsz lo,F ; NO - decrement loop counter, did it became zero? | |
2363 bra divemode_option_sim_time_loop ; NO - loop | |
2364 ;bra divemode_option_sim_time_done ; YES - done | |
2365 | |
2366 divemode_option_sim_time_done: | |
2367 movff hi,backtrack_deltatime ; restore time elapsed since last depth recording | |
2368 ENDIF ; _cave_mode | |
2369 | |
2370 divemode_option_sim_time_exit: | |
2371 return ; done (leaving option avail for repeated selection) | |
2372 | |
2373 | |
2374 ;----------------------------------------------------------------------------- | |
2375 ; Change Gas / Diluent | |
2376 ; | |
1959 gas_switch_common: | 2377 gas_switch_common: |
1960 bcf request_gas_change ; clear request flag | 2378 bcf request_gas_change ; clear request flag |
1961 IFDEF _ccr_pscr | 2379 IFDEF _ccr_pscr |
1962 btfss request_back_to_loop ; is a switchback from OC bailout to loop requested? | 2380 btfss request_back_to_loop ; is a switchback from OC bailout to loop requested? |
1963 bra gas_switched_common0 ; NO - continue with checking if selected gas is valid | 2381 bra gas_switched_common0 ; NO - continue with checking if selected gas is valid |
1964 bcf request_back_to_loop ; YES - clear flag | 2382 bcf request_back_to_loop ; YES - clear flag |
1965 movff active_dil,menu_pos_cur ; - reload last diluent | 2383 movff active_dil,menu_pos_cur ; - reload last diluent |
1966 bra gas_switched_common1 ; - continue with common part | 2384 bra gas_switched_common1 ; - continue with common part |
1967 ENDIF | 2385 ENDIF |
1968 gas_switched_common0: | 2386 gas_switched_common0: |
1969 tstfsz menu_pos_cur ; menu_pos_cur = 0 ? | 2387 tstfsz menu_pos_cur ; menu_pos_cur = 0 ? |
1970 bra gas_switched_common1 ; NO - valid gas | 2388 bra gas_switched_common1 ; NO - valid gas |
1971 return ; YES - something went wrong, invalid gas, abort | 2389 return ; YES - something went wrong, invalid gas, abort |
1972 gas_switched_common1: | 2390 gas_switched_common1: |
1973 movf menu_pos_cur,W ; get selected gas into WREG (1-5) | 2391 movf menu_pos_cur,W ; get selected gas into WREG (1-5) |
1974 IFDEF _ccr_pscr | 2392 IFDEF _ccr_pscr |
1975 btfsc FLAG_oc_mode ; in OC mode? | 2393 btfsc FLAG_oc_mode ; in OC mode? |
1976 bra gas_switched_common_OC ; YES | 2394 bra gas_switched_common_OC ; YES |
1977 btfsc bailout_mode ; in bailout? | 2395 btfsc bailout_mode ; in bailout? |
1978 bra gas_switched_common_OC ; YES | 2396 bra gas_switched_common_OC ; YES |
1979 gas_switched_common_loop: ; NO to both - must be loop mode then | 2397 gas_switched_common_loop: ; NO to both - must be loop mode then |
1980 rcall setup_dil_registers ; set up real tissues with WREG = diluent 1-6 | 2398 call setup_dil_registers ; set up real tissues with WREG = diluent 1-6 |
1981 rcall deco_setup_cc_diluents ; set up deco planning with WREG = diluent 1-6 | 2399 call deco_setup_cc_diluents ; set up deco planning with WREG = diluent 1-6 |
1982 bra gas_switched_common3 ; continue with common part | 2400 bra gas_switched_common3 ; continue with common part |
1983 ENDIF ; _ccr_pscr | 2401 ENDIF ; _ccr_pscr |
2402 | |
1984 gas_switched_common_OC: | 2403 gas_switched_common_OC: |
1985 rcall setup_gas_registers ; set up real tissues with WREG = gas 1-6 | 2404 call setup_gas_registers ; set up real tissues with WREG = gas 1-6 |
1986 rcall deco_setup_oc_gases ; set up deco planning with WREG = gas 1-6 | 2405 call deco_setup_oc_gases ; set up deco planning with WREG = gas 1-6 |
1987 ;bra gas_switched_common3 ; continue with common part | 2406 ;bra gas_switched_common3 ; continue with common part |
2407 | |
1988 gas_switched_common3: | 2408 gas_switched_common3: |
1989 banksel int_O_breathed_ppO2 | 2409 banksel int_O_breathed_ppO2 |
1990 bcf int_O_breathed_ppO2+1,int_low_flag ; | clear all flags that control color-coding | 2410 bcf int_O_breathed_ppO2+1,int_low_flag ; | clear all flags that control color-coding |
1991 bcf int_O_breathed_ppO2+1,int_high_flag ; | to have the new gas initially displayed in | 2411 bcf int_O_breathed_ppO2+1,int_high_flag ; | to have the new gas initially displayed in |
1992 bcf int_O_breathed_ppO2+1,int_attention_flag ; | memo color instead of a warning or attention | 2412 bcf int_O_breathed_ppO2+1,int_attention_flag ; | memo color instead of a warning or attention |
2002 ENDIF | 2422 ENDIF |
2003 bsf event_gas_change ; (NO) - set gas change event (normal change) | 2423 bsf event_gas_change ; (NO) - set gas change event (normal change) |
2004 goto restart_deco_engine_wo_ceiling ; abort running deco calculations and restart (and return) | 2424 goto restart_deco_engine_wo_ceiling ; abort running deco calculations and restart (and return) |
2005 | 2425 |
2006 | 2426 |
2427 ;----------------------------------------------------------------------------- | |
2428 ; Reload the current Gas / Diluent | |
2429 ; | |
2007 gas_update_common: | 2430 gas_update_common: |
2008 bcf request_gas_update ; reset the request flag | 2431 bcf request_gas_update ; reset the request flag |
2009 movf active_gas,W ; load WREG with currently used gas | 2432 movf active_gas,W ; load WREG with currently used gas |
2010 IFDEF _ccr_pscr | 2433 IFDEF _ccr_pscr |
2011 btfsc FLAG_oc_mode ; in OC mode? | 2434 btfsc FLAG_oc_mode ; in OC mode? |
2016 bra gas_switched_common_loop ; - set up diluent gases | 2439 bra gas_switched_common_loop ; - set up diluent gases |
2017 ELSE | 2440 ELSE |
2018 bra gas_switched_common_OC ; reload OC gases | 2441 bra gas_switched_common_OC ; reload OC gases |
2019 ENDIF | 2442 ENDIF |
2020 | 2443 |
2021 ; Code to pass all parameters to the C code | 2444 |
2022 | 2445 ;----------------------------------------------------------------------------- |
2023 global get_first_gas_to_WREG | 2446 ; Toggle GF/aGF (finalization) |
2024 get_first_gas_to_WREG: ; gets first gas (1-5) into WREG | 2447 ; |
2025 lfsr FSR1,opt_gas_type ; load base address of the gas types | 2448 divemodemode_togglegf: |
2026 clrf lo ; start with gas 0 | 2449 bcf request_toggle_GF ; clear request flag |
2027 get_first_gas_to_WREG2: | 2450 goto restart_deco_engine ; restart the deco engine and return |
2028 movf lo,W ; set index | 2451 |
2029 movf PLUSW1,W ; get type of gas (0=Disabled, 1=First, 2=Travel, 3=Deco) | 2452 |
2030 sublw .1 ; is it of type First? | 2453 ;----------------------------------------------------------------------------- |
2031 bz get_first_gas_to_WREG3 ; YES - found the First gas | 2454 ; Set a Marker in the Dive Profile |
2032 incf lo,F ; NO - increment index | 2455 ; |
2033 movlw NUM_GAS+1 ; - get highest index+1 | 2456 set_logbook_marker: |
2034 cpfseq lo ; - all gases checked? | 2457 bcf request_set_marker ; clear request flag |
2035 bra get_first_gas_to_WREG2 ; NO - not yet | 2458 movlw d'6' ; set type of alarm: manual marker |
2036 movlw .1 ; YES - default to gas 1 | 2459 movwf alarm_type ; copy to alarm register |
2037 movff WREG,opt_gas_type+0 ; - force it to be of type First | 2460 bsf event_occured ; set event flag |
2038 return ; - done | |
2039 get_first_gas_to_WREG3: | |
2040 movf lo,W ; copy index of gas found to be the First to WREG | |
2041 incf WREG,W ; turn index into gas number (0-4 -> 1-5) | |
2042 return ; done | 2461 return ; done |
2043 | 2462 |
2044 ;============================================================================= | 2463 |
2045 | 2464 ;----------------------------------------------------------------------------- |
2046 IFDEF _ccr_pscr | |
2047 | |
2048 global get_first_dil_to_WREG | |
2049 get_first_dil_to_WREG: ; gets first dil (1-5) into WREG | |
2050 lfsr FSR1,opt_dil_type ; load base address of the dil types | |
2051 clrf lo ; start with dil 0 | |
2052 get_first_dil_to_WREG2: | |
2053 movf lo,W ; set index | |
2054 movf PLUSW1,W ; get type of Dil (0=Disabled, 1=First, 2=Normal) | |
2055 sublw .1 ; is it of type First? | |
2056 bz get_first_dil_to_WREG3 ; YES - found the First dil | |
2057 incf lo,F ; NO - increment index | |
2058 movlw NUM_GAS+1 ; - get highest index+1 | |
2059 cpfseq lo ; - dils checked? | |
2060 bra get_first_dil_to_WREG2 ; NO - not yet | |
2061 movlw .1 ; YES - default to dil 1 | |
2062 movff WREG,opt_dil_type+0 ; - force it to be of type First | |
2063 return ; - done | |
2064 get_first_dil_to_WREG3: | |
2065 movf lo,W ; copy index of dil found to be the First to WREG | |
2066 incf WREG,W ; turn index into dil number (0-4 -> 1-5) | |
2067 return ; done | |
2068 | |
2069 ENDIF | |
2070 | |
2071 ;============================================================================= | |
2072 | |
2073 global deco_setup_oc_gases | |
2074 deco_setup_oc_gases: ; with currently breathed gas in WREG (1-5 or 6) | |
2075 movff char_O_deco_status,lo ; working copy of char_O_deco_status in bank common | |
2076 deco_setup_oc_gases_pre: ; entry point with lo preloaded | |
2077 movff WREG,char_I_current_gas_num ; set gas to start with when doing the deco calculations | |
2078 ; | |
2079 ; Memory Map: | |
2080 ; --------------------------------------------------------------------------------- | |
2081 ; opt_gas_O2_ratio res NUM_GAS | char_I_deco_O2_ratio res NUM_GAS | |
2082 ; opt_dil_O2_ratio res NUM_GAS | | |
2083 ; opt_gas_He_ratio res NUM_GAS | char_I_deco_He_ratio res NUM_GAS | |
2084 ; opt_dil_He_ratio res NUM_GAS | | |
2085 ; opt_gas_type res NUM_GAS | char_I_deco_gas_type res NUM_GAS | |
2086 ; opt_dil_type res NUM_GAS | | |
2087 ; opt_gas_change res NUM_GAS | char_I_deco_gas_change res NUM_GAS | |
2088 ; opt_dil_change res NUM_GAS | | |
2089 ; | |
2090 lfsr FSR2,char_I_deco_O2_ratio ; load FSR2 with base address of char_I_deco_O2_ratio | |
2091 ; FSR2 will step through all char_I_deco_... vars | |
2092 lfsr FSR1,opt_gas_O2_ratio ; load FSR1 with base address of opt_gas_O2_ratio | |
2093 rcall deco_setup_copy ; copy all OC O2 ratios | |
2094 lfsr FSR1,opt_gas_He_ratio ; load FSR1 with base address of opt_gas_He_ratio | |
2095 rcall deco_setup_copy ; copy all OC He ratios | |
2096 lfsr FSR1,opt_gas_type ; load FSR1 with base address of opt_gas_type | |
2097 rcall deco_setup_copy ; copy all gas types | |
2098 lfsr FSR1,opt_gas_change ; load FSR1 with base address of opt_gas_change | |
2099 rcall deco_setup_copy ; copy all gas change depths | |
2100 ; switch deco engine to oc mode: | |
2101 bcf lo,DECO_MODE_PSCR_FLAG ; - clear the pSCR-mode flag (may not be set, but never mind) | |
2102 bcf lo,DECO_MODE_LOOP_FLAG ; - clear the loop/CCR-mode flag | |
2103 movff lo,char_O_deco_status ; - bank safe write-back of char_O_deco_status | |
2104 return ; done | |
2105 | |
2106 ;============================================================================= | |
2107 | |
2108 IFDEF _ccr_pscr | |
2109 | |
2110 global deco_setup_cc_diluents | |
2111 deco_setup_cc_diluents: ; with currently breathed diluent in WREG (1-5 or 6) | |
2112 movff char_O_deco_status,lo ; working copy of char_O_deco_status in bank common | |
2113 deco_setup_cc_diluents_pre: ; entry point with lo preloaded | |
2114 btfsc bailout_mode ; check if in bailout condition | --------------- FOR SAFETY ONLY -------------- | |
2115 bra deco_setup_oc_gases_pre ; YES - revert to setting up OC gases | This branch should never happen to be taken... | |
2116 movff WREG,char_I_current_gas_num ; NO - set diluent to start with when doing the deco calculations | |
2117 ; | |
2118 ; Memory Map: | |
2119 ; --------------------------------------------------------------------------------- | |
2120 ; opt_gas_O2_ratio res NUM_GAS | | |
2121 ; opt_dil_O2_ratio res NUM_GAS | char_I_deco_O2_ratio res NUM_GAS | |
2122 ; opt_gas_He_ratio res NUM_GAS | | |
2123 ; opt_dil_He_ratio res NUM_GAS | char_I_deco_He_ratio res NUM_GAS | |
2124 ; opt_gas_type res NUM_GAS | | |
2125 ; opt_dil_type res NUM_GAS | char_I_deco_gas_type res NUM_GAS | |
2126 ; opt_gas_change res NUM_GAS | | |
2127 ; opt_dil_change res NUM_GAS | char_I_deco_gas_change res NUM_GAS | |
2128 ; | |
2129 lfsr FSR2,char_I_deco_O2_ratio ; load FSR2 with base address of char_I_deco_O2_ratio. | |
2130 ; FSR2 will step through all char_I_deco_... vars. | |
2131 lfsr FSR1,opt_dil_O2_ratio ; load FSR1 with base address of opt_dil_O2_ratio | |
2132 rcall deco_setup_copy ; copy all dil O2 ratios | |
2133 lfsr FSR1,opt_dil_He_ratio ; load FSR1 with base address of opt_dil_He_ratio | |
2134 rcall deco_setup_copy ; copy all dil He ratios | |
2135 lfsr FSR1,opt_dil_type ; load FSR1 with base address of opt_dil_type | |
2136 rcall deco_setup_copy ; copy all dil types | |
2137 lfsr FSR1,opt_dil_change ; load FSR1 with base address of opt_dil_change | |
2138 rcall deco_setup_copy ; copy all dil change depths | |
2139 ; switch to CCR / pSCR mode: | |
2140 bsf lo,DECO_MODE_LOOP_FLAG ; - loop flag is set in both, CCR and pSCR mode | |
2141 bcf lo,DECO_MODE_PSCR_FLAG ; - clear pSCR mode flag by default | |
2142 btfsc FLAG_pscr_mode ; - check if we are in pSCR mode | |
2143 bsf lo,DECO_MODE_PSCR_FLAG ; YES - set additional flag for pSCR mode | |
2144 movff lo,char_O_deco_status ; - bank safe write-back of char_O_deco_status | |
2145 return ; done | |
2146 | |
2147 ENDIF | |
2148 | |
2149 ;============================================================================= | |
2150 | |
2151 deco_setup_copy: | |
2152 movlw NUM_GAS ; load loop counter with number of gases (5) | |
2153 deco_setup_copy_loop: | |
2154 movff POSTINC1,POSTINC2 ; copy from (FSR1) to (FSR2) | |
2155 decfsz WREG ; decrement loop counter and check if it became 0 | |
2156 bra deco_setup_copy_loop ; NO - not yet, loop | |
2157 return ; YES - done | |
2158 | |
2159 | |
2160 global setup_gas_registers | |
2161 setup_gas_registers: ; with currently breathed gas in WREG (1-5 or 6) | |
2162 movwf active_gas ; set as current gas | |
2163 movlw .6 | |
2164 cpfseq active_gas ; gas = gas6 ? | |
2165 bra setup_gas_registers_15 ; NO - load gas 1-5 | |
2166 movff gas6_O2_ratio,char_I_O2_ratio ; copy gas6 O2 ratio to deco engine | |
2167 IFDEF _helium | |
2168 movff gas6_He_ratio,char_I_He_ratio ; copy gas6 H2 ratio to deco engine | |
2169 ENDIF | |
2170 movlw .3 ; declare gas6 as a deco gas | |
2171 movff WREG,char_I_current_gas_type; copy gas type to deco engine | |
2172 movff depth_meter,char_I_gas6_depth;set current depth as change depth | |
2173 bra setup_gas_registers_com ; continue with common part | |
2174 setup_gas_registers_15: | |
2175 lfsr FSR1,opt_gas_O2_ratio ; load base address of gas data | |
2176 decf active_gas,W ; set index to O2 ratio of current gas (1-5 -> 0-4) | |
2177 movff PLUSW1,char_I_O2_ratio ; copy O2 ratio to deco engine | |
2178 addlw .10 ; advance index from O2 ratio to He ratio | |
2179 IFDEF _helium | |
2180 movff PLUSW1,char_I_He_ratio ; copy He ratio to deco engine | |
2181 ENDIF | |
2182 addlw .10 ; advance index from He ratio to gas type | |
2183 movff PLUSW1,char_I_current_gas_type ; copy gas type (0=Disabled, 1=First, 2=Travel, 3=Deco) | |
2184 setup_gas_registers_com: | |
2185 movff char_O_main_status,lo ; working copy of char_O_main_status in bank common | |
2186 bcf lo,DECO_MODE_PSCR_FLAG ; clear the pSCR-mode flag (if applicable) | |
2187 bcf lo,DECO_MODE_LOOP_FLAG ; clear the loop/CCR-mode flag | |
2188 movff lo,char_O_main_status ; bank safe write-back of char_O_main_status | |
2189 movf active_gas,W ; reload WREG with gas 1-5 or 6 (important!) | |
2190 return | |
2191 | |
2192 ;============================================================================= | |
2193 | |
2194 IFDEF _ccr_pscr | |
2195 | |
2196 global setup_dil_registers | |
2197 setup_dil_registers: ; with currently breathed gas in WREG (1-5 or 6) | |
2198 btfsc bailout_mode ; check if in bailout condition | --------------- FOR SAFETY ONLY -------------- | |
2199 bra setup_gas_registers ; revert to setting up OC gases in bailout condition | This branch should never happen to be taken... | |
2200 movwf active_dil ; set as current diluent | |
2201 movlw .6 | |
2202 cpfseq active_dil ; diluent = gas6 ? | |
2203 bra setup_dil_registers_15 ; NO - load diluent 1-5 | |
2204 movff gas6_O2_ratio,char_I_O2_ratio ; copy gas6 O2 ratio to deco engine | |
2205 IFDEF _helium | |
2206 movff gas6_He_ratio,char_I_He_ratio ; copy gas6 H2 ratio to deco engine | |
2207 ENDIF | |
2208 movlw .2 ; declare gas6 as a normal diluent | |
2209 movff WREG,char_I_current_gas_type; copy gas type to deco engine | |
2210 movff depth_meter,char_I_gas6_depth;set current depth as change depth | |
2211 bra setup_dil_registers_com ; continue with common part | |
2212 setup_dil_registers_15: | |
2213 lfsr FSR1,opt_dil_O2_ratio ; load base address of diluent data | |
2214 decf active_dil,W ; set index to O2 ratio of current diluent (1-5 -> 0-4) | |
2215 movff PLUSW1,char_I_O2_ratio ; copy O2 ratio to deco engine | |
2216 addlw .10 ; advance index from O2 ratio to He ratio | |
2217 IFDEF _helium | |
2218 movff PLUSW1,char_I_He_ratio ; copy He ratio to deco engine | |
2219 ENDIF | |
2220 addlw .10 ; advance index from He ratio to diluent type | |
2221 movff PLUSW1,char_I_current_gas_type ; copy diluent type (0=Disabled, 1=First, 2=Normal) | |
2222 setup_dil_registers_com: | |
2223 movff char_O_main_status,lo ; working copy of char_O_main_status in bank common | |
2224 bsf lo,DECO_MODE_LOOP_FLAG ; loop flag is set in both, CCR and pSCR mode | |
2225 bcf lo,DECO_MODE_PSCR_FLAG ; clear pSCR mode flag by default | |
2226 btfsc FLAG_pscr_mode ; check if we are in pSCR mode | |
2227 bsf lo,DECO_MODE_PSCR_FLAG ; YES - set additional flag for pSCR mode | |
2228 movff lo,char_O_main_status ; bank safe write-back of char_O_main_status | |
2229 movf active_dil,W ; reload WREG with diluent 1-5 or 6 (important!) | |
2230 return | |
2231 | |
2232 ENDIF | |
2233 | |
2234 ;============================================================================= | |
2235 | |
2236 divemode_option_gaschange: ; switch to the "better gas" / "better diluent" | |
2237 IFDEF _ccr_pscr | |
2238 btfsc FLAG_oc_mode ; in OC mode? | |
2239 bra divemode_option_gaschange_oc; YES | |
2240 btfsc bailout_mode ; in bailout? | |
2241 bra divemode_option_gaschange_oc; YES | |
2242 divemode_option_gaschange_loop: ; in CCR/pSCR mode and not in bailout | |
2243 movff best_dil_number,menu_pos_cur; NO - select best diluent | |
2244 bcf better_dil_available ; - clear flag immediately | |
2245 bra divemode_option_gaschange3 ; - continue with common part | |
2246 ENDIF | |
2247 divemode_option_gaschange_oc: ; in OC or bailout | |
2248 movff best_gas_number,menu_pos_cur; select best gas | |
2249 bcf better_gas_available ; clear flag immediately | |
2250 divemode_option_gaschange3 ; common part | |
2251 bsf request_gas_change ; request a gas/diluent change | |
2252 goto menuview_toggle_reset ; terminate the pre-menu (and return) | |
2253 | |
2254 divemode_option_divemenu: ; start/setup dive mode menu | |
2255 btfss divemode ; in dive mode? | |
2256 goto menuview_toggle_reset ; NO - block menu, terminate the pre-menu | |
2257 call TFT_clear_divemode_menu ; YES - clear menu area | |
2258 bcf dive_options_menu ; - set dive options menu as not shown anymore | |
2259 goto do_main_divemenu ; - hand over to 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 | |
2272 call TFT_show_menu_cursor_divemode ; show the cursor | |
2273 clrf active_premenu ; set pre-menu is not shown any more | |
2274 bcf safety_stop_active ; set safety stop is not shown any more | |
2275 bsf dive_main_menu ; set main menu is shown now | |
2276 movlw divemode_timeout_mainmenu ; get timeout for main menu | |
2277 call reset_timeout_time ; reload timeout | |
2278 goto diveloop_menu_exit ; go back to dive loop (menu processor resets STKPTR!) | |
2279 | |
2280 divemode_option_sim_quit: ; quit simulation mode | |
2281 clrf simulatormode_depth ; set target depth to zero | |
2282 bsf quit_simulatormode ; request ISR to end simulator mode | |
2283 call menuview_toggle_reset ; terminate the pre-menu | |
2284 btfsc FLAG_apnoe_mode ; in apnoe mode? | |
2285 bcf divemode ; YES - force end of dive mode | |
2286 return ; done | |
2287 | |
2288 divemode_option_sim_down: ; plus 1 meter | |
2289 movlw ostc_depth_max-1 ; load depth limit into WREG | |
2290 cpfsgt simulatormode_depth ; simulated depth <= limit ? | |
2291 incf simulatormode_depth,F ; YES - increment simulated depth | |
2292 return ; done | |
2293 | |
2294 divemode_option_sim_up: ; minus 1 meter | |
2295 tstfsz simulatormode_depth ; simulated depth > 0 ? | |
2296 decf simulatormode_depth,F ; YES - decrement simulated depth | |
2297 return ; done | |
2298 | |
2299 divemode_option_sim_time: | |
2300 ; check for pending +5' request on deco engine | |
2301 movff char_I_sim_advance_time,WREG; get mailbox content | |
2302 tstfsz WREG ; mailbox clear (=0) ? | |
2303 return ; NO - still having a pending +5' request, refuse new request | |
2304 | |
2305 ; advance tissues pressures and deco obligation by 5 minutes | |
2306 movlw .5 ; + 5 minutes | |
2307 movff WREG,char_I_sim_advance_time; copy to mailbox | |
2308 call restart_deco_engine ; condition deco engine to execute the +5 minutes | |
2309 | |
2310 ; stop dive time incrementing in ISR | |
2311 bcf count_divetime | |
2312 | |
2313 ; add 5 minutes to counted_divetime_mins | |
2314 ADDLI .5,counted_divetime_mins | |
2315 | |
2316 ; add 5 minutes (300 seconds) to total_divetime_secs | |
2317 ADDLI .300,total_divetime_secs | |
2318 | |
2319 ; continue dive time incrementing in ISR | |
2320 bsf count_divetime | |
2321 | |
2322 ; add 5 minutes (300 seconds) to resettable time accumulator | |
2323 ADDLI .300,divesecs_avg_trip | |
2324 | |
2325 ; add 5 minutes (300 seconds) to total time accumulator | |
2326 ADDLI .300,divesecs_avg_total | |
2327 | |
2328 ; calculate 300 x depth in mbar (300 = 5 min * 60 sec/min) | |
2329 MOVII pressure_rel_cur_cached,xB | |
2330 MOVLI .300,xA | |
2331 call mult16x16 ; xC = xA * xB | |
2332 | |
2333 ; add to the resettable depth accumulator | |
2334 movf xC+0,W | |
2335 addwf pressure_rel_accu_trip+0,F | |
2336 movf xC+1,W | |
2337 addwfc pressure_rel_accu_trip+1,F | |
2338 movf xC+2,W | |
2339 addwfc pressure_rel_accu_trip+2,F | |
2340 movf xC+3,W | |
2341 addwfc pressure_rel_accu_trip+3,F | |
2342 | |
2343 ; add to the total depth accumulator | |
2344 movf xC+0,W | |
2345 addwf pressure_rel_accu_total+0,F | |
2346 movf xC+1,W | |
2347 addwfc pressure_rel_accu_total+1,F | |
2348 movf xC+2,W | |
2349 addwfc pressure_rel_accu_total+2,F | |
2350 movf xC+3,W | |
2351 addwfc pressure_rel_accu_total+3,F | |
2352 | |
2353 IFDEF _cave_mode | |
2354 ; update backtracking data | |
2355 btfss cave_mode ; cave mode switched on? | |
2356 bra divemode_option_sim_time_exit ; NO - skip backtracking depth recording | |
2357 btfsc dive_turned ; YES - dive turned? | |
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: | |
2377 ; goto menuview_toggle_reset ; terminate the pre-menu and return | |
2378 return ; just return, leaving option avail for repeated selection | |
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 | |
2390 IFDEF _compass | |
2391 divemode_option_course: | |
2392 ; store heading for compass view | |
2393 MOVII compass_heading_shown,compass_bearing | |
2394 bsf compass_bearing_set ; set flag to show heading | |
2395 goto menuview_toggle_reset ; terminate the pre-menu and return | |
2396 ENDIF | |
2397 | |
2398 divemode_option_layout: ; switch layout | |
2399 call menuview_toggle_reset ; terminate the pre-menu | |
2400 call TFT_ClearScreen ; clear the whole screen | |
2401 btg alt_layout_active ; toggle layout | |
2402 | |
2403 bcf depth_warn_att_last ; set warning or attention on the depth not shown | |
2404 bcf depth_inverse_last ; set depth displayed in inverse as not shown | |
2405 bcf sign_shown ; set warning/attention/advice sign not shown | |
2406 bcf velocity_active_num ; set numerical vertical velocity display not shown | |
2407 bcf velocity_active_vsi ; set vertical vertical velocity display not shown | |
2408 bcf safety_stop_active ; set safety stop not shown | |
2409 | |
2410 bsf FLAG_TFT_divemode_mask ; request redraw of dive screen mask | |
2411 bsf FLAG_TFT_divetime ; request redraw of dive time | |
2412 bsf FLAG_TFT_depth_current ; request redraw of current depth | |
2413 bsf FLAG_TFT_depth_maximum ; request redraw of maximum depth | |
2414 bsf FLAG_TFT_active_gas_divemode; request redraw of gas and setpoint | |
2415 bsf FLAG_TFT_temperature ; request redraw of temperature | |
2416 bsf FLAG_TFT_customview_callup ; request redraw of custom view | |
2417 | |
2418 goto request_redraw_NDL_deco_data; request redraw of NDL/deco data and return | |
2419 | |
2420 | |
2421 ;============================================================================= | |
2422 ; Find the best gas and diluent for the current depth | 2465 ; Find the best gas and diluent for the current depth |
2423 ; and check if a gas/diluent change is to be advised. | 2466 ; and check if a gas/diluent change is to be advised. |
2424 ; | 2467 ; |
2425 ; Output: best_gas_number : number of best gas, 0= none avail, 255= not computed | 2468 ; Output: best_gas_number : number of best gas, 0= none avail, 255= not computed |
2426 ; best_dil_number : number of best dil, 0= none avail, 255= not computed | 2469 ; best_dil_number : number of best dil, 0= none avail, 255= not computed |
2497 bz check_gas_best_dil3 ; has a best diluent been found at all? NO - nothing to signal for | 2540 bz check_gas_best_dil3 ; has a best diluent been found at all? NO - nothing to signal for |
2498 cpfseq active_dil ; is this the currently used diluent? | 2541 cpfseq active_dil ; is this the currently used diluent? |
2499 bra check_gas_best_dil2 ; NO - a better diluent has been found | 2542 bra check_gas_best_dil2 ; NO - a better diluent has been found |
2500 bra check_gas_best_dil3 ; YES - no need to signal a better diluent if this diluent is already in use | 2543 bra check_gas_best_dil3 ; YES - no need to signal a better diluent if this diluent is already in use |
2501 check_gas_best_dil2: | 2544 check_gas_best_dil2: |
2502 btfsc sp_fallback ; in fallback condition? | 2545 btfsc warn_det_sensors_lost ; all sensors lost? |
2503 bra check_gas_best_dil3 ; YES - suppress better diluent prompt in this case | 2546 bra check_gas_best_dil3 ; YES - suppress better diluent prompt in this case |
2504 ; not using the best gas - show better diluent hint whenever a better diluent is available | 2547 ; not using the best gas - show better diluent hint whenever a better diluent is available |
2505 bsf better_dil_available ; signal that a better diluent is available | 2548 bsf better_dil_available ; signal that a better diluent is available |
2506 bsf FLAG_TFT_active_gas_divemode ; redraw gas/setpoint/diluent | 2549 bsf FLAG_TFT_active_gas_divemode ; redraw gas/setpoint/diluent |
2507 check_gas_best_dil3: | 2550 check_gas_best_dil3: |
2566 bra check_gas_best_loop ; NO - loop | 2609 bra check_gas_best_loop ; NO - loop |
2567 return ; YES - done | 2610 return ; YES - done |
2568 | 2611 |
2569 | 2612 |
2570 check_gas_best_common: ; with gas to be checked in check_gas_num (1-5) | 2613 check_gas_best_common: ; with gas to be checked in check_gas_num (1-5) |
2571 ; ; and current gas in lo (1-5) | 2614 ; and current gas in lo (1-5) |
2572 ; | 2615 ; |
2573 ; Memory Map: | 2616 ; Memory Map: |
2574 ; --------------------------------------------------------------------------------------- | 2617 ; --------------------------------------------------------------------------------------- |
2575 ; opt_gas_O2_ratio res 5 ; base address for gases | 2618 ; opt_gas_O2_ratio res 5 ; base address for gases |
2576 ; opt_dil_O2_ratio res 5 ; base address for diluents | 2619 ; opt_dil_O2_ratio res 5 ; base address for diluents |
2667 ; we have a (new) best gas | 2710 ; we have a (new) best gas |
2668 movff check_gas_num, best_gas_num ; YES - set checked gas (1-5) as best gas | 2711 movff check_gas_num, best_gas_num ; YES - set checked gas (1-5) as best gas |
2669 movff check_gas_depth,best_gas_depth ; - memorize its change depth | 2712 movff check_gas_depth,best_gas_depth ; - memorize its change depth |
2670 return ; - done | 2713 return ; - done |
2671 | 2714 |
2672 | 2715 IFDEF _ccr_pscr |
2673 ;============================================================================= | 2716 |
2717 | |
2718 ;----------------------------------------------------------------------------- | |
2674 ; Check for Auto-SP | 2719 ; Check for Auto-SP |
2675 ; | 2720 ; |
2676 IFDEF _ccr_pscr | 2721 check_dive_autosp: |
2677 | |
2678 check_dive_autosp: ; check for Auto-SP | |
2679 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP | 2722 movff opt_ccr_mode,WREG ; =0: Fixed SP, =1: Sensor, =2: Auto SP |
2680 sublw .2 ; opt_ccr_mode = 2 (Auto SP)? | 2723 sublw .2 ; opt_ccr_mode = 2 (Auto SP)? |
2681 bz check_dive_autosp2 ; YES - check | 2724 bz check_dive_autosp2 ; YES - check |
2682 return ; NO - return for sensor or fixed mode | 2725 return ; NO - return for sensor or fixed mode |
2726 | |
2683 check_dive_autosp2: | 2727 check_dive_autosp2: |
2684 ; check SP2 | 2728 ; check SP2 |
2685 btfsc FLAG_SP2_used ; SP 2 used so far? | 2729 btfsc FLAG_SP2_used ; SP 2 used so far? |
2686 bra check_dive_autosp3 ; YES - continue with SP 3 | 2730 bra check_dive_autosp3 ; YES - continue with SP 3 |
2687 movff opt_setpoint_change+1,lo ; NO - get depth in m | 2731 movff opt_setpoint_change+1,lo ; NO - get depth in m |
2694 bra check_dive_autosp3 ; NO - continue with SP 3 | 2738 bra check_dive_autosp3 ; NO - continue with SP 3 |
2695 ; auto switch to SP2 | 2739 ; auto switch to SP2 |
2696 movff opt_setpoint_cbar+1,char_I_const_ppO2 ; YES - use SP | 2740 movff opt_setpoint_cbar+1,char_I_const_ppO2 ; YES - use SP |
2697 rcall xmit_sp_set_flag ; - send SP to external devices | 2741 rcall xmit_sp_set_flag ; - send SP to external devices |
2698 bsf FLAG_SP2_used ; - set SP 2 used flag | 2742 bsf FLAG_SP2_used ; - set SP 2 used flag |
2743 | |
2699 check_dive_autosp3: | 2744 check_dive_autosp3: |
2700 ; check SP3 | 2745 ; check SP3 |
2701 btfsc FLAG_SP3_used ; SP 3 used so far? | 2746 btfsc FLAG_SP3_used ; SP 3 used so far? |
2702 bra check_dive_autosp4 ; YES - continue with SP 4 | 2747 bra check_dive_autosp4 ; YES - continue with SP 4 |
2703 movff opt_setpoint_change+2,lo ; NO - get depth in m | 2748 movff opt_setpoint_change+2,lo ; NO - get depth in m |
2710 bra check_dive_autosp4 ; NO - continue with SP 4 | 2755 bra check_dive_autosp4 ; NO - continue with SP 4 |
2711 ; auto switch to SP3 | 2756 ; auto switch to SP3 |
2712 movff opt_setpoint_cbar+2,char_I_const_ppO2 ; YES - use SP | 2757 movff opt_setpoint_cbar+2,char_I_const_ppO2 ; YES - use SP |
2713 rcall xmit_sp_set_flag ; - send SP to external devices | 2758 rcall xmit_sp_set_flag ; - send SP to external devices |
2714 bsf FLAG_SP3_used ; - set SP 3 used flag | 2759 bsf FLAG_SP3_used ; - set SP 3 used flag |
2760 | |
2715 check_dive_autosp4: | 2761 check_dive_autosp4: |
2716 ; check SP4 | 2762 ; check SP4 |
2717 btfsc FLAG_SP4_used ; SP 4 used so far? | 2763 btfsc FLAG_SP4_used ; SP 4 used so far? |
2718 bra check_dive_autosp5 ; YES - continue with SP 5 | 2764 bra check_dive_autosp5 ; YES - continue with SP 5 |
2719 movff opt_setpoint_change+3,lo ; NO - get depth in m | 2765 movff opt_setpoint_change+3,lo ; NO - get depth in m |
2726 bra check_dive_autosp5 ; NO - continue with SP 5 | 2772 bra check_dive_autosp5 ; NO - continue with SP 5 |
2727 ; auto switch to SP4 | 2773 ; auto switch to SP4 |
2728 movff opt_setpoint_cbar+3,char_I_const_ppO2 ; YES - use SP | 2774 movff opt_setpoint_cbar+3,char_I_const_ppO2 ; YES - use SP |
2729 rcall xmit_sp_set_flag ; - send SP to external devices | 2775 rcall xmit_sp_set_flag ; - send SP to external devices |
2730 bsf FLAG_SP4_used ; - set SP 4 used flag | 2776 bsf FLAG_SP4_used ; - set SP 4 used flag |
2777 | |
2731 check_dive_autosp5: | 2778 check_dive_autosp5: |
2732 ; check SP5 | 2779 ; check SP5 |
2733 btfsc FLAG_SP5_used ; SP 5 used so far? | 2780 btfsc FLAG_SP5_used ; SP 5 used so far? |
2734 bra check_dive_autosp6 ; YES - done | 2781 bra check_dive_autosp6 ; YES - done |
2735 movff opt_setpoint_change+4,lo ; NO - get depth in m | 2782 movff opt_setpoint_change+4,lo ; NO - get depth in m |
2742 bra check_dive_autosp6 ; NO - done | 2789 bra check_dive_autosp6 ; NO - done |
2743 ; auto switch to SP5 | 2790 ; auto switch to SP5 |
2744 movff opt_setpoint_cbar+4,char_I_const_ppO2 ; YES - use SP | 2791 movff opt_setpoint_cbar+4,char_I_const_ppO2 ; YES - use SP |
2745 rcall xmit_sp_set_flag ; - send SP to external devices | 2792 rcall xmit_sp_set_flag ; - send SP to external devices |
2746 bsf FLAG_SP5_used ; - set SP 5 used flag | 2793 bsf FLAG_SP5_used ; - set SP 5 used flag |
2794 | |
2747 check_dive_autosp6: | 2795 check_dive_autosp6: |
2748 return | 2796 return ; done |
2749 | 2797 |
2798 | |
2799 ;----------------------------------------------------------------------------- | |
2800 ; Helper Function - transmit new Setpoint to external Electronics and flag Change | |
2801 ; | |
2750 xmit_sp_set_flag: | 2802 xmit_sp_set_flag: |
2751 IFDEF _external_sensor | 2803 IFDEF _external_sensor |
2752 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics | 2804 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics |
2753 ENDIF | 2805 ENDIF |
2754 bsf event_occured ; set global event flag | 2806 bsf event_occured ; set global event flag |
2755 bsf event_SP_change ; set setpoint event flag | 2807 bsf event_SP_change ; set setpoint event flag |
2756 return | 2808 return |
2757 | 2809 |
2758 ENDIF ; _ccr_pscr | 2810 ENDIF ; _ccr_pscr |
2759 | 2811 |
2812 | |
2760 ;============================================================================= | 2813 ;============================================================================= |
2761 | 2814 dmode2 CODE |
2762 set_logbook_marker: | |
2763 bcf request_set_marker ; clear request flag | |
2764 movlw d'6' ; set type of alarm: manual marker | |
2765 movwf alarm_type ; copy to alarm register | |
2766 bsf event_occured ; set event flag | |
2767 return | |
2768 | |
2769 ;============================================================================= | 2815 ;============================================================================= |
2770 ; Setup everything to enter dive mode | 2816 |
2817 | |
2818 ;----------------------------------------------------------------------------- | |
2819 ; Setup everything to enter OC Dive Mode | |
2771 ; | 2820 ; |
2772 global dive_boot_oc | 2821 global dive_boot_oc |
2773 dive_boot_oc: | 2822 dive_boot_oc: |
2774 ; set-up registers | |
2775 rcall get_first_gas_to_WREG ; get first gas (1-5) into WREG | 2823 rcall get_first_gas_to_WREG ; get first gas (1-5) into WREG |
2776 rcall setup_gas_registers ; set-up of gas parameters of currently breathed gas (with WREG = gas 1-5) | 2824 rcall setup_gas_registers ; set-up of gas parameters of currently breathed gas (with WREG = gas 1-5) |
2777 rcall deco_setup_oc_gases ; set-up of gas list for deco calculations (with WREG = gas 1-5) | 2825 rcall deco_setup_oc_gases ; set-up of gas list for deco calculations (with WREG = gas 1-5) |
2778 return | 2826 return ; done |
2827 | |
2828 | |
2829 ;----------------------------------------------------------------------------- | |
2830 ; Helper Function - get first Gas (1-5) into WREG | |
2831 ; | |
2832 global get_first_gas_to_WREG | |
2833 get_first_gas_to_WREG: | |
2834 lfsr FSR1,opt_gas_type ; load base address of the gas types | |
2835 clrf lo ; start with gas 0 | |
2836 get_first_gas_to_WREG2: | |
2837 movf lo,W ; set index | |
2838 movf PLUSW1,W ; get type of gas (0=Disabled, 1=First, 2=Travel, 3=Deco) | |
2839 sublw .1 ; is it of type First? | |
2840 bz get_first_gas_to_WREG3 ; YES - found the First gas | |
2841 incf lo,F ; NO - increment index | |
2842 movlw NUM_GAS+1 ; - get highest index+1 | |
2843 cpfseq lo ; - all gases checked? | |
2844 bra get_first_gas_to_WREG2 ; NO - not yet | |
2845 movlw .1 ; YES - default to gas 1 | |
2846 movff WREG,opt_gas_type+0 ; - force it to be of type First | |
2847 return ; - done | |
2848 get_first_gas_to_WREG3: | |
2849 movf lo,W ; copy index of gas found to be the First to WREG | |
2850 incf WREG,W ; turn index into gas number (0-4 -> 1-5) | |
2851 return ; done | |
2852 | |
2853 | |
2854 ;----------------------------------------------------------------------------- | |
2855 ; Helper Function - load currently breathed Gas into Deco Engine | |
2856 ; | |
2857 global setup_gas_registers | |
2858 setup_gas_registers: | |
2859 movwf active_gas ; set as current gas | |
2860 movlw .6 ; gas = gas6 ? | |
2861 cpfseq active_gas ; ... | |
2862 bra setup_gas_registers_15 ; NO - load gas 1-5 | |
2863 | |
2864 ; load gas 6 | |
2865 movff opt_gas6_O2_ratio,char_I_O2_ratio ; copy gas6 O2 ratio to deco engine | |
2866 IFDEF _helium | |
2867 movff opt_gas6_He_ratio,char_I_He_ratio ; copy gas6 H2 ratio to deco engine | |
2868 ENDIF | |
2869 movlw .3 ; declare gas6 as a deco gas | |
2870 movff WREG,char_I_current_gas_type ; copy gas type to deco engine | |
2871 movff depth_meter,char_I_gas6_depth ;set current depth as change depth | |
2872 bra setup_gas_registers_com ; continue with common part | |
2873 | |
2874 setup_gas_registers_15: | |
2875 lfsr FSR1,opt_gas_O2_ratio ; load base address of gas data | |
2876 decf active_gas,W ; set index to O2 ratio of current gas (1-5 -> 0-4) | |
2877 movff PLUSW1,char_I_O2_ratio ; copy O2 ratio to deco engine | |
2878 addlw .10 ; advance index from O2 ratio to He ratio | |
2879 IFDEF _helium | |
2880 movff PLUSW1,char_I_He_ratio ; copy He ratio to deco engine | |
2881 ENDIF | |
2882 addlw .10 ; advance index from He ratio to gas type | |
2883 movff PLUSW1,char_I_current_gas_type ; copy gas type (0=Disabled, 1=First, 2=Travel, 3=Deco) | |
2884 setup_gas_registers_com: | |
2885 movff char_O_main_status,lo ; working copy of char_O_main_status in bank common | |
2886 bcf lo,DECO_MODE_PSCR_FLAG ; clear the pSCR-mode flag (if applicable) | |
2887 bcf lo,DECO_MODE_LOOP_FLAG ; clear the loop/CCR-mode flag | |
2888 movff lo,char_O_main_status ; bank safe write-back of char_O_main_status | |
2889 movf active_gas,W ; reload WREG with gas 1-5 or 6 (important!) | |
2890 return ; done | |
2891 | |
2892 | |
2893 ;----------------------------------------------------------------------------- | |
2894 ; Helper Function - load OC Gases into Deco Engine (currently breathed gas in WREG) | |
2895 ; | |
2896 global deco_setup_oc_gases | |
2897 deco_setup_oc_gases: | |
2898 movff char_O_deco_status,lo ; get working copy of char_O_deco_status in bank common | |
2899 deco_setup_oc_gases_pre: ; entry point with lo preloaded | |
2900 movff WREG,char_I_current_gas_num ; set gas to start with when doing the deco calculations | |
2901 ; | |
2902 ; Memory Map: | |
2903 ; --------------------------------------------------------------------------------- | |
2904 ; opt_gas_O2_ratio res NUM_GAS | char_I_deco_O2_ratio res NUM_GAS | |
2905 ; opt_dil_O2_ratio res NUM_GAS | | |
2906 ; opt_gas_He_ratio res NUM_GAS | char_I_deco_He_ratio res NUM_GAS | |
2907 ; opt_dil_He_ratio res NUM_GAS | | |
2908 ; opt_gas_type res NUM_GAS | char_I_deco_gas_type res NUM_GAS | |
2909 ; opt_dil_type res NUM_GAS | | |
2910 ; opt_gas_change res NUM_GAS | char_I_deco_gas_change res NUM_GAS | |
2911 ; opt_dil_change res NUM_GAS | | |
2912 ; | |
2913 lfsr FSR2,char_I_deco_O2_ratio ; load FSR2 with base address of char_I_deco_O2_ratio | |
2914 ; FSR2 will step through all char_I_deco_... vars | |
2915 lfsr FSR1,opt_gas_O2_ratio ; load FSR1 with base address of opt_gas_O2_ratio | |
2916 rcall deco_setup_copy ; copy all OC O2 ratios | |
2917 lfsr FSR1,opt_gas_He_ratio ; load FSR1 with base address of opt_gas_He_ratio | |
2918 rcall deco_setup_copy ; copy all OC He ratios | |
2919 lfsr FSR1,opt_gas_type ; load FSR1 with base address of opt_gas_type | |
2920 rcall deco_setup_copy ; copy all gas types | |
2921 lfsr FSR1,opt_gas_change ; load FSR1 with base address of opt_gas_change | |
2922 rcall deco_setup_copy ; copy all gas change depths | |
2923 | |
2924 ; switch deco engine to oc mode | |
2925 bcf lo,DECO_MODE_PSCR_FLAG ; clear the pSCR-mode flag (may not be set, but never mind) | |
2926 bcf lo,DECO_MODE_LOOP_FLAG ; clear the loop/CCR-mode flag | |
2927 movff lo,char_O_deco_status ; bank safe write-back of char_O_deco_status | |
2928 return ; done | |
2929 | |
2930 | |
2931 ;----------------------------------------------------------------------------- | |
2932 ; Helper Function - dedicated Memory Copy | |
2933 deco_setup_copy: | |
2934 movlw NUM_GAS ; load loop counter with number of gases (5) | |
2935 deco_setup_copy_loop: | |
2936 movff POSTINC1,POSTINC2 ; copy from (FSR1) to (FSR2) | |
2937 decfsz WREG ; decrement loop counter and check if it became 0 | |
2938 bra deco_setup_copy_loop ; NO - not yet, loop | |
2939 return ; YES - done | |
2940 | |
2779 | 2941 |
2780 | 2942 |
2781 IFDEF _ccr_pscr | 2943 IFDEF _ccr_pscr |
2782 | 2944 |
2945 ;----------------------------------------------------------------------------- | |
2946 ; Setup everything to enter CCR/pSCR Dive Mode - Part 1 | |
2947 ; | |
2783 global dive_boot_cc | 2948 global dive_boot_cc |
2784 dive_boot_cc: | 2949 dive_boot_cc: |
2785 ; set-up registers | |
2786 rcall get_first_dil_to_WREG ; get first diluent (1-5) into WREG | 2950 rcall get_first_dil_to_WREG ; get first diluent (1-5) into WREG |
2787 rcall setup_dil_registers ; set-up of diluent parameters for currently breathed diluent (with WREG = current diluent 1-5) | 2951 rcall setup_dil_registers ; set-up of diluent parameters for currently breathed diluent (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) | 2952 rcall deco_setup_cc_diluents ; set-up of diluent list for deco calculations (with WREG = current diluent 1-5) |
2789 return | 2953 return ; done |
2790 | 2954 |
2791 | 2955 |
2956 ;----------------------------------------------------------------------------- | |
2957 ; Helper Function - get first Diluent (1-5) into WREG | |
2958 ; | |
2959 global get_first_dil_to_WREG | |
2960 get_first_dil_to_WREG: ; gets first dil (1-5) into WREG | |
2961 lfsr FSR1,opt_dil_type ; load base address of the dil types | |
2962 clrf lo ; start with dil 0 | |
2963 get_first_dil_to_WREG2: | |
2964 movf lo,W ; set index | |
2965 movf PLUSW1,W ; get type of Dil (0=Disabled, 1=First, 2=Normal) | |
2966 sublw .1 ; is it of type First? | |
2967 bz get_first_dil_to_WREG3 ; YES - found the First dil | |
2968 incf lo,F ; NO - increment index | |
2969 movlw NUM_GAS+1 ; - get highest index+1 | |
2970 cpfseq lo ; - dils checked? | |
2971 bra get_first_dil_to_WREG2 ; NO - not yet | |
2972 movlw .1 ; YES - default to dil 1 | |
2973 movff WREG,opt_dil_type+0 ; - force it to be of type First | |
2974 return ; - done | |
2975 get_first_dil_to_WREG3: | |
2976 movf lo,W ; copy index of dil found to be the First to WREG | |
2977 incf WREG,W ; turn index into dil number (0-4 -> 1-5) | |
2978 return ; done | |
2979 | |
2980 | |
2981 ;----------------------------------------------------------------------------- | |
2982 ; Helper Function - load currently breathed Diluent into Deco Engine | |
2983 ; | |
2984 global setup_dil_registers | |
2985 setup_dil_registers: | |
2986 btfsc bailout_mode ; check if in bailout condition | --------------- FOR SAFETY ONLY -------------- | |
2987 bra setup_gas_registers ; revert to setting up OC gases in bailout condition | This branch should never happen to be taken... | |
2988 movwf active_dil ; set as current diluent | |
2989 movlw .6 ; diluent = gas6 ? | |
2990 cpfseq active_dil ; ... | |
2991 bra setup_dil_registers_15 ; NO - load diluent 1-5 | |
2992 | |
2993 ; load gas 6 | |
2994 movff opt_gas6_O2_ratio,char_I_O2_ratio ; copy gas6 O2 ratio to deco engine | |
2995 IFDEF _helium | |
2996 movff opt_gas6_He_ratio,char_I_He_ratio ; copy gas6 He ratio to deco engine | |
2997 ENDIF | |
2998 movlw .2 ; declare gas6 as a normal diluent | |
2999 movff WREG,char_I_current_gas_type ; copy gas type to deco engine | |
3000 movff depth_meter,char_I_gas6_depth ;set current depth as change depth | |
3001 bra setup_dil_registers_com ; continue with common part | |
3002 | |
3003 setup_dil_registers_15: | |
3004 lfsr FSR1,opt_dil_O2_ratio ; load base address of diluent data | |
3005 decf active_dil,W ; set index to O2 ratio of current diluent (1-5 -> 0-4) | |
3006 movff PLUSW1,char_I_O2_ratio ; copy O2 ratio to deco engine | |
3007 addlw .10 ; advance index from O2 ratio to He ratio | |
3008 IFDEF _helium | |
3009 movff PLUSW1,char_I_He_ratio ; copy He ratio to deco engine | |
3010 ENDIF | |
3011 addlw .10 ; advance index from He ratio to diluent type | |
3012 movff PLUSW1,char_I_current_gas_type ; copy diluent type (0=Disabled, 1=First, 2=Normal) | |
3013 setup_dil_registers_com: | |
3014 movff char_O_main_status,lo ; working copy of char_O_main_status in bank common | |
3015 bsf lo,DECO_MODE_LOOP_FLAG ; loop flag is set in both, CCR and pSCR mode | |
3016 bcf lo,DECO_MODE_PSCR_FLAG ; clear pSCR mode flag by default | |
3017 btfsc FLAG_pscr_mode ; check if we are in pSCR mode | |
3018 bsf lo,DECO_MODE_PSCR_FLAG ; YES - set additional flag for pSCR mode | |
3019 movff lo,char_O_main_status ; bank safe write-back of char_O_main_status | |
3020 movf active_dil,W ; reload WREG with diluent 1-5 or 6 (important!) | |
3021 return ; done | |
3022 | |
3023 | |
3024 ;----------------------------------------------------------------------------- | |
3025 ; Helper Function - load Diluents into Deco Engine (currently breathed dil in WREG) | |
3026 ; | |
3027 global deco_setup_cc_diluents | |
3028 deco_setup_cc_diluents: | |
3029 movff char_O_deco_status,lo ; working copy of char_O_deco_status in bank common | |
3030 deco_setup_cc_diluents_pre: ; entry point with lo preloaded | |
3031 btfsc bailout_mode ; check if in bailout condition | --------------- FOR SAFETY ONLY -------------- | |
3032 bra deco_setup_oc_gases_pre ; YES - revert to setting up OC gases | This branch should never happen to be taken... | |
3033 movff WREG,char_I_current_gas_num ; NO - set diluent to start with when doing the deco calculations | |
3034 ; | |
3035 ; Memory Map: | |
3036 ; --------------------------------------------------------------------------------- | |
3037 ; opt_gas_O2_ratio res NUM_GAS | | |
3038 ; opt_dil_O2_ratio res NUM_GAS | char_I_deco_O2_ratio res NUM_GAS | |
3039 ; opt_gas_He_ratio res NUM_GAS | | |
3040 ; opt_dil_He_ratio res NUM_GAS | char_I_deco_He_ratio res NUM_GAS | |
3041 ; opt_gas_type res NUM_GAS | | |
3042 ; opt_dil_type res NUM_GAS | char_I_deco_gas_type res NUM_GAS | |
3043 ; opt_gas_change res NUM_GAS | | |
3044 ; opt_dil_change res NUM_GAS | char_I_deco_gas_change res NUM_GAS | |
3045 ; | |
3046 lfsr FSR2,char_I_deco_O2_ratio ; load FSR2 with base address of char_I_deco_O2_ratio. | |
3047 ; FSR2 will step through all char_I_deco_... vars. | |
3048 lfsr FSR1,opt_dil_O2_ratio ; load FSR1 with base address of opt_dil_O2_ratio | |
3049 rcall deco_setup_copy ; copy all dil O2 ratios | |
3050 lfsr FSR1,opt_dil_He_ratio ; load FSR1 with base address of opt_dil_He_ratio | |
3051 rcall deco_setup_copy ; copy all dil He ratios | |
3052 lfsr FSR1,opt_dil_type ; load FSR1 with base address of opt_dil_type | |
3053 rcall deco_setup_copy ; copy all dil types | |
3054 lfsr FSR1,opt_dil_change ; load FSR1 with base address of opt_dil_change | |
3055 rcall deco_setup_copy ; copy all dil change depths | |
3056 ; switch to CCR / pSCR mode: | |
3057 bsf lo,DECO_MODE_LOOP_FLAG ; - loop flag is set in both, CCR and pSCR mode | |
3058 bcf lo,DECO_MODE_PSCR_FLAG ; - clear pSCR mode flag by default | |
3059 btfsc FLAG_pscr_mode ; - check if we are in pSCR mode | |
3060 bsf lo,DECO_MODE_PSCR_FLAG ; YES - set additional flag for pSCR mode | |
3061 movff lo,char_O_deco_status ; - bank safe write-back of char_O_deco_status | |
3062 return ; done | |
3063 | |
3064 | |
3065 ;----------------------------------------------------------------------------- | |
3066 ; Setup everything to enter CCR / pSCR Dive Mode - Part 2 | |
3067 ; | |
2792 dive_boot_cc_part2: | 3068 dive_boot_cc_part2: |
2793 ; revoke sensors from usage if they do not have a valid calibration | 3069 ; revoke sensors from usage if they do not have a valid calibration |
2794 bsf use_O2_sensor1 | 3070 bsf use_O2_sensor1 |
2795 bsf use_O2_sensor2 | |
2796 bsf use_O2_sensor3 | |
2797 btfss sensor1_calibrated_ok | 3071 btfss sensor1_calibrated_ok |
2798 bcf use_O2_sensor1 | 3072 bcf use_O2_sensor1 |
3073 | |
3074 bsf use_O2_sensor2 | |
2799 btfss sensor2_calibrated_ok | 3075 btfss sensor2_calibrated_ok |
2800 bcf use_O2_sensor2 | 3076 bcf use_O2_sensor2 |
3077 | |
3078 bsf use_O2_sensor3 | |
2801 btfss sensor3_calibrated_ok | 3079 btfss sensor3_calibrated_ok |
2802 bcf use_O2_sensor3 | 3080 bcf use_O2_sensor3 |
2803 | 3081 |
2804 IFDEF _external_sensor | 3082 IFDEF _external_sensor |
2805 ; check for external HUD/ppO2 Monitor | 3083 ; check for external HUD/ppO2 Monitor |
2806 btfss optical_input ; do we have an optical input? | 3084 btfss ext_input_optical ; do we have an optical input? |
2807 bra dive_boot_cc_part2_1 ; NO | 3085 bra dive_boot_cc_part2_1 ; NO |
2808 btfsc sensor1_active ; YES - copy valid flags from HUD/ppO2 Monitor | 3086 btfsc sensor1_active ; YES - process flags from HUD/ppO2 Monitor |
2809 bsf use_O2_sensor1 ; - ... | 3087 bsf use_O2_sensor1 ; - ... |
2810 btfsc sensor2_active ; - ... | 3088 btfsc sensor2_active ; - ... |
2811 bsf use_O2_sensor2 ; - ... | 3089 bsf use_O2_sensor2 ; - ... |
2812 btfsc sensor3_active ; - ... | 3090 btfsc sensor3_active ; - ... |
2813 bsf use_O2_sensor3 ; - ... | 3091 bsf use_O2_sensor3 ; - ... |
2814 ENDIF | 3092 ENDIF |
2815 | 3093 |
2816 dive_boot_cc_part2_1: | 3094 dive_boot_cc_part2_1: |
2817 ; In pSCR mode, only settings 0 (calculated ppO2) and 1 (ppO2 from sensors) are defined. | 3095 ; In pSCR mode, only settings 0 (calculated ppO2) and 1 (ppO2 from sensors) are defined. |
2818 ; In case we still have 3 (auto SP) selected out of previous CCR mode, we reset to 0. | 3096 ; In case we still have 3 (auto SP) selected out of previous CCR mode, we reset to 0. |
2819 btfss FLAG_pscr_mode | 3097 btfss FLAG_pscr_mode ; in pSCR mode? |
2820 bra dive_boot_cc_part2_2 | 3098 bra dive_boot_cc_part2_2 ; NO |
2821 movff opt_ccr_mode,WREG ; =0: Fixed SP (CCR) / calculated SP (pSCR), =1: Sensor, =2: Auto SP | 3099 movff opt_ccr_mode,WREG ; YES - get mode (=0: Fixed SP (CCR) / calculated SP (pSCR), =1: Sensor, =2: Auto SP) |
2822 sublw .2 ; opt_ccr_mode = 1 (Auto SP)? | 3100 sublw .2 ; opt_ccr_mode = 1 (Auto SP)? |
2823 bnz dive_boot_cc_part2_2 | 3101 bnz dive_boot_cc_part2_2 ; NO - ok |
2824 movlw .0 | 3102 movlw .0 ; YES - revert to calculated SP |
2825 movff WREG,opt_ccr_mode | 3103 movff WREG,opt_ccr_mode ; ... |
3104 | |
2826 dive_boot_cc_part2_2: | 3105 dive_boot_cc_part2_2: |
2827 bsf event_SP_change ; set setpoint event flag | 3106 bsf event_SP_change ; set setpoint event flag |
2828 | 3107 |
2829 ; Start with SP1 (CCR) or 0 (pSCR) as default. | 3108 ; Start with SP1 (CCR) or 0 (pSCR) as default. |
2830 ; If in sensor mode, this value will be overwritten by calc_deko_divemode_sensor | 3109 ; If in sensor mode, this value will be overwritten by calc_deko_divemode_sensor |
2831 clrf WREG ; pre-load WREG with setpoint value 0 for pSCR calculated | 3110 clrf WREG ; pre-load WREG with setpoint value 0 for pSCR calculated |
2832 btfsc FLAG_ccr_mode ; in CCR mode? | 3111 btfsc FLAG_ccr_mode ; in CCR mode? |
2833 movff opt_setpoint_cbar+0,WREG ; YES - get value of setpoint 1 into WREG | 3112 movff opt_setpoint_cbar+0,WREG ; YES - get value of setpoint 1 into WREG |
2834 movff WREG,char_I_const_ppO2 ; write setpoint to deco engine | 3113 movff WREG,char_I_const_ppO2 ; write setpoint to deco engine |
3114 | |
2835 IFDEF _external_sensor | 3115 IFDEF _external_sensor |
2836 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics | 3116 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics |
2837 goto calc_deko_divemode_sensor ; read & process sensor data (and return) | 3117 goto calc_deko_divemode_sensor ; process sensor readings and return |
2838 ELSE | 3118 ELSE |
2839 return ; done | 3119 return ; done |
2840 ENDIF | 3120 ENDIF |
2841 | 3121 |
2842 ENDIF ; _ccr_pscr | 3122 ENDIF ; _ccr_pscr |
2843 | 3123 |
3124 | |
2844 ;============================================================================= | 3125 ;============================================================================= |
2845 | 3126 dmode3 CODE |
3127 ;============================================================================= | |
3128 | |
3129 | |
3130 ;----------------------------------------------------------------------------- | |
3131 ; Initialize Dive Mode | |
3132 ; | |
2846 diveloop_boot: | 3133 diveloop_boot: |
2847 ; do the basic initialization | 3134 ; do the basic initialization |
2848 call restart_set_modes_and_flags | 3135 call restart_set_modes_and_flags ; basic settings depending on deco mode |
2849 | 3136 |
2850 ; stop accelerometer and compass | 3137 ; save on energy |
2851 call I2C_sleep_compass | 3138 call I2C_sleep_compass ; stop accelerometer and compass |
2852 | 3139 |
2853 ; do an early initialization of all deco engine output variables to | 3140 ; do an early initialization of all deco engine output variables to |
2854 ; avoid glitches in the display outputs during deco engine start-up | 3141 ; avoid glitches in the display outputs during deco engine start-up |
2855 call deco_init_output_vars; ; (C-code) | 3142 call deco_init_output_vars; ; (C-code) |
2856 banksel common ; back to bank common | 3143 banksel common ; back to bank common |
2857 | 3144 |
3145 ; configure screen layout | |
3146 TSTOSC opt_layout ; alternative layout enabled? | |
3147 bsf alt_layout_active ; YES - start with alternative layout | |
3148 | |
3149 ; configure tissue graphics | |
3150 TSTOSS opt_tissue_graphics ; shall show: 0= pres+sat, 1= N2+He | |
3151 bsf tissue_graphic_layout ; YES - show press+sat | |
3152 TSTOSC char_I_model ; GF factors enabled? | |
3153 bsf tissue_graphic_gf ; YES - show GF lines | |
3154 | |
2858 ; reset max relative pressure (max depth) | 3155 ; reset max relative pressure (max depth) |
2859 bsf reset_max_pressure ; request ISR to reset the max pressure | 3156 bsf reset_max_pressure ; request ISR to reset the max pressure |
2860 | |
2861 | 3157 |
2862 IFDEF _min_depth_option | 3158 IFDEF _min_depth_option |
2863 ; reset the resettable min/max relative pressure (trip-wise min/max depth) | 3159 ; reset the resettable min/max relative pressure (trip-wise min/max depth) |
2864 bsf reset_trip_pressure ; request ISR to reset the resettable min/max pressure | 3160 bsf reset_trip_pressure ; request ISR to reset the resettable min/max pressure |
2865 ENDIF | 3161 ENDIF |
2905 bsf lo,DECO_START_NORM ; set flag for doing a normal plan | 3201 bsf lo,DECO_START_NORM ; set flag for doing a normal plan |
2906 bsf lo,DECO_INITIALIZE ; set flag for initializing the deco engine | 3202 bsf lo,DECO_INITIALIZE ; set flag for initializing the deco engine |
2907 movff lo,char_O_deco_status ; bank-safe copy back to deco engine | 3203 movff lo,char_O_deco_status ; bank-safe copy back to deco engine |
2908 | 3204 |
2909 ; disable "fast forward" function | 3205 ; disable "fast forward" function |
2910 movlw .0 | 3206 movlw .0 ; set fast forward to zero |
2911 movff WREG,char_I_sim_advance_time | 3207 movff WREG,char_I_sim_advance_time; ... |
2912 | 3208 |
2913 ; write last stop depth to deco engine | 3209 ; write last stop depth to deco engine |
2914 movff opt_last_stop,char_I_last_stop_depth | 3210 movff opt_last_stop,char_I_last_stop_depth |
2915 | 3211 |
2916 ; initialize max depth for apnoe mode | 3212 ; initialize max depth for apnoe mode |
2917 CLRI apnoe_max_pressure | 3213 CLRI apnoe_max_pressure ; reset to zero |
2918 | 3214 |
2919 ; reset minimum temperature, ISR-safe 2 byte copy | 3215 ; reset minimum temperature, ISR-safe 2 byte copy |
2920 SMOVII temperature_cur,temperature_min | 3216 SMOVII temperature_cur,temperature_min |
2921 | 3217 |
2922 ; ISR-safe copy of start-of-dive date and time for logbook (6 bytes in total) | 3218 ; ISR-safe copy of start-of-dive date and time for logbook (6 bytes in total) |
2929 ; save supersaturation at beginning of dive (only lower byte is used for value) | 3225 ; save supersaturation at beginning of dive (only lower byte is used for value) |
2930 movff int_O_lead_supersat+0,supersat_start | 3226 movff int_O_lead_supersat+0,supersat_start |
2931 | 3227 |
2932 clrf menu_pos_cur ; reset current menu position | 3228 clrf menu_pos_cur ; reset current menu position |
2933 clrf active_premenu ; no pre-menu task active | 3229 clrf active_premenu ; no pre-menu task active |
2934 bsf o2_sensors_agree ; initialize sensors disagree warning system | |
2935 | 3230 |
2936 clrf safety_stop_countdown ; clear safety stop count-down | 3231 clrf safety_stop_countdown ; clear safety stop count-down |
2937 | 3232 |
2938 CLRI last_pressure_velocity ; initialize last pressure for velocity calculation | 3233 CLRI last_pressure_velocity ; initialize last pressure for velocity calculation |
2939 CLRI dive_timeout_timer ; initialize timeout counter | 3234 CLRI dive_timeout_timer ; initialize timeout counter |
2956 | 3251 |
2957 btfss tr_functions_activated ; TR functions activated? | 3252 btfss tr_functions_activated ; TR functions activated? |
2958 bra diveloop_boot_0 ; NO - skip TR function initialization | 3253 bra diveloop_boot_0 ; NO - skip TR function initialization |
2959 | 3254 |
2960 banksel int_IO_pressure_value | 3255 banksel int_IO_pressure_value |
2961 clrf WREG ; clear WREG | 3256 |
2962 bsf WREG,int_not_avail_flag ; set WREG to coding for integer numbers -> data not available | 3257 clrf WREG ; set WREG to coding for integer numbers -> data not available |
3258 bsf WREG,int_not_avail_flag ; ... | |
2963 clrf int_IO_pressure_value+0 ; clear low byte of 1st pressure reading value | 3259 clrf int_IO_pressure_value+0 ; clear low byte of 1st pressure reading value |
2964 movwf int_IO_pressure_value+1 ; copy to high byte of 1st pressure reading value | 3260 movwf int_IO_pressure_value+1 ; copy to high byte of 1st pressure reading value |
2965 clrf int_IO_pressure_value+2 ; clear low byte of 2nd pressure reading value | 3261 clrf int_IO_pressure_value+2 ; clear low byte of 2nd pressure reading value |
2966 movwf int_IO_pressure_value+3 ; copy to high byte of 2nd pressure reading value | 3262 movwf int_IO_pressure_value+3 ; copy to high byte of 2nd pressure reading value |
2967 clrf int_I_pressure_drop+0 ; clear low byte of 1st pressure drop value | 3263 clrf int_I_pressure_drop+0 ; clear low byte of 1st pressure drop value |
2989 IFDEF _ccr_pscr | 3285 IFDEF _ccr_pscr |
2990 setf best_dil_number ; initialize best diluent as not computed yet (255) | 3286 setf best_dil_number ; initialize best diluent as not computed yet (255) |
2991 ENDIF | 3287 ENDIF |
2992 | 3288 |
2993 btfsc FLAG_oc_mode ; in OC mode? | 3289 btfsc FLAG_oc_mode ; in OC mode? |
2994 rcall dive_boot_oc ; YES - add OC mode settings | 3290 call dive_boot_oc ; YES - add OC mode settings |
2995 | 3291 |
2996 IFDEF _ccr_pscr | 3292 IFDEF _ccr_pscr |
2997 btfsc FLAG_ccr_mode ; in CCR mode? | 3293 btfsc FLAG_ccr_mode ; in CCR mode? |
2998 rcall dive_boot_cc ; YES - add CC mode settings | 3294 call dive_boot_cc ; YES - add CC mode settings |
2999 btfsc FLAG_ccr_mode ; in CCR mode? | 3295 btfsc FLAG_ccr_mode ; in CCR mode? |
3000 rcall dive_boot_cc_part2 ; YES - add CC sensor and SP settings | 3296 call dive_boot_cc_part2 ; YES - add CC sensor and SP settings |
3001 | 3297 |
3002 btfsc FLAG_pscr_mode ; in pSCR mode? | 3298 btfsc FLAG_pscr_mode ; in pSCR mode? |
3003 rcall dive_boot_cc ; YES - add CC mode settings | 3299 call dive_boot_cc ; YES - add CC mode settings |
3004 btfsc FLAG_pscr_mode ; in pSCR mode? | 3300 btfsc FLAG_pscr_mode ; in pSCR mode? |
3005 rcall dive_boot_cc_part2 ; YES - add CC sensor and SP settings | 3301 call dive_boot_cc_part2 ; YES - add CC sensor and SP settings |
3006 ENDIF | 3302 ENDIF |
3007 | 3303 |
3008 bcf bailout_mode ; not in bailout mode | 3304 bcf bailout_mode ; not in bailout mode |
3009 | 3305 |
3010 call ghostwriter_short_header ; write short header with dive number into profile memory | 3306 call ghostwriter_short_header ; write short header with dive number into profile memory |
3037 | 3333 |
3038 return ; done with dive mode boot | 3334 return ; done with dive mode boot |
3039 | 3335 |
3040 | 3336 |
3041 ;============================================================================= | 3337 ;============================================================================= |
3042 | 3338 dmode4 CODE |
3339 ;============================================================================= | |
3340 | |
3341 | |
3342 ;----------------------------------------------------------------------------- | |
3343 ; Check all Sorts of Parameters and issue Warnings and Attentions if applicable | |
3344 ; | |
3043 divemode_check_warnings: | 3345 divemode_check_warnings: |
3044 movlw .1 ; one message at a time in alternative layout | 3346 movlw .1 ; one message at a time in alternative layout |
3045 btfss alt_layout_active ; in alternative layout? | 3347 btfss alt_layout_active ; in alternative layout? |
3046 movlw .2 ; NO - two messages at a time in normal layout | 3348 movlw .2 ; NO - two messages at a time in normal layout |
3047 cpfsgt message_counter ; more than one (alt layout) / 2 (normal layout) messages currently active? | 3349 cpfsgt message_counter ; had more than 1 / 2 messages in the last round? |
3048 bra divemode_check_warnings1 ; NO - update messages every second | 3350 bra divemode_check_warnings1 ; NO - update messages every second |
3049 | 3351 |
3050 ; ; YES - update every 4 seconds: | 3352 ; ; YES - update every 4 seconds: |
3051 ; btfss timebase_1sec ; - on second 1 or 3 ? | 3353 ; btfss timebase_1sec ; - on second 1 or 3 ? |
3052 ; return ; NO - no update in this cycle | 3354 ; return ; NO - no update in this cycle |
3053 ; btfss timebase_2sec ; YES - on second 3 ? | 3355 ; btfss timebase_2sec ; YES - on second 3 ? |
3054 ; return ; NO - no update in this cycle | 3356 ; return ; NO - no update in this cycle |
3055 ; ;bra divemode_check_warnings1 ; YES - update messages | 3357 ; ;bra divemode_check_warnings1 ; YES - update messages |
3056 | 3358 |
3057 ; NO - update every 2 seconds | 3359 ; YES - update every 2 seconds |
3058 btfsc timebase_1sec ; - on even second? | 3360 btfsc timebase_1sec ; - on even second? |
3059 return ; NO - done | 3361 return ; NO - done |
3060 ;bra divemode_check_warnings1 ; YES - update messages | 3362 ;bra divemode_check_warnings1 ; YES - update messages |
3061 | 3363 |
3062 divemode_check_warnings1: | 3364 divemode_check_warnings1: |
3063 ; start a new message collection cycle | |
3064 bcf message_advice ; clear flag for messages of level advice | |
3065 bcf message_attention ; clear flag for messages of level attention | |
3066 bcf message_warning ; clear flag for messages of level warning | |
3067 clrf message_counter ; clear message counter | 3365 clrf message_counter ; clear message counter |
3068 | 3366 |
3069 ; messages sorted by severity: highest severity warnings first, then attentions, advices and last info | 3367 ; messages sorted by severity: highest severity warnings first, then attentions, advices and last info |
3070 | 3368 |
3071 ; warnings for all modes | 3369 ; warnings for all modes |
3072 call check_warn_battery ; check if the battery level should be displayed/warned | 3370 call check_battery ; check battery status |
3073 rcall check_depth_limit ; check current depth against set depth limit | 3371 rcall check_depth_limit ; check current depth |
3074 call check_divetimeout ; check and show the dive mode timeout (not actually a warning) | 3372 call check_divetimeout ; check dive timeout |
3075 | 3373 |
3076 btfsc FLAG_apnoe_mode ; in apnoe mode? | 3374 btfsc FLAG_apnoe_mode ; in apnoe mode? |
3077 bra divemode_check_warnings2 ; YES | 3375 bra divemode_check_warnings2 ; YES - skip deco mode checks |
3078 | 3376 |
3079 btfsc FLAG_gauge_mode ; in gauge mode? | 3377 btfsc FLAG_gauge_mode ; in gauge mode? |
3080 bra divemode_check_warnings2 ; YES | 3378 bra divemode_check_warnings2 ; YES - skip deco mode checks |
3081 | 3379 |
3082 ; warnings applicable only in deco modes | 3380 ; warnings applicable only in deco modes |
3083 | 3381 |
3084 IFDEF _cave_mode | 3382 IFDEF _cave_mode |
3085 rcall check_cavemode ; check cave mode status | 3383 rcall check_cavemode ; check cave mode status |
3086 ENDIF | 3384 ENDIF |
3087 | 3385 |
3088 rcall check_display_ftts ; show @+x time (or cave mode cTTS) | 3386 rcall check_display_ftts ; show fTTS time (or cave mode cTTS) |
3089 | 3387 rcall check_ppO2 ; check ppO2 |
3090 rcall check_ppO2 ; check ppO2 and displays warning, if required | |
3091 | 3388 |
3092 IFDEF _external_sensor | 3389 IFDEF _external_sensor |
3093 btfss o2_sensors_agree ; are the sensor values within the threshold range? | 3390 rcall check_ext_sensors ; check external sensors |
3094 rcall check_warn_sensors_disagree ; NO - do further evaluation | |
3095 btfsc o2_sensors_agree ; are the sensor values within the threshold range? | |
3096 bcf o2_sensors_warning ; YES - clear flag for a new warning | |
3097 ENDIF | 3391 ENDIF |
3098 | 3392 |
3099 rcall check_outside ; check of ZHL16 model violation | 3393 rcall check_outside ; check of ZHL16 model violation |
3100 | 3394 |
3101 IFDEF _helium | 3395 IFDEF _ccr_pscr |
3102 rcall check_IBCD ; check for IBCD attention or warning | |
3103 ENDIF | |
3104 | |
3105 btfsc FLAG_ccr_mode ; in CCR mode? | 3396 btfsc FLAG_ccr_mode ; in CCR mode? |
3106 rcall check_OC_gas_avail ; YES - check if a breathable OC (bailout) gas is available | 3397 rcall check_OC_gas_avail ; YES - check if a breathable OC (bailout) gas is available |
3107 btfsc FLAG_pscr_mode ; in pSCR mode? | 3398 btfsc FLAG_pscr_mode ; in pSCR mode? |
3108 rcall check_OC_gas_avail ; YES - check if a breathable OC (bailout) gas is available | 3399 rcall check_OC_gas_avail ; YES - check if a breathable OC (bailout) gas is available |
3400 ENDIF | |
3109 | 3401 |
3110 btfsc decostop_active ; in deco mode? | 3402 btfsc decostop_active ; in deco mode? |
3111 rcall check_and_store_sat_violation; YES - sets warnings, if required | 3403 rcall check_saturation ; YES - check tissue saturation |
3112 | 3404 |
3113 rcall check_mbubbles ; check for micro bubbles | 3405 rcall check_mbubbles ; check for micro bubbles |
3114 rcall check_cns_violation ; check CNS value and display it, if required | 3406 rcall check_cns_violation_now ; check current CNS value |
3115 rcall check_gas_needs ; show gas needs warning if any gas need for ascent is > threshold | 3407 rcall check_cns_violation_eod ; check end-of-dive CNS value (needs to be done after check_cns_violation_now) |
3116 rcall check_eod_cns_violation ; check CNS values for end-of-dive and display warning, if required | 3408 rcall check_gas_needs ; check for gas needs |
3409 rcall check_gas_change ; check for diluent or gas change advice | |
3410 | |
3411 IFDEF _ccr_pscr | |
3412 btfsc FLAG_ccr_mode ; in CCR mode? | |
3413 rcall check_gas_density ; YES - check gas density | |
3414 btfsc FLAG_pscr_mode ; in pSCR mode? | |
3415 rcall check_gas_density ; YES - check gas density | |
3416 ENDIF | |
3117 | 3417 |
3118 btfsc use_aGF ; using alternative GF factors? | 3418 btfsc use_aGF ; using alternative GF factors? |
3119 rcall warn_agf ; YES - show memo | 3419 rcall remind_agf_in_use ; YES - show reminder |
3120 | |
3121 btfsc sp_fallback ; in fallback condition due to O2 sensor failure? | |
3122 rcall warn_fallback ; YES - show a warning | |
3123 | |
3124 btfsc better_dil_available ; is a better diluent available? | |
3125 rcall advice_gas_change ; YES - display a gas change advice | |
3126 | |
3127 btfsc better_gas_available ; is a better gas available? | |
3128 rcall advice_gas_change ; YES - display a gas change advice | |
3129 | 3420 |
3130 divemode_check_warnings2: | 3421 divemode_check_warnings2: |
3422 | |
3131 IFDEF _rx_functions | 3423 IFDEF _rx_functions |
3132 btfss tr_functions_activated ; TR functions activated? | 3424 btfss tr_functions_activated ; TR functions activated? |
3133 bra divemode_check_warnings3 ; NO - skip | 3425 bra divemode_check_warnings3 ; NO - skip |
3134 call check_tr_functions ; YES - check transmitter functions | 3426 call check_tr_functions ; YES - check transmitter functions |
3135 call check_tr_messages ; - check SAC attention and switch advice | 3427 call check_tr_messages ; - check SAC attention and switch advice |
3136 ENDIF | 3428 ENDIF |
3137 | 3429 |
3138 divemode_check_warnings3: | 3430 divemode_check_warnings3: |
3139 ; Display / clear the advice, attention or warning icon | 3431 |
3140 btfsc message_advice ; any message of level advice? | 3432 ; compute if an advice / attention / warning sign shall be shown |
3141 bsf FLAG_TFT_sign_show ; YES | 3433 rcall divemode_check_sign |
3142 btfsc message_attention ; any message of level attention? | 3434 |
3143 bsf FLAG_TFT_sign_show ; YES | 3435 ; increment message page number |
3144 btfsc message_warning ; any message of level warning? | |
3145 bsf FLAG_TFT_sign_show ; YES | |
3146 btfss FLAG_TFT_sign_show ; any message of above levels? | |
3147 bsf FLAG_TFT_sign_clear ; NO - clear sign | |
3148 | |
3149 ; Increment message page number | |
3150 incf message_page,F ; increment page number | 3436 incf message_page,F ; increment page number |
3151 bcf STATUS,C ; clear carry bit | 3437 bcf STATUS,C ; clear carry bit |
3152 movf message_page,W ; get page number into WREG | 3438 movf message_page,W ; get page number into WREG |
3153 btfss alt_layout_active ; in alternative layout? | 3439 btfss alt_layout_active ; in alternative layout? |
3154 rlcf WREG,W ; NO - each page can take two messages | 3440 rlcf WREG,W ; NO - each page can take two messages |
3155 cpfsgt message_counter ; number of actual messages > message capacity ? | 3441 cpfsgt message_counter ; number of actual messages > message capacity ? |
3156 clrf message_page ; NO - all messages could be shown, restart from first page next time | 3442 clrf message_page ; NO - all messages could be shown, restart from first page next time |
3157 | 3443 |
3158 ; Clear both rows of messages if there is nothing to show at all | 3444 ; clear both rows of messages if there is nothing to show at all |
3159 tstfsz message_counter ; any message to show? | 3445 tstfsz message_counter ; any message to show? |
3160 bra divemode_check_warnings4 ; YES - look if second row needs to be cleared | 3446 bra divemode_check_warnings4 ; YES - look if second row needs to be cleared |
3161 bsf FLAG_TFT_message_clear_both ; NO - request clearing of left-over messages | 3447 bsf FLAG_TFT_message_clear_both ; NO - request clearing of left-over messages |
3162 return ; - done | 3448 return ; - done |
3163 | 3449 |
3164 divemode_check_warnings4: | 3450 divemode_check_warnings4: |
3165 ; Clear 2nd row of messages if there is nothing to show (on this page) | 3451 ; clear 2nd row of messages if there is nothing to show (on this page) |
3166 btfss message_2nd_row_used ; does the 2nd row contain a message? | 3452 btfss message_2nd_row_used ; does the 2nd row contain a message? |
3167 bsf FLAG_TFT_message_clear_2nd ; NO - set flag to clear the 2nd row | 3453 bsf FLAG_TFT_message_clear_2nd ; NO - set flag to clear the 2nd row |
3168 return ; done | 3454 return ; done |
3169 | 3455 |
3170 ;----------------------------------------------------------------------------- | 3456 |
3171 | 3457 ;----------------------------------------------------------------------------- |
3172 global check_warn_battery | 3458 ; Helper Function - check if an Advice / Attention / Warning Sign shall be shown |
3173 check_warn_battery: | 3459 ; |
3460 divemode_check_sign: | |
3461 ; clear sign flags | |
3462 bcf sign_advice ; clear flag for showing advice sign | |
3463 bcf sign_attention ; clear flag for showing attention sign | |
3464 bcf sign_warning ; clear flag for showing warning sign | |
3465 | |
3466 ; check for new advices | |
3467 movf DM_flags_advc_det,W ; get current advices | |
3468 andwf DM_flags_advc_ack,W ; keep only those acknowledgments that have current advices | |
3469 movwf DM_flags_advc_ack ; store updated acknowledgments | |
3470 xorwf DM_flags_advc_det,W ; find advices that have not been acknowledged yet | |
3471 tstfsz WREG ; any new advice? | |
3472 bsf sign_advice ; YES - set flag for showing advice sign | |
3473 | |
3474 ; check for new attentions (1) | |
3475 movf DM_flags_att1_det,W ; get current attentions | |
3476 andwf DM_flags_att1_ack,W ; keep only those acknowledgments that have current attentions | |
3477 movwf DM_flags_att1_ack ; store updated acknowledgments | |
3478 xorwf DM_flags_att1_det,W ; find attentions that have not been acknowledged yet | |
3479 tstfsz WREG ; any new attention? | |
3480 bsf sign_attention ; YES - set flag for showing attention sign | |
3481 | |
3482 ; check for new attentions (2) | |
3483 movf DM_flags_att2_det,W ; get current attentions | |
3484 andwf DM_flags_att2_ack,W ; keep only those acknowledgments that have current attentions | |
3485 movwf DM_flags_att2_ack ; store updated acknowledgments | |
3486 xorwf DM_flags_att2_det,W ; find attentions that have not been acknowledged yet | |
3487 tstfsz WREG ; any new attention? | |
3488 bsf sign_attention ; YES - set flag for showing attention sign | |
3489 | |
3490 ; check for new attentions (3) | |
3491 movf DM_flags_att3_det,W ; get current attentions | |
3492 andwf DM_flags_att3_ack,W ; keep only those acknowledgments that have current attentions | |
3493 movwf DM_flags_att3_ack ; store updated acknowledgments | |
3494 xorwf DM_flags_att3_det,W ; find attentions that have not been acknowledged yet | |
3495 tstfsz WREG ; any new attention? | |
3496 bsf sign_attention ; YES - set flag for showing attention sign | |
3497 | |
3498 ; check for new warnings (1) | |
3499 movf DM_flags_war1_det,W ; get current warnings | |
3500 andwf DM_flags_war1_ack,W ; keep only those acknowledgments that have current warnings | |
3501 movwf DM_flags_war1_ack ; store updated acknowledgments | |
3502 xorwf DM_flags_war1_det,W ; find warnings that have not been acknowledged yet | |
3503 tstfsz WREG ; any new warning? | |
3504 bsf sign_warning ; YES - set flag for showing warning sign | |
3505 | |
3506 ; check for new warnings (2) | |
3507 movf DM_flags_war2_det,W ; get current warnings | |
3508 andwf DM_flags_war2_ack,W ; keep only those acknowledgments that have current warnings | |
3509 movwf DM_flags_war2_ack ; store updated acknowledgments | |
3510 xorwf DM_flags_war2_det,W ; find warnings that have not been acknowledged yet | |
3511 tstfsz WREG ; any new warning? | |
3512 bsf sign_warning ; YES - set flag for showing warning sign | |
3513 | |
3514 ; show or clear the advice / attention / warning sign | |
3515 btfsc sign_advice ; shall show advice sign? | |
3516 bsf FLAG_TFT_sign_show ; YES - show sign | |
3517 btfsc sign_attention ; shall show attention sign? | |
3518 bsf FLAG_TFT_sign_show ; YES - show sign | |
3519 btfsc sign_warning ; shall show warning sign? | |
3520 bsf FLAG_TFT_sign_show ; YES - show sign | |
3521 btfss FLAG_TFT_sign_show ; shall show any sign? | |
3522 bsf FLAG_TFT_sign_clear ; NO - then clear the sign | |
3523 | |
3524 return ; done | |
3525 | |
3526 | |
3527 ;----------------------------------------------------------------------------- | |
3528 ; Check Battery Power | |
3529 ; | |
3530 global check_battery | |
3531 check_battery: | |
3532 bcf warn_det_batt_low ; clear warning for battery low | |
3174 movlw battery_show_level+1 ; get threshold for showing battery level, incremented by 1 | 3533 movlw battery_show_level+1 ; get threshold for showing battery level, incremented by 1 |
3175 cpfslt batt_percent ; battery percentage ok? | 3534 cpfslt batt_percent ; battery percentage ok? |
3176 return ; YES - no display, no warning | 3535 return ; YES - done |
3177 ; Display Battery, but warn? | 3536 btfsc battery_low_condition ; NO - battery low condition detected? |
3178 btfsc battery_low_condition ; battery low condition detected? | 3537 bsf warn_det_batt_low ; YES - set warning for battery low |
3179 bsf message_warning ; YES - set warning flag for battery low | 3538 movf active_customview,W ; - get current custom view |
3180 movlw index_clock_batt_surfpress ; index of custom view clock, battery and surface pressure | 3539 xorlw index_clock_batt_surfpress ; - battery shown in custom view? |
3181 cpfseq active_customview ; battery shown in custom view? | 3540 bnz check_battery_mesg ; NO - show message |
3182 bra check_warn_battery2 ; NO - show warning | 3541 return ; YES - do not show twice, done |
3183 return ; YES - do not show twice (in custom view and in message area) | 3542 |
3184 check_warn_battery2: | 3543 check_battery_mesg: |
3185 incf message_counter,F ; increase counter | 3544 incf message_counter,F ; increase message counter |
3186 goto TFT_msg_batt_percent_divemode ; show warning message for battery low (battery percent) and return | 3545 goto TFT_message_battery_percent ; show message for battery low (battery percent) and return |
3187 | 3546 |
3188 | 3547 |
3548 ;----------------------------------------------------------------------------- | |
3549 ; Show Dive Timeout Counter if Dive Time is not counted | |
3550 ; | |
3189 check_divetimeout: | 3551 check_divetimeout: |
3190 btfsc count_divetime ; is dive time counted? | 3552 btfsc count_divetime ; is dive time counted? |
3191 return ; YES - do nothing | 3553 return ; YES - nothing to do, done |
3192 incf message_counter,F ; increase counter | 3554 incf message_counter,F ; NO - increase message counter |
3193 goto TFT_divetimeout ; show timeout counter (and return) | 3555 goto TFT_message_divetimeout ; - show timeout counter and return |
3194 | 3556 |
3195 | 3557 |
3558 ;----------------------------------------------------------------------------- | |
3559 ; Check ppO2 of all Gases / Diluents in use | |
3560 ; | |
3196 check_ppO2: | 3561 check_ppO2: |
3197 IFDEF _ccr_pscr | 3562 IFDEF _ccr_pscr |
3198 btfsc FLAG_oc_mode ; are we in OC mode? | 3563 ; check if breathing from the loop |
3564 btfsc FLAG_oc_mode ; in OC mode? | |
3199 bra check_ppO2_1 ; YES - continue with breathed gas | 3565 bra check_ppO2_1 ; YES - continue with breathed gas |
3200 btfsc bailout_mode ; NO - in bailout? | 3566 btfsc bailout_mode ; NO - in bailout? |
3201 bra check_ppO2_1 ; YES - continue with breathed gas | 3567 bra check_ppO2_1 ; YES - continue with breathed gas |
3202 ; CCR / pSCR mode - checks on pure diluent | 3568 ; CCR / pSCR mode - check the pure diluent |
3569 bcf warn_det_ppO2_diluent ; clear warning for pure diluent ppO2 | |
3570 bcf attn_det_ppo2_diluent ; clear attention for pure diluent ppO2 | |
3203 MOVII int_O_pure_ppO2,mpr ; get value and attention/warning flags for the pure diluent | 3571 MOVII int_O_pure_ppO2,mpr ; get value and attention/warning flags for the pure diluent |
3204 btfsc hi,int_warning_flag ; is there a ppO2 low or high warning on the pure diluent? | 3572 btfsc hi,int_warning_flag ; ppO2 of the pure diluent in warning state? |
3205 rcall check_ppO2_dw ; YES - show warning and return on next line | 3573 bra check_ppO2_dil_warn ; YES - show warning |
3206 btfsc hi,int_attention_flag ; ppO2 of the pure diluent in attention state? | 3574 btfsc hi,int_attention_flag ; ppO2 of the pure diluent in attention state? |
3207 rcall check_ppO2_da ; YES - show attention and return on next line | 3575 bra check_ppO2_dil_attn ; YES - show attention |
3208 ENDIF | 3576 bra check_ppO2_1 ; continue with checking breathed gas |
3209 ; all modes - checks on breathed gas (OC or from loop) | 3577 |
3578 check_ppO2_dil_warn: | |
3579 bsf warn_det_ppO2_diluent ; set warning for pure diluent ppO2 | |
3580 rcall check_ppO2_show_mesg ; show ppO2 message | |
3581 bra check_ppO2_1 ; continue with checking breathed gas | |
3582 | |
3583 check_ppO2_dil_attn: | |
3584 bsf attn_det_ppo2_diluent ; set attention for pure diluent ppO2 | |
3585 rcall check_ppO2_show_mesg ; show ppO2 message | |
3586 ;bra check_ppO2_1 ; continue with checking breathed gas | |
3587 ENDIF ; _ccr_pscr | |
3588 | |
3210 check_ppO2_1: | 3589 check_ppO2_1: |
3590 ; all modes - check breathed gas (OC or loop) | |
3591 bcf attn_det_ppo2_breathed ; clear attention for breathed ppO2 | |
3592 bcf warn_det_ppO2_breathed ; clear warning for breathed ppO2 | |
3211 MOVII int_O_breathed_ppO2,mpr ; get value and attention/warning flags for the breathed gas | 3593 MOVII int_O_breathed_ppO2,mpr ; get value and attention/warning flags for the breathed gas |
3212 btfsc hi,int_attention_flag ; breathed ppO2 in attention state (when in loop mode, no attention will be generated)? | 3594 btfsc hi,int_attention_flag ; breathed ppO2 in attention state (when in loop mode, no attention will be generated)? |
3213 bra check_ppo2_display_a ; YES - set attention flag and show ppO2 | 3595 bra check_ppO2_breath_attn ; YES - set attention flag and show ppO2 |
3214 btfsc hi,int_low_flag ; breathed ppO2 too low? | 3596 btfsc hi,int_low_flag ; NO - breathed ppO2 too low? |
3215 bra check_ppO2_low ; YES - record the warning and show ppO2 | 3597 bra check_ppO2_breath_warn_low ; YES - record the warning and show ppO2 |
3216 btfsc hi,int_high_flag ; breathed ppO2 too high? | 3598 btfsc hi,int_high_flag ; NO - breathed ppO2 too high? |
3217 bra check_ppO2_high ; YES - record the warning and show ppO2 | 3599 bra check_ppO2_breath_warn_high ; YES - record the warning and show ppO2 |
3218 TSTOSS opt_showppo2 ; show ppO2 anyhow? (0 = no, 1 = show always) | 3600 bra check_ppO2_breath_ok ; NO - ppO2 is ok |
3219 return ; NO - no warnings, no show - done | 3601 |
3220 bra check_ppO2_common_2 ; YES - but only when in OC or bailout... | 3602 check_ppO2_breath_attn: |
3221 check_ppO2_low: | 3603 bsf attn_det_ppo2_breathed ; set attention for breathed ppO2 |
3604 bra check_ppO2_show ; show ppO2 message | |
3605 | |
3606 check_ppO2_breath_warn_low: | |
3222 movlw d'4' ; set type of alarm (ppO2 low) | 3607 movlw d'4' ; set type of alarm (ppO2 low) |
3223 bra check_ppO2_common ; continue with common part | 3608 bra check_ppO2_breath_common ; continue with common part |
3224 check_ppO2_high: | 3609 |
3610 check_ppO2_breath_warn_high: | |
3225 movlw d'5' ; set type of alarm (ppO2 high) | 3611 movlw d'5' ; set type of alarm (ppO2 high) |
3226 check_ppO2_common: | 3612 ;bra check_ppO2_breath_common ; continue with common part |
3613 | |
3614 check_ppO2_breath_common: | |
3227 movwf alarm_type ; copy alarm type to alarm register | 3615 movwf alarm_type ; copy alarm type to alarm register |
3228 bsf event_occured ; set event flag | 3616 bsf event_occured ; set event flag |
3229 bsf message_warning ; show warning sign for breathed ppO2 | 3617 bsf warn_det_ppO2_breathed ; set warning for breathed ppO2 |
3230 check_ppO2_common_2: | 3618 bra check_ppO2_show ; show ppO2 message |
3231 btfsc FLAG_oc_mode ; are we in OC mode? | 3619 |
3232 bra check_ppo2_display ; YES - show | 3620 check_ppO2_breath_ok: |
3621 TSTOSS opt_showppo2 ; shall always show ppO2 (0 = no, 1 = yes) | |
3622 return ; NO - done | |
3623 ;bra check_ppO2_show ; YES - show ppO2 message | |
3624 | |
3625 check_ppO2_show: | |
3233 IFDEF _ccr_pscr | 3626 IFDEF _ccr_pscr |
3234 btfsc bailout_mode ; are we in bailout mode? | 3627 btfsc FLAG_oc_mode ; in OC mode? |
3235 bra check_ppo2_display ; YES - show | 3628 bra check_ppO2_show_1 ; YES - show ppO2 message |
3236 ENDIF | 3629 btfsc bailout_mode ; in bailout mode? |
3630 bra check_ppO2_show_1 ; YES - show ppO2 message | |
3237 return ; NO - in loop mode, ppO2 is already shown via setpoint display | 3631 return ; NO - in loop mode, ppO2 is already shown via setpoint display |
3238 check_ppo2_display_a: | 3632 ENDIF |
3239 bsf message_attention ; show attention sign for breathed ppO2 | 3633 check_ppO2_show_1: |
3240 check_ppo2_display: | 3634 movf active_customview,W ; get current custom view |
3241 movlw index_ppo2_ead_end_cns ; index of custom view ppO2, EAD/END and CNS (without He) or gas density (with He) | 3635 xorlw index_ppo2_ead_end_cns ; ppO2 shown already via custom view? |
3242 cpfseq active_customview ; ppO2 shown? | 3636 bz check_ppO2_done ; YES - done |
3243 bra check_ppO2_b ; NO | 3637 movf active_customview,W ; get current custom view (again) |
3244 return ; YES - do not show twice (in custom view and in warning area) | 3638 xorlw index_pscr_info ; ppO2 shown already via custom view? |
3245 check_ppO2_b: | 3639 bz check_ppO2_done ; YES - done |
3246 movlw index_pscr_info ; index of custom view with pSCR data | 3640 ;bra check_ppO2_show_mesg ; NO - show ppO2 message |
3247 cpfseq active_customview ; ppO2 shown? | 3641 |
3248 bra check_ppO2_d ; NO - show ppO2 | 3642 check_ppO2_show_mesg: |
3249 return ; YES - do not show twice (in custom view and in warning area) | 3643 incf message_counter,F ; increase message counter |
3250 check_ppO2_dw: | 3644 goto TFT_message_ppo2 ; show ppO2 message and return |
3251 bsf message_warning ; show warning sign for diluent ppO2 | 3645 |
3252 check_ppO2_da: | 3646 check_ppO2_done: |
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) | 3647 return ; done |
3254 check_ppO2_d: | 3648 |
3255 incf message_counter,F ; increase counter | 3649 |
3256 goto TFT_show_ppo2_warning ; show warning message for breathed gas or diluent ppO2 and return | 3650 ;----------------------------------------------------------------------------- |
3257 | 3651 ; Show fTTS Message |
3258 | 3652 ; |
3259 check_display_ftts: | 3653 check_display_ftts: |
3260 IFDEF _ccr_pscr | 3654 IFDEF _ccr_pscr |
3261 btfsc bailout_mode ; in bailout mode? | 3655 btfsc bailout_mode ; in bailout mode? |
3262 return ; YES - in bailout no fTTS is computed, done | 3656 return ; YES - in bailout no fTTS is computed, done |
3263 ENDIF | 3657 ENDIF |
3264 btfss count_divetime ; is dive time counted? | 3658 btfss count_divetime ; is dive time counted? |
3265 return ; NO - omit, done | 3659 return ; NO - omit, done |
3266 movff char_I_extra_time,lo ; YES - get extra time | 3660 movff char_I_extra_time,lo ; YES - get extra time |
3267 tstfsz lo ; - extra time > 0 ? | 3661 tstfsz lo ; - extra time > 0 ? |
3268 bra check_display_ftts_1 ; YES - continue checking bailout condition | 3662 bra check_display_ftts_mesg ; YES - show fTTS |
3269 return ; NO - no fTTS computed, done | 3663 return ; NO - no fTTS computed, done |
3270 check_display_ftts_1: | 3664 |
3665 check_display_ftts_mesg: | |
3271 incf message_counter,F ; increase counter | 3666 incf message_counter,F ; increase counter |
3272 goto TFT_show_ftts ; show @+x time | 3667 goto TFT_message_ftts ; show @+x time |
3273 | 3668 |
3274 | 3669 |
3275 global check_cns_violation | 3670 ;----------------------------------------------------------------------------- |
3276 check_cns_violation: | 3671 ; check current CNS Value |
3277 ; Check if CNS should be displayed | 3672 ; |
3673 global check_cns_violation_now | |
3674 check_cns_violation_now: | |
3675 bcf warn_det_cns_current ; clear warning for CNS | |
3676 bcf attn_det_cns_current ; clear attention for CNS | |
3278 movff int_O_CNS_current+1,WREG ; get current CNS, high byte | 3677 movff int_O_CNS_current+1,WREG ; get current CNS, high byte |
3279 btfsc WREG,int_warning_flag ; warning flag set? | 3678 btfsc WREG,int_warning_flag ; warning flag set? |
3280 bra check_cns_violation_1 ; YES - issue warning | 3679 bra check_cns_violation_now_warn; YES - show a warning |
3281 btfsc WREG,int_attention_flag ; NO - attention flag set? | 3680 btfsc WREG,int_attention_flag ; attention flag set? |
3282 bra check_cns_violation_2 ; YES - issue attention | 3681 bra check_cns_violation_now_attn; YES - show an attention |
3283 return ; NO - done | 3682 return ; NO - done |
3284 check_cns_violation_1: | 3683 |
3285 bsf message_warning ; show warning sign for CNS | 3684 check_cns_violation_now_warn: |
3286 check_cns_violation_2: | 3685 bsf warn_det_cns_current ; set warning for CNS |
3287 bsf message_attention ; show attention sign for CNS | 3686 bra check_cns_violation_now_mesg; show message |
3687 | |
3688 check_cns_violation_now_attn: | |
3689 bsf attn_det_cns_current ; set attention for CNS | |
3690 ;bra check_cns_violation_now_mesg; show message | |
3691 | |
3692 check_cns_violation_now_mesg: | |
3288 IFNDEF _helium | 3693 IFNDEF _helium |
3289 movlw index_ppo2_ead_end_cns ; index of custom view ppO2, EAD/END and CNS (without He) or gas density (with He) | 3694 movf active_customview,W ; get current custom view |
3290 cpfseq active_customview ; CNS shown? | 3695 xorlw index_ppo2_ead_end_cns ; CNS shown? |
3291 bra check_cns_violation_3 ; NO | 3696 bz check_cns_violation_now_done; YES - done |
3292 return ; YES - do not show twice (in custom view and in warning area) | 3697 ENDIF |
3293 ENDIF | 3698 movf active_customview,W ; get current custom view (again) |
3294 check_cns_violation_3: | 3699 xorlw index_CNS ; CNS shown? |
3295 movlw index_CNS ; index of custom view with CNS values | 3700 bz check_cns_violation_now_done; YES - done |
3296 cpfseq active_customview ; CNS shown? | 3701 incf message_counter,F ; NO - increase counter |
3297 bra check_cns_violation_4 ; NO | 3702 goto TFT_message_cns ; - show message and return |
3298 return ; YES - do not show twice (in custom view and in warning area) | 3703 |
3299 check_cns_violation_4: | 3704 check_cns_violation_now_done: |
3300 incf message_counter,F ; increase counter | 3705 return ; done |
3301 goto TFT_show_cns ; show attention/warning message for CNS and return | 3706 |
3302 | 3707 |
3303 | 3708 ;----------------------------------------------------------------------------- |
3304 global check_eod_cns_violation ; check end-of-dive CNS values | 3709 ; check end-of-Dive CNS Value |
3305 check_eod_cns_violation: | 3710 ; |
3306 movff int_O_CNS_current+1,WREG ; get current CNS, high byte | 3711 global check_cns_violation_eod |
3307 btfsc WREG,int_warning_flag ; current CNS value in warning state? | 3712 check_cns_violation_eod: |
3308 return ; YES - inhibit end-of-dive warning if current CNS is already in warning | 3713 bcf attn_det_cns_eod ; clear attention for end-of-dive CNS |
3714 btfsc warn_det_cns_current ; current CNS value in warning state? | |
3715 return ; YES - inhibit end-of-dive CNS checks if current CNS is already in warning | |
3716 ;bra check_cns_violation_eod_norm; NO - check normal plan | |
3717 | |
3718 check_cns_violation_eod_norm: | |
3309 movff int_O_CNS_norm+1,WREG ; get CNS at end of dive in normal plan, high byte | 3719 movff int_O_CNS_norm+1,WREG ; get CNS at end of dive in normal plan, high byte |
3310 btfsc WREG,int_invalid_flag ; flag for invalid value set? | 3720 btfsc WREG,int_invalid_flag ; flag for invalid value set? |
3311 bra check_eod_cns_violation1 ; YES - continue with checking the other CNS value | 3721 bra check_cns_violation_eod_alt ; YES - continue with checking alternative plan |
3312 btfsc WREG,int_warning_flag ; NO - flag for warning set? | 3722 btfsc WREG,int_warning_flag ; NO - flag for warning set? |
3313 bra check_eod_cns_violation2 ; YES - issue warning | 3723 bra check_cns_violation_eod_warn; YES - show message |
3314 check_eod_cns_violation1: ; NO - continue with checking the other CNS value | 3724 ;bra check_cns_violation_eod_alt ; NO - check alternative plan |
3725 | |
3726 check_cns_violation_eod_alt: | |
3315 movff int_O_CNS_alt+1,WREG ; get CNS at end of dive in alternative plan, high byte | 3727 movff int_O_CNS_alt+1,WREG ; get CNS at end of dive in alternative plan, high byte |
3316 btfsc WREG,int_invalid_flag ; flag for invalid value set? | 3728 btfsc WREG,int_invalid_flag ; flag for invalid value set? |
3317 return ; YES - done with CNS checking | 3729 return ; YES - done |
3318 btfsc WREG,int_warning_flag ; NO - flag for warning set? | 3730 btfsc WREG,int_warning_flag ; NO - flag for warning set? |
3319 bra check_eod_cns_violation2 ; YES - issue warning | 3731 bra check_cns_violation_eod_warn; YES - show message |
3320 return ; NO - done with CNS checking | 3732 return ; NO - done |
3321 check_eod_cns_violation2: ; issue warning (actually only on attention level) | 3733 |
3322 bsf message_attention ; show attention sign for end-of-dive CNS | 3734 check_cns_violation_eod_warn: |
3323 movlw index_CNS ; index of custom view with CNS values | 3735 bsf attn_det_cns_eod ; set attention(!) for end-of-dive CNS |
3324 cpfseq active_customview ; CNS values shown? | 3736 movf active_customview,W ; get current custom view |
3325 bra display_eod_cns_violation ; NO - issue textual warning | 3737 xorlw index_CNS ; CNS shown? |
3326 return ; YES - do not show twice (in custom view and in warning area) | 3738 bz check_cns_violation_eod_done; YES - done |
3327 display_eod_cns_violation: | 3739 incf message_counter,F ; NO - increase message counter |
3328 incf message_counter,F ; increase counter | 3740 goto TFT_message_cns_eod ; - show message for end-of-dive CNS and return |
3329 goto TFT_warning_eod_cns ; show warning message for end-of-dive CNS and return | 3741 |
3330 | 3742 check_cns_violation_eod_done: |
3331 | 3743 return ; done |
3332 global check_and_store_sat_violation | 3744 |
3333 check_and_store_sat_violation: | 3745 |
3334 movff int_O_lead_supersat+1,WREG ; get upper byte of leading tissue's supersaturation | 3746 ;----------------------------------------------------------------------------- |
3335 btfss WREG,int_warning_flag ; check if the warning flag is set | 3747 ; Check current Tissue Supersaturation |
3336 bra check_and_store_sat_violation2 ; NO - continue with checking for attention flag | 3748 ; |
3337 movlw d'2' ; YES - set type of alarm | 3749 global check_saturation |
3338 movwf alarm_type ; - copy to alarm register | 3750 check_saturation: |
3339 bsf event_occured ; - set event flag | 3751 bcf attn_det_saturation ; clear attention for saturation |
3340 bsf message_warning ; - show warning sign for saturation | 3752 bcf warn_det_saturation ; clear warning for saturation |
3341 bra check_and_store_sat_violation3 ; - show saturation | 3753 bcf attn_det_ibcd ; clear attention for IBCD |
3342 check_and_store_sat_violation2: | 3754 movff int_O_lead_supersat+1,WREG ; get upper byte of leading tissue's supersaturation |
3343 btfsc WREG,int_attention_flag ; check if the attention flag is set | 3755 btfss WREG,int_warning_flag ; warning flag set? |
3344 bra check_and_store_sat_violation3 ; YES - show saturation | 3756 bra check_saturation_1 ; NO - continue with checking for attention flag |
3345 TSTOSS opt_enable_IBCD ; NO - IBCD warning activated? | 3757 movlw d'2' ; YES - set type of alarm |
3346 bra check_and_store_sat_violation4 ; NO - continue checking of deco info | 3758 movwf alarm_type ; - copy to alarm register |
3347 movff char_O_deco_warnings,WREG ; YES - get the deco warnings vector | 3759 bsf event_occured ; - set event flag |
3348 btfss WREG,IBCD_warning ; - is the IBCD warning flag set? | 3760 bsf warn_det_saturation ; - set warning |
3349 bra check_and_store_sat_violation4 ; NO - continue checking for deco info | 3761 bra check_saturation_mesg ; - show saturation message |
3350 check_and_store_sat_violation3: ; YES - show saturation | 3762 |
3351 bsf message_attention ; show attention sign for saturation | 3763 check_saturation_1: |
3352 incf message_counter,F ; increase counter | 3764 btfss WREG,int_attention_flag ; attention flag set? |
3353 goto TFT_warning_saturation ; show attention/warning message for saturation and return | 3765 bra check_saturation_2 ; NO - continue with checking for IBCD |
3354 check_and_store_sat_violation4: ; check for deco info | 3766 bsf attn_det_saturation ; YES - set attention |
3355 btfss divemode ; in dive mode? | 3767 bra check_saturation_mesg ; - show saturation message |
3356 return ; NO - done, return | 3768 |
3769 check_saturation_2: | |
3770 IFDEF _helium | |
3771 TSTOSS opt_enable_IBCD ; IBCD warning activated? | |
3772 bra check_saturation_3 ; NO - continue with checking deco info | |
3773 movff char_O_deco_warnings,WREG ; YES - get the deco warnings vector | |
3774 btfss WREG,IBCD_warning ; - IBCD warning flag set? | |
3775 bra check_saturation_3 ; NO - continue with checking deco info | |
3776 bsf attn_det_ibcd ; YES - set attention | |
3777 bra check_saturation_mesg ; - show saturation message | |
3778 ENDIF | |
3779 | |
3780 check_saturation_3: | |
3781 btfss divemode ; in dive mode? | |
3782 return ; NO - done | |
3357 IFDEF _ccr_pscr | 3783 IFDEF _ccr_pscr |
3358 btfsc bailout_mode ; YES - in bailout mode? | 3784 btfsc bailout_mode ; YES - in bailout mode? |
3359 return ; YES - done, return (deco zone flag is not updated when in bailout mode) | 3785 return ; YES - done (deco zone flag is not updated when in bailout mode) |
3360 ENDIF | 3786 ENDIF |
3361 movff char_O_deco_info,WREG ; NO - get the deco info vector | 3787 movff char_O_deco_info,WREG ; NO - get the deco info vector |
3362 btfss WREG,deco_zone ; check if the deco zone flag is set | 3788 btfss WREG,deco_zone ; deco zone flag set? |
3363 return ; NO - done, return | 3789 return ; NO - done |
3364 btfsc use_aGF ; YES - using alternative GF factors? | 3790 btfsc use_aGF ; YES - using alternative GF factors? |
3365 return ; YES - suppress deco zone info | 3791 return ; YES - suppress deco zone info |
3366 btfsc alt_layout_active ; NO - in alternative layout? | 3792 btfsc alt_layout_active ; NO - in alternative layout? |
3367 return ; YES - suppress deco zone info | 3793 return ; YES - suppress deco zone info |
3368 incf message_counter,F ; NO - increase counter | 3794 incf message_counter,F ; NO - increase message counter |
3369 goto TFT_info_deco ; - show deco info | 3795 goto TFT_message_deco_info ; - show deco info and return |
3370 | 3796 |
3371 | 3797 check_saturation_mesg: |
3798 IFDEF _helium | |
3799 btfss attn_det_ibcd ; IBCD detected? | |
3800 bra check_saturation_mesg_1 ; NO - show saturation message | |
3801 incf message_counter,F ; YES - increase message counter | |
3802 call TFT_message_IBCD ; - show IBCD message | |
3803 ENDIF | |
3804 check_saturation_mesg_1: | |
3805 incf message_counter,F ; increase message counter | |
3806 goto TFT_message_saturation ; show saturation message and return | |
3807 | |
3808 | |
3809 ;----------------------------------------------------------------------------- | |
3810 ; Check Depth Limit | |
3811 ; | |
3372 check_depth_limit: | 3812 check_depth_limit: |
3373 bcf depth_limit_exceeded ; clear warning flag by default | 3813 bcf warn_det_depth_limit ; clear warning by default |
3374 movff opt_max_depth,WREG ; get depth limit | 3814 movff opt_max_depth,WREG ; get depth limit |
3375 cpfsgt depth_meter ; current depth > depth limit? | 3815 cpfsgt depth_meter ; current depth > depth limit? |
3376 return ; NO | 3816 return ; NO - done |
3377 bsf depth_limit_exceeded ; YES - set flag for depth limit exceeded | 3817 bsf warn_det_depth_limit ; YES - set warning |
3378 incf message_counter,F ; - increase counter | 3818 incf message_counter,F ; - increase message counter |
3379 bsf message_warning ; - show warning sign for depth | 3819 goto TFT_message_depth_limit ; - show message |
3380 goto TFT_warning_depth ; - show warning message for depth | 3820 |
3381 | 3821 |
3382 | 3822 ;----------------------------------------------------------------------------- |
3823 ; Check Bühlmann Model Violation | |
3824 ; | |
3383 check_outside: | 3825 check_outside: |
3826 bcf warn_det_outside ; clear warning | |
3827 bcf attn_det_outside ; clear attention | |
3384 movff char_O_deco_warnings,WREG ; bank-safe copy of deco warnings | 3828 movff char_O_deco_warnings,WREG ; bank-safe copy of deco warnings |
3385 btfss WREG,outside_warning_lock ; are we outside of the ZH-L16 model? | 3829 btfss WREG,outside_warning ; currently outside the ZH-L16 model? |
3830 bra check_outside_1 ; NO | |
3831 bsf warn_det_outside ; YES - set warning | |
3832 bra check_outside_mesg ; - show message | |
3833 | |
3834 check_outside_1: | |
3835 btfss WREG,outside_warning_lock ; had been outside of the ZH-L16 model? | |
3386 return ; NO - done | 3836 return ; NO - done |
3387 incf message_counter,F ; YES - increase counter | 3837 bsf attn_det_outside ; YES - set attention |
3388 bsf message_attention ; - show attention sign for outside | 3838 ;bra check_outside_mesg ; - show message |
3389 btfsc WREG,outside_warning ; - are we outside the ZH-L16 model right now (-> warning)? | 3839 |
3390 bsf message_warning ; - show warning sign for outside | 3840 check_outside_mesg: |
3391 goto TFT_warning_outside ; - show warning/attention message for outside and return | 3841 incf message_counter,F ; increase message counter |
3392 | 3842 goto TFT_message_outside ; show message and return |
3393 | 3843 |
3844 | |
3845 ;----------------------------------------------------------------------------- | |
3846 ; Check raised Probability for Micro-Bubbles | |
3847 ; | |
3394 global check_mbubbles | 3848 global check_mbubbles |
3395 check_mbubbles: | 3849 check_mbubbles: |
3850 bcf warn_det_microbubble ; clear warning | |
3851 bcf attn_det_microbubble ; clear attention | |
3396 movff char_O_deco_warnings,WREG ; bank-safe copy for deco warnings | 3852 movff char_O_deco_warnings,WREG ; bank-safe copy for deco warnings |
3397 btfsc WREG,mbubble_warning ; are we in micro bubbling zone right now? | 3853 btfss WREG,mbubble_warning ; currently in micro bubbling zone? |
3398 bra check_mbubbles_warn ; YES | 3854 bra check_mbubbles_1 ; NO |
3399 btfss WREG,mbubble_warning_lock ; were we in micro bubbling zone? | 3855 bsf warn_det_microbubble ; YES - set warning |
3856 bra check_mbubbles_mesg ; - show message | |
3857 | |
3858 check_mbubbles_1 | |
3859 btfss WREG,mbubble_warning_lock ; had been in micro bubbling zone? | |
3400 return ; NO - done | 3860 return ; NO - done |
3401 check_mbubble_att ; YES - attention level | 3861 bsf attn_det_microbubble ; YES - set attention |
3402 incf message_counter,F ; increase counter | 3862 ;bra check_mbubbles_mesg ; - show message |
3403 bsf message_attention ; show attention sign for micro bubbles | 3863 |
3404 goto TFT_warning_mbubbles ; show micro bubble attention (and return) - TFT_warning_mbubbles switches by itself between attention and warning | 3864 check_mbubbles_mesg: |
3405 check_mbubbles_warn: ; locked micro bubbles - warning level if at issue, attention level if locked | 3865 incf message_counter,F ; increase message counter |
3406 incf message_counter,F ; increase counter | 3866 goto TFT_message_mbubbles ; show message and return |
3407 bsf message_warning ; show warning sign for micro bubbles | 3867 |
3408 goto TFT_warning_mbubbles ; show warning message for micro bubbles (and return) | 3868 |
3869 IFDEF _ccr_pscr | |
3870 ;----------------------------------------------------------------------------- | |
3871 ; Check Gas Density | |
3872 ; | |
3873 check_gas_density: | |
3874 TSTOSS opt_gas_density_check ; shall check gas density? | |
3875 return ; NO - done | |
3876 bcf warn_det_gas_density ; YES - clear attention for gas density by default | |
3877 bcf attn_det_gas_density ; - clear warning for gas density by default | |
3878 movff int_O_gas_density+1,WREG ; - get upper byte of current gas density | |
3879 btfsc WREG,int_warning_flag ; - warning flag set? | |
3880 bra check_gas_density_warn ; YES - generate a warning | |
3881 btfsc WREG,int_attention_flag ; NO - attention flag set? | |
3882 bra check_gas_density_attn ; YES - generate an attention | |
3883 ;bra check_gas_density_ok ; NO - gas density ok | |
3884 | |
3885 check_gas_density_ok: | |
3886 bcf shown_gas_density_attn ; re-arm custom view show-up for warning | |
3887 bcf shown_gas_density_warn ; re-arm custom view show-up for attention | |
3888 return ; done | |
3889 | |
3890 check_gas_density_warn: | |
3891 bsf warn_det_gas_density ; set warning | |
3892 bcf shown_gas_density_attn ; re-arm custom view show-up for attention | |
3893 btfsc shown_gas_density_warn ; has the custom view been shown before on warning level? | |
3894 bra check_gas_density_mesg ; YES - do not show the gas needs custom view again | |
3895 btfsc custom_view_locked ; NO - custom view locked? | |
3896 bra check_gas_density_mesg ; YES - do not show it now | |
3897 bsf shown_gas_density_warn ; NO - set custom view as shown now | |
3898 bra check_gas_density_cv ; - show gas needs custom view | |
3899 | |
3900 check_gas_density_attn: | |
3901 bsf attn_det_gas_density ; set attention | |
3902 bcf shown_gas_density_warn ; re-arm custom view show-up for warning | |
3903 btfsc shown_gas_density_attn ; has the custom view been shown before on attention level? | |
3904 bra check_gas_density_mesg ; YES - do not show the gas needs custom view again | |
3905 btfsc custom_view_locked ; NO - custom view locked? | |
3906 bra check_gas_density_mesg ; YES - do not show it now | |
3907 bsf shown_gas_density_attn ; NO - set custom view as shown now | |
3908 ;bra check_gas_density_cv ; - show gas needs custom view | |
3909 | |
3910 check_gas_density_cv: | |
3911 movlw index_ppo2_ead_end_cns ; get custom view number of gas density | |
3912 call dive_customview_show ; show custom view | |
3913 ;bra check_gas_density_mesg ; show message | |
3914 | |
3915 check_gas_density_mesg: | |
3916 incf message_counter,F ; increase message counter | |
3917 goto TFT_message_gas_density ; show gas density message and return | |
3918 | |
3919 | |
3920 ;----------------------------------------------------------------------------- | |
3921 ; Check if an OC Bailout Gas is available | |
3922 ; | |
3923 check_OC_gas_avail: | |
3924 bcf warn_det_no_bo_gas ; clear warning by default | |
3925 tstfsz best_gas_number ; is a breathable OC (bailout) gas available? | |
3926 return ; YES - a breathable gas is available, done | |
3927 btfsc bailout_mode ; NO - in bailout? | |
3928 return ; YES - suppress warning, done | |
3929 bsf warn_det_no_bo_gas ; NO - set warning for no bailout gas | |
3930 incf message_counter,F ; - increase message counter | |
3931 goto TFT_message_no_BO_gas ; - show message and return | |
3932 | |
3933 ENDIF ; _ccr_pscr | |
3409 | 3934 |
3410 | 3935 |
3411 IFDEF _cave_mode | 3936 IFDEF _cave_mode |
3412 | 3937 |
3938 ;----------------------------------------------------------------------------- | |
3939 ; Check Cave Profile Storage Usage | |
3940 ; | |
3413 check_cavemode: | 3941 check_cavemode: |
3942 bcf warn_det_cave_shut_down ; clear warning by default | |
3943 bcf attn_det_cave_shut_down ; clear attention by default | |
3414 btfsc backtrack_entire_full ; is the backtracking storage entirely used up? | 3944 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 | 3945 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? | 3946 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 | 3947 bra check_cavemode_almost_full ; YES - show attention message that cave mode will stop soon |
3418 btfss alt_layout_active ; NO - alternative layout active? | 3948 btfss cave_mode ; NO - cave mode switched on? |
3419 bra check_cavemode_info ; NO - show cave mode active info | 3949 return ; NO - do not show info |
3420 return ; YES - suppress info message | 3950 btfsc alt_layout_active ; YES - alternative layout active? |
3951 return ; YES - suppress info message | |
3952 ;bra check_cavemode_mesg ; NO - show cave mode active info | |
3953 | |
3954 check_cavemode_mesg: | |
3955 incf message_counter,F ; increase message counter | |
3956 goto TFT_message_cave_mode ; show cave mode message | |
3421 | 3957 |
3422 check_cavemode_full: | 3958 check_cavemode_full: |
3423 btfss backtrack_shutdown ; backtracking shut down already? | 3959 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 | 3960 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) | 3961 bsf backtrack_shutdown ; remember shut down as been executed (anyhow) |
3426 incf message_counter,F ; increase counter | 3962 btfss cave_mode ; has the cave mode been switched on again meanwhile? |
3963 bsf warn_det_cave_shut_down ; NO - set warning level | |
3427 btfsc cave_mode ; has the cave mode been switched on again meanwhile? | 3964 btfsc cave_mode ; has the cave mode been switched on again meanwhile? |
3428 goto TFT_cave_shutdown_attention ; YES - show attention message for cave mode shutdown ands return | 3965 bsf attn_det_cave_shut_down ; YES - set attention level |
3429 bsf message_warning ; NO - show warning sign for cave mode shutdown | 3966 bra check_cavemode_mesg ; show message |
3430 goto TFT_cave_shutdown_warning ; - show warning message for cave mode shutdown and return | |
3431 | 3967 |
3432 check_cavemode_almost_full: | 3968 check_cavemode_almost_full: |
3433 btfss cave_mode ; cave mode switched on? | 3969 btfss cave_mode ; cave mode switched on? |
3434 return ; NO - suppress message | 3970 return ; NO - suppress message |
3435 incf message_counter,F ; YES - increase counter | 3971 bsf attn_det_cave_shut_down ; YES - set an attention |
3436 goto TFT_cave_shutdown_attention ; - show attention message that cave mode will shut down soon | 3972 bra check_cavemode_mesg ; - show message |
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 | 3973 |
3444 ENDIF ; _cave_mode | 3974 ENDIF ; _cave_mode |
3445 | 3975 |
3446 | 3976 |
3447 warn_agf: | 3977 ;----------------------------------------------------------------------------- |
3448 incf message_counter,F ; increase counter | 3978 ; Show aGF Reminder |
3449 goto TFT_warning_agf ; show aGF reminder (and return) | 3979 ; |
3450 | 3980 remind_agf_in_use: |
3451 warn_fallback: | 3981 incf message_counter,F ; increase message counter |
3452 incf message_counter,F ; increase counter | 3982 goto TFT_message_agf ; show aGF reminder and return |
3453 bsf message_warning ; show warning sign for fallback | 3983 |
3454 goto TFT_warning_fallback ; show warning message for fallback and return | 3984 |
3455 | 3985 ;----------------------------------------------------------------------------- |
3456 ;============================================================================= | 3986 ; Check better Gas / Diluent Advice |
3987 ; | |
3988 check_gas_change: | |
3989 bcf advc_det_change_gas ; clear advice by default | |
3990 IFDEF _ccr_pscr | |
3991 btfsc better_dil_available ; is a better diluent available? | |
3992 bra check_gas_change_mesg ; YES - show a gas change advice | |
3993 ENDIF | |
3994 btfsc better_gas_available ; is a better gas available? | |
3995 bra check_gas_change_mesg ; YES - show a gas change advice | |
3996 return ; NO - done | |
3997 | |
3998 check_gas_change_mesg: | |
3999 bsf advc_det_change_gas ; set advice | |
4000 incf message_counter,F ; increase message counter | |
4001 goto TFT_message_gas_change ; show advice and return | |
4002 | |
3457 | 4003 |
3458 IFDEF _rx_functions | 4004 IFDEF _rx_functions |
3459 | 4005 |
4006 ;----------------------------------------------------------------------------- | |
4007 ; Check SAC and Swap-Tank Advice | |
4008 ; | |
3460 check_tr_messages: | 4009 check_tr_messages: |
4010 bcf attn_det_sac_rate ; clear SAC attention by default | |
4011 bcf advc_det_switch_tank ; clear switch advice by default | |
3461 btfss count_divetime ; is the dive time counted, i.e. deeper than dive threshold? | 4012 btfss count_divetime ; is the dive time counted, i.e. deeper than dive threshold? |
3462 return ; NO - suppress messages | 4013 return ; NO - suppress check |
3463 movff int_O_SAC_measured+1,WREG ; YES - bank-safe copy of measured SAC rate | 4014 movff int_O_SAC_measured+1,WREG ; YES - bank-safe copy of measured SAC rate |
3464 btfss WREG,int_attention_flag ; - attention flag set? | 4015 btfss WREG,int_attention_flag ; - attention flag set? |
3465 bra check_tr_messages2 ; NO - skip | 4016 bra check_tr_messages_chk_swap ; NO - continue with checking for swap advice |
3466 btfsc WREG,int_not_avail_flag ; SAC rate available? | 4017 btfsc WREG,int_not_avail_flag ; SAC rate available? |
3467 bra check_tr_messages2 ; NO - continue with swap advice | 4018 bra check_tr_messages_chk_swap ; NO - continue with checking for swap advice |
3468 bsf message_attention ; YES - show attention sign for SAC rate | 4019 bsf attn_det_sac_rate ; YES - set attention for SAC rate |
3469 movlw index_pressures_SAC ; - index of custom view with SAC rate | 4020 movf active_customview,W ; - get current custom view |
3470 cpfseq active_customview ; - SAC rate shown right now? | 4021 xorlw index_pressures_SAC ; - SAC rate shown? |
3471 bra check_tr_messages1 ; NO - show attention message | 4022 bz check_tr_messages_chk_swap ; YES - do not show twice, continue with swap advice |
3472 bra check_tr_messages2 ; YES - do not show twice, continue with swap advice | 4023 ;bra check_tr_messages_mesg_sac ; NO - show SAC message |
3473 check_tr_messages1: | 4024 |
3474 incf message_counter,F ; increase counter | 4025 check_tr_messages_mesg_sac: |
3475 call TFT_attention_sac ; show attention message for SAC rate | 4026 incf message_counter,F ; increase message counter |
3476 check_tr_messages2: | 4027 call TFT_message_sac ; show message for SAC rate |
4028 ;bra check_tr_messages_chk_swap ; continue with switch advice | |
4029 | |
4030 check_tr_messages_chk_swap: | |
3477 movff char_O_deco_info,WREG ; bank-safe copy of deco info vector | 4031 movff char_O_deco_info,WREG ; bank-safe copy of deco info vector |
3478 btfss WREG,ind_double_switch ; swap tank flag set? | 4032 btfss WREG,ind_double_switch ; swap tank flag set? |
3479 return ; NO | 4033 return ; NO - done |
3480 incf message_counter,F ; YES - increase counter | 4034 ;bra check_tr_messages_mesg_swap ; YES - show swap message |
3481 bsf message_advice ; - show advice sign for switching tanks | 4035 |
3482 goto TFT_advice_switch ; - show advice message for switching tanks and return | 4036 check_tr_messages_mesg_swap: |
3483 | 4037 bsf advc_det_switch_tank ; set advice |
4038 incf message_counter,F ; increase message counter | |
4039 goto TFT_message_switch_tanks ; show message for switching tanks and return | |
4040 | |
4041 | |
4042 ;----------------------------------------------------------------------------- | |
4043 ; Check Transmitter States | |
4044 ; | |
3484 check_tr_functions: | 4045 check_tr_functions: |
3485 clrf xmitter_flags_mesg ; set all messages as not shown yet | 4046 ; check transmitter 1 |
3486 movlw index_pressures_SAC ; index of custom view pressure readings | |
3487 cpfseq active_customview ; pressure readings shown? | |
3488 bra check_tr_functions_tr1 ; NO - continue with checking transmitter 1 | |
3489 bsf pres_customview_shown ; YES - suppress redraw by faking it has already been redrawn | |
3490 check_tr_functions_tr1: | |
3491 movff char_I_pressure_stat+0,WREG ; get status of 1st pressure reading | 4047 movff char_I_pressure_stat+0,WREG ; get status of 1st pressure reading |
3492 rcall check_tr_functions_helper1 ; check for transmitter 1 lost | 4048 rcall check_tr_functions_helper1 ; check for transmitter 1 lost |
3493 rcall check_tr_functions_helper2 ; check for transmitter 1 low battery | 4049 rcall check_tr_functions_helper2 ; check for transmitter 1 low battery |
3494 movff int_IO_pressure_value+1,WREG ; get high byte of 1st pressure reading | 4050 movff int_IO_pressure_value+1,WREG ; get high byte of 1st pressure reading |
3495 rcall check_tr_functions_helper3 ; check for transmitter 1 pressure warning | 4051 rcall check_tr_functions_helper3 ; check for transmitter 1 pressure warning |
3496 rcall check_tr_functions_helper4 ; check for transmitter 1 pressure attention | 4052 rcall check_tr_functions_helper4 ; check for transmitter 1 pressure attention |
3497 check_tr_functions_tr2: | 4053 ; check transmitter 2 |
3498 movff char_I_pressure_stat+1,WREG ; get status of 2nd pressure reading | 4054 movff char_I_pressure_stat+1,WREG ; get status of 2nd pressure reading |
3499 rcall check_tr_functions_helper5 ; check for transmitter 2 lost | 4055 rcall check_tr_functions_helper5 ; check for transmitter 2 lost |
3500 rcall check_tr_functions_helper6 ; check for transmitter 2 low battery | 4056 rcall check_tr_functions_helper6 ; check for transmitter 2 low battery |
3501 movff int_IO_pressure_value+3,WREG ; get high byte of 2nd pressure reading | 4057 movff int_IO_pressure_value+3,WREG ; get high byte of 2nd pressure reading |
3502 rcall check_tr_functions_helper7 ; check for transmitter 2 pressure warning | 4058 rcall check_tr_functions_helper7 ; check for transmitter 2 pressure warning |
3503 rcall check_tr_functions_helper8 ; check for transmitter 2 pressure attention | 4059 rcall check_tr_functions_helper8 ; check for transmitter 2 pressure attention |
3504 check_tr_functions_show_xmtr: | 4060 |
3505 btfss show_transmitter_attention ; shall show transmitter attention message? | 4061 ; results for transmitter |
3506 bra check_tr_functions_show_warn ; NO - continue with pressure warning | 4062 btfsc attn_det_xmit1_bat ; do we have a transmitter 1 attention? |
3507 bsf message_attention ; YES - show attention sign for transmitter | 4063 bra check_tr_functions_xmitter_mesg ; YES - show transmitter message |
3508 incf message_counter,F ; - increase counter | 4064 btfsc attn_det_xmit2_bat ; do we have a transmitter 2 attention? |
3509 call TFT_attention_transmitter ; - show transmitter attention message | 4065 bra check_tr_functions_xmitter_mesg ; YES - show transmitter message |
3510 check_tr_functions_show_warn: | 4066 check_tr_functions_1: |
3511 btfss show_pres_warning ; shall show pressure warning? | 4067 btfsc warn_det_pressure1 ; do we have a pressure 1 warning? |
3512 bra check_tr_functions_show_att ; NO - continue with pressure attention | 4068 bra check_tr_functions_pres_mesg ; YES - show pressure message |
3513 bsf message_warning ; YES - show warning sign for pressure | 4069 btfsc warn_det_pressure2 ; do we have a pressure 2 warning? |
3514 incf message_counter,F ; - increase counter | 4070 bra check_tr_functions_pres_mesg ; YES - show pressure message |
3515 goto TFT_warning_pres_reading ; - show warning message for pressure reading and return | 4071 btfsc attn_det_pressure1 ; do we have a pressure 1 attention? |
3516 check_tr_functions_show_att: | 4072 bra check_tr_functions_pres_mesg ; YES - show pressure message |
3517 btfss show_pres_attention ; shall show pressure attention? | 4073 btfsc attn_det_pressure2 ; do we have a pressure 2 attention? |
3518 return ; NO - done | 4074 bra check_tr_functions_pres_mesg ; YES - show pressure message |
3519 bsf message_attention ; YES - show attention sign for pressure | 4075 return ; done |
3520 incf message_counter,F ; - increase counter | 4076 |
3521 goto TFT_attention_pres_reading ; - show attention message for pressure reading and return | 4077 check_tr_functions_xmitter_mesg: |
4078 incf message_counter,F ; increase message counter | |
4079 call TFT_message_transmitter ; show transmitter message | |
4080 bra check_tr_functions_1 ; continue with pressure messages | |
4081 | |
4082 check_tr_functions_pres_mesg: | |
4083 incf message_counter,F ; increase message counter | |
4084 goto TFT_message_pressure ; show pressure message and return | |
3522 | 4085 |
3523 check_tr_functions_helper1: | 4086 check_tr_functions_helper1: |
3524 btfsc WREG,char_transmitter_lost ; transmitter 1 lost? | 4087 btfsc WREG,char_transmitter_lost ; transmitter 1 lost? |
3525 bra check_tr_functions_helper1a ; YES - show transmitter attention message | 4088 bra check_tr_functions_helper1a ; YES - show transmitter attention message |
3526 bcf transmitter1_lost ; NO - clear flag for old lost attention | 4089 bcf shown_xmit1_lost ; NO - clear flag for old message |
3527 return ; - done | 4090 return ; - done |
3528 check_tr_functions_helper1a: | 4091 check_tr_functions_helper1a: |
3529 ; bsf show_transmitter_attention ; show transmitter attention | 4092 btfsc shown_xmit1_lost ; is it a new message? |
3530 btfsc transmitter1_lost ; is it a new message? | |
3531 return ; NO - do not show the pressure readings custom view again | 4093 return ; NO - do not show the pressure readings custom view again |
3532 bsf transmitter1_lost ; YES - memorize it's an old message now | 4094 bsf shown_xmit1_lost ; YES - memorize it's an old message now |
3533 bra check_tr_functions_show_cv ; - show custom view | 4095 rcall check_tr_functions_show_cv ; - show custom view |
3534 | 4096 |
3535 check_tr_functions_helper2: | 4097 check_tr_functions_helper2: |
3536 btfsc WREG,char_transmitter_low_bat ; transmitter 1 low battery? | 4098 btfsc WREG,char_transmitter_low_bat ; transmitter 1 low battery? |
3537 bra check_tr_functions_helper2a ; YES - show transmitter attention message | 4099 bra check_tr_functions_helper2a ; YES - show transmitter attention message |
3538 bcf transmitter1_battery ; NO - clear flag for old battery attention | 4100 bcf shown_xmit1_battery ; NO - clear flag for old message |
4101 bcf attn_det_xmit1_bat ; - clear transmitter 1 attention | |
3539 return ; - done | 4102 return ; - done |
3540 check_tr_functions_helper2a: | 4103 check_tr_functions_helper2a: |
3541 bsf show_transmitter_attention ; show transmitter attention | 4104 bsf attn_det_xmit1_bat ; set transmitter 1 attention |
3542 btfsc transmitter1_battery ; is it a new message? | 4105 btfsc shown_xmit1_battery ; is it a new message? |
3543 return ; NO - do not show the pressure readings custom view again | 4106 return ; NO - do not show the pressure readings custom view again |
3544 bsf transmitter1_battery ; YES - memorize it's an old message now | 4107 bsf shown_xmit1_battery ; YES - memorize it's an old message now |
3545 bra check_tr_functions_show_cv ; - show custom view | 4108 rcall check_tr_functions_show_cv ; - show custom view |
3546 | 4109 |
3547 check_tr_functions_helper3: | 4110 check_tr_functions_helper3: |
3548 btfsc WREG,int_warning_flag ; transmitter 1 pressure warning? | 4111 btfsc WREG,int_warning_flag ; transmitter 1 pressure warning? |
3549 bra check_tr_functions_helper3a ; YES - show pressure reading message as warning | 4112 bra check_tr_functions_helper3a ; YES - show pressure reading message as warning |
3550 bcf transmitter1_pres_warn ; NO - clear flag for old warning | 4113 bcf shown_xmit1_pres_warn ; NO - clear flag for old message |
4114 bcf warn_det_pressure1 ; - clear pressure 1 warning | |
3551 return ; - done | 4115 return ; - done |
3552 check_tr_functions_helper3a: | 4116 check_tr_functions_helper3a: |
3553 bsf show_pres_warning ; show pressure warning | 4117 bsf warn_det_pressure1 ; set pressure 1 warning |
3554 btfsc transmitter1_pres_warn ; is it a new message? | 4118 btfsc shown_xmit1_pres_warn ; is it a new message? |
3555 return ; NO - do not show the pressure readings custom view again | 4119 return ; NO - do not show the pressure readings custom view again |
3556 bsf transmitter1_pres_warn ; YES - memorize it's an old message now | 4120 bsf shown_xmit1_pres_warn ; YES - memorize it's an old message now |
3557 bra check_tr_functions_show_cv ; - show custom view | 4121 bra check_tr_functions_show_cv ; - show custom view |
3558 | 4122 |
3559 check_tr_functions_helper4: | 4123 check_tr_functions_helper4: |
3560 btfsc WREG,int_attention_flag ; transmitter 1 pressure attention? | 4124 btfsc WREG,int_attention_flag ; transmitter 1 pressure attention? |
3561 bra check_tr_functions_helper4a ; YES - show pressure reading message as attention | 4125 bra check_tr_functions_helper4a ; YES - show pressure reading message as attention |
3562 bcf transmitter1_pres_att ; NO - clear flag for old attention | 4126 bcf shown_xmit1_pres_attn ; NO - clear flag for old message |
4127 bcf attn_det_pressure1 ; - clear pressure 1 attention | |
3563 return ; - done | 4128 return ; - done |
3564 check_tr_functions_helper4a | 4129 check_tr_functions_helper4a |
3565 bsf show_pres_attention ; show pressure attention | 4130 bsf attn_det_pressure1 ; set pressure 1 attention |
3566 btfsc transmitter1_pres_att ; is it a new message? | 4131 btfsc shown_xmit1_pres_attn ; is it a new message? |
3567 return ; NO - do not show the pressure readings custom view again | 4132 return ; NO - do not show the pressure readings custom view again |
3568 bsf transmitter1_pres_att ; YES - memorize it's an old message now | 4133 bsf shown_xmit1_pres_attn ; YES - memorize it's an old message now |
3569 bra check_tr_functions_show_cv ; - show custom view | 4134 bra check_tr_functions_show_cv ; - show custom view |
3570 | 4135 |
3571 check_tr_functions_helper5: | 4136 check_tr_functions_helper5: |
3572 btfsc WREG,char_transmitter_lost ; transmitter 2 lost? | 4137 btfsc WREG,char_transmitter_lost ; transmitter 2 lost? |
3573 bra check_tr_functions_helper5a ; YES - show transmitter attention message | 4138 bra check_tr_functions_helper5a ; YES - show transmitter attention message |
3574 bcf transmitter2_lost ; NO - clear flag for old lost attention | 4139 bcf shown_xmit2_lost ; NO - clear flag for old lost message |
3575 return ; - done | 4140 return ; - done |
3576 check_tr_functions_helper5a: | 4141 check_tr_functions_helper5a: |
3577 ; bsf show_transmitter_attention ; show transmitter attention | 4142 btfsc shown_xmit2_lost ; is it a new message? |
3578 btfsc transmitter2_lost ; is it a new message? | |
3579 return ; NO - do not show the pressure readings custom view again | 4143 return ; NO - do not show the pressure readings custom view again |
3580 bsf transmitter2_lost ; YES - memorize it's an old message now | 4144 bsf shown_xmit2_lost ; YES - memorize it's an old message now |
3581 bra check_tr_functions_show_cv ; - show custom view | 4145 bra check_tr_functions_show_cv ; - show custom view |
3582 | 4146 |
3583 check_tr_functions_helper6: | 4147 check_tr_functions_helper6: |
3584 btfsc WREG,char_transmitter_low_bat ; transmitter 2 low battery? | 4148 btfsc WREG,char_transmitter_low_bat ; transmitter 2 low battery? |
3585 bra check_tr_functions_helper6a ; YES - show transmitter attention message | 4149 bra check_tr_functions_helper6a ; YES - show transmitter attention message |
3586 bcf transmitter2_battery ; NO - clear flag for old battery attention | 4150 bcf shown_xmit2_battery ; NO - clear flag for old battery message |
4151 bcf attn_det_xmit2_bat ; - clear transmitter 2 attention | |
3587 return ; - done | 4152 return ; - done |
3588 check_tr_functions_helper6a: | 4153 check_tr_functions_helper6a: |
3589 bsf show_transmitter_attention ; show transmitter attention | 4154 bsf attn_det_xmit2_bat ; set transmitter 2 attention |
3590 btfsc transmitter2_battery ; is it a new message? | 4155 btfsc shown_xmit2_battery ; is it a new message? |
3591 return ; NO - do not show the pressure readings custom view again | 4156 return ; NO - do not show the pressure readings custom view again |
3592 bsf transmitter2_battery ; YES - memorize it's an old message now | 4157 bsf shown_xmit2_battery ; YES - memorize it's an old message now |
3593 bra check_tr_functions_show_cv ; - show custom view | 4158 bra check_tr_functions_show_cv ; - show custom view |
3594 | 4159 |
3595 check_tr_functions_helper7: | 4160 check_tr_functions_helper7: |
3596 btfsc WREG,int_warning_flag ; transmitter 2 pressure warning? | 4161 btfsc WREG,int_warning_flag ; transmitter 2 pressure warning? |
3597 bra check_tr_functions_helper7a ; YES - show pressure reading message as warning | 4162 bra check_tr_functions_helper7a ; YES - show pressure reading message as warning |
3598 bcf transmitter2_pres_warn ; NO - clear flag for old warning | 4163 bcf shown_xmit2_pres_warn ; NO - clear flag for old message |
4164 bcf warn_det_pressure2 ; - clear pressure 2 warning | |
3599 return ; - done | 4165 return ; - done |
3600 check_tr_functions_helper7a: | 4166 check_tr_functions_helper7a: |
3601 bsf show_pres_warning ; show pressure warning | 4167 bsf warn_det_pressure2 ; set pressure 2 warning |
3602 btfsc transmitter2_pres_warn ; is it a new message? | 4168 btfsc shown_xmit2_pres_warn ; is it a new message? |
3603 return ; NO - do not show the pressure readings custom view again | 4169 return ; NO - do not show the pressure readings custom view again |
3604 bsf transmitter2_pres_warn ; YES - memorize it's an old message now | 4170 bsf shown_xmit2_pres_warn ; YES - memorize it's an old message now |
3605 bra check_tr_functions_show_cv ; - show custom view | 4171 bra check_tr_functions_show_cv ; - show custom view |
3606 | 4172 |
3607 check_tr_functions_helper8: | 4173 check_tr_functions_helper8: |
3608 btfsc WREG,int_attention_flag ; transmitter 2 pressure attention? | 4174 btfsc WREG,int_attention_flag ; transmitter 2 pressure attention? |
3609 bra check_tr_functions_helper8a ; YES - show pressure reading message as attention | 4175 bra check_tr_functions_helper8a ; YES - show pressure reading message as attention |
3610 bcf transmitter2_pres_att ; NO - clear flag for old attention | 4176 bcf shown_xmit2_pres_attn ; NO - clear flag for old message |
4177 bcf attn_det_pressure2 ; - clear pressure 2 attention | |
3611 return ; - done | 4178 return ; - done |
3612 check_tr_functions_helper8a | 4179 check_tr_functions_helper8a |
3613 bsf show_pres_attention ; show pressure attention | 4180 bsf attn_det_pressure2 ; set pressure 2 attention |
3614 btfsc transmitter2_pres_att ; is it a new message? | 4181 btfsc shown_xmit2_pres_attn ; is it a new message? |
3615 return ; NO - do not show the pressure readings custom view again | 4182 return ; NO - do not show the pressure readings custom view again |
3616 bsf transmitter2_pres_att ; YES - memorize it's an old message now | 4183 bsf shown_xmit2_pres_attn ; YES - memorize it's an old message now |
3617 ;bra check_tr_functions_show_cv ; - show custom view | 4184 ;bra check_tr_functions_show_cv ; - show custom view |
3618 | 4185 |
3619 check_tr_functions_show_cv: | 4186 check_tr_functions_show_cv: |
3620 btfsc pres_customview_shown ; is the pressure readings custom view not shown yet? | 4187 btfsc custom_view_locked ; NO - custom view locked? |
3621 return ; NO - already shown, done | 4188 return ; YES - do not show now |
3622 btfsc custom_view_locked ; YES - custom view locked? | 4189 movlw index_pressures_SAC ; NO - get custom view number of pressure readings |
3623 return ; YES - done | 4190 goto dive_customview_show ; - show custom view and return |
3624 bsf pres_customview_shown ; NO - mark as shown now | 4191 |
3625 movlw index_pressures_SAC ; - get custom view number of pressure readings | 4192 ENDIF ; _rx_functions |
3626 goto dive_customview_show ; - draw custom view and return | 4193 |
3627 | 4194 |
3628 ENDIF | 4195 ;----------------------------------------------------------------------------- |
3629 | 4196 ; Check Gas Needs |
3630 ;============================================================================= | 4197 ; |
3631 | |
3632 check_gas_needs: | 4198 check_gas_needs: |
3633 banksel int_O_gas_need_pres | 4199 bcf attn_det_gas_needs ; clear attention by default |
4200 bcf warn_det_gas_needs ; clear warning by default | |
4201 banksel int_O_gas_need_pres ; switch to bank where int_O_gas_need_pres is stored | |
3634 movf int_O_gas_need_pres+1,W ; get high byte from pres need of 1st tank | 4202 movf int_O_gas_need_pres+1,W ; get high byte from pres need of 1st tank |
3635 iorwf int_O_gas_need_pres+3,W ; inclusive or with high byte from pres need of 2nd tank | 4203 iorwf int_O_gas_need_pres+3,W ; inclusive or with high byte from pres need of 2nd tank |
3636 iorwf int_O_gas_need_pres+5,W ; inclusive or with high byte from pres need of 3rd tank | 4204 iorwf int_O_gas_need_pres+5,W ; inclusive or with high byte from pres need of 3rd tank |
3637 iorwf int_O_gas_need_pres+7,W ; inclusive or with high byte from pres need of 4th tank | 4205 iorwf int_O_gas_need_pres+7,W ; inclusive or with high byte from pres need of 4th tank |
3638 iorwf int_O_gas_need_pres+9,W ; inclusive or with high byte from pres need of 5th tank | 4206 iorwf int_O_gas_need_pres+9,W ; inclusive or with high byte from pres need of 5th tank |
3639 banksel common | 4207 banksel common ; back to bank common |
3640 btfsc WREG,int_invalid_flag ; check if invalid flag is set | 4208 btfsc WREG,int_invalid_flag ; any invalid flag set? |
3641 return ; YES - no further checking required | 4209 bra check_gas_needs_ok ; YES - no further checking required |
3642 btfsc WREG,int_warning_flag ; NO - check if any gas has a pres_need >= pres_fill | 4210 btfsc WREG,int_warning_flag ; NO - any gas with pres_need >= pres_fill ? |
3643 bra check_gas_needs_warn ; YES - generate a warning | 4211 bra check_gas_needs_warn ; YES - generate a warning |
3644 btfsc WREG,int_attention_flag ; NO - check if any gas has a pres_need >= pres_fill * threshold | 4212 btfsc WREG,int_attention_flag ; NO - any gas with pres_need >= pres_fill * threshold ? |
3645 bra check_gas_needs_att ; YES - generate an attention | 4213 bra check_gas_needs_attn ; YES - generate an attention |
3646 bcf gas_needs_attention ; NO - clear flag for a new attention | 4214 ;bra check_gas_needs_ok ; NO - gas needs ok |
3647 bcf gas_needs_warning ; - clear flag for a new warning | 4215 |
3648 return ; - done | 4216 check_gas_needs_ok: |
4217 bcf shown_gas_needs_warn ; re-arm custom view show-up for warning | |
4218 bcf shown_gas_needs_attn ; re-arm custom view show-up for attention | |
4219 return ; done | |
3649 | 4220 |
3650 check_gas_needs_warn: | 4221 check_gas_needs_warn: |
3651 bsf message_warning ; show warning sign for gas needs | 4222 bsf warn_det_gas_needs ; set warning |
3652 incf message_counter,F ; increase counter | 4223 bcf shown_gas_needs_attn ; re-arm custom view show-up for attention |
3653 btfsc gas_needs_warning ; is it a new warning? | 4224 btfsc shown_gas_needs_warn ; has the custom view been shown before on warning level? |
3654 bra check_gas_needs_warn_1 ; NO - do not show the gas needs custom view again | 4225 bra check_gas_needs_mesg ; YES - do not show the gas needs custom view again |
3655 btfsc custom_view_locked ; YES - custom view locked? | 4226 btfsc custom_view_locked ; NO - custom view locked? |
3656 bra check_gas_needs_warn_1 ; YES - done | 4227 bra check_gas_needs_mesg ; YES - do not show it now |
3657 bsf gas_needs_warning ; NO - memorize it's an old now | 4228 bsf shown_gas_needs_warn ; NO - set custom view as shown now |
3658 movlw index_gas_needs_ascent ; - get custom view number of gas needs | 4229 bra check_gas_needs_cv ; - show gas needs custom view |
3659 call dive_customview_show ; - draw custom view | 4230 |
3660 check_gas_needs_warn_1: | 4231 check_gas_needs_attn: |
3661 goto TFT_warning_gas_needs ; - show warning message for gas needs and return | 4232 bsf attn_det_gas_needs ; set attention |
3662 | 4233 bcf shown_gas_needs_warn ; re-arm custom view show-up for warning |
3663 check_gas_needs_att: | 4234 btfsc shown_gas_needs_attn ; has the custom view been shown before on attention level? |
3664 bsf message_attention ; show attention sign for gas needs | 4235 bra check_gas_needs_mesg ; YES - do not show the gas needs custom view again |
3665 incf message_counter,F ; increase counter | 4236 btfsc custom_view_locked ; NO - custom view locked? |
3666 btfsc gas_needs_attention ; is it a new attention? | 4237 bra check_gas_needs_mesg ; YES - do not show it now |
3667 bra check_gas_needs_att_1 ; NO - do not show the gas needs custom view again | 4238 bsf shown_gas_needs_attn ; NO - set custom view as shown now |
3668 btfsc custom_view_locked ; YES - custom view locked? | 4239 ;bra check_gas_needs_cv ; - show gas needs custom view |
3669 bra check_gas_needs_att_1 ; YES - done | 4240 |
3670 bsf gas_needs_attention ; NO - memorize it's an old now | 4241 check_gas_needs_cv: |
3671 movlw index_gas_needs_ascent ; - get custom view number of gas needs | 4242 movlw index_gas_needs_ascent ; get custom view number of gas needs |
3672 call dive_customview_show ; - draw custom view | 4243 call dive_customview_show ; show custom view |
3673 check_gas_needs_att_1: | 4244 ;bra check_gas_needs_mesg ; show message |
3674 goto TFT_attention_gas_needs ; - show attention message for gas needs and return | 4245 |
4246 check_gas_needs_mesg: | |
4247 incf message_counter,F ; increase message counter | |
4248 goto TFT_message_gas_needs ; show message for gas needs and return | |
4249 | |
4250 | |
4251 IFDEF _external_sensor | |
4252 | |
4253 ;----------------------------------------------------------------------------- | |
4254 ; Check external Sensors for Loss and Divergence | |
4255 ; | |
4256 check_ext_sensors: | |
4257 btfsc warn_det_sensors_lost ; all sensors lost? | |
4258 bra check_ext_sensors_lost_all ; YES - show a warning and return | |
4259 | |
4260 btfsc attn_det_sensor1_lost ; sensor 1 lost? | |
4261 rcall check_ext_sensors_lost_1 ; YES - show an attention | |
4262 | |
4263 btfsc attn_det_sensor2_lost ; sensor 2 lost? | |
4264 rcall check_ext_sensors_lost_2 ; YES - show an attention | |
4265 | |
4266 btfsc attn_det_sensor3_lost ; sensor 3 lost? | |
4267 rcall check_ext_sensors_lost_3 ; YES - show an attention | |
4268 | |
4269 btfsc warn_det_sensors_div ; sensor values divergence? | |
4270 bra check_ext_sensors_diverg ; YES - show a warning and return | |
4271 | |
4272 return ; done | |
4273 | |
4274 check_ext_sensors_lost_all: | |
4275 btfsc shown_sensors_lost ; has the custom view been shown before? | |
4276 bra warn_sensors_lost_mesg ; YES - do not show the sensor custom view again | |
4277 btfsc custom_view_locked ; NO - custom view locked? | |
4278 bra warn_sensors_lost_mesg ; YES - do not show it now | |
4279 bsf shown_sensors_lost ; NO - set it as shown now | |
4280 movlw index_ppo2_sensors ; - get custom view number of sensors | |
4281 call dive_customview_show ; - show custom view | |
4282 ;bra warn_sensors_lost_mesg ; - show message | |
4283 | |
4284 warn_sensors_lost_mesg: | |
4285 incf message_counter,F ; increase message counter | |
4286 goto TFT_message_fallback ; show message and return | |
4287 | |
4288 check_ext_sensors_lost_1: | |
4289 btfsc shown_sensor1_fail ; has the custom view been shown before for sensor 1? | |
4290 return ; YES - do not show the sensor custom view again | |
4291 btfsc custom_view_locked ; NO - custom view locked? | |
4292 return ; YES - do not show it now | |
4293 bsf shown_sensor1_fail ; NO - set it as shown now | |
4294 bra check_ext_sensors_show_cv ; - show sensor custom view | |
4295 | |
4296 check_ext_sensors_lost_2: | |
4297 btfsc shown_sensor2_fail ; has the custom view been shown before for sensor 2? | |
4298 return ; YES - do not show the sensor custom view again | |
4299 btfsc custom_view_locked ; NO - custom view locked? | |
4300 return ; YES - do not show it now | |
4301 bsf shown_sensor2_fail ; NO - set it as shown now | |
4302 bra check_ext_sensors_show_cv ; - show sensor custom view | |
4303 | |
4304 check_ext_sensors_lost_3: | |
4305 btfsc shown_sensor3_fail ; has the custom view been shown before for sensor 3? | |
4306 return ; YES - do not show the sensor custom view again | |
4307 btfsc custom_view_locked ; NO - custom view locked? | |
4308 return ; YES - do not show it now | |
4309 bsf shown_sensor3_fail ; NO - set it as shown now | |
4310 ;bra check_ext_sensors_show_cv ; - show sensor custom view | |
4311 | |
4312 check_ext_sensors_show_cv: | |
4313 movlw index_ppo2_sensors ; get custom view number of sensors | |
4314 goto dive_customview_show ; show custom view and return | |
4315 | |
4316 check_ext_sensors_diverg: | |
4317 btfsc shown_sensors_diverg ; has the custom view been shown before for divergence? | |
4318 bra check_ext_sensors_diverg_mesg ; YES - do not show the sensor custom view again | |
4319 btfsc custom_view_locked ; NO - custom view locked? | |
4320 bra check_ext_sensors_diverg_mesg ; YES - do not show it now | |
4321 bsf shown_sensors_diverg ; NO - set it as shown now | |
4322 movlw index_ppo2_sensors ; - get custom view number of sensors | |
4323 call dive_customview_show ; - show custom view | |
4324 ;bra check_ext_sensors_diverg_mesg ; - show message | |
4325 | |
4326 check_ext_sensors_diverg_mesg: | |
4327 incf message_counter,F ; increase message counter | |
4328 goto TFT_message_divergence ; show message and return | |
4329 | |
4330 ENDIF ; _external_sensor | |
4331 | |
3675 | 4332 |
3676 ;============================================================================= | 4333 ;============================================================================= |
3677 | 4334 dmode5 CODE |
3678 IFDEF _external_sensor | |
3679 | |
3680 check_warn_sensors_disagree: | |
3681 incf message_counter,F ; increase counter | |
3682 bsf message_warning ; show warning sign for sensor disagree | |
3683 btfsc o2_sensors_warning ; is it a new warning? | |
3684 goto TFT_warning_sensor_disagree ; NO - don't show sensor custom view again, just show sensor disagree warning and return | |
3685 bsf o2_sensors_warning ; YES - memorize it's an old warning now | |
3686 call show_sensors_custview ; - show sensors custom view | |
3687 goto TFT_warning_sensor_disagree ; - show warning message for sensor disagree and return | |
3688 | |
3689 ENDIF | |
3690 | |
3691 ;============================================================================= | 4335 ;============================================================================= |
3692 | 4336 |
3693 IFDEF _helium | 4337 |
3694 | 4338 ;----------------------------------------------------------------------------- |
3695 check_IBCD: | 4339 ; Restart the Deco Engine |
3696 TSTOSS opt_enable_IBCD ; IBCD warning activated? | 4340 ; |
3697 return ; NO - done | |
3698 movff char_O_deco_warnings,WREG ; YES - get deco warnings vector | |
3699 btfss WREG,IBCD_warning ; IBCD warning flag set? | |
3700 return ; NO - return | |
3701 incf message_counter,F ; YES - increase counter | |
3702 goto TFT_warning_IBCD ; write warning to display | |
3703 | |
3704 ENDIF | |
3705 | |
3706 ;============================================================================= | |
3707 | |
3708 check_OC_gas_avail: | |
3709 tstfsz best_gas_number ; is a breathable OC (bailout) gas available? | |
3710 return ; YES (>0) - a breathable gas is available | |
3711 IFDEF _ccr_pscr | |
3712 btfsc bailout_mode ; in bailout? | |
3713 return ; YES - suppress warning | |
3714 ENDIF | |
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 | |
3718 | |
3719 | |
3720 advice_gas_change: | |
3721 bsf message_advice ; show advice sign | |
3722 incf message_counter,F ; increase counter | |
3723 goto TFT_advice_gas_change ; show advice (and return) | |
3724 | |
3725 | |
3726 global restart_deco_engine | 4341 global restart_deco_engine |
3727 global restart_deco_engine_wo_ceiling | 4342 global restart_deco_engine_wo_ceiling |
3728 restart_deco_engine: | 4343 restart_deco_engine: |
3729 banksel int_O_ceiling ; switch to bank where the shared "_O_" variables are stored | 4344 banksel int_O_ceiling ; switch to bank where the shared "_O_" variables are stored |
3730 bsf int_O_ceiling+1,char_invalid_flag ; invalidate ceiling (int_O_ceiling has its invalid flag on a char's position!) | 4345 bsf int_O_ceiling+1,char_invalid_flag ; invalidate ceiling (int_O_ceiling has its invalid flag on a char's position!) |
3731 | 4346 |
3732 restart_deco_engine_wo_ceiling: | 4347 restart_deco_engine_wo_ceiling: |
3733 banksel char_O_deco_gas ; switch to bank where the shared "_O_" variables are stored | 4348 banksel char_O_deco_gas ; switch to bank where the stops table is stored |
3734 bsf char_O_deco_gas+0,char_invalid_flag ; invalidate deco data (stop table data) | 4349 bsf char_O_deco_gas+0,char_invalid_flag ; invalidate deco data (stop table data) |
4350 banksel int_O_NDL_norm ; switch to bank where the shared "_O_" variables are stored | |
3735 bsf int_O_NDL_norm+1,int_invalid_flag ; invalidate NDL time (normal plan) | 4351 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) | 4352 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) | 4353 bsf int_O_TST_norm+1,int_invalid_flag ; invalidate TST time (normal plan) |
3738 bsf int_O_CNS_norm+1,int_invalid_flag ; invalidate CNS at end of dive in normal plan | 4354 bsf int_O_CNS_norm+1,int_invalid_flag ; invalidate CNS at end of dive in normal plan |
3739 | 4355 |
3740 restart_deco_engine_wo_norm: | 4356 restart_deco_engine_wo_norm: |
3741 banksel common ; bank to bank common | 4357 banksel common ; bank to bank common |
3742 bsf request_restart_engine ; request restart of the deco engine | 4358 bsf request_restart_engine ; request restart of the deco engine |
3743 | 4359 |
3744 inval_alternative_plan_data: | 4360 inval_alternative_plan_data: |
3745 banksel int_O_TTS_alt ; switch to bank where the shared "_O_" variables are stored | 4361 banksel int_O_NDL_alt ; switch to bank where the shared "_O_" variables are stored |
3746 bsf int_O_NDL_alt+1,int_invalid_flag ; invalidate NDL time (alternative plan) | 4362 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) | 4363 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) | 4364 bsf int_O_TST_alt+1,int_invalid_flag ; invalidate TST time (alternative plan) |
3749 bsf int_O_CNS_alt+1,int_invalid_flag ; invalidate CNS at end of dive in alternative plan | 4365 bsf int_O_CNS_alt+1,int_invalid_flag ; invalidate CNS at end of dive in alternative plan |
3750 bsf int_O_gas_need_pres+1,int_invalid_flag ; invalidate ascent gas needs | 4366 bsf int_O_gas_need_pres+1,int_invalid_flag ; invalidate ascent gas needs |
3755 ENDIF | 4371 ENDIF |
3756 | 4372 |
3757 banksel common ; bank to bank common | 4373 banksel common ; bank to bank common |
3758 bsf new_deco_data_avail ; set flag for new NDL and deco data available to have the display updated | 4374 bsf new_deco_data_avail ; set flag for new NDL and deco data available to have the display updated |
3759 | 4375 |
3760 return | 4376 return ; done |
4377 | |
3761 | 4378 |
3762 ;============================================================================= | 4379 ;============================================================================= |
3763 ; Simulator Mode | 4380 dmode6 CODE |
3764 ; | 4381 ;============================================================================= |
3765 global do_demo_divemode | 4382 |
3766 do_demo_divemode: | 4383 |
4384 ;----------------------------------------------------------------------------- | |
4385 ; Start-up Simulator Mode | |
4386 ; | |
4387 global demo_divemode | |
4388 demo_divemode: | |
3767 call TFT_ClearScreen ; blank screen | 4389 call TFT_ClearScreen ; blank screen |
3768 | 4390 |
3769 ; leaving menu mode, so have option values in EEPROM up-to-date | 4391 ; 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 ? | 4392 btfsc option_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 | 4393 call option_check_and_store_all ; YES - check and store all option values in EEPROM |
3772 bcf options_changed ; clear flag | |
3773 | 4394 |
3774 ; +++ COMMENT OUT FOR TESTING PURPOSE ONLY !!! +++ | 4395 ; +++ COMMENT OUT FOR TESTING PURPOSE ONLY !!! +++ |
3775 bsf simulatormode ; restore tissue pressures and CNS value after finishing simulator use | 4396 bsf simulatormode ; restore tissue pressures and CNS value after finishing simulator use |
3776 ; +++ DO NOT COMMENT OUT IN OPERATIONAL USE !!! +++ | 4397 ; +++ DO NOT COMMENT OUT IN OPERATIONAL USE !!! +++ |
3777 | 4398 |
3793 btfss sensor_override_active ; has the ISR confirmed switch to simulator mode? | 4414 btfss sensor_override_active ; has the ISR confirmed switch to simulator mode? |
3794 bra $-2 ; NO - not yet, loop waiting for the ISR to kick in | 4415 bra $-2 ; NO - not yet, loop waiting for the ISR to kick in |
3795 | 4416 |
3796 ; branch into dive mode | 4417 ; branch into dive mode |
3797 bsf divemode ; activate dive mode (to be done after simulator mode is activated) | 4418 bsf divemode ; activate dive mode (to be done after simulator mode is activated) |
3798 goto diveloop ; branch to dive mode code | 4419 goto diveloop ; start dive mode |
4420 | |
4421 ;----------------------------------------------------------------------------- | |
3799 | 4422 |
3800 END | 4423 END |