annotate src/divemenu_tree.asm @ 40:1e2d2b0bca5b

Bugfix: Simulator in CC mode
author mh@mh-THINK.fritz.box
date Thu, 15 Aug 2013 14:34:50 +0200
parents 11d4fc797f74
children 2825f1d2262f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
heinrichsweikamp
parents:
diff changeset
3 ; File divemenu_tree.asm
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; OSTC3 dive mode menu
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2013-02-02 : [mH] Made out of menu_tree.asm
heinrichsweikamp
parents:
diff changeset
11
heinrichsweikamp
parents:
diff changeset
12 #include "ostc3.inc" ; Mandatory header
heinrichsweikamp
parents:
diff changeset
13 #include "menu_processor.inc"
heinrichsweikamp
parents:
diff changeset
14 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c
heinrichsweikamp
parents:
diff changeset
15 #include "tft_outputs.inc"
heinrichsweikamp
parents:
diff changeset
16 #include "customview.inc"
heinrichsweikamp
parents:
diff changeset
17 #include "strings.inc"
heinrichsweikamp
parents:
diff changeset
18
heinrichsweikamp
parents:
diff changeset
19 divegui CODE
heinrichsweikamp
parents:
diff changeset
20 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
21 ; Main Menu
heinrichsweikamp
parents:
diff changeset
22 global do_main_divemenu
heinrichsweikamp
parents:
diff changeset
23 do_main_divemenu:
heinrichsweikamp
parents:
diff changeset
24 call menu_processor_reset ; restart from first icon.
heinrichsweikamp
parents:
diff changeset
25
heinrichsweikamp
parents:
diff changeset
26 do_continue_main_divemenu:
heinrichsweikamp
parents:
diff changeset
27 call menu_processor_pop ; drop exit line.
heinrichsweikamp
parents:
diff changeset
28 call menu_processor_pop ; drop exit line.
heinrichsweikamp
parents:
diff changeset
29
heinrichsweikamp
parents:
diff changeset
30 btfsc FLAG_ccr_mode
heinrichsweikamp
parents:
diff changeset
31 bra main_divemenu_ccr ; CCR Menu
heinrichsweikamp
parents:
diff changeset
32
heinrichsweikamp
parents:
diff changeset
33 bcf ccr_diluent_setup ; For OC gases
heinrichsweikamp
parents:
diff changeset
34 bcf is_bailout_menu
heinrichsweikamp
parents:
diff changeset
35 movlw .1
heinrichsweikamp
parents:
diff changeset
36 movwf menupos ; Set to first option in divemode menu
heinrichsweikamp
parents:
diff changeset
37 MENU_BEGIN tMainMenu, .4
heinrichsweikamp
parents:
diff changeset
38 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist
heinrichsweikamp
parents:
diff changeset
39 MENU_CALL tDivemenu_ResetAvr, do_divemode_resetavr
heinrichsweikamp
parents:
diff changeset
40 MENU_CALL tDivemenu_ToggleGF, do_divemode_togglegf
heinrichsweikamp
parents:
diff changeset
41 MENU_CALL tExit, do_exit_divemode_menu
heinrichsweikamp
parents:
diff changeset
42 MENU_END
heinrichsweikamp
parents:
diff changeset
43
heinrichsweikamp
parents:
diff changeset
44 main_divemenu_ccr:
heinrichsweikamp
parents:
diff changeset
45 bsf ccr_diluent_setup ; For diluents
heinrichsweikamp
parents:
diff changeset
46 movlw .1
heinrichsweikamp
parents:
diff changeset
47 movwf menupos ; Set to first option in divemode menu
heinrichsweikamp
parents:
diff changeset
48 MENU_BEGIN tMainMenu, .6
heinrichsweikamp
parents:
diff changeset
49 MENU_CALL tDiveBailout, do_divemode_gaslist_bail
heinrichsweikamp
parents:
diff changeset
50 MENU_CALL tDivemenu_Setpoint, do_divemode_splist
heinrichsweikamp
parents:
diff changeset
51 MENU_CALL tDivemenu_Gaslist, do_divemode_gaslist
heinrichsweikamp
parents:
diff changeset
52 MENU_CALL tDivemenu_ResetAvr, do_divemode_resetavr
heinrichsweikamp
parents:
diff changeset
53 MENU_CALL tDivemenu_ToggleGF, do_divemode_togglegf
heinrichsweikamp
parents:
diff changeset
54 MENU_CALL tExit, do_exit_divemode_menu
heinrichsweikamp
parents:
diff changeset
55 MENU_END
heinrichsweikamp
parents:
diff changeset
56
heinrichsweikamp
parents:
diff changeset
57
heinrichsweikamp
parents:
diff changeset
58 do_togglegf:
heinrichsweikamp
parents:
diff changeset
59 TSTOSS opt_enable_aGF ; =1: aGF can be selected underwater
heinrichsweikamp
parents:
diff changeset
60 bra do_exit_divemode_menu ; exit
heinrichsweikamp
parents:
diff changeset
61 bsf toggle_gf ; Set flag...
heinrichsweikamp
parents:
diff changeset
62 bra do_exit_divemode_menu ; ...and exit
heinrichsweikamp
parents:
diff changeset
63
heinrichsweikamp
parents:
diff changeset
64 do_switch_to_sensor:
heinrichsweikamp
parents:
diff changeset
65 movlw .1 ; Switch to Sensor
heinrichsweikamp
parents:
diff changeset
66 movff WREG,opt_ccr_mode ; =0: Fixed SP, =1: Sensor
heinrichsweikamp
parents:
diff changeset
67 bra do_switch_sp2
heinrichsweikamp
parents:
diff changeset
68
heinrichsweikamp
parents:
diff changeset
69 do_divemode_resetavr:
heinrichsweikamp
parents:
diff changeset
70 bsf reset_average_depth ; Set Flag
heinrichsweikamp
parents:
diff changeset
71 bra do_exit_divemode_menu ; And exit
heinrichsweikamp
parents:
diff changeset
72
heinrichsweikamp
parents:
diff changeset
73 extern diveloop_loop4
heinrichsweikamp
parents:
diff changeset
74 extern timeout_divemode_menu2
heinrichsweikamp
parents:
diff changeset
75 do_switch_gas:
heinrichsweikamp
parents:
diff changeset
76 bsf divemode_gaschange ; Set flag
heinrichsweikamp
parents:
diff changeset
77 do_switch_gasX:
heinrichsweikamp
parents:
diff changeset
78 btfsc is_bailout_menu ; Bailout confirmed?
heinrichsweikamp
parents:
diff changeset
79 bsf is_bailout ; =1: Bailout
heinrichsweikamp
parents:
diff changeset
80 do_exit_divemode_menu:
heinrichsweikamp
parents:
diff changeset
81 call timeout_divemode_menu2
heinrichsweikamp
parents:
diff changeset
82 clrf STKPTR
heinrichsweikamp
parents:
diff changeset
83 goto diveloop_loop4
heinrichsweikamp
parents:
diff changeset
84
heinrichsweikamp
parents:
diff changeset
85 do_switch_sp:
heinrichsweikamp
parents:
diff changeset
86 decf menupos,W ; 1-5 -> 0-4
heinrichsweikamp
parents:
diff changeset
87 lfsr FSR1,char_I_setpoint_cbar
heinrichsweikamp
parents:
diff changeset
88 movff PLUSW1,char_I_const_ppO2; Setup fixed Setpoint
heinrichsweikamp
parents:
diff changeset
89 bsf setpoint_changed ; Set flag (For profile)
heinrichsweikamp
parents:
diff changeset
90
heinrichsweikamp
parents:
diff changeset
91 clrf WREG ; Switch to fixed SP
heinrichsweikamp
parents:
diff changeset
92 movff WREG,opt_ccr_mode ; =0: Fixed SP, =1: Sensor
heinrichsweikamp
parents:
diff changeset
93 clrf WREG
heinrichsweikamp
parents:
diff changeset
94 movff WREG,char_O_deco_status ; Restart decoplan computation
heinrichsweikamp
parents:
diff changeset
95
heinrichsweikamp
parents:
diff changeset
96 do_switch_sp2:
heinrichsweikamp
parents:
diff changeset
97 ; Clear some flags in case we were in bailout before...
heinrichsweikamp
parents:
diff changeset
98 bcf is_bailout ; =1: Bailout
heinrichsweikamp
parents:
diff changeset
99 bcf is_bailout_menu ;
heinrichsweikamp
parents:
diff changeset
100 bcf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode
heinrichsweikamp
parents:
diff changeset
101 bcf blinking_better_gas ; Clear blinking flag
heinrichsweikamp
parents:
diff changeset
102 bra do_exit_divemode_menu ; And exit
heinrichsweikamp
parents:
diff changeset
103
heinrichsweikamp
parents:
diff changeset
104 do_divemode_gaslist_bail:
heinrichsweikamp
parents:
diff changeset
105 bcf ccr_diluent_setup ; For OC gases
heinrichsweikamp
parents:
diff changeset
106 bsf is_bailout_menu ; =1: Bailout
heinrichsweikamp
parents:
diff changeset
107 do_divemode_gaslist:
heinrichsweikamp
parents:
diff changeset
108 btfsc is_bailout ; In Bailout case?
heinrichsweikamp
parents:
diff changeset
109 bcf ccr_diluent_setup ; Yes, use OC gases
heinrichsweikamp
parents:
diff changeset
110 bsf short_gas_decriptions
heinrichsweikamp
parents:
diff changeset
111 movlw .1
heinrichsweikamp
parents:
diff changeset
112 movwf menupos ; Set to first option in divemode menu
heinrichsweikamp
parents:
diff changeset
113 MENU_BEGIN tGaslist, .6
heinrichsweikamp
parents:
diff changeset
114 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas
heinrichsweikamp
parents:
diff changeset
115 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas
heinrichsweikamp
parents:
diff changeset
116 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas
heinrichsweikamp
parents:
diff changeset
117 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas
heinrichsweikamp
parents:
diff changeset
118 MENU_DYNAMIC gaslist_strcat_gas_mod, do_switch_gas
heinrichsweikamp
parents:
diff changeset
119 MENU_CALL tMore, do_divemode_gaslist_more0
heinrichsweikamp
parents:
diff changeset
120 MENU_END
heinrichsweikamp
parents:
diff changeset
121
heinrichsweikamp
parents:
diff changeset
122 do_divemode_gaslist_more0:
heinrichsweikamp
parents:
diff changeset
123 movlw .1
heinrichsweikamp
parents:
diff changeset
124 movwf menupos ; Set to first option in divemode menu
heinrichsweikamp
parents:
diff changeset
125 do_divemode_gaslist_more:
heinrichsweikamp
parents:
diff changeset
126 MENU_BEGIN tGaslist, .6
heinrichsweikamp
parents:
diff changeset
127 MENU_DYNAMIC gaslist_strcat_gasx, do_dive_nothing
heinrichsweikamp
parents:
diff changeset
128 MENU_CALL tO2Plus, do_dive_pO2
heinrichsweikamp
parents:
diff changeset
129 MENU_CALL tO2Minus, do_dive_mO2
heinrichsweikamp
parents:
diff changeset
130 MENU_CALL tHePlus, do_dive_pHe
heinrichsweikamp
parents:
diff changeset
131 MENU_CALL tHeMinus, do_dive_mHe
heinrichsweikamp
parents:
diff changeset
132 MENU_CALL tEnter, do_switch_gasX
heinrichsweikamp
parents:
diff changeset
133 MENU_END
heinrichsweikamp
parents:
diff changeset
134
heinrichsweikamp
parents:
diff changeset
135 do_dive_nothing:
heinrichsweikamp
parents:
diff changeset
136 bra do_divemode_gaslist_more
heinrichsweikamp
parents:
diff changeset
137
heinrichsweikamp
parents:
diff changeset
138 do_dive_pO2:
heinrichsweikamp
parents:
diff changeset
139 banksel char_I_O2_ratio
heinrichsweikamp
parents:
diff changeset
140 incf char_I_O2_ratio,F ; O2++
heinrichsweikamp
parents:
diff changeset
141 movf char_I_He_ratio,W
heinrichsweikamp
parents:
diff changeset
142 addwf char_I_O2_ratio,W
heinrichsweikamp
parents:
diff changeset
143 movwf temp_bankx400
heinrichsweikamp
parents:
diff changeset
144 movlw .101
heinrichsweikamp
parents:
diff changeset
145 cpfslt temp_bankx400 ; O2+He<101?
heinrichsweikamp
parents:
diff changeset
146 decf char_I_O2_ratio,F ; O2-- (Unchanged)
heinrichsweikamp
parents:
diff changeset
147 ; bra do_divemode_gaslist_more_common
heinrichsweikamp
parents:
diff changeset
148 do_divemode_gaslist_more_common:
heinrichsweikamp
parents:
diff changeset
149 banksel common
heinrichsweikamp
parents:
diff changeset
150 bsf gas6_changed ; Set flag
heinrichsweikamp
parents:
diff changeset
151 bra do_divemode_gaslist_more
heinrichsweikamp
parents:
diff changeset
152
heinrichsweikamp
parents:
diff changeset
153 do_dive_mO2:
heinrichsweikamp
parents:
diff changeset
154 banksel char_I_O2_ratio
heinrichsweikamp
parents:
diff changeset
155 decf char_I_O2_ratio,F ; O2--
heinrichsweikamp
parents:
diff changeset
156 movlw gaslist_min_o2
heinrichsweikamp
parents:
diff changeset
157 cpfslt char_I_O2_ratio
heinrichsweikamp
parents:
diff changeset
158 bra do_divemode_gaslist_more_common
heinrichsweikamp
parents:
diff changeset
159 movlw gaslist_min_o2
heinrichsweikamp
parents:
diff changeset
160 movwf char_I_O2_ratio
heinrichsweikamp
parents:
diff changeset
161 bra do_divemode_gaslist_more_common
heinrichsweikamp
parents:
diff changeset
162
heinrichsweikamp
parents:
diff changeset
163
heinrichsweikamp
parents:
diff changeset
164 do_dive_pHe:
heinrichsweikamp
parents:
diff changeset
165 banksel char_I_O2_ratio
heinrichsweikamp
parents:
diff changeset
166 incf char_I_He_ratio,F ; He++
heinrichsweikamp
parents:
diff changeset
167 movf char_I_He_ratio,W
heinrichsweikamp
parents:
diff changeset
168 addwf char_I_O2_ratio,W
heinrichsweikamp
parents:
diff changeset
169 movwf lo
heinrichsweikamp
parents:
diff changeset
170 movlw .101
heinrichsweikamp
parents:
diff changeset
171 cpfslt lo ; O2+He<101?
heinrichsweikamp
parents:
diff changeset
172 decf char_I_He_ratio,F ; Yes, He-- (Unchanged)
heinrichsweikamp
parents:
diff changeset
173 banksel common
heinrichsweikamp
parents:
diff changeset
174 bra do_divemode_gaslist_more_common
heinrichsweikamp
parents:
diff changeset
175
heinrichsweikamp
parents:
diff changeset
176 do_dive_mHe:
heinrichsweikamp
parents:
diff changeset
177 banksel char_I_O2_ratio
heinrichsweikamp
parents:
diff changeset
178 decf char_I_He_ratio,F ; He--
heinrichsweikamp
parents:
diff changeset
179 bnn do_divemode_gaslist_more_common
heinrichsweikamp
parents:
diff changeset
180 clrf char_I_He_ratio
heinrichsweikamp
parents:
diff changeset
181 bra do_divemode_gaslist_more_common
heinrichsweikamp
parents:
diff changeset
182
heinrichsweikamp
parents:
diff changeset
183 do_divemode_splist:
heinrichsweikamp
parents:
diff changeset
184 bsf short_gas_decriptions
heinrichsweikamp
parents:
diff changeset
185 movlw .1
heinrichsweikamp
parents:
diff changeset
186 movwf menupos ; Set to first option in divemode menu
heinrichsweikamp
parents:
diff changeset
187 MENU_BEGIN tGaslist, .6
heinrichsweikamp
parents:
diff changeset
188 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp
heinrichsweikamp
parents:
diff changeset
189 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp
heinrichsweikamp
parents:
diff changeset
190 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp
heinrichsweikamp
parents:
diff changeset
191 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp
heinrichsweikamp
parents:
diff changeset
192 MENU_DYNAMIC gaslist_strcat_setpoint, do_switch_sp
heinrichsweikamp
parents:
diff changeset
193 MENU_CALL tCCRSensor, do_divemode_sensor
heinrichsweikamp
parents:
diff changeset
194 MENU_END
heinrichsweikamp
parents:
diff changeset
195
heinrichsweikamp
parents:
diff changeset
196 do_divemode_sensor:
heinrichsweikamp
parents:
diff changeset
197 ; Set customview to 1 (HUD Data)
heinrichsweikamp
parents:
diff changeset
198 clrf menupos3 ; customview to come-1
heinrichsweikamp
parents:
diff changeset
199 bsf toggle_customview ; Set flag, the customview will be toggled very soon now...
heinrichsweikamp
parents:
diff changeset
200 movlw .1
heinrichsweikamp
parents:
diff changeset
201 movwf menupos ; Set to first option in divemode menu
heinrichsweikamp
parents:
diff changeset
202 MENU_BEGIN tGaslist, .2
heinrichsweikamp
parents:
diff changeset
203 MENU_CALL tDivemenu_UseSensor, do_switch_to_sensor
heinrichsweikamp
parents:
diff changeset
204 MENU_CALL tExit, do_continue_main_divemenu
heinrichsweikamp
parents:
diff changeset
205 MENU_END
heinrichsweikamp
parents:
diff changeset
206
heinrichsweikamp
parents:
diff changeset
207 do_divemode_togglegf:
heinrichsweikamp
parents:
diff changeset
208 ; Set customview to 5 (GF informations)
heinrichsweikamp
parents:
diff changeset
209 movlw .4
heinrichsweikamp
parents:
diff changeset
210 movwf menupos3 ; Customview to come-1
heinrichsweikamp
parents:
diff changeset
211 bsf toggle_customview ; Set flag, the customview will be toggled very soon now...
heinrichsweikamp
parents:
diff changeset
212 movlw .1
heinrichsweikamp
parents:
diff changeset
213 movwf menupos ; Set to first option in divemode menu
heinrichsweikamp
parents:
diff changeset
214 MENU_BEGIN tDivemenu_ToggleGF, .2
heinrichsweikamp
parents:
diff changeset
215 MENU_CALL tDivemenu_ToggleGF, do_togglegf
heinrichsweikamp
parents:
diff changeset
216 MENU_CALL tExit, do_continue_main_divemenu
heinrichsweikamp
parents:
diff changeset
217 MENU_END
heinrichsweikamp
parents:
diff changeset
218
heinrichsweikamp
parents:
diff changeset
219 END