annotate src/divemode.asm @ 655:c7b7b8a358cd default tip

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