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