Mercurial > public > hwos_code
annotate src/divemenu_tree.asm @ 377:f0828110d864
set char_I_current_gas for gas6 use
author | heinrichsweikamp |
---|---|
date | Thu, 10 Sep 2015 13:05:26 +0200 |
parents | 5c6da9fa5cb0 |
children | 7be43d886bb1 |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
3 ; File divemenu_tree.asm | |
4 ; | |
275 | 5 ; OSTC dive mode menu |
0 | 6 ; |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
8 ;============================================================================= | |
9 ; HISTORY | |
10 ; 2013-02-02 : [mH] Made out of menu_tree.asm | |
11 | |
275 | 12 #include "hwos.inc" ; Mandatory header |
0 | 13 #include "menu_processor.inc" |
14 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c | |
15 #include "tft_outputs.inc" | |
16 #include "customview.inc" | |
17 #include "strings.inc" | |
195 | 18 #include "calibrate.inc" |
0 | 19 |
20 divegui CODE | |
21 ;============================================================================= | |
22 ; Main Menu | |
23 global do_main_divemenu | |
24 do_main_divemenu: | |
25 call menu_processor_reset ; restart from first icon. | |
26 | |
27 do_continue_main_divemenu: | |
28 call menu_processor_pop ; drop exit line. | |
29 call menu_processor_pop ; drop exit line. | |
30 | |
31 btfsc FLAG_ccr_mode | |
32 bra main_divemenu_ccr ; CCR Menu | |
33 | |
34 bcf ccr_diluent_setup ; For OC gases | |
35 bcf is_bailout_menu | |
36 movlw .1 | |
37 movwf menupos ; Set to first option in divemode menu | |
38 MENU_BEGIN tMainMenu, .4 | |
39 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist | |
40 MENU_CALL tDivemenu_ResetAvr, do_divemode_resetavr | |
41 MENU_CALL tDivemenu_ToggleGF, do_divemode_togglegf | |
42 MENU_CALL tExit, do_exit_divemode_menu | |
43 MENU_END | |
44 | |
45 main_divemenu_ccr: | |
46 bsf ccr_diluent_setup ; For diluents | |
47 movlw .1 | |
48 movwf menupos ; Set to first option in divemode menu | |
49 MENU_BEGIN tMainMenu, .6 | |
50 MENU_CALL tDiveBailout, do_divemode_gaslist_bail | |
51 MENU_CALL tDivemenu_Setpoint, do_divemode_splist | |
52 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist | |
53 MENU_CALL tDivemenu_ResetAvr, do_divemode_resetavr | |
54 MENU_CALL tDivemenu_ToggleGF, do_divemode_togglegf | |
55 MENU_CALL tExit, do_exit_divemode_menu | |
56 MENU_END | |
57 | |
58 | |
59 do_togglegf: | |
60 TSTOSS opt_enable_aGF ; =1: aGF can be selected underwater | |
61 bra do_exit_divemode_menu ; exit | |
62 bsf toggle_gf ; Set flag... | |
63 bra do_exit_divemode_menu ; ...and exit | |
64 | |
65 do_switch_to_sensor: | |
66 movlw .1 ; Switch to Sensor | |
67 movff WREG,opt_ccr_mode ; =0: Fixed SP, =1: Sensor | |
192 | 68 bsf voting_logic_sensor1 |
69 bsf voting_logic_sensor2 | |
70 bsf voting_logic_sensor3 | |
193 | 71 extern divemode_setup_sensor_values |
72 call divemode_setup_sensor_values ; Setup sensor values | |
195 | 73 call check_sensors ; Check O2 sensor thresholds for fallback |
0 | 74 bra do_switch_sp2 |
75 | |
76 do_divemode_resetavr: | |
77 bsf reset_average_depth ; Set Flag | |
78 bra do_exit_divemode_menu ; And exit | |
79 | |
53
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
0
diff
changeset
|
80 |
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
0
diff
changeset
|
81 do_switch_gas6: |
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
0
diff
changeset
|
82 movlw .6 |
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
0
diff
changeset
|
83 movwf active_gas ; Gas6 selected |
377 | 84 movff WREG,char_I_current_gas ; for p2_deco.c |
53
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
0
diff
changeset
|
85 bra do_switch_gasX |
0 | 86 extern diveloop_loop4 |
87 extern timeout_divemode_menu2 | |
88 do_switch_gas: | |
89 bsf divemode_gaschange ; Set flag | |
90 do_switch_gasX: | |
91 btfsc is_bailout_menu ; Bailout confirmed? | |
92 bsf is_bailout ; =1: Bailout | |
93 do_exit_divemode_menu: | |
94 call timeout_divemode_menu2 | |
95 clrf STKPTR | |
96 goto diveloop_loop4 | |
97 | |
98 do_switch_sp: | |
99 decf menupos,W ; 1-5 -> 0-4 | |
100 lfsr FSR1,char_I_setpoint_cbar | |
101 movff PLUSW1,char_I_const_ppO2; Setup fixed Setpoint | |
352
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
102 movff char_I_const_ppO2,WREG |
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
103 call transmit_setpoint ; Transmit current setpoint from WREG (in cbar) to external electronics |
0 | 104 bsf setpoint_changed ; Set flag (For profile) |
99
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
97
diff
changeset
|
105 bsf event_occured ; Set global event byte |
0 | 106 |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
53
diff
changeset
|
107 ; Reconfigure last diluent |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
53
diff
changeset
|
108 extern setup_dil_registers |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
53
diff
changeset
|
109 bcf is_bailout ; =1: Bailout |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
53
diff
changeset
|
110 movff active_diluent,WREG ; As a backup when switching back from Bailout to CCR |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
53
diff
changeset
|
111 decf WREG ; 0-4 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
53
diff
changeset
|
112 call setup_dil_registers ; With WREG=Gas 0-4 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
53
diff
changeset
|
113 |
0 | 114 clrf WREG ; Switch to fixed SP |
115 movff WREG,opt_ccr_mode ; =0: Fixed SP, =1: Sensor | |
116 clrf WREG | |
117 movff WREG,char_O_deco_status ; Restart decoplan computation | |
118 | |
119 do_switch_sp2: | |
120 ; Clear some flags in case we were in bailout before... | |
121 bcf is_bailout ; =1: Bailout | |
122 bcf is_bailout_menu ; | |
123 bcf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | |
124 bcf blinking_better_gas ; Clear blinking flag | |
125 bra do_exit_divemode_menu ; And exit | |
126 | |
127 do_divemode_gaslist_bail: | |
128 bcf ccr_diluent_setup ; For OC gases | |
129 bsf is_bailout_menu ; =1: Bailout | |
130 do_divemode_gaslist: | |
131 btfsc is_bailout ; In Bailout case? | |
132 bcf ccr_diluent_setup ; Yes, use OC gases | |
133 bsf short_gas_decriptions | |
134 movlw .1 | |
135 movwf menupos ; Set to first option in divemode menu | |
136 MENU_BEGIN tGaslist, .6 | |
137 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas | |
138 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas | |
139 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas | |
140 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas | |
141 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas | |
142 MENU_CALL tMore, do_divemode_gaslist_more0 | |
143 MENU_END | |
144 | |
145 do_divemode_gaslist_more0: | |
146 movlw .1 | |
147 movwf menupos ; Set to first option in divemode menu | |
148 do_divemode_gaslist_more: | |
149 MENU_BEGIN tGaslist, .6 | |
150 MENU_DYNAMIC gaslist_strcat_gasx, do_dive_nothing | |
151 MENU_CALL tO2Plus, do_dive_pO2 | |
152 MENU_CALL tO2Minus, do_dive_mO2 | |
153 MENU_CALL tHePlus, do_dive_pHe | |
154 MENU_CALL tHeMinus, do_dive_mHe | |
182 | 155 MENU_CALL tExit, do_switch_gas6 |
0 | 156 MENU_END |
157 | |
158 do_dive_nothing: | |
159 bra do_divemode_gaslist_more | |
160 | |
161 do_dive_pO2: | |
162 banksel char_I_O2_ratio | |
163 incf char_I_O2_ratio,F ; O2++ | |
164 movf char_I_He_ratio,W | |
165 addwf char_I_O2_ratio,W | |
166 movwf temp_bankx400 | |
167 movlw .101 | |
168 cpfslt temp_bankx400 ; O2+He<101? | |
169 decf char_I_O2_ratio,F ; O2-- (Unchanged) | |
170 ; bra do_divemode_gaslist_more_common | |
171 do_divemode_gaslist_more_common: | |
181
32c17df38423
BUGFIX: END/EAD updated when adjusting current gas during the dive
heinrichsweikamp
parents:
99
diff
changeset
|
172 movf char_I_O2_ratio,W ; Add O2... |
32c17df38423
BUGFIX: END/EAD updated when adjusting current gas during the dive
heinrichsweikamp
parents:
99
diff
changeset
|
173 addwf char_I_He_ratio,W ; ...and He... |
32c17df38423
BUGFIX: END/EAD updated when adjusting current gas during the dive
heinrichsweikamp
parents:
99
diff
changeset
|
174 sublw .100 ; ...subtract both from 100 |
32c17df38423
BUGFIX: END/EAD updated when adjusting current gas during the dive
heinrichsweikamp
parents:
99
diff
changeset
|
175 movwf char_I_N2_ratio ; -> N2! |
0 | 176 banksel common |
177 bsf gas6_changed ; Set flag | |
178 bra do_divemode_gaslist_more | |
179 | |
180 do_dive_mO2: | |
181 banksel char_I_O2_ratio | |
182 decf char_I_O2_ratio,F ; O2-- | |
183 movlw gaslist_min_o2 | |
184 cpfslt char_I_O2_ratio | |
185 bra do_divemode_gaslist_more_common | |
186 movlw gaslist_min_o2 | |
187 movwf char_I_O2_ratio | |
188 bra do_divemode_gaslist_more_common | |
189 | |
190 | |
191 do_dive_pHe: | |
192 banksel char_I_O2_ratio | |
193 incf char_I_He_ratio,F ; He++ | |
194 movf char_I_He_ratio,W | |
195 addwf char_I_O2_ratio,W | |
196 movwf lo | |
197 movlw .101 | |
198 cpfslt lo ; O2+He<101? | |
199 decf char_I_He_ratio,F ; Yes, He-- (Unchanged) | |
200 bra do_divemode_gaslist_more_common | |
201 | |
202 do_dive_mHe: | |
203 banksel char_I_O2_ratio | |
204 decf char_I_He_ratio,F ; He-- | |
205 bnn do_divemode_gaslist_more_common | |
206 clrf char_I_He_ratio | |
207 bra do_divemode_gaslist_more_common | |
208 | |
209 do_divemode_splist: | |
210 bsf short_gas_decriptions | |
211 movlw .1 | |
212 movwf menupos ; Set to first option in divemode menu | |
249 | 213 movf hardware_flag,W |
214 sublw 0x11 ; 2 with BLE | |
215 btfsc STATUS,Z | |
216 bra do_divemode_splist2 | |
0 | 217 MENU_BEGIN tGaslist, .6 |
218 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
219 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
220 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
221 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
222 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
223 MENU_CALL tCCRSensor, do_divemode_sensor | |
224 MENU_END | |
225 | |
249 | 226 do_divemode_splist2: |
227 MENU_BEGIN tGaslist, .5 | |
228 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
229 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
230 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
231 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
232 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
233 MENU_END | |
234 | |
235 | |
0 | 236 do_divemode_sensor: |
237 ; Set customview to 1 (HUD Data) | |
238 clrf menupos3 ; customview to come-1 | |
239 bsf toggle_customview ; Set flag, the customview will be toggled very soon now... | |
240 movlw .1 | |
241 movwf menupos ; Set to first option in divemode menu | |
242 MENU_BEGIN tGaslist, .2 | |
243 MENU_CALL tDivemenu_UseSensor, do_switch_to_sensor | |
244 MENU_CALL tExit, do_continue_main_divemenu | |
245 MENU_END | |
246 | |
247 do_divemode_togglegf: | |
248 ; Set customview to 5 (GF informations) | |
249 movlw .4 | |
250 movwf menupos3 ; Customview to come-1 | |
251 bsf toggle_customview ; Set flag, the customview will be toggled very soon now... | |
252 movlw .1 | |
253 movwf menupos ; Set to first option in divemode menu | |
254 MENU_BEGIN tDivemenu_ToggleGF, .2 | |
255 MENU_CALL tDivemenu_ToggleGF, do_togglegf | |
256 MENU_CALL tExit, do_continue_main_divemenu | |
257 MENU_END | |
258 | |
259 END |