Mercurial > public > hwos_code
annotate src/divemenu_tree.asm @ 374:67c258bd34e3
docu update
author | heinrichsweikamp |
---|---|
date | Tue, 25 Aug 2015 14:22:55 +0200 |
parents | 5c6da9fa5cb0 |
children | f0828110d864 |
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 |
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
0
diff
changeset
|
84 bra do_switch_gasX |
0 | 85 extern diveloop_loop4 |
86 extern timeout_divemode_menu2 | |
87 do_switch_gas: | |
88 bsf divemode_gaschange ; Set flag | |
89 do_switch_gasX: | |
90 btfsc is_bailout_menu ; Bailout confirmed? | |
91 bsf is_bailout ; =1: Bailout | |
92 do_exit_divemode_menu: | |
93 call timeout_divemode_menu2 | |
94 clrf STKPTR | |
95 goto diveloop_loop4 | |
96 | |
97 do_switch_sp: | |
98 decf menupos,W ; 1-5 -> 0-4 | |
99 lfsr FSR1,char_I_setpoint_cbar | |
100 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
|
101 movff char_I_const_ppO2,WREG |
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
102 call transmit_setpoint ; Transmit current setpoint from WREG (in cbar) to external electronics |
0 | 103 bsf setpoint_changed ; Set flag (For profile) |
99
87cc1adfe4da
show event "bailout" in the internal logbook
heinrichsweikamp
parents:
97
diff
changeset
|
104 bsf event_occured ; Set global event byte |
0 | 105 |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
53
diff
changeset
|
106 ; Reconfigure last diluent |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
53
diff
changeset
|
107 extern setup_dil_registers |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
53
diff
changeset
|
108 bcf is_bailout ; =1: Bailout |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
53
diff
changeset
|
109 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
|
110 decf WREG ; 0-4 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
53
diff
changeset
|
111 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
|
112 |
0 | 113 clrf WREG ; Switch to fixed SP |
114 movff WREG,opt_ccr_mode ; =0: Fixed SP, =1: Sensor | |
115 clrf WREG | |
116 movff WREG,char_O_deco_status ; Restart decoplan computation | |
117 | |
118 do_switch_sp2: | |
119 ; Clear some flags in case we were in bailout before... | |
120 bcf is_bailout ; =1: Bailout | |
121 bcf is_bailout_menu ; | |
122 bcf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | |
123 bcf blinking_better_gas ; Clear blinking flag | |
124 bra do_exit_divemode_menu ; And exit | |
125 | |
126 do_divemode_gaslist_bail: | |
127 bcf ccr_diluent_setup ; For OC gases | |
128 bsf is_bailout_menu ; =1: Bailout | |
129 do_divemode_gaslist: | |
130 btfsc is_bailout ; In Bailout case? | |
131 bcf ccr_diluent_setup ; Yes, use OC gases | |
132 bsf short_gas_decriptions | |
133 movlw .1 | |
134 movwf menupos ; Set to first option in divemode menu | |
135 MENU_BEGIN tGaslist, .6 | |
136 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas | |
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_CALL tMore, do_divemode_gaslist_more0 | |
142 MENU_END | |
143 | |
144 do_divemode_gaslist_more0: | |
145 movlw .1 | |
146 movwf menupos ; Set to first option in divemode menu | |
147 do_divemode_gaslist_more: | |
148 MENU_BEGIN tGaslist, .6 | |
149 MENU_DYNAMIC gaslist_strcat_gasx, do_dive_nothing | |
150 MENU_CALL tO2Plus, do_dive_pO2 | |
151 MENU_CALL tO2Minus, do_dive_mO2 | |
152 MENU_CALL tHePlus, do_dive_pHe | |
153 MENU_CALL tHeMinus, do_dive_mHe | |
182 | 154 MENU_CALL tExit, do_switch_gas6 |
0 | 155 MENU_END |
156 | |
157 do_dive_nothing: | |
158 bra do_divemode_gaslist_more | |
159 | |
160 do_dive_pO2: | |
161 banksel char_I_O2_ratio | |
162 incf char_I_O2_ratio,F ; O2++ | |
163 movf char_I_He_ratio,W | |
164 addwf char_I_O2_ratio,W | |
165 movwf temp_bankx400 | |
166 movlw .101 | |
167 cpfslt temp_bankx400 ; O2+He<101? | |
168 decf char_I_O2_ratio,F ; O2-- (Unchanged) | |
169 ; bra do_divemode_gaslist_more_common | |
170 do_divemode_gaslist_more_common: | |
181
32c17df38423
BUGFIX: END/EAD updated when adjusting current gas during the dive
heinrichsweikamp
parents:
99
diff
changeset
|
171 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
|
172 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
|
173 sublw .100 ; ...subtract both from 100 |
32c17df38423
BUGFIX: END/EAD updated when adjusting current gas during the dive
heinrichsweikamp
parents:
99
diff
changeset
|
174 movwf char_I_N2_ratio ; -> N2! |
0 | 175 banksel common |
176 bsf gas6_changed ; Set flag | |
177 bra do_divemode_gaslist_more | |
178 | |
179 do_dive_mO2: | |
180 banksel char_I_O2_ratio | |
181 decf char_I_O2_ratio,F ; O2-- | |
182 movlw gaslist_min_o2 | |
183 cpfslt char_I_O2_ratio | |
184 bra do_divemode_gaslist_more_common | |
185 movlw gaslist_min_o2 | |
186 movwf char_I_O2_ratio | |
187 bra do_divemode_gaslist_more_common | |
188 | |
189 | |
190 do_dive_pHe: | |
191 banksel char_I_O2_ratio | |
192 incf char_I_He_ratio,F ; He++ | |
193 movf char_I_He_ratio,W | |
194 addwf char_I_O2_ratio,W | |
195 movwf lo | |
196 movlw .101 | |
197 cpfslt lo ; O2+He<101? | |
198 decf char_I_He_ratio,F ; Yes, He-- (Unchanged) | |
199 bra do_divemode_gaslist_more_common | |
200 | |
201 do_dive_mHe: | |
202 banksel char_I_O2_ratio | |
203 decf char_I_He_ratio,F ; He-- | |
204 bnn do_divemode_gaslist_more_common | |
205 clrf char_I_He_ratio | |
206 bra do_divemode_gaslist_more_common | |
207 | |
208 do_divemode_splist: | |
209 bsf short_gas_decriptions | |
210 movlw .1 | |
211 movwf menupos ; Set to first option in divemode menu | |
249 | 212 movf hardware_flag,W |
213 sublw 0x11 ; 2 with BLE | |
214 btfsc STATUS,Z | |
215 bra do_divemode_splist2 | |
0 | 216 MENU_BEGIN tGaslist, .6 |
217 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
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_CALL tCCRSensor, do_divemode_sensor | |
223 MENU_END | |
224 | |
249 | 225 do_divemode_splist2: |
226 MENU_BEGIN tGaslist, .5 | |
227 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp | |
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_END | |
233 | |
234 | |
0 | 235 do_divemode_sensor: |
236 ; Set customview to 1 (HUD Data) | |
237 clrf menupos3 ; customview to come-1 | |
238 bsf toggle_customview ; Set flag, the customview will be toggled very soon now... | |
239 movlw .1 | |
240 movwf menupos ; Set to first option in divemode menu | |
241 MENU_BEGIN tGaslist, .2 | |
242 MENU_CALL tDivemenu_UseSensor, do_switch_to_sensor | |
243 MENU_CALL tExit, do_continue_main_divemenu | |
244 MENU_END | |
245 | |
246 do_divemode_togglegf: | |
247 ; Set customview to 5 (GF informations) | |
248 movlw .4 | |
249 movwf menupos3 ; Customview to come-1 | |
250 bsf toggle_customview ; Set flag, the customview will be toggled very soon now... | |
251 movlw .1 | |
252 movwf menupos ; Set to first option in divemode menu | |
253 MENU_BEGIN tDivemenu_ToggleGF, .2 | |
254 MENU_CALL tDivemenu_ToggleGF, do_togglegf | |
255 MENU_CALL tExit, do_continue_main_divemenu | |
256 MENU_END | |
257 | |
258 END |