Mercurial > public > hwos_code
comparison src/divemenu_tree.asm @ 582:b455b31ce022
work on 2.97 stable
author | heinrichsweikamp |
---|---|
date | Mon, 26 Feb 2018 16:40:28 +0100 |
parents | e6d5a1f02daf |
children | 6636cbe64c6d |
comparison
equal
deleted
inserted
replaced
581:f5de1ff88814 | 582:b455b31ce022 |
---|---|
1 ;============================================================================= | 1 ;============================================================================= |
2 ; | 2 ; |
3 ; File divemenu_tree.asm REFACTORED VERSION V2.96a | 3 ; File divemenu_tree.asm REFACTORED VERSION V2.98 |
4 ; | 4 ; |
5 ; OSTC dive mode menu | 5 ; OSTC dive mode menu |
6 ; | 6 ; |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. |
8 ;============================================================================= | 8 ;============================================================================= |
9 ; HISTORY | 9 ; HISTORY |
10 ; 2013-02-02 : [mH] Made out of menu_tree.asm | 10 ; 2013-02-02 : [mH] Made out of menu_tree.asm |
11 | 11 |
12 #include "hwos.inc" ; Mandatory header | 12 #include "hwos.inc" ; Mandatory header |
13 #include "menu_processor.inc" | 13 #include "menu_processor.inc" |
14 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c | 14 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c |
15 #include "tft_outputs.inc" | 15 #include "tft_outputs.inc" |
16 #include "customview.inc" | 16 #include "customview.inc" |
17 #include "strings.inc" | 17 #include "strings.inc" |
18 #include "calibrate.inc" | 18 #include "calibrate.inc" |
19 | 19 |
20 | 20 extern timeout_divemode_menu2 |
21 divegui CODE | 21 extern diveloop_loop4 |
22 | |
23 | |
24 divegui CODE | |
25 | |
22 ;============================================================================= | 26 ;============================================================================= |
23 ; Main Menu | 27 ; Main Menu |
24 global do_main_divemenu | 28 global do_main_divemenu |
25 do_main_divemenu: | 29 do_main_divemenu: |
26 call menu_processor_reset ; restart from first icon. | 30 call menu_processor_reset ; restart from first icon |
27 | 31 movlw .1 |
28 do_continue_main_divemenu: | 32 movwf menupos1 ; set to first option in divemode menu |
29 call menu_processor_pop ; drop exit line. | |
30 call menu_processor_pop ; drop exit line. | |
31 | |
32 btfsc FLAG_ccr_mode | 33 btfsc FLAG_ccr_mode |
33 bra main_divemenu_loop ; goto CCR / pSCR Menu menu | 34 bra main_divemenu_loop ; goto CCR / pSCR Menu menu |
34 btfsc FLAG_pscr_mode | 35 btfsc FLAG_pscr_mode |
35 bra main_divemenu_loop ; goto CCR / pSCR Menu menu | 36 bra main_divemenu_loop ; goto CCR / pSCR Menu menu |
36 | 37 |
37 main_divemenu_OC: | 38 main_divemenu_OC: |
38 bcf ccr_diluent_setup | 39 bcf ccr_diluent_setup |
39 bcf is_bailout_menu | 40 bcf is_bailout_menu |
40 movlw .1 | 41 |
41 movwf menupos ; Set to first option in divemode menu | 42 MENU_BEGIN tMainMenu, .5 |
42 | 43 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist |
43 MENU_BEGIN tMainMenu, .5 | 44 MENU_CALL tDivemenu_ResetAvg, do_reset_average |
44 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist | 45 MENU_CALL tDivemenu_ToggleGF, do_toggle_gf |
45 MENU_CALL tDivemenu_ResetAvg, do_reset_average | 46 MENU_CALL tDivemenu_Marker, do_set_marker |
46 MENU_CALL tDivemenu_ToggleGF, do_toggle_gf | 47 MENU_CALL tExit, do_exit_divemode_menu |
47 MENU_CALL tDivemenu_Marker, do_set_marker | |
48 MENU_CALL tExit, do_exit_divemode_menu | |
49 MENU_END | 48 MENU_END |
50 | 49 |
51 main_divemenu_loop: | 50 main_divemenu_loop: |
52 bsf ccr_diluent_setup ; default to operations on diluents | 51 bsf ccr_diluent_setup ; default to operations on diluents |
53 bcf is_bailout_menu ; default to none-bailout menu | 52 bcf is_bailout_menu ; default to none-bailout menu |
54 movlw .1 | 53 btfsc FLAG_pscr_mode |
55 movwf menupos ; Set to first option in divemode menu | 54 bra main_divemenu_pscr ; PSCR Menu |
56 | 55 |
57 btfsc FLAG_pscr_mode | 56 MENU_BEGIN tMainMenu, .6 |
58 bra main_divemenu_pscr ; PSCR Menu | 57 MENU_CALL tDiveBailout, do_divemode_gaslist_bail |
59 | 58 MENU_CALL tDivemenu_Setpoint, do_divemode_splist |
60 MENU_BEGIN tMainMenu, .6 | 59 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist |
61 MENU_CALL tDiveBailout, do_divemode_gaslist_bail | 60 MENU_CALL tDivemenu_ResetAvg, do_reset_average |
62 MENU_CALL tDivemenu_Setpoint, do_divemode_splist | 61 MENU_CALL tDivemenu_ToggleGF, do_toggle_gf |
63 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist | 62 MENU_CALL tExit, do_exit_divemode_menu |
64 MENU_CALL tDivemenu_ResetAvg, do_reset_average | 63 MENU_END |
65 MENU_CALL tDivemenu_ToggleGF, do_toggle_gf | 64 |
66 MENU_CALL tExit, do_exit_divemode_menu | |
67 MENU_END | |
68 | |
69 main_divemenu_pscr: | 65 main_divemenu_pscr: |
70 movf hardware_flag,W | 66 btfsc analog_o2_input ; do we have an analog input? |
71 sublw 0x11 ; 2 with BLE | 67 bra main_divemenu_pscr_sensors ; YES |
72 btfsc STATUS,Z | 68 btfsc s8_digital ; do we have a digital input? |
73 bra main_divemenu_pscr_no_sensors | 69 bra main_divemenu_pscr_sensors ; YES |
74 movf hardware_flag,W | |
75 sublw 0x13 ; + | |
76 btfsc STATUS,Z | |
77 bra main_divemenu_pscr_no_sensors | |
78 | |
79 MENU_BEGIN tMainMenu, .6 | |
80 MENU_CALL tDiveBailout, do_divemode_gaslist_bail | |
81 MENU_CALL tCCRSensor, do_divemode_setpoint_pscr | |
82 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist | |
83 MENU_CALL tDivemenu_ResetAvg, do_reset_average | |
84 MENU_CALL tDivemenu_ToggleGF, do_toggle_gf | |
85 MENU_CALL tExit, do_exit_divemode_menu | |
86 MENU_END | |
87 | 70 |
88 main_divemenu_pscr_no_sensors: | 71 main_divemenu_pscr_no_sensors: |
89 MENU_BEGIN tMainMenu, .6 | 72 MENU_BEGIN tMainMenu, .6 |
90 MENU_CALL tDiveBailout, do_divemode_gaslist_bail | 73 MENU_CALL tDiveBailout, do_divemode_gaslist_bail |
91 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist | 74 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist |
92 MENU_CALL tDivemenu_ResetAvg, do_reset_average | 75 MENU_CALL tDivemenu_ResetAvg, do_reset_average |
93 MENU_CALL tDivemenu_ToggleGF, do_toggle_gf | 76 MENU_CALL tDivemenu_ToggleGF, do_toggle_gf |
94 MENU_CALL tDivemenu_Marker, do_set_marker | 77 MENU_CALL tDivemenu_Marker, do_set_marker |
95 MENU_CALL tExit, do_exit_divemode_menu | 78 MENU_CALL tExit, do_exit_divemode_menu |
96 MENU_END | 79 MENU_END |
97 | 80 |
81 main_divemenu_pscr_sensors: | |
82 MENU_BEGIN tMainMenu, .6 | |
83 MENU_CALL tDiveBailout, do_divemode_gaslist_bail | |
84 MENU_CALL tCCRSensor, do_divemode_setpoint_pscr | |
85 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist | |
86 MENU_CALL tDivemenu_ResetAvg, do_reset_average | |
87 MENU_CALL tDivemenu_ToggleGF, do_toggle_gf | |
88 MENU_CALL tExit, do_exit_divemode_menu | |
89 MENU_END | |
90 | |
98 | 91 |
99 do_toggle_gf: | 92 do_toggle_gf: |
100 movff char_I_deco_model,WREG ; 0 = ZH-L16, 1 = ZH-L16-GF | 93 movff char_I_deco_model,WREG ; 0 = ZH-L16, 1 = ZH-L16-GF |
101 decfsz WREG,W ; Toggle GF only in GF modes - in GF mode? | 94 decfsz WREG,W ; Toggle GF only in GF modes - in GF mode? |
102 bra do_continue_main_divemenu ; No, do nothing and return | 95 bra do_main_divemenu ; No, do nothing and return |
103 TSTOSS opt_enable_aGF ; =1: aGF can be selected underwater | 96 TSTOSS opt_enable_aGF ; =1: aGF can be selected underwater |
104 bra do_continue_main_divemenu ; No, do nothing and return | 97 bra do_main_divemenu ; No, do nothing and return |
105 movlw .4 ; Set customview to 5 (GF informations) | 98 movlw .4 ; Set customview to 5 (GF informations) |
106 movwf menupos3 ; Customview to come-1 | 99 movwf menupos3 ; Customview to come-1 |
107 bsf toggle_customview ; Set flag, the customview will be toggled very soon now... | 100 bsf toggle_customview ; Set flag, the customview will be toggled very soon now... |
108 movlw .1 | 101 movlw .1 |
109 movwf menupos ; Set to first option in divemode menu | 102 movwf menupos1 ; Set to first option in divemode menu |
110 | 103 |
111 MENU_BEGIN tDivemenu_ToggleGF, .2 | 104 MENU_BEGIN tDivemenu_ToggleGF, .2 |
112 MENU_CALL tDivemenu_ToggleGF, do_togglegf | 105 MENU_CALL tDivemenu_ToggleGF, do_togglegf |
113 MENU_CALL tExit, do_continue_main_divemenu | 106 MENU_CALL tBack, do_main_divemenu |
114 MENU_END | 107 MENU_END |
115 | 108 |
116 do_togglegf: | 109 do_togglegf: |
117 ;TSTOSS opt_enable_aGF ; =1: aGF can be selected underwater ## check is now done before entering menu | 110 ;TSTOSS opt_enable_aGF ; =1: aGF can be selected underwater ; check is now done before entering menu |
118 ;bra do_exit_divemode_menu ; continue with exiting menu code | 111 ;bra do_exit_divemode_menu ; continue with exiting menu code |
119 bsf toggle_gf ; Set flag... | 112 bsf toggle_gf ; Set flag... |
120 bra do_exit_divemode_menu ; continue with exiting menu code | 113 bra do_exit_divemode_menu ; continue with exiting menu code |
121 | 114 |
122 | 115 |
123 do_set_marker: | 116 do_set_marker: |
124 movlw d'6' ; Type of Alarm (Manual Marker) | 117 bsf FLAG_set_marker ; set flag... |
125 movwf AlarmType ; Copy to Alarm Register | 118 bra do_exit_divemode_menu ; ... and exit |
126 bsf event_occured ; Set Event Flag | 119 |
127 bra do_exit_divemode_menu ; And exit | 120 |
128 | |
129 | |
130 do_reset_average: | 121 do_reset_average: |
131 bsf reset_average_depth ; Set Flag | 122 bsf reset_average_depth ; Set Flag |
132 bra do_exit_divemode_menu ; continue with exiting menu code | 123 bra do_exit_divemode_menu ; continue with exiting menu code |
133 | 124 |
134 | 125 |
135 do_switch_sensor: ; entry point when coming from switch to sensor | 126 do_switch_sensor: ; entry point when coming from switch to sensor |
136 movlw .1 ; Switch to Sensor | 127 movlw .1 ; Switch to Sensor |
137 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP | 128 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP |
138 ; enable all sensors | 129 ; enable all sensors |
139 bsf use_O2_sensor1 | 130 bsf use_O2_sensor1 |
140 bsf use_O2_sensor2 | 131 bsf use_O2_sensor2 |
141 bsf use_O2_sensor3 | 132 bsf use_O2_sensor3 |
142 bra do_switch_sp_com ; continue with common part | 133 bra do_switch_sp_com ; continue with common part |
143 | 134 |
144 do_switch_sp: ; entry point when coming from manual setpoint selection (CCR) | 135 do_switch_sp: ; entry point when coming from manual setpoint selection (CCR) |
145 decf menupos,W ; 1-5 -> 0-4 | 136 decf menupos1,W ; 1-5 -> 0-4 |
146 lfsr FSR1,char_I_setpoint_cbar | 137 lfsr FSR1,char_I_setpoint_cbar |
147 movff PLUSW1,char_I_const_ppO2 ; setup fixed setpoint | 138 movff PLUSW1,char_I_const_ppO2 ; setup fixed setpoint |
148 movff char_I_const_ppO2,WREG | 139 movff char_I_const_ppO2,WREG |
149 call transmit_setpoint ; tansmit current setpoint from WREG (in cbar) to external electronics | 140 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics |
150 bcf setpoint_fallback ; clear fallback condition (stops fallback warning) | 141 bcf setpoint_fallback ; clear fallback condition (stops fallback warning) |
151 clrf WREG ; Switch to fixed SP | 142 clrf WREG ; Switch to fixed SP |
152 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP | 143 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP |
153 bra do_switch_sp_com | 144 bra do_switch_sp_com |
154 | 145 |
155 do_switch_sp_calc: ; entry point when coming from switch to calculated ppO2 (pSCR) | 146 do_switch_sp_calc: ; entry point when coming from switch to calculated ppO2 (pSCR) |
156 bcf setpoint_fallback ; clear fallback condition (stops fallback warning) | 147 bcf setpoint_fallback ; clear fallback condition (stops fallback warning) |
157 clrf WREG ; Switch to fixed SP | 148 clrf WREG ; Switch to fixed SP |
158 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP | 149 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP |
159 movff WREG,char_I_const_ppO2 ; set setpoint to 0, this forces deco engine to take the computed ppO2 | 150 movff WREG,char_I_const_ppO2 ; set setpoint to 0, this forces deco engine to take the computed ppO2 |
160 | 151 |
161 do_switch_sp_com: ; merge point to common part | 152 do_switch_sp_com: ; merge point to common part |
162 bsf event_occured ; set global event byte | 153 bsf event_occured ; set global event byte |
163 bsf setpoint_changed ; set flag (for profile) | 154 bsf setpoint_changed ; set flag (for profile) |
164 | 155 |
165 ; Clear some flags in case we were in bailout before... | 156 ; Clear some flags in case we were in bailout before... |
166 bcf is_bailout ; end bailout mode | 157 bcf is_bailout ; end bailout mode |
167 ;bcf is_bailout_menu ; not needed | 158 ;bcf is_bailout_menu ; not needed |
168 bcf better_gas_available ; =1: A better gas is available and a gas change is advised in divemode | 159 bcf better_gas_available ; =1: A better gas is available and a gas change is advised in divemode |
169 bcf blinking_better_gas ; clear blinking flag | 160 bcf blinking_better_gas ; clear blinking flag |
170 call customview_mask ; update customview mask to (eventually) rewrite ppO2(Dil): to ppO2: | 161 call customview_mask ; update customview mask to (eventually) rewrite ppO2(Dil): to ppO2: |
171 | 162 |
172 movff active_diluent,menupos ; reconfigure last diluent (menupos is transfer register for selected gas/diluent towards gas_switched_common:) | 163 bsf FLAG_back_to_loop ; indicate that it is a switchback from OC bailout to CCR/pSCR loop |
173 bsf divemode_gaschange ; initiate reconfiguration to loop mode on last diluent | 164 bsf divemode_gaschange ; initiate reconfiguration to loop mode on last diluent |
174 | 165 |
175 bra do_exit_divemode_menu ; continue with exiting menu code | 166 bra do_exit_divemode_menu ; continue with exiting menu code |
176 | 167 |
177 | 168 |
178 do_divemode_gaslist_bail: ; entry point from CCR/pSCR to bailout to OC gases | 169 do_divemode_gaslist_bail: ; entry point from CCR/pSCR to bailout to OC gases |
179 bcf ccr_diluent_setup ; switch to OC gases | 170 bcf ccr_diluent_setup ; switch to OC gases |
180 bsf is_bailout_menu ; flag it is a bailout action | 171 bsf is_bailout_menu ; flag it is a bailout action |
181 do_divemode_gaslist: ; entry point for switching: OC -> gases, loop -> diluents | 172 do_divemode_gaslist: ; entry point for switching: OC -> gases, loop -> diluents |
182 btfsc is_bailout ; in bailout mode? | 173 btfsc is_bailout ; in bailout mode? |
183 bcf ccr_diluent_setup ; yes - for safety reasons, redirect to OC (bailout) gases | 174 bcf ccr_diluent_setup ; yes - for safety reasons, redirect to OC (bailout) gases |
175 do_divemode_gaslist_com: | |
184 bsf short_gas_decriptions | 176 bsf short_gas_decriptions |
185 movlw .1 | 177 movlw .1 |
186 movwf menupos ; Set to first option in divemode menu | 178 movwf menupos1 ; Set to first option in divemode menu |
187 MENU_BEGIN tGaslist, .6 | 179 MENU_BEGIN tGaslist, .6 |
188 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas | 180 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas |
189 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas | 181 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas |
190 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas | 182 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas |
191 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas | 183 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas |
192 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas | 184 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas |
193 MENU_CALL tMore, do_divemode_gaslist_more | 185 MENU_CALL tMore, do_divemode_gaslist_more |
194 MENU_END | 186 MENU_END |
187 | |
195 | 188 |
196 do_divemode_gaslist_more: | 189 do_divemode_gaslist_more: |
197 movlw .1 | 190 movlw .1 |
198 movwf menupos ; Set to first option in divemode menu | 191 movwf menupos1 ; Set to first option in divemode menu |
199 | 192 |
200 movff char_I_O2_ratio,gas6_O2_ratio ; initialize gas6 with currently breathed gas - O2 ratio | 193 movff char_I_O2_ratio,gas6_O2_ratio ; initialize gas6 with currently breathed gas - O2 ratio |
201 movff char_I_He_ratio,gas6_He_ratio ; initialize gas6 with currently breathed gas - He ratio | 194 movff char_I_He_ratio,gas6_He_ratio ; initialize gas6 with currently breathed gas - He ratio |
202 | 195 |
203 do_divemode_gaslist_more_loop: | 196 do_divemode_gaslist_more_common: |
204 MENU_BEGIN tGaslist, .6 | 197 MENU_BEGIN tGaslist, .6 |
205 MENU_CALL tO2Plus, do_dive_pO2 | 198 MENU_CALL tO2Plus, do_dive_pO2 |
206 MENU_CALL tO2Minus, do_dive_mO2 | 199 MENU_CALL tO2Minus, do_dive_mO2 |
207 MENU_CALL tHePlus, do_dive_pHe | 200 MENU_CALL tHePlus, do_dive_pHe |
208 MENU_CALL tHeMinus, do_dive_mHe | 201 MENU_CALL tHeMinus, do_dive_mHe |
209 MENU_DYNAMIC gaslist_strcat_gas6, do_switch_gas6 | 202 MENU_DYNAMIC gaslist_strcat_gas6, do_switch_gas6 |
210 MENU_CALL tDivemenu_LostGas, do_lost_gas | 203 MENU_CALL tDivemenu_LostGas, do_lost_gas |
211 MENU_END | 204 MENU_END |
205 | |
212 | 206 |
213 do_lost_gas: | 207 do_lost_gas: |
214 movlw .1 | 208 movlw .1 |
215 movwf menupos ; Set to first option in divemode menu | 209 movwf menupos1 ; Set to first option in divemode menu |
216 do_lost_gas_loop: | 210 do_lost_gas_common: |
217 bsf short_gas_decriptions | 211 bsf short_gas_decriptions |
218 MENU_BEGIN tDivemenu_LostGas, .6 | 212 MENU_BEGIN tDivemenu_LostGas, .6 |
219 MENU_DYNAMIC gaslist_strcat_gas_mod, do_toggle_active ; Toggle the gas (in)active | 213 MENU_DYNAMIC gaslist_strcat_gas_mod, do_toggle_active ; Toggle the gas (in)active |
220 MENU_DYNAMIC gaslist_strcat_gas_mod, do_toggle_active ; Toggle the gas (in)active | 214 MENU_DYNAMIC gaslist_strcat_gas_mod, do_toggle_active ; Toggle the gas (in)active |
221 MENU_DYNAMIC gaslist_strcat_gas_mod, do_toggle_active ; Toggle the gas (in)active | 215 MENU_DYNAMIC gaslist_strcat_gas_mod, do_toggle_active ; Toggle the gas (in)active |
222 MENU_DYNAMIC gaslist_strcat_gas_mod, do_toggle_active ; Toggle the gas (in)active | 216 MENU_DYNAMIC gaslist_strcat_gas_mod, do_toggle_active ; Toggle the gas (in)active |
223 MENU_DYNAMIC gaslist_strcat_gas_mod, do_toggle_active ; Toggle the gas (in)active | 217 MENU_DYNAMIC gaslist_strcat_gas_mod, do_toggle_active ; Toggle the gas (in)active |
224 MENU_CALL tExit, do_exit_divemode_menu | 218 MENU_CALL tExit, do_exit_divemode_menu |
225 MENU_END | 219 MENU_END |
226 | 220 |
227 | 221 |
228 do_switch_gas6: | 222 do_switch_gas6: |
229 movlw .6 ; gas 6 | 223 movlw .6 ; gas 6 |
230 movwf menupos ; transfer register for selected gas towards gas_switched_common: | 224 movwf menupos1 ; transfer register for selected gas towards gas_switched_common: |
231 bsf gas6_changed ; set flag for profile recording | 225 bsf gas6_changed ; set flag for profile recording |
232 ;bra do_switch_gas ; continue with common gas-switched code | 226 ;bra do_switch_gas ; continue with common gas-switched code |
233 | 227 |
234 do_switch_gas: | 228 do_switch_gas: |
235 bsf divemode_gaschange ; Set flag, will also trigger restart of deco_engine | 229 bsf divemode_gaschange ; Set flag, will also trigger restart of deco_engine |
236 btfsc is_bailout_menu ; Bailout confirmed? | 230 btfsc is_bailout_menu ; Bailout confirmed? |
237 bsf is_bailout ; begin bailout mode | 231 bsf is_bailout ; begin bailout mode |
238 call customview_mask ; update custom view mask to (eventually) rewrite ppO2(Dil): to ppO2: | 232 call customview_mask ; update custom view mask to (eventually) rewrite ppO2(Dil): to ppO2: |
239 ;bra do_exit_divemode_menu ; continue with exiting menu code | 233 ;bra do_exit_divemode_menu ; continue with exiting menu code |
240 | 234 |
241 do_exit_divemode_menu: | 235 do_exit_divemode_menu: |
242 extern timeout_divemode_menu2 | |
243 call timeout_divemode_menu2 | 236 call timeout_divemode_menu2 |
244 clrf STKPTR | 237 clrf STKPTR |
245 extern diveloop_loop4 | |
246 goto diveloop_loop4 | 238 goto diveloop_loop4 |
247 | 239 |
248 | 240 |
249 do_toggle_active: | 241 do_toggle_active: |
250 extern restart_deco_engine_wo_ceiling | 242 extern restart_deco_engine_wo_ceiling |
251 call restart_deco_engine_wo_ceiling | 243 call restart_deco_engine_wo_ceiling |
252 movlw .5 | 244 movlw .5 |
253 btfsc ccr_diluent_setup ; diluents? | 245 btfsc ccr_diluent_setup ; diluents? |
254 addwf menupos,F ; yes 1-5 -> 6-10 | 246 addwf menupos1,F ; yes 1-5 -> 6-10 |
255 decf menupos,W ; -> 0-4 for gases / 5-9 for diluents | 247 decf menupos1,W ; -> 0-4 for gases / 5-9 for diluents |
256 lfsr FSR1,opt_gas_type+0 | 248 lfsr FSR1,opt_gas_type+0 |
257 movff PLUSW1,lo | 249 movff PLUSW1,lo |
258 tstfsz lo ; Already disabled? | 250 tstfsz lo ; Already disabled? |
259 bra do_toggle_active2 ; No, disable now! | 251 bra do_toggle_active2 ; No, disable now! |
260 lfsr FSR1,opt_gas_type_backup+0 ; copy opt_gas_type_backup+W back to opt_gas_type+W | 252 lfsr FSR1,opt_gas_type_backup+0 ; copy opt_gas_type_backup+W back to opt_gas_type+W |
261 movff PLUSW1,lo | 253 movff PLUSW1,lo |
262 lfsr FSR1,opt_gas_type+0 | 254 lfsr FSR1,opt_gas_type+0 |
263 movff lo,PLUSW1 | 255 movff lo,PLUSW1 |
264 lfsr FSR1,opt_OC_bail_gas_change_backup+0 ; copy opt_OC_bail_gas_change_backup+W back to opt_OC_bail_gas_change+W | 256 lfsr FSR1,opt_OC_bail_gas_change_backup+0 ; copy opt_OC_bail_gas_change_backup+W back to opt_OC_bail_gas_change+W |
265 movff PLUSW1,lo | 257 movff PLUSW1,lo |
266 lfsr FSR1,opt_OC_bail_gas_change+0 | 258 lfsr FSR1,opt_OC_bail_gas_change+0 |
267 movff lo,PLUSW1 | 259 movff lo,PLUSW1 |
268 bra do_toggle_active3 | 260 bra do_toggle_active3 |
269 do_toggle_active2: | 261 do_toggle_active2: |
270 clrf PLUSW1 ; 0=Disabled, 1=First, 2=Travel, 3=Deco | 262 clrf PLUSW1 ; 0=Disabled, 1=First, 2=Travel, 3=Deco |
271 lfsr FSR1,opt_OC_bail_gas_change+0 | 263 lfsr FSR1,opt_OC_bail_gas_change+0 |
272 clrf PLUSW1 ; also delete change depth here to have the menu updated immediately | 264 clrf PLUSW1 ; also delete change depth here to have the menu updated immediately |
273 do_toggle_active3: | 265 do_toggle_active3: |
274 movlw .5 | 266 movlw .5 |
275 btfsc ccr_diluent_setup ; use OC gases? | 267 btfsc ccr_diluent_setup ; use OC gases? |
276 subwf menupos,F ; Back to 1-5 | 268 subwf menupos1,F ; back to 1-5 |
277 bra do_lost_gas_loop ; Return to list and show updated result | 269 bra do_lost_gas ; return to list and show updated result |
278 | 270 |
279 | 271 |
280 do_dive_pO2: | 272 do_dive_pO2: |
281 banksel gas6_O2_ratio | 273 banksel gas6_O2_ratio |
282 incf gas6_O2_ratio,F ; O2++ | 274 incf gas6_O2_ratio,F ; O2++ |
283 movf gas6_He_ratio,W | 275 movf gas6_He_ratio,W |
284 addwf gas6_O2_ratio,W | 276 addwf gas6_O2_ratio,W |
285 movwf gas6_temp | 277 movwf gas6_temp |
286 movlw .101 | 278 movlw .101 |
287 cpfslt gas6_temp ; O2+He<101? | 279 cpfslt gas6_temp ; O2 + He < 101 ? |
288 decf gas6_O2_ratio,F ; O2-- (Unchanged) | 280 decf gas6_O2_ratio,F ; O2-- (unchanged) |
289 banksel common | 281 banksel common |
290 bra do_divemode_gaslist_more_loop | 282 bra do_divemode_gaslist_more_common |
291 | 283 |
292 do_dive_mO2: | 284 do_dive_mO2: |
293 banksel gas6_O2_ratio | 285 banksel gas6_O2_ratio |
294 decf gas6_O2_ratio,F ; O2-- | 286 decf gas6_O2_ratio,F ; O2-- |
295 movlw gaslist_min_o2 | 287 movlw gaslist_min_o2 |
296 cpfslt gas6_O2_ratio | 288 cpfslt gas6_O2_ratio ; O2 < minimum allowed %O2? |
297 bra do_dive_mO2_done | 289 bra do_dive_mO2_done ; NO |
298 movlw gaslist_min_o2 | 290 movlw gaslist_min_o2 ; YES - restore minimum |
299 movwf gas6_O2_ratio | 291 movwf gas6_O2_ratio |
300 do_dive_mO2_done: | 292 do_dive_mO2_done: |
301 banksel common | 293 banksel common |
302 bra do_divemode_gaslist_more_loop | 294 bra do_divemode_gaslist_more_common |
303 | 295 |
304 do_dive_pHe: | 296 do_dive_pHe: |
305 banksel gas6_O2_ratio | 297 banksel gas6_O2_ratio |
306 incf gas6_He_ratio,F ; He++ | 298 incf gas6_He_ratio,F ; He++ |
307 movf gas6_He_ratio,W | 299 movf gas6_He_ratio,W |
308 addwf gas6_O2_ratio,W | 300 addwf gas6_O2_ratio,W |
309 movwf lo | 301 movwf lo |
310 movlw .101 | 302 movlw .101 |
311 cpfslt lo ; O2+He<101? | 303 cpfslt lo ; O2 + He < 101 ? |
312 decf gas6_He_ratio,F ; Yes, He-- (Unchanged) | 304 decf gas6_He_ratio,F ; Yes, He-- (Unchanged) |
313 banksel common | 305 banksel common |
314 bra do_divemode_gaslist_more_loop | 306 bra do_divemode_gaslist_more_common |
315 | 307 |
316 do_dive_mHe: | 308 do_dive_mHe: |
317 banksel gas6_O2_ratio | 309 banksel gas6_O2_ratio |
318 decf gas6_He_ratio,F ; He-- | 310 decf gas6_He_ratio,F ; He-- |
319 bnn do_dive_mHe_done | 311 bnn do_dive_mHe_done ; H2 < 0? |
320 clrf gas6_He_ratio | 312 clrf gas6_He_ratio ; YES - reset to 0 |
321 do_dive_mHe_done: | 313 do_dive_mHe_done: |
322 banksel common | 314 banksel common |
323 bra do_divemode_gaslist_more_loop | 315 bra do_divemode_gaslist_more_common |
316 | |
324 | 317 |
325 do_divemode_splist: | 318 do_divemode_splist: |
326 bsf short_gas_decriptions | 319 bsf short_gas_decriptions |
327 movlw .1 | 320 movlw .1 |
328 movwf menupos ; Set to first option in divemode menu | 321 movwf menupos1 ; set to first option in divemode menu |
329 | 322 |
330 movf hardware_flag,W | 323 do_divemode_splist_common: |
331 sublw 0x11 ; 2 with BLE | 324 btfsc analog_o2_input ; do we have an analog input? |
332 btfsc STATUS,Z | 325 bra do_divemode_splist_sensor ; YES |
333 bra do_divemode_splist_no_sensor ; no sensor | 326 btfsc s8_digital ; do we have a digital input? |
334 movf hardware_flag,W | 327 bra do_divemode_splist_sensor ; YES |
335 sublw 0x13 ; + | |
336 btfsc STATUS,Z | |
337 bra do_divemode_splist_no_sensor ; no sensor | |
338 | |
339 do_divemode_splist_with_sensor: | |
340 MENU_BEGIN tGaslist, .6 | |
341 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
342 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
343 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
344 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
345 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
346 MENU_CALL tCCRSensor, do_divemode_sensor | |
347 MENU_END | |
348 | 328 |
349 do_divemode_splist_no_sensor: | 329 do_divemode_splist_no_sensor: |
350 MENU_BEGIN tGaslist, .5 | 330 MENU_BEGIN tGaslist, .5 |
351 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | 331 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp |
352 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | 332 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp |
353 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | 333 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp |
354 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | 334 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp |
355 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | 335 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp |
356 MENU_END | 336 MENU_END |
337 | |
338 do_divemode_splist_sensor: | |
339 MENU_BEGIN tGaslist, .6 | |
340 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
341 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
342 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
343 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
344 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
345 MENU_CALL tCCRSensor, do_divemode_sensor | |
346 MENU_END | |
357 | 347 |
358 | 348 |
359 do_divemode_sensor: | 349 do_divemode_sensor: |
360 clrf menupos3 ; show customview 1 (HUD Data) | 350 clrf menupos3 ; show customview 1 (HUD Data) |
361 bsf toggle_customview | 351 bsf toggle_customview |
362 movlw .1 | 352 movlw .1 |
363 movwf menupos ; Set to 1st option: use sensors | 353 movwf menupos1 ; Set to 1st option: use sensors |
364 do_divemode_sensor_loop: | 354 |
365 MENU_BEGIN tGaslist, .6 | 355 do_return_divemode_sensor: |
366 MENU_CALL tDivemenu_UseSensor, do_switch_sensor | 356 MENU_BEGIN tGaslist, .6 |
357 MENU_CALL tDivemenu_UseSensor, do_switch_sensor | |
367 MENU_CALL tBack, do_divemode_splist | 358 MENU_CALL tBack, do_divemode_splist |
368 MENU_CALL tExit, do_exit_divemode_menu | 359 MENU_CALL tExit, do_exit_divemode_menu |
369 MENU_CALL tDiveHudMask1, do_toggle_sensor | 360 MENU_CALL tDiveHudMask1, do_toggle_sensor |
370 MENU_CALL tDiveHudMask2, do_toggle_sensor | 361 MENU_CALL tDiveHudMask2, do_toggle_sensor |
371 MENU_CALL tDiveHudMask3, do_toggle_sensor | 362 MENU_CALL tDiveHudMask3, do_toggle_sensor |
372 MENU_END | 363 MENU_END |
373 | 364 |
374 do_divemode_setpoint_pscr: | 365 do_divemode_setpoint_pscr: |
375 movlw .1 | 366 movlw .1 |
376 movwf menupos ; Set to 1st option: use calculated ppO2 | 367 movwf menupos1 ; Set to 1st option: use calculated ppO2 |
377 MENU_BEGIN tGaslist, .6 | 368 MENU_BEGIN tGaslist, .6 |
378 MENU_CALL tCalculated, do_switch_sp_calc | 369 MENU_CALL tCalculated, do_switch_sp_calc |
379 MENU_CALL tDivemenu_UseSensor, do_switch_sensor | 370 MENU_CALL tDivemenu_UseSensor, do_switch_sensor |
380 MENU_CALL tExit, do_continue_main_divemenu | 371 MENU_CALL tExit, do_exit_divemode_menu |
381 MENU_CALL tDiveHudMask1, do_toggle_sensor | 372 MENU_CALL tDiveHudMask1, do_toggle_sensor |
382 MENU_CALL tDiveHudMask2, do_toggle_sensor | 373 MENU_CALL tDiveHudMask2, do_toggle_sensor |
383 MENU_CALL tDiveHudMask3, do_toggle_sensor | 374 MENU_CALL tDiveHudMask3, do_toggle_sensor |
384 MENU_END | 375 MENU_END |
376 | |
385 | 377 |
386 do_toggle_sensor: | 378 do_toggle_sensor: |
387 movff menupos,lo ; backup position | 379 movff menupos1,lo ; backup position |
388 decf menupos,f ; 4, 5, 6 -> 3, 4, 5 | 380 decf menupos1,f ; 4, 5, 6 -> 3, 4, 5 |
389 decf menupos,f ; 3, 4, 5 -> 2, 3, 4 | 381 decf menupos1,f ; 3, 4, 5 -> 2, 3, 4 |
390 decf menupos,f ; 2, 3, 4 -> 1, 2, 3 | 382 decf menupos1,f ; 2, 3, 4 -> 1, 2, 3 |
391 dcfsnz menupos ; 1, 2, 3 -> 0, 1, 2 | 383 dcfsnz menupos1 ; 1, 2, 3 -> 0, 1, 2 |
392 btg use_O2_sensor1 ; = | 384 btg use_O2_sensor1 ; = |
393 dcfsnz menupos ; 0, 1, 2 -> -1, 0, 1 | 385 dcfsnz menupos1 ; 0, 1, 2 -> -1, 0, 1 |
394 btg use_O2_sensor2 ; = | 386 btg use_O2_sensor2 ; = |
395 dcfsnz menupos ; -1,0, 1 -> -2,-1, 0 | 387 dcfsnz menupos1 ; -1,0, 1 -> -2,-1, 0 |
396 btg use_O2_sensor3 ; = | 388 btg use_O2_sensor3 ; = |
397 movff lo,menupos ; reload position | 389 movff lo,menupos1 ; restore position |
398 bra do_divemode_sensor_loop | 390 bra do_return_divemode_sensor |
399 | 391 |
400 | 392 END |
401 END |