Mercurial > public > hwos_code
comparison src/divemenu_tree.asm @ 623:c40025d8e750
3.03 beta released
| author | heinrichsweikamp |
|---|---|
| date | Mon, 03 Jun 2019 14:01:48 +0200 |
| parents | ca4556fb60b9 |
| children | 185ba2f91f59 |
comparison
equal
deleted
inserted
replaced
| 622:02d1386429a6 | 623:c40025d8e750 |
|---|---|
| 1 ;============================================================================= | 1 ;============================================================================= |
| 2 ; | 2 ; |
| 3 ; File divemenu_tree.asm REFACTORED VERSION V2.99e | 3 ; File divemenu_tree.asm combined next generation V3.03.4 |
| 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 rights 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 |
| 17 #include "strings.inc" | 17 #include "strings.inc" |
| 18 #include "calibrate.inc" | 18 #include "calibrate.inc" |
| 19 | 19 |
| 20 extern timeout_divemode_menu2 | 20 extern timeout_divemode_menu2 |
| 21 extern restart_deco_engine_wo_ceiling | 21 extern restart_deco_engine_wo_ceiling |
| 22 extern diveloop_loop4 | 22 extern diveloop_menu_exit |
| 23 | 23 |
| 24 | 24 |
| 25 dmenu_tree CODE | 25 dmenu_tree CODE |
| 26 | 26 |
| 27 ;============================================================================= | 27 ;============================================================================= |
| 28 ; Main Menu | 28 ; Main Menu |
| 29 | 29 |
| 30 do_return_main_divemenu: | 30 do_return_main_divemenu: |
| 31 call menu_processor_double_pop ; drop exit line and back to last line | 31 call menu_processor_double_pop ; drop exit line and back to last line |
| 32 incf selected_item,W ; item numbers start with 0, menu positions with 1 | 32 incf selected_item,W ; item numbers start with 0, menu positions with 1 |
| 33 movwf menupos1 ; position cursor where we came from | 33 movwf menu_pos_cur ; position cursor where we came from |
| 34 bra do_main_divemenu_common | 34 bra do_main_divemenu_common |
| 35 | 35 |
| 36 global do_main_divemenu | 36 global do_main_divemenu |
| 37 do_main_divemenu: | 37 do_main_divemenu: |
| 38 call menu_processor_reset ; restart from first icon | 38 call menu_processor_reset ; restart from first icon |
| 39 movlw .1 | 39 movlw .1 |
| 40 movwf menupos1 ; set to first option in divemode menu | 40 movwf menu_pos_cur ; set to first option in dive mode menu |
| 41 | 41 |
| 42 do_main_divemenu_common: | 42 do_main_divemenu_common: |
| 43 IFDEF _ccr_pscr | |
| 43 btfsc FLAG_ccr_mode | 44 btfsc FLAG_ccr_mode |
| 44 bra main_divemenu_loop ; goto CCR / pSCR Menu menu | 45 bra main_divemenu_loop ; goto CCR / pSCR Menu menu |
| 45 btfsc FLAG_pscr_mode | 46 btfsc FLAG_pscr_mode |
| 46 bra main_divemenu_loop ; goto CCR / pSCR Menu menu | 47 bra main_divemenu_loop ; goto CCR / pSCR Menu menu |
| 48 ENDIF | |
| 47 | 49 |
| 48 main_divemenu_OC: | 50 main_divemenu_OC: |
| 49 bcf FLAG_diluent_setup ; set to operations on OC gases | 51 IFDEF _ccr_pscr |
| 50 bcf is_bailout_menu | 52 bcf is_diluent_menu ; selecting OC gases ... |
| 53 bcf is_bailout_menu ; ... not for bailout reason | |
| 54 ENDIF | |
| 51 | 55 |
| 52 IFDEF _cave_mode | 56 IFDEF _cave_mode |
| 53 btfss FLAG_cave_mode ; in cave mode? | 57 btfss cave_mode ; in cave mode? |
| 54 bra main_divemenu_OC_no_cave ; NO - do OC menu without turn option | 58 bra main_divemenu_OC_no_cave ; NO - do OC menu without turn option |
| 55 | 59 |
| 56 MENU_BEGIN tMainMenu, .6 | 60 MENU_BEGIN tMainMenu, .6 |
| 57 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist | 61 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist |
| 58 MENU_CALL tDivemenu_ResetAvg, do_reset_average | 62 MENU_CALL tDivemenu_ResetAvg, do_reset_average |
| 70 MENU_DYNAMIC do_toggle_gf_label, do_toggle_gf | 74 MENU_DYNAMIC do_toggle_gf_label, do_toggle_gf |
| 71 MENU_CALL tDivemenu_Marker, do_set_marker | 75 MENU_CALL tDivemenu_Marker, do_set_marker |
| 72 MENU_CALL tExit, do_exit_divemode_menu | 76 MENU_CALL tExit, do_exit_divemode_menu |
| 73 MENU_END | 77 MENU_END |
| 74 | 78 |
| 79 ;============================================================================= | |
| 80 | |
| 81 IFDEF _ccr_pscr | |
| 75 | 82 |
| 76 main_divemenu_loop: | 83 main_divemenu_loop: |
| 77 bsf FLAG_diluent_setup ; set to operations on diluents | 84 bsf is_diluent_menu ; selecting diluents ... |
| 78 bcf is_bailout_menu ; flag as none-bailout menu | 85 bcf is_bailout_menu ; ... (definitely) not for bailout reason |
| 79 btfsc FLAG_pscr_mode | 86 btfsc FLAG_pscr_mode |
| 80 bra main_divemenu_pscr ; pSCR menu | 87 bra main_divemenu_pscr ; pSCR menu |
| 81 | 88 |
| 82 MENU_BEGIN tMainMenu, .6 | 89 MENU_BEGIN tMainMenu, .6 |
| 83 MENU_CALL tDiveBailout, do_divemode_gaslist_bail | 90 MENU_CALL tDiveBailout, do_divemode_gaslist_bail |
| 86 MENU_CALL tDivemenu_Avg_Mkr, do_reset_avg_set_mkr | 93 MENU_CALL tDivemenu_Avg_Mkr, do_reset_avg_set_mkr |
| 87 MENU_DYNAMIC do_toggle_gf_label, do_toggle_gf | 94 MENU_DYNAMIC do_toggle_gf_label, do_toggle_gf |
| 88 MENU_CALL tExit, do_exit_divemode_menu | 95 MENU_CALL tExit, do_exit_divemode_menu |
| 89 MENU_END | 96 MENU_END |
| 90 | 97 |
| 98 | |
| 91 main_divemenu_pscr: | 99 main_divemenu_pscr: |
| 100 | |
| 101 IFDEF _external_sensor | |
| 92 btfsc analog_o2_input ; do we have an analog input (OSTC cR)? | 102 btfsc analog_o2_input ; do we have an analog input (OSTC cR)? |
| 93 bra main_divemenu_pscr_sensors ; YES | 103 bra main_divemenu_pscr_sensors ; YES |
| 94 btfsc optical_input ; do we have an optical input (OSTC 3)? | 104 btfsc optical_input ; do we have an optical input (OSTC 3)? |
| 95 bra main_divemenu_pscr_sensors ; YES | 105 bra main_divemenu_pscr_sensors ; YES |
| 106 ENDIF | |
| 96 | 107 |
| 97 main_divemenu_pscr_no_sensors: | 108 main_divemenu_pscr_no_sensors: |
| 98 MENU_BEGIN tMainMenu, .6 | 109 MENU_BEGIN tMainMenu, .6 |
| 99 MENU_CALL tDiveBailout, do_divemode_gaslist_bail | 110 MENU_CALL tDiveBailout, do_divemode_gaslist_bail |
| 100 MENU_CALL tDivemenu_Premix, do_divemode_gaslist | 111 MENU_CALL tDivemenu_Premix, do_divemode_gaslist |
| 102 MENU_CALL tDivemenu_Avg_Mkr, do_reset_avg_set_mkr | 113 MENU_CALL tDivemenu_Avg_Mkr, do_reset_avg_set_mkr |
| 103 MENU_DYNAMIC do_toggle_gf_label, do_toggle_gf | 114 MENU_DYNAMIC do_toggle_gf_label, do_toggle_gf |
| 104 MENU_CALL tExit, do_exit_divemode_menu | 115 MENU_CALL tExit, do_exit_divemode_menu |
| 105 MENU_END | 116 MENU_END |
| 106 | 117 |
| 118 | |
| 119 IFDEF _external_sensor | |
| 107 main_divemenu_pscr_sensors: | 120 main_divemenu_pscr_sensors: |
| 108 MENU_BEGIN tMainMenu, .6 | 121 MENU_BEGIN tMainMenu, .6 |
| 109 MENU_CALL tDiveBailout, do_divemode_gaslist_bail | 122 MENU_CALL tDiveBailout, do_divemode_gaslist_bail |
| 110 MENU_CALL tCCRSensor, do_divemode_setpoint_pscr | 123 MENU_CALL tCCRSensor, do_divemode_setpoint_pscr |
| 111 MENU_CALL tDivemenu_Premix, do_divemode_gaslist | 124 MENU_CALL tDivemenu_Premix, do_divemode_gaslist |
| 112 MENU_CALL tDivemenu_Avg_Mkr, do_reset_avg_set_mkr | 125 MENU_CALL tDivemenu_Avg_Mkr, do_reset_avg_set_mkr |
| 113 MENU_DYNAMIC do_toggle_gf_label, do_toggle_gf | 126 MENU_DYNAMIC do_toggle_gf_label, do_toggle_gf |
| 114 MENU_CALL tExit, do_exit_divemode_menu | 127 MENU_CALL tExit, do_exit_divemode_menu |
| 115 MENU_END | 128 MENU_END |
| 116 | 129 ENDIF ; _external_sensor |
| 130 | |
| 131 ENDIF ; _ccr_pscr | |
| 132 | |
| 133 ;============================================================================= | |
| 117 | 134 |
| 118 do_toggle_gf: | 135 do_toggle_gf: |
| 119 TSTOSS char_I_deco_model ; toggle GF only in GF modes - in GF mode? (0 = ZH-L16, 1 = ZH-L16-GF) | 136 TSTOSS char_I_deco_model ; toggle GF only in GF modes - in GF mode? (0 = ZH-L16, 1 = ZH-L16-GF) |
| 120 bra do_main_divemenu_common ; NO - do nothing and return | 137 bra do_main_divemenu_common ; NO - do nothing and return |
| 121 TSTOSS opt_enable_aGF ; =1: aGF can be selected underwater | 138 TSTOSS opt_enable_aGF ; =1: aGF can be selected underwater |
| 122 bra do_main_divemenu_common ; NO - do nothing and return | 139 bra do_main_divemenu_common ; NO - do nothing and return |
| 123 movlw index_gf_factors-1 ; custom view number one below GF factors | 140 movlw index_gf_factors-1 ; custom view number one below GF factors |
| 124 movwf menupos3 ; set custom view number | 141 movwf active_customview ; set custom view number |
| 125 bsf toggle_customview ; initiate toggle to desired custom view -> GF factors | 142 bsf request_next_custview ; initiate toggle to desired custom view -> GF factors |
| 126 movlw .1 | 143 movlw .1 |
| 127 movwf menupos1 ; set to first option in dive mode menu | 144 movwf menu_pos_cur ; set to first option in dive mode menu |
| 128 | 145 |
| 129 MENU_BEGIN tDivemenu_ToggleGF, .2 | 146 MENU_BEGIN tDivemenu_ToggleGF, .2 |
| 130 MENU_CALL tDivemenu_ToggleGF, do_togglegf | 147 MENU_CALL tDivemenu_ToggleGF, do_togglegf |
| 131 MENU_CALL tBack, do_return_main_divemenu | 148 MENU_CALL tBack, do_return_main_divemenu |
| 132 MENU_END | 149 MENU_END |
| 133 | 150 |
| 134 do_togglegf: | 151 do_togglegf: |
| 135 bsf toggle_gf ; set command flag... | 152 bsf request_toggle_GF ; set request flag |
| 136 bra do_exit_divemode_menu ; continue with exiting menu code | 153 bra do_exit_divemode_menu ; continue with exiting menu code |
| 137 | 154 |
| 138 | 155 |
| 139 do_reset_avg_set_mkr: | 156 do_reset_avg_set_mkr: |
| 140 movlw .1 | 157 movlw .1 |
| 141 movwf menupos1 ; set to first option in dive mode menu | 158 movwf menu_pos_cur ; set to first option in dive mode menu |
| 142 | 159 |
| 143 IFDEF _cave_mode | 160 IFDEF _cave_mode |
| 144 btfss FLAG_cave_mode ; in cave mode? | 161 btfss cave_mode ; in cave mode? |
| 145 bra do_reset_average_no_cave ; NO - do menu without turn option | 162 bra do_reset_average_no_cave ; NO - do menu without turn option |
| 146 | 163 |
| 147 MENU_BEGIN tDivemenu_Avg_Mkr, .4 | 164 MENU_BEGIN tDivemenu_Avg_Mkr, .4 |
| 148 MENU_CALL tDivemenu_ResetAvg, do_reset_average | 165 MENU_CALL tDivemenu_ResetAvg, do_reset_average |
| 149 MENU_CALL tDivemenu_Marker, do_set_marker | 166 MENU_CALL tDivemenu_Marker, do_set_marker |
| 159 MENU_CALL tBack, do_return_main_divemenu | 176 MENU_CALL tBack, do_return_main_divemenu |
| 160 MENU_END | 177 MENU_END |
| 161 | 178 |
| 162 | 179 |
| 163 do_reset_average: | 180 do_reset_average: |
| 164 bsf reset_average_depth ; set flag... | 181 bsf request_reset_avg ; request reset of resettable average depth and dive time |
| 165 bra do_exit_divemode_menu ; ... and exit | 182 IFDEF _min_depth_option |
| 183 bsf reset_trip_pressure ; request ISR to reset the min and max trip-wise pressures | |
| 184 ENDIF | |
| 185 bra do_exit_divemode_menu ; exit | |
| 186 | |
| 166 | 187 |
| 167 do_set_marker: | 188 do_set_marker: |
| 168 bsf FLAG_set_marker ; set flag... | 189 bsf request_set_marker ; set request flag |
| 169 bra do_exit_divemode_menu ; ... and exit | 190 bra do_exit_divemode_menu ; exit |
| 191 | |
| 170 | 192 |
| 171 IFDEF _cave_mode | 193 IFDEF _cave_mode |
| 172 do_turn_dive: | 194 do_turn_dive: |
| 173 bsf toggle_turn_dive ; set flag... | 195 bsf request_turn_dive ; set request flag |
| 174 bra do_exit_divemode_menu ; ... and exit | 196 bra do_exit_divemode_menu ; exit |
| 175 ENDIF | 197 ENDIF |
| 176 | 198 |
| 177 | 199 |
| 200 IFDEF _external_sensor | |
| 178 do_switch_sensor: ; entry point when coming from switch to sensor | 201 do_switch_sensor: ; entry point when coming from switch to sensor |
| 179 movlw .1 ; switch to sensor | 202 movlw .1 ; switch to sensor |
| 180 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP | 203 movff WREG,opt_ccr_mode ; =0: fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP |
| 181 ; enable all sensors | |
| 182 bsf use_O2_sensor1 | |
| 183 bsf use_O2_sensor2 | |
| 184 bsf use_O2_sensor3 | |
| 185 bra do_switch_sp_com ; continue with common part | 204 bra do_switch_sp_com ; continue with common part |
| 205 ENDIF | |
| 206 | |
| 207 ;============================================================================= | |
| 208 | |
| 209 IFDEF _ccr_pscr | |
| 186 | 210 |
| 187 do_switch_sp: ; entry point when coming from manual setpoint selection (CCR) | 211 do_switch_sp: ; entry point when coming from manual setpoint selection (CCR) |
| 188 decf menupos1,W ; 1-5 -> 0-4 | 212 decf menu_pos_cur,W ; 1-5 -> 0-4 |
| 189 lfsr FSR1,char_I_setpoint_cbar | 213 lfsr FSR1,opt_setpoint_cbar |
| 190 movff PLUSW1,char_I_const_ppO2 ; setup fixed setpoint | 214 movff PLUSW1,char_I_const_ppO2 ; setup fixed setpoint |
| 191 movff char_I_const_ppO2,WREG | 215 IFDEF _external_sensor |
| 192 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics | 216 call transmit_setpoint ; transmit current setpoint from WREG (in cbar) to external electronics |
| 193 bcf setpoint_fallback ; clear fallback condition (stops fallback warning) | 217 ENDIF |
| 218 bcf sp_fallback ; clear fallback condition (stops fallback warning) | |
| 194 clrf WREG ; switch to fixed SP | 219 clrf WREG ; switch to fixed SP |
| 195 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP | 220 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP |
| 196 bra do_switch_sp_com | 221 bra do_switch_sp_com |
| 197 | 222 |
| 223 | |
| 198 do_switch_sp_calc: ; entry point when coming from switch to calculated ppO2 (pSCR) | 224 do_switch_sp_calc: ; entry point when coming from switch to calculated ppO2 (pSCR) |
| 199 bcf setpoint_fallback ; clear fallback condition (stops fallback warning) | 225 bcf sp_fallback ; clear fallback condition (stops fallback warning) |
| 200 clrf WREG ; Switch to fixed SP | 226 clrf WREG ; switch to fixed SP |
| 201 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP | 227 movff WREG,opt_ccr_mode ; =0: Fixed SP (CCR) / calculated (pSCR), =1: Sensor, =2: Auto SP |
| 202 movff WREG,char_I_const_ppO2 ; set setpoint to 0, this forces deco engine to take the computed ppO2 | 228 movff WREG,char_I_const_ppO2 ; set setpoint to 0, this forces deco engine to take the computed ppO2 |
| 203 | 229 ;bra do_switch_sp_com |
| 204 do_switch_sp_com: ; merge point to common part | 230 |
| 205 bsf event_occured ; set global event byte | 231 |
| 206 bsf setpoint_changed ; set flag (for profile) | 232 do_switch_sp_com: ; common part |
| 233 bsf event_occured ; set global event byte | |
| 234 bsf event_SP_change ; set setpoint event flag | |
| 207 | 235 |
| 208 ; Clear some flags in case we were in bailout before... | 236 ; Clear some flags in case we were in bailout before... |
| 209 bcf FLAG_bailout_mode ; end bailout mode | 237 bcf bailout_mode ; end bailout mode |
| 210 ;bcf is_bailout_menu ; not needed | |
| 211 bcf better_gas_available ; =1: a better gas is available and a gas change is advised in dive mode | 238 bcf better_gas_available ; =1: a better gas is available and a gas change is advised in dive mode |
| 212 bcf better_dil_available ; =1: a better diluent is available and a gas change is advised in dive mode | 239 bcf better_dil_available ; =1: a better diluent is available and a gas change is advised in dive mode |
| 213 bcf blinking_better_gas ; clear blinking flag | 240 bcf better_gas_blinking ; clear blinking flag |
| 214 bcf blinking_better_dil ; clear blinking flag | 241 bcf better_dil_blinking ; clear blinking flag |
| 215 bsf redraw_custview_mask ; request update of custom view mask to (eventually) rewrite "ppO2(Dil)" to "ppO2" or SAC label | 242 call dive_customview_mask ; redraw custom view mask to (eventually) rewrite "ppO2(Dil)" to "ppO2" or SAC label |
| 216 | 243 |
| 217 bsf FLAG_back_to_loop ; indicate that it is a switchback from OC bailout to CCR/pSCR loop | 244 bsf request_back_to_loop ; indicate that it is a switchback from OC bailout to CCR/pSCR loop |
| 218 bsf divemode_gaschange ; initiate reconfiguration to loop mode on last diluent | 245 bsf request_gaschange ; initiate reconfiguration to loop mode on last diluent |
| 219 | 246 |
| 220 bra do_exit_divemode_menu ; continue with exiting menu code | 247 bra do_exit_divemode_menu ; continue with exiting menu code |
| 221 | 248 |
| 222 | 249 |
| 223 do_divemode_gaslist_bail: ; entry point from CCR/pSCR to bailout to OC gases | 250 do_divemode_gaslist_bail: ; entry point from CCR/pSCR to bailout to OC gases |
| 224 bcf FLAG_diluent_setup ; switch to OC gases | 251 bcf is_diluent_menu ; select OC gases |
| 225 bsf is_bailout_menu ; flag it is a bailout action | 252 bsf is_bailout_menu ; flag it is a bailout action |
| 253 ;bra do_divemode_gaslist | |
| 254 | |
| 255 ENDIF ; _ccr_pscr | |
| 256 | |
| 257 ;============================================================================= | |
| 258 | |
| 226 do_divemode_gaslist: ; entry point for switching: OC -> gases, loop -> diluents | 259 do_divemode_gaslist: ; entry point for switching: OC -> gases, loop -> diluents |
| 227 btfsc FLAG_bailout_mode ; in bailout mode? | 260 IFDEF _ccr_pscr |
| 228 bcf FLAG_diluent_setup ; yes - for safety reasons, redirect to OC (bailout) gases | 261 btfsc bailout_mode ; in bailout mode? |
| 229 bsf short_gas_decriptions ; do not show "Gas x" etc. | 262 bcf is_diluent_menu ; YES - for safety reasons, redirect to selecting OC (bailout) gases |
| 263 ENDIF | |
| 264 bsf short_gas_descriptions ; do not show "Gas x" etc. | |
| 230 bsf better_gas_hint ; mark the gas which is the best gas/diluent | 265 bsf better_gas_hint ; mark the gas which is the best gas/diluent |
| 231 movf best_gas_number,W ; load number of best gas (1-5)into WREG | 266 movf best_gas_number,W ; load number of best gas (1-5)into WREG |
| 232 btfsc FLAG_diluent_setup ; in diluent selection? | 267 IFDEF _ccr_pscr |
| 268 btfsc is_diluent_menu ; in diluent selection? | |
| 233 movf best_dil_number,W ; YES - overwrite with best diluent (1-5) | 269 movf best_dil_number,W ; YES - overwrite with best diluent (1-5) |
| 270 ENDIF | |
| 234 bnz do_divemode_gaslist_1 ; best gas/dil number = 0 (none available) ? | 271 bnz do_divemode_gaslist_1 ; best gas/dil number = 0 (none available) ? |
| 235 movlw .1 ; YES - default to first gas/dil | 272 movlw .1 ; YES - default to first gas/dil |
| 236 btfsc WREG,7 ; best gas/dil number >= 128 (not computed yet) ? | 273 btfsc WREG,7 ; best gas/dil number >= 128 (not computed yet) ? |
| 237 movlw .1 ; YES - default to first gas/dil | 274 movlw .1 ; YES - default to first gas/dil |
| 238 do_divemode_gaslist_1: | 275 do_divemode_gaslist_1: |
| 239 movwf menupos1 ; position cursor to best gas/dil (or first option if none avail) | 276 movwf menu_pos_cur ; position cursor to best gas/dil (or first option if none avail) |
| 240 MENU_BEGIN tGaslist, .6 | 277 MENU_BEGIN tGaslist, .6 |
| 241 MENU_DYNAMIC gaslist_strcat_gas_cd, do_switch_gas | 278 MENU_DYNAMIC gaslist_strcat_gas_cd, do_switch_gas |
| 242 MENU_DYNAMIC gaslist_strcat_gas_cd, do_switch_gas | 279 MENU_DYNAMIC gaslist_strcat_gas_cd, do_switch_gas |
| 243 MENU_DYNAMIC gaslist_strcat_gas_cd, do_switch_gas | 280 MENU_DYNAMIC gaslist_strcat_gas_cd, do_switch_gas |
| 244 MENU_DYNAMIC gaslist_strcat_gas_cd, do_switch_gas | 281 MENU_DYNAMIC gaslist_strcat_gas_cd, do_switch_gas |
| 247 MENU_END | 284 MENU_END |
| 248 | 285 |
| 249 | 286 |
| 250 do_divemode_gaslist_more: | 287 do_divemode_gaslist_more: |
| 251 movlw .1 | 288 movlw .1 |
| 252 movwf menupos1 ; set to first option in dive mode menu | 289 movwf menu_pos_cur ; set to first option in dive mode menu |
| 253 | 290 |
| 254 movff char_I_O2_ratio,gas6_O2_ratio ; initialize gas6 with currently breathed gas - O2 ratio | 291 movff char_I_O2_ratio,gas6_O2_ratio ; initialize gas6 with currently breathed gas - O2 ratio |
| 292 IFDEF _helium | |
| 255 movff char_I_He_ratio,gas6_He_ratio ; initialize gas6 with currently breathed gas - He ratio | 293 movff char_I_He_ratio,gas6_He_ratio ; initialize gas6 with currently breathed gas - He ratio |
| 294 ENDIF | |
| 256 | 295 |
| 257 do_divemode_gaslist_more_common: | 296 do_divemode_gaslist_more_common: |
| 297 IFDEF _helium | |
| 258 MENU_BEGIN tGaslist, .6 | 298 MENU_BEGIN tGaslist, .6 |
| 259 MENU_CALL tO2Plus, do_dive_pO2 | 299 MENU_CALL tO2Plus, do_dive_pO2 |
| 260 MENU_CALL tO2Minus, do_dive_mO2 | 300 MENU_CALL tO2Minus, do_dive_mO2 |
| 261 MENU_CALL tHePlus, do_dive_pHe | 301 MENU_CALL tHePlus, do_dive_pHe |
| 262 MENU_CALL tHeMinus, do_dive_mHe | 302 MENU_CALL tHeMinus, do_dive_mHe |
| 263 MENU_DYNAMIC gaslist_strcat_gas6, do_switch_gas6 | 303 MENU_DYNAMIC gaslist_strcat_gas6, do_switch_gas6 |
| 264 MENU_CALL tDivemenu_LostGas, do_lost_gas | 304 MENU_CALL tDivemenu_LostGas, do_lost_gas |
| 265 MENU_END | 305 MENU_END |
| 306 ELSE | |
| 307 MENU_BEGIN tGaslist, .4 | |
| 308 MENU_CALL tO2Plus, do_dive_pO2 | |
| 309 MENU_CALL tO2Minus, do_dive_mO2 | |
| 310 MENU_DYNAMIC gaslist_strcat_gas6, do_switch_gas6 | |
| 311 MENU_CALL tDivemenu_LostGas, do_lost_gas | |
| 312 MENU_CALL tExit, do_exit_divemode_menu | |
| 313 MENU_END | |
| 314 ENDIF | |
| 266 | 315 |
| 267 | 316 |
| 268 do_lost_gas: | 317 do_lost_gas: |
| 269 movlw .1 | 318 movlw .1 |
| 270 movwf menupos1 ; set to first option in dive mode menu | 319 movwf menu_pos_cur ; set to first option in dive mode menu |
| 271 do_lost_gas_common: | 320 do_lost_gas_common: |
| 272 bsf short_gas_decriptions ; do not show "Gas x" etc. | 321 bsf short_gas_descriptions ; do not show "Gas x" etc. |
| 273 bcf better_gas_hint ; do not mark the best gas/diluent | 322 bcf better_gas_hint ; do not mark the best gas/diluent |
| 274 MENU_BEGIN tDivemenu_LostGas, .6 | 323 MENU_BEGIN tDivemenu_LostGas, .6 |
| 275 MENU_DYNAMIC gaslist_strcat_gas_cd, do_toggle_active ; toggle the gas (in)active | 324 MENU_DYNAMIC gaslist_strcat_gas_cd, do_toggle_active ; toggle the gas (in)active |
| 276 MENU_DYNAMIC gaslist_strcat_gas_cd, do_toggle_active ; toggle the gas (in)active | 325 MENU_DYNAMIC gaslist_strcat_gas_cd, do_toggle_active ; toggle the gas (in)active |
| 277 MENU_DYNAMIC gaslist_strcat_gas_cd, do_toggle_active ; toggle the gas (in)active | 326 MENU_DYNAMIC gaslist_strcat_gas_cd, do_toggle_active ; toggle the gas (in)active |
| 281 MENU_END | 330 MENU_END |
| 282 | 331 |
| 283 | 332 |
| 284 do_switch_gas6: | 333 do_switch_gas6: |
| 285 movlw .6 ; gas 6 | 334 movlw .6 ; gas 6 |
| 286 movwf menupos1 ; transfer register for selected gas towards gas_switched_common | 335 movwf menu_pos_cur ; transfer register for selected gas towards gas_switched_common |
| 287 bsf gas6_changed ; set flag for profile recording | 336 bsf event_gas_change_gas6 ; set flag for profile recording |
| 288 ;bra do_switch_gas ; continue with common gas-switched code | 337 ;bra do_switch_gas ; continue with common gas-switched code |
| 289 | 338 |
| 339 | |
| 290 do_switch_gas: | 340 do_switch_gas: |
| 291 bsf divemode_gaschange ; set flag, will also trigger restart of deco_engine | 341 bsf request_gaschange ; initiate gas change, will also trigger restart of deco_engine |
| 292 btfss is_bailout_menu ; doing a bailout? | 342 btfss is_bailout_menu ; doing a bailout? |
| 293 bra do_switch_gas_1 ; NO | 343 bra do_switch_gas_1 ; NO |
| 294 bsf FLAG_bailout_mode ; YES - begin bailout mode | 344 bsf bailout_mode ; YES - begin bailout mode |
| 295 IFDEF _cave_mode | 345 IFDEF _cave_mode |
| 296 btfsc FLAG_cave_mode ; - in cave mode? | 346 btfsc cave_mode ; - in cave mode? |
| 297 bsf FLAG_dive_turned ; YES - set dive as turned | 347 bsf dive_turned ; YES - set dive as turned |
| 298 ENDIF | 348 ENDIF |
| 299 do_switch_gas_1: | 349 do_switch_gas_1: |
| 300 bcf setpoint_fallback ; eventually terminate fallback mode and get rid of its warning | 350 bcf sp_fallback ; eventually terminate fallback mode and get rid of its warning |
| 301 bsf redraw_custview_mask ; request update of custom view mask to (eventually) rewrite "ppO2(Dil)" to "ppO2" or SAC label | 351 call dive_customview_mask ; redraw custom view mask to (eventually) rewrite "ppO2(Dil)" to "ppO2" or SAC label |
| 302 ;bra do_exit_divemode_menu ; continue with exiting menu code | 352 ;bra do_exit_divemode_menu ; continue with exiting menu code |
| 353 | |
| 303 | 354 |
| 304 do_exit_divemode_menu: | 355 do_exit_divemode_menu: |
| 305 call timeout_divemode_menu2 | 356 call timeout_divemode_menu2 |
| 306 clrf STKPTR | 357 clrf STKPTR |
| 307 goto diveloop_loop4 | 358 goto diveloop_menu_exit |
| 308 | 359 |
| 309 | 360 |
| 310 do_toggle_active: | 361 do_toggle_active: |
| 311 movlw .5 | 362 movlw .5 |
| 312 btfsc FLAG_diluent_setup ; operating on diluents? | 363 IFDEF _ccr_pscr |
| 313 addwf menupos1,F ; YES - add offset of 5 to shift 1-5 -> 6-10 | 364 btfsc is_diluent_menu ; operating on diluents? |
| 314 decf menupos1,W ; 1-10 -> 0-4 for gases / 5-9 for diluents | 365 addwf menu_pos_cur,F ; YES - add offset of 5 to shift 1-5 -> 6-10 |
| 366 ENDIF | |
| 367 decf menu_pos_cur,W ; 1-10 -> 0-4 for gases / 5-9 for diluents | |
| 315 lfsr FSR1,opt_gas_type ; load base address of gas types | 368 lfsr FSR1,opt_gas_type ; load base address of gas types |
| 316 movff PLUSW1,lo ; get gas/dil type | 369 movff PLUSW1,lo ; get gas/dil type |
| 317 tstfsz lo ; already disabled? | 370 tstfsz lo ; already disabled? |
| 318 bra do_toggle_active_disable ; NO - disable now | 371 bra do_toggle_active_disable ; NO - disable now |
| 319 do_toggle_active_enable ; YES - re-enable now | 372 do_toggle_active_enable ; YES - re-enable now |
| 325 do_toggle_active_disable: ; disable gas / diluent | 378 do_toggle_active_disable: ; disable gas / diluent |
| 326 ;lfsr FSR1,opt_gas_type ; (still set) | 379 ;lfsr FSR1,opt_gas_type ; (still set) |
| 327 clrf PLUSW1 ; set type to disabled (0=disabled, 1=first, 2=travel/normal, 3=deco/-) | 380 clrf PLUSW1 ; set type to disabled (0=disabled, 1=first, 2=travel/normal, 3=deco/-) |
| 328 do_toggle_active_common: | 381 do_toggle_active_common: |
| 329 movlw .5 | 382 movlw .5 |
| 330 btfsc FLAG_diluent_setup ; operating on diluents? | 383 IFDEF _ccr_pscr |
| 331 subwf menupos1,F ; NO - back to 0-4 for gases 1-5 | 384 btfsc is_diluent_menu ; operating on diluents? |
| 332 bcf blinking_better_gas ; clear blinking flag for gases to avoid "leftovers" | 385 subwf menu_pos_cur,F ; YES - back to 1-5 |
| 333 bcf blinking_better_dil ; clear blinking flag for diluents to avoid "leftovers" | 386 bcf better_dil_blinking ; clear blinking flag for diluents to avoid "leftovers" |
| 387 ENDIF | |
| 388 bcf better_gas_blinking ; clear blinking flag for gases to avoid "leftovers" | |
| 334 call restart_deco_engine_wo_ceiling ; invalidate deco data (but not the ceiling) and restart deco engine | 389 call restart_deco_engine_wo_ceiling ; invalidate deco data (but not the ceiling) and restart deco engine |
| 335 bra do_lost_gas_common | 390 bra do_lost_gas_common |
| 336 | 391 |
| 392 | |
| 337 do_dive_pO2: | 393 do_dive_pO2: |
| 338 banksel gas6_O2_ratio | |
| 339 incf gas6_O2_ratio,F ; O2++ | 394 incf gas6_O2_ratio,F ; O2++ |
| 395 IFDEF _helium | |
| 340 movf gas6_He_ratio,W | 396 movf gas6_He_ratio,W |
| 341 addwf gas6_O2_ratio,W | 397 addwf gas6_O2_ratio,W |
| 342 movwf gas6_temp | 398 ELSE |
| 399 movf gas6_O2_ratio,W | |
| 400 ENDIF | |
| 401 movwf lo | |
| 343 movlw .101 | 402 movlw .101 |
| 344 cpfslt gas6_temp ; O2 + He < 101 ? | 403 cpfslt lo ; O2 + He < 101 ? |
| 345 decf gas6_O2_ratio,F ; O2-- (unchanged) | 404 decf gas6_O2_ratio,F ; O2-- (unchanged) |
| 346 banksel common | |
| 347 bra do_divemode_gaslist_more_common | 405 bra do_divemode_gaslist_more_common |
| 348 | 406 |
| 407 | |
| 349 do_dive_mO2: | 408 do_dive_mO2: |
| 350 banksel gas6_O2_ratio | |
| 351 decf gas6_O2_ratio,F ; O2-- | 409 decf gas6_O2_ratio,F ; O2-- |
| 352 movlw gaslist_min_o2 | 410 movlw gaslist_min_o2 |
| 353 cpfslt gas6_O2_ratio ; O2 < minimum allowed %O2? | 411 cpfslt gas6_O2_ratio ; O2 < minimum allowed %O2 ? |
| 354 bra do_dive_mO2_done ; NO | 412 bra do_dive_mO2_done ; NO |
| 355 movlw gaslist_min_o2 ; YES - restore minimum | 413 movlw gaslist_min_o2 ; YES - restore minimum |
| 356 movwf gas6_O2_ratio | 414 movwf gas6_O2_ratio |
| 357 do_dive_mO2_done: | 415 do_dive_mO2_done: |
| 358 banksel common | |
| 359 bra do_divemode_gaslist_more_common | 416 bra do_divemode_gaslist_more_common |
| 360 | 417 |
| 418 ;============================================================================= | |
| 419 | |
| 420 IFDEF _helium | |
| 421 | |
| 361 do_dive_pHe: | 422 do_dive_pHe: |
| 362 banksel gas6_O2_ratio | |
| 363 incf gas6_He_ratio,F ; He++ | 423 incf gas6_He_ratio,F ; He++ |
| 364 movf gas6_He_ratio,W | 424 movf gas6_He_ratio,W |
| 365 addwf gas6_O2_ratio,W | 425 addwf gas6_O2_ratio,W |
| 366 movwf lo | 426 movwf lo |
| 367 movlw .101 | 427 movlw .101 |
| 368 cpfslt lo ; O2 + He < 101 ? | 428 cpfslt lo ; O2 + He < 101 ? |
| 369 decf gas6_He_ratio,F ; Yes, He-- (unchanged) | 429 decf gas6_He_ratio,F ; YES - He-- (unchanged) |
| 370 banksel common | |
| 371 bra do_divemode_gaslist_more_common | 430 bra do_divemode_gaslist_more_common |
| 372 | 431 |
| 373 do_dive_mHe: | 432 do_dive_mHe: |
| 374 banksel gas6_O2_ratio | |
| 375 decf gas6_He_ratio,F ; He-- | 433 decf gas6_He_ratio,F ; He-- |
| 376 bnn do_dive_mHe_done ; H2 < 0? | 434 bnn do_dive_mHe_done ; H2 < 0 ? |
| 377 clrf gas6_He_ratio ; YES - reset to 0 | 435 clrf gas6_He_ratio ; YES - reset to 0 |
| 378 do_dive_mHe_done: | 436 do_dive_mHe_done: |
| 379 banksel common | |
| 380 bra do_divemode_gaslist_more_common | 437 bra do_divemode_gaslist_more_common |
| 381 | 438 |
| 439 ENDIF | |
| 440 | |
| 441 ;============================================================================= | |
| 442 | |
| 443 IFDEF _ccr_pscr | |
| 382 | 444 |
| 383 do_divemode_splist: | 445 do_divemode_splist: |
| 384 bsf short_gas_decriptions | 446 bsf short_gas_descriptions ; do not show "SP" etc. |
| 385 movlw .1 | 447 movlw .1 ; default to first menu item |
| 386 movwf menupos1 ; set to first option in dive mode menu | 448 movff opt_ccr_mode,lo ; get CCR mode (0: Fixed SP, 1: Sensor, 2: Auto SP) |
| 449 dcfsnz lo,F ; mode = sensor ? | |
| 450 movlw .6 ; YES - load menu item number for 'sensor' | |
| 451 btfsc sp_fallback ; in fallback condition? | |
| 452 movlw .1 ; YES - revert to first menu item | |
| 453 movwf menu_pos_cur ; set cursor position | |
| 387 | 454 |
| 388 do_divemode_splist_common: | 455 do_divemode_splist_common: |
| 389 btfsc analog_o2_input ; do we have an analog input (OSTC cR)? | 456 |
| 457 IFDEF _external_sensor | |
| 458 btfsc analog_o2_input ; do we have an analog or S8 digital input (OSTC cR)? | |
| 390 bra do_divemode_splist_sensor ; YES | 459 bra do_divemode_splist_sensor ; YES |
| 391 ; btfsc s8_digital ; do we have a digital input? | |
| 392 ; bra do_divemode_splist_sensor ; YES | |
| 393 btfsc optical_input ; do we have an optical input (OSTC 3)? | 460 btfsc optical_input ; do we have an optical input (OSTC 3)? |
| 394 bra do_divemode_splist_sensor ; YES | 461 bra do_divemode_splist_sensor ; YES |
| 462 ENDIF | |
| 395 | 463 |
| 396 do_divemode_splist_no_sensor: | 464 do_divemode_splist_no_sensor: |
| 397 MENU_BEGIN tGaslist, .5 | 465 MENU_BEGIN tGaslist, .5 |
| 398 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | 466 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp |
| 399 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | 467 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp |
| 400 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | 468 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp |
| 401 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | 469 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp |
| 402 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | 470 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp |
| 403 MENU_END | 471 MENU_END |
| 404 | 472 |
| 473 | |
| 474 IFDEF _external_sensor | |
| 475 | |
| 405 do_divemode_splist_sensor: | 476 do_divemode_splist_sensor: |
| 406 MENU_BEGIN tGaslist, .6 | 477 MENU_BEGIN tGaslist, .6 |
| 407 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | 478 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp |
| 408 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | 479 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp |
| 409 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | 480 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp |
| 413 MENU_END | 484 MENU_END |
| 414 | 485 |
| 415 | 486 |
| 416 do_divemode_sensor: | 487 do_divemode_sensor: |
| 417 movlw index_ppo2_sensors-1 ; custom view number one below ppO2 sensors | 488 movlw index_ppo2_sensors-1 ; custom view number one below ppO2 sensors |
| 418 movwf menupos3 ; set custom view number | 489 movwf active_customview ; set custom view number |
| 419 bsf toggle_customview ; initiate toggle to desired custom view -> ppO2 sensors | 490 bsf request_next_custview ; initiate toggle to desired custom view -> ppO2 sensors |
| 420 movlw .1 | 491 movlw .1 |
| 421 movwf menupos1 ; set to 1st option: use sensors | 492 movwf menu_pos_cur ; set to 1st option: use sensors |
| 422 | 493 |
| 423 do_return_divemode_sensor: | 494 do_return_divemode_sensor: |
| 424 MENU_BEGIN tGaslist, .6 | 495 MENU_BEGIN tGaslist, .6 |
| 425 MENU_CALL tDivemenu_UseSensor, do_switch_sensor | 496 MENU_CALL tDivemenu_UseSensor, do_switch_sensor |
| 426 MENU_CALL tBack, do_divemode_splist | 497 MENU_CALL tBack, do_divemode_splist |
| 428 MENU_CALL tDiveHudMask1, do_toggle_sensor | 499 MENU_CALL tDiveHudMask1, do_toggle_sensor |
| 429 MENU_CALL tDiveHudMask2, do_toggle_sensor | 500 MENU_CALL tDiveHudMask2, do_toggle_sensor |
| 430 MENU_CALL tDiveHudMask3, do_toggle_sensor | 501 MENU_CALL tDiveHudMask3, do_toggle_sensor |
| 431 MENU_END | 502 MENU_END |
| 432 | 503 |
| 504 | |
| 433 do_divemode_setpoint_pscr: | 505 do_divemode_setpoint_pscr: |
| 434 movlw .1 | 506 movlw .1 |
| 435 movwf menupos1 ; set to 1st option: use calculated ppO2 | 507 movwf menu_pos_cur ; set to 1st option: use calculated ppO2 |
| 436 MENU_BEGIN tGaslist, .6 | 508 MENU_BEGIN tGaslist, .6 |
| 437 MENU_CALL tCalculated, do_switch_sp_calc | 509 MENU_CALL tCalculated, do_switch_sp_calc |
| 438 MENU_CALL tDivemenu_UseSensor, do_switch_sensor | 510 MENU_CALL tDivemenu_UseSensor, do_switch_sensor |
| 439 MENU_CALL tExit, do_exit_divemode_menu | 511 MENU_CALL tExit, do_exit_divemode_menu |
| 440 MENU_CALL tDiveHudMask1, do_toggle_sensor | 512 MENU_CALL tDiveHudMask1, do_toggle_sensor |
| 442 MENU_CALL tDiveHudMask3, do_toggle_sensor | 514 MENU_CALL tDiveHudMask3, do_toggle_sensor |
| 443 MENU_END | 515 MENU_END |
| 444 | 516 |
| 445 | 517 |
| 446 do_toggle_sensor: | 518 do_toggle_sensor: |
| 447 movff menupos1,lo ; backup position | 519 movff menu_pos_cur,lo ; backup position |
| 448 decf menupos1,f ; 4, 5, 6 -> 3, 4, 5 | 520 decf menu_pos_cur,f ; 4, 5, 6 -> 3, 4, 5 |
| 449 decf menupos1,f ; 3, 4, 5 -> 2, 3, 4 | 521 decf menu_pos_cur,f ; 3, 4, 5 -> 2, 3, 4 |
| 450 decf menupos1,f ; 2, 3, 4 -> 1, 2, 3 | 522 decf menu_pos_cur,f ; 2, 3, 4 -> 1, 2, 3 |
| 451 dcfsnz menupos1 ; 1, 2, 3 -> 0, 1, 2 | 523 dcfsnz menu_pos_cur ; 1, 2, 3 -> 0, 1, 2 |
| 452 btg use_O2_sensor1 ; = | 524 btg use_O2_sensor1 ; = |
| 453 dcfsnz menupos1 ; 0, 1, 2 -> -1, 0, 1 | 525 dcfsnz menu_pos_cur ; 0, 1, 2 -> -1, 0, 1 |
| 454 btg use_O2_sensor2 ; = | 526 btg use_O2_sensor2 ; = |
| 455 dcfsnz menupos1 ; -1,0, 1 -> -2,-1, 0 | 527 dcfsnz menu_pos_cur ; -1,0, 1 -> -2,-1, 0 |
| 456 btg use_O2_sensor3 ; = | 528 btg use_O2_sensor3 ; = |
| 457 movff lo,menupos1 ; restore position | 529 movff lo,menu_pos_cur ; restore position |
| 458 bra do_return_divemode_sensor | 530 bra do_return_divemode_sensor |
| 459 | 531 |
| 532 ENDIF ; _external_sensor | |
| 533 ENDIF ; _ccr_pscr | |
| 534 | |
| 535 ;============================================================================= | |
| 536 | |
| 460 END | 537 END |
