Mercurial > public > hwos_code
annotate src/simulator.asm @ 550:5ac0733d550a
2.26 stable release (DE_EN)
author | heinrichsweikamp |
---|---|
date | Wed, 27 Sep 2017 09:55:15 +0200 |
parents | 7c408bfaf2e8 |
children | b7eb98dbd800 |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
3 ; File simulator.asm | |
4 ; | |
5 ; Decoplan interface to C model code. | |
6 ; | |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
8 ;============================================================================= | |
9 ; HISTORY | |
10 ; 2011-07-09 : [jDG] Creation... | |
11 | |
275 | 12 #include "hwos.inc" ; Mandatory include. |
0 | 13 #include "convert.inc" ; output_* |
14 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c | |
15 #include "strings.inc" ; STRCPY,... | |
16 #include "tft.inc" ; WIN_LEFT,... | |
17 #include "wait.inc" ; speed_* | |
18 #include "start.inc" | |
19 #include "divemode.inc" | |
20 #include "math.inc" | |
21 #include "eeprom_rs232.inc" | |
50 | 22 #include "tft_outputs.inc" |
298
2fe34fc0e2ae
new submenu for gas consumption, show actual mix instead of GAS1-GAS5 in deco planner
heinrichsweikamp
parents:
296
diff
changeset
|
23 #include "gaslist.inc" |
0 | 24 |
25 gui CODE | |
26 | |
27 extern deco_clear_tissue | |
28 extern deco_push_tissues_to_vault | |
29 extern deco_calc_dive_interval | |
30 extern deco_calc_hauptroutine | |
31 extern deco_calc_tissue | |
32 extern deco_calc_CNS_fraction | |
33 extern deco_calc_CNS_planning | |
34 extern deco_pull_tissues_from_vault | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
35 extern TFT_display_decotype_surface1 |
0 | 36 |
37 extern log_screendump_and_onesecond, logbook_preloop_tasks | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
38 extern do_planner_menu |
0 | 39 |
40 ;---- Private temp variables ------------------------------------------------- | |
418 | 41 CBLOCK tmp+0x12 ; Reserved space for wordprocessor and convert |
0 | 42 decoplan_index ; within each page |
43 decoplan_gindex ; global index | |
44 decoplan_last ; Depth of last stop (CF#29) | |
45 decoplan_flags ; Various private flags. | |
46 decoplan_CNS:2 ; Backup CNS before vault restore | |
255 | 47 decoplan_page ; page number |
418 | 48 ; Reserved to tmp+0x18... |
0 | 49 ENDC |
50 #define decoplan_last_ceiling_shown decoplan_flags,0 | |
51 | |
52 ;---- Demo decoplanner ------------------------------------------------------- | |
53 global do_demo_planner | |
54 | |
55 do_demo_planner: | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
56 btfsc FLAG_gauge_mode ; =1: In Gauge mode |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
57 goto do_planner_menu |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
58 btfsc FLAG_apnoe_mode ; =1: In Apnea mode |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
59 goto do_planner_menu |
0 | 60 ; call deco_reset ; TODO: remove reset all Decodata |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
61 rcall deco_planer |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
62 rcall deco_show_plan |
0 | 63 goto do_planner_menu |
64 | |
65 ;============================================================================= | |
66 ; Pass all parameters to the C code | |
67 ; | |
68 | |
69 global get_first_dil_to_WREG | |
70 get_first_dil_to_WREG: ; Gets first dil (0-4) into WREG | |
71 lfsr FSR1,opt_dil_type ; Point to dil types | |
72 clrf lo ; start with Gas0 | |
81
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
73 get_first_dil_to_WREG2: |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
74 movf lo,W ; |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
75 movf PLUSW1,W ; Get Type of Dil #lo |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
76 sublw .1 ; it is = 1 (First Dil) |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
77 bz get_first_dil_to_WREG3 ; Found the first dil! |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
78 incf lo,F ; ++ |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
79 movlw NUM_GAS+1 |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
80 cpfseq lo ; All done? |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
81 bra get_first_dil_to_WREG2 ; Not yet |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
82 ; No first dil found, use #1 |
542 | 83 movlw .0 |
81
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
84 movff WREG,opt_dil_type+0 ; Set Dil1 to First |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
85 return |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
86 get_first_dil_to_WREG3: |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
87 movf lo,W ; Put into Wreg |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
88 return ; Done |
0 | 89 |
90 global get_first_gas_to_WREG | |
91 get_first_gas_to_WREG: ; Gets first gas (0-4) into WREG | |
92 lfsr FSR1,opt_gas_type ; Point to gas types | |
93 clrf lo ; start with Gas0 | |
94 get_first_gas_to_WREG2: | |
95 movf lo,W ; | |
96 movf PLUSW1,W ; Get Type of Gas #lo | |
97 sublw .1 ; it is = 1 (First Gas) | |
98 bz get_first_gas_to_WREG3 ; Found the first gas! | |
99 incf lo,F ; ++ | |
100 movlw NUM_GAS+1 | |
101 cpfseq lo ; All done? | |
102 bra get_first_gas_to_WREG2 ; Not yet | |
81
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
103 ; No first gas found, use #1 |
542 | 104 movlw .0 |
81
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
105 movff WREG,opt_gas_type+0 ; Set Gas1 to First |
8e13866b5496
add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents:
50
diff
changeset
|
106 return |
0 | 107 get_first_gas_to_WREG3: |
108 movf lo,W ; Put into Wreg | |
109 return ; Done | |
110 | |
111 deco_setup: | |
112 banksel char_I_step_is_1min ; Select the right bank... | |
113 clrf char_I_step_is_1min ; Default to 2sec steps. | |
114 | |
115 ; Fixed ambient surface pressure to 1bar. | |
116 movlw LOW(.1000) | |
117 movwf int_I_pres_surface+0 | |
118 movwf int_I_pres_respiration+0 | |
119 movlw HIGH(.1000) | |
120 movwf int_I_pres_surface+1 | |
121 movwf int_I_pres_respiration+1 | |
122 | |
46 | 123 clrf int_I_divemins+0 ; Dive start |
0 | 124 clrf int_I_divemins+1 |
548 | 125 |
46 | 126 banksel common ; Bank1 |
127 bcf use_agf ; =1: Use aGF | |
128 | |
40 | 129 rcall deco_setup_dive |
545 | 130 |
548 | 131 movlw .0 ; Bank safe "clrf" |
545 | 132 movff WREG,char_I_const_ppO2 ; deactivate CCR-mode in deco calculations unless in CCR mode (char_I_const_ppO2 is filled below again) |
0 | 133 |
548 | 134 ; Setup char_I_const_ppO2 for CC modes |
46 | 135 btfsc FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active |
40 | 136 movff char_I_setpoint_cbar+0,char_I_const_ppO2 ; Setup fixed Setpoint (Always start with SP1) |
545 | 137 rcall get_first_gas_to_WREG ; Gets first gas (0-4) into WREG |
40 | 138 |
545 | 139 ; Overwrite WREG in CCR and PSCR Mode |
140 btfsc FLAG_ccr_mode | |
141 rcall get_first_dil_to_WREG | |
142 btfsc FLAG_pscr_mode | |
143 rcall get_first_dil_to_WREG | |
144 | |
549 | 145 incf WREG ; 1-5 |
0 | 146 movff WREG,char_I_first_gas ; Copy for compatibility |
549 | 147 decf WREG ; 0-4 |
0 | 148 extern setup_gas_registers |
545 | 149 call setup_gas_registers ; With WREG=Gas 0-4, set current N2/He/O2 ratios. |
0 | 150 extern set_actual_ppo2 |
545 | 151 goto set_actual_ppo2 ; Then configure char_I_actual_ppO2 (For CNS) (And return!) |
0 | 152 |
153 global deco_setup_dive | |
154 deco_setup_dive: ; Called from divemode | |
155 banksel common ; Bank1 | |
156 | |
545 | 157 btfsc is_bailout |
158 bra deco_setup_dive_oc | |
159 btfsc FLAG_ccr_mode | |
160 bra deco_setup_dive_cc | |
161 btfsc FLAG_pscr_mode | |
162 bra deco_setup_dive_cc | |
163 | |
164 deco_setup_dive_oc: | |
165 rcall deco_setup_oc_gases ; Setup OC/Bailout Gases | |
166 bra deco_setup_dive_cont | |
167 deco_setup_dive_cc: | |
168 rcall deco_setup_cc_diluents ; Setup CC Diluents | |
169 deco_setup_dive_cont: | |
0 | 170 |
178 | 171 movff divemins+0,int_I_divemins+0 ; Current dive time. |
172 movff divemins+1,int_I_divemins+1 | |
173 | |
0 | 174 movlw deco_distance |
175 movff WREG,char_I_deco_distance | |
176 movff opt_last_stop,char_I_depth_last_deco | |
177 movff opt_GF_low,char_I_GF_Low_percentage | |
178 movff opt_GF_high,char_I_GF_High_percentage | |
179 ;Overwrite GF if aGF is wanted | |
180 btfsc use_agf ; =1: Use aGF | |
181 movff opt_aGF_low,char_I_GF_Low_percentage | |
182 btfsc use_agf ; =1: Use aGF | |
183 movff opt_aGF_high,char_I_GF_High_percentage | |
184 return | |
185 | |
186 deco_setup_cc_diluents: | |
187 movff opt_dil_He_ratio+0,char_I_deco_He_ratio+0 | |
188 movff char_I_deco_He_ratio+0,lo | |
189 movff opt_dil_O2_ratio+0,WREG | |
190 addwf lo,W ; O2 + He -> WREG | |
191 sublw .100 ; 100 - (O2 + He) -> WREG | |
192 movff WREG,char_I_deco_N2_ratio+0 | |
193 movff opt_dil_type+0,WREG ; 0=Disabled, 1=First, 2=Normal | |
194 tstfsz WREG ; Disabled? | |
195 bra $+4 ; No | |
542 | 196 movff WREG,char_I_dil_change+0 ; Yes, clear char_I_deco_gas_change (Bank safe) |
0 | 197 |
198 movff opt_dil_He_ratio+1,char_I_deco_He_ratio+1 | |
199 movff char_I_deco_He_ratio+1,lo | |
200 movff opt_dil_O2_ratio+1,WREG | |
201 addwf lo,W ; O2 + He -> WREG | |
202 sublw .100 ; 100 - (O2 + He) -> WREG | |
203 movff WREG,char_I_deco_N2_ratio+1 | |
204 movff opt_dil_type+1,WREG ; 0=Disabled, 1=First, 2=Normal | |
205 tstfsz WREG ; Disabled? | |
206 bra $+4 ; No | |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
207 movff WREG,char_I_dil_change+1 ; Yes, clear char_I_dil_change |
0 | 208 |
209 movff opt_dil_He_ratio+2,char_I_deco_He_ratio+2 | |
210 movff char_I_deco_He_ratio+2,lo | |
211 movff opt_dil_O2_ratio+2,WREG | |
212 addwf lo,W ; O2 + He -> WREG | |
213 sublw .100 ; 100 - (O2 + He) -> WREG | |
214 movff WREG,char_I_deco_N2_ratio+2 | |
215 movff opt_dil_type+2,WREG ; 0=Disabled, 1=First, 2=Normal | |
216 tstfsz WREG ; Disabled? | |
217 bra $+4 ; No | |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
218 movff WREG,char_I_dil_change+2 ; Yes, clear char_I_dil_change |
0 | 219 |
220 movff opt_dil_He_ratio+3,char_I_deco_He_ratio+3 | |
221 movff char_I_deco_He_ratio+3,lo | |
222 movff opt_dil_O2_ratio+3,WREG | |
223 addwf lo,W ; O2 + He -> WREG | |
224 sublw .100 ; 100 - (O2 + He) -> WREG | |
225 movff WREG,char_I_deco_N2_ratio+3 | |
226 movff opt_dil_type+3,WREG ; 0=Disabled, 1=First, 2=Normal | |
227 tstfsz WREG ; Disabled? | |
228 bra $+4 ; No | |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
229 movff WREG,char_I_dil_change+3 ; Yes, clear char_I_dil_change |
0 | 230 |
231 movff opt_dil_He_ratio+4,char_I_deco_He_ratio+4 | |
232 movff char_I_deco_He_ratio+4,lo | |
233 movff opt_dil_O2_ratio+4,WREG | |
234 addwf lo,W ; O2 + He -> WREG | |
235 sublw .100 ; 100 - (O2 + He) -> WREG | |
236 movff WREG,char_I_deco_N2_ratio+4 | |
237 movff opt_dil_type+4,WREG ; 0=Disabled, 1=First, 2=Normal | |
238 tstfsz WREG ; Disabled? | |
239 bra $+4 ; No | |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
240 movff WREG,char_I_dil_change+4 ; Yes, clear char_I_dil_change |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
241 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
242 ; Setup char_I_deco_gas_change array |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
243 movff char_I_dil_change+0, char_I_deco_gas_change+0 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
244 movff char_I_dil_change+1, char_I_deco_gas_change+1 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
245 movff char_I_dil_change+2, char_I_deco_gas_change+2 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
246 movff char_I_dil_change+3, char_I_deco_gas_change+3 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
247 movff char_I_dil_change+4, char_I_deco_gas_change+4 |
0 | 248 return |
249 | |
250 deco_setup_oc_gases: | |
251 movff opt_gas_He_ratio+0,char_I_deco_He_ratio+0 | |
252 movff char_I_deco_He_ratio+0,lo | |
253 movff opt_gas_O2_ratio+0,WREG | |
254 addwf lo,W ; O2 + He -> WREG | |
255 sublw .100 ; 100 - (O2 + He) -> WREG | |
256 movff WREG,char_I_deco_N2_ratio+0 | |
174
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
257 banksel opt_gas_type+0 |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
258 movlw .3 ; 3=Deco |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
259 cpfseq opt_gas_type+0 ; Gas is deco type? |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
260 clrf opt_OC_bail_gas_change+0 ; No, clear depth for 0=Disabled, 1=First and 2=Travel |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
261 banksel common |
0 | 262 |
263 movff opt_gas_He_ratio+1,char_I_deco_He_ratio+1 | |
264 movff char_I_deco_He_ratio+1,lo | |
265 movff opt_gas_O2_ratio+1,WREG | |
266 addwf lo,W ; O2 + He -> WREG | |
267 sublw .100 ; 100 - (O2 + He) -> WREG | |
268 movff WREG,char_I_deco_N2_ratio+1 | |
174
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
269 banksel opt_gas_type+1 |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
270 movlw .3 ; 3=Deco |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
271 cpfseq opt_gas_type+1 ; Gas is deco type? |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
272 clrf opt_OC_bail_gas_change+1 ; No, clear depth for 0=Disabled, 1=First and 2=Travel |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
273 banksel common |
0 | 274 |
275 movff opt_gas_He_ratio+2,char_I_deco_He_ratio+2 | |
276 movff char_I_deco_He_ratio+2,lo | |
277 movff opt_gas_O2_ratio+2,WREG | |
278 addwf lo,W ; O2 + He -> WREG | |
279 sublw .100 ; 100 - (O2 + He) -> WREG | |
280 movff WREG,char_I_deco_N2_ratio+2 | |
174
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
281 banksel opt_gas_type+2 |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
282 movlw .3 ; 3=Deco |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
283 cpfseq opt_gas_type+2 ; Gas is deco type? |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
284 clrf opt_OC_bail_gas_change+2 ; No, clear depth for 0=Disabled, 1=First and 2=Travel |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
285 banksel common |
0 | 286 |
287 movff opt_gas_He_ratio+3,char_I_deco_He_ratio+3 | |
288 movff char_I_deco_He_ratio+3,lo | |
289 movff opt_gas_O2_ratio+3,WREG | |
290 addwf lo,W ; O2 + He -> WREG | |
291 sublw .100 ; 100 - (O2 + He) -> WREG | |
292 movff WREG,char_I_deco_N2_ratio+3 | |
174
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
293 banksel opt_gas_type+3 |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
294 movlw .3 ; 3=Deco |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
295 cpfseq opt_gas_type+3 ; Gas is deco type? |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
296 clrf opt_OC_bail_gas_change+3 ; No, clear depth for 0=Disabled, 1=First and 2=Travel |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
297 banksel common |
0 | 298 |
299 movff opt_gas_He_ratio+4,char_I_deco_He_ratio+4 | |
300 movff char_I_deco_He_ratio+4,lo | |
301 movff opt_gas_O2_ratio+4,WREG | |
302 addwf lo,W ; O2 + He -> WREG | |
303 sublw .100 ; 100 - (O2 + He) -> WREG | |
304 movff WREG,char_I_deco_N2_ratio+4 | |
174
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
305 banksel opt_gas_type+4 |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
306 movlw .3 ; 3=Deco |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
307 cpfseq opt_gas_type+4 ; Gas is deco type? |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
308 clrf opt_OC_bail_gas_change+4 ; No, clear depth for 0=Disabled, 1=First and 2=Travel |
932e91074bdb
CHANGE: Clarify Travel Gases with "---" as change depth
heinrichsweikamp
parents:
148
diff
changeset
|
309 banksel common |
94
f2201aa374db
BUGFIX: compass calibration does now timeout automatically after 60s
heinrichsweikamp
parents:
81
diff
changeset
|
310 |
f2201aa374db
BUGFIX: compass calibration does now timeout automatically after 60s
heinrichsweikamp
parents:
81
diff
changeset
|
311 movlw .0 |
f2201aa374db
BUGFIX: compass calibration does now timeout automatically after 60s
heinrichsweikamp
parents:
81
diff
changeset
|
312 movff WREG,char_I_const_ppO2 ; Clear constant ppO2 for OC/bailout |
97
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
313 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
314 ; Setup char_I_deco_gas_change array |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
315 movff opt_OC_bail_gas_change+0, char_I_deco_gas_change+0 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
316 movff opt_OC_bail_gas_change+1, char_I_deco_gas_change+1 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
317 movff opt_OC_bail_gas_change+2, char_I_deco_gas_change+2 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
318 movff opt_OC_bail_gas_change+3, char_I_deco_gas_change+3 |
53a99a2dc6a1
CHANGE: Always compute bailout plan based on all active gases
heinrichsweikamp
parents:
94
diff
changeset
|
319 movff opt_OC_bail_gas_change+4, char_I_deco_gas_change+4 |
0 | 320 return |
321 | |
322 ;============================================================================= | |
323 ; Reset decompression tissues | |
324 ; | |
325 global deco_reset | |
326 deco_reset: | |
327 rcall deco_setup ; Setup all model parameters. | |
328 call deco_clear_tissue ; Set all tissues to Pamb * N2_ratio | |
329 call deco_clear_CNS_fraction ; Reset CNS value. | |
330 banksel common ; Bank1 | |
331 return | |
332 | |
333 ;============================================================================= | |
334 ; Launch decoplanning | |
335 ; | |
336 global deco_planer | |
337 deco_planer: | |
338 call speed_fastest ; Quick ! | |
339 rcall deco_setup ; Setup all model parameters. | |
340 call deco_push_tissues_to_vault | |
341 banksel common ; Bank1 | |
342 | |
343 ;---- Specific settings ------------------------------------------------------ | |
295
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
344 deco_planer_redo: |
0 | 345 banksel char_O_deco_status ; Bank 2 |
346 movlw .3 ; Start in surface state. | |
347 movwf char_O_deco_status | |
348 | |
349 banksel char_I_step_is_1min ; Bank 3 | |
350 movlw 1 | |
351 movwf char_I_step_is_1min ; Set 1min steps | |
352 | |
353 ;---- Add delay at surface, if needed ---------------------------------------- | |
354 tstfsz char_I_dive_interval | |
355 call deco_calc_dive_interval | |
356 | |
357 ;---- Dive loop -------------------------------------------------------------- | |
358 | |
359 ; Compute dive ambiant conditions | |
360 banksel char_I_bottom_depth | |
361 movf char_I_bottom_depth,W | |
362 mullw .100 | |
363 movlw LOW(.1000) | |
364 addwf PRODL,W | |
365 movwf int_I_pres_respiration+0 | |
366 movlw HIGH(.1000) | |
367 addwfc PRODH,W | |
368 movwf int_I_pres_respiration+1 | |
369 | |
370 banksel int_I_divemins ; Bank 4 | |
371 clrf int_I_divemins+0 ; Clear dive time | |
372 clrf int_I_divemins+1 | |
373 | |
374 clrf TMR5L | |
375 clrf TMR5H ; 30,51757813µs/bit in TMR5L:TMR5H | |
376 call deco_calc_hauptroutine ; Reset + simulate first min. | |
377 | |
378 deco_planer_loop: | |
379 banksel int_I_divemins ; Bank 3 | |
380 incf int_I_divemins,F ; Done 1 min. | |
381 btg LEDg | |
382 | |
383 movf char_I_bottom_time,W ; Finished ? | |
384 xorwf int_I_divemins,W | |
385 bz deco_planer_endloop ; YES | |
111 | 386 |
0 | 387 call deco_calc_tissue ; JUST calc tissue (faster). |
388 call deco_calc_CNS_fraction ; Also calculate CNS (in 1min loop) | |
389 bra deco_planer_loop | |
390 | |
391 deco_planer_endloop: | |
392 banksel char_I_step_is_1min | |
393 clrf char_I_step_is_1min ; Back to 2sec loops | |
394 | |
296
af13a18a233b
Slight more efficient bail deco, Test with 2 bail tanks.
jDG
parents:
295
diff
changeset
|
395 ;---- BAILOUT: Switch to OC gases for ascent cycles -------------------------- |
af13a18a233b
Slight more efficient bail deco, Test with 2 bail tanks.
jDG
parents:
295
diff
changeset
|
396 banksel common |
af13a18a233b
Slight more efficient bail deco, Test with 2 bail tanks.
jDG
parents:
295
diff
changeset
|
397 btfss is_bailout ; Doing a bailout decoplan ? |
af13a18a233b
Slight more efficient bail deco, Test with 2 bail tanks.
jDG
parents:
295
diff
changeset
|
398 bra deco_planer_finishing ; NO: keep gases |
af13a18a233b
Slight more efficient bail deco, Test with 2 bail tanks.
jDG
parents:
295
diff
changeset
|
399 |
af13a18a233b
Slight more efficient bail deco, Test with 2 bail tanks.
jDG
parents:
295
diff
changeset
|
400 rcall deco_setup_oc_gases ; Switch to OC gas and no const_ppO2 |
545 | 401 |
402 movlw .0 | |
403 movff WREG,char_I_const_ppO2 ; deactivate CCR-mode deco calculations | |
296
af13a18a233b
Slight more efficient bail deco, Test with 2 bail tanks.
jDG
parents:
295
diff
changeset
|
404 |
0 | 405 ;---- Wait until status reach zero ------------------------------------------- |
406 deco_planer_finishing: | |
407 btg LEDg | |
295
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
408 ; clrf TMR5L |
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
409 ; clrf TMR5H ; 30,51757813µs/bit in TMR5L:TMR5H |
0 | 410 call deco_calc_hauptroutine ; Simulate 2sec more |
411 | |
412 banksel char_O_deco_status ; Bank 2 | |
413 movf char_O_deco_status,W | |
295
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
414 bnz deco_planer_finishing |
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
415 |
296
af13a18a233b
Slight more efficient bail deco, Test with 2 bail tanks.
jDG
parents:
295
diff
changeset
|
416 ;---- Done: add CNS from decoplan, and restore tissues |
0 | 417 call deco_calc_CNS_planning |
418 movff int_O_CNS_fraction+0,decoplan_CNS+0 | |
419 movff int_O_CNS_fraction+1,decoplan_CNS+1 | |
420 call deco_pull_tissues_from_vault | |
421 bcf LEDg | |
422 banksel common ; Bank1 | |
423 movlw b'00111000' ; 1:8 Prescaler -> 65,536ms@16MHz | |
424 movwf T3CON | |
425 call speed_normal | |
426 return | |
427 | |
428 ;----------------------------------------------------------------------------- | |
429 ; Draw a stop of the deco plan (simulator or dive). | |
430 ; Inputs: lo = depth. Range 3m...93m | |
431 ; + 80 if this is a switch-gas stop. | |
432 ; up = minutes. range 1'..240'. | |
433 ; win_top = line to draw on screen. | |
434 ; Trashed: up, lo, win_height, win_leftx2, win_width, win_color*, | |
435 ; WREG, PROD, TBLPTR TABLAT. | |
436 ; | |
437 deco_plan_show_stop: | |
438 ;---- Print depth ---------------------------------------------------- | |
439 btfss lo,7 ; Bit set ? | |
440 bra deco_plan_show_std_stop ; No : Just an usual stop. | |
441 | |
50 | 442 call TFT_attention_color |
0 | 443 bcf lo,7 ; and cleanup depth. |
444 bra deco_plan_show_nstd_stop | |
445 | |
446 deco_plan_show_std_stop: | |
50 | 447 call TFT_standard_color |
0 | 448 |
449 deco_plan_show_nstd_stop: | |
450 lfsr FSR2,buffer | |
451 | |
452 TSTOSS opt_units ; 0=Meters, 1=Feets | |
453 bra deco_plan_show_nstd_stop_metric | |
454 | |
455 WIN_LEFT .85 | |
456 movf lo,W ; lo = m | |
457 mullw .100 ; PRODL:PRODH = mbar | |
458 movff PRODL,lo | |
459 movff PRODH,hi | |
460 ; Convert with 334feet/100m to have 10ft, 20ft, 30ft stops... | |
461 movff lo,xA+0 | |
462 movff hi,xA+1 | |
463 movlw LOW d'334' ; 334feet/100m | |
464 movwf xB+0 | |
465 movlw HIGH d'334' | |
466 movwf xB+1 | |
467 call mult16x16 ; xA*xB=xC (lo:hi * 328) | |
468 movlw d'50' ; round up | |
469 addwf xC+0,F | |
470 movlw 0 | |
471 addwfc xC+1,F | |
472 addwfc xC+2,F | |
473 addwfc xC+3,F | |
474 movlw d'100' | |
475 movwf xB+0 | |
476 clrf xB+1 | |
477 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
478 movff xC+0,lo | |
479 movff xC+1,hi ; restore lo and hi with updated value | |
480 bsf leftbind | |
481 bsf ignore_digit4 ; Only full feet | |
482 output_16 | |
483 STRCAT_PRINT "ft " | |
484 bra deco_plan_show_nstd_stop_common | |
485 | |
486 deco_plan_show_nstd_stop_metric: | |
487 WIN_LEFT .90 | |
488 bsf leftbind | |
489 output_8 ; outputs into Postinc2! | |
490 STRCAT_PRINT "m " | |
491 deco_plan_show_nstd_stop_common: | |
492 ;---- Print duration ------------------------------------------------- | |
493 WIN_LEFT .135 | |
494 lfsr FSR2,buffer | |
495 | |
496 movf lo,W ; Swap up & lo | |
497 movff up,lo | |
498 movwf up | |
499 | |
500 output_8 ; Allow up to 240' | |
371 | 501 STRCAT "' " ; 1 to 3 chars for depth. |
502 clrf WREG | |
503 movff WREG,buffer+.3 ; limit to 4 chars | |
504 STRCAT_PRINT "" | |
0 | 505 |
506 movf lo,W ; Swap back up & lo | |
507 movff up,lo | |
508 movwf up | |
509 | |
510 ;--------------------------------------------------------------------- | |
511 ; Draw the bar graph used for deco stops (decoplan in simulator or dive). | |
512 incf win_top,F | |
513 movlw .19 | |
514 movwf win_height | |
515 movlw .118 | |
516 movwf win_leftx2 ; column left (0-159) | |
517 movlw .16 | |
432 | 518 movwf win_width+0 ; column max width. |
519 clrf win_width+1 | |
0 | 520 |
521 ; Draw used area (up = minutes): | |
522 movlw .16 ; Limit length (16min) | |
523 cpfslt up | |
524 movwf up | |
525 movff up,win_bargraph ; Active width, the rest is cleared. | |
526 call TFT_box | |
527 | |
528 ; Restore win_top | |
50 | 529 call TFT_standard_color |
0 | 530 decf win_top,F ; Restore win_top |
531 return | |
532 | |
533 ;----------------------------------------------------------------------------- | |
534 ; Clear unused area belw last stop | |
535 ; Inputs: win_top : last used area... | |
536 deco_plan_show_clear_bottom: | |
537 movf win_top,W ; Get back from bank0 | |
371 | 538 sublw .239 ; No: bottom row in planning |
0 | 539 movwf win_height |
540 | |
541 WIN_LEFT .85 ; Full divemenu width | |
371 | 542 movlw .159-.85+1 |
432 | 543 movwf win_width+0 |
544 clrf win_width+1 | |
0 | 545 |
546 clrf win_color1 ; Fill with black | |
547 clrf win_color2 | |
548 | |
432 | 549 goto TFT_box ; and return |
0 | 550 |
551 ;----------------------------------------------------------------------------- | |
371 | 552 ; Display the decoplan (simulator). |
0 | 553 ; Inputs: char_O_deco_table (array of stop times, in minutes) |
554 ; decoplan_page = page number. | |
555 ; | |
556 deco_show_plan_page: | |
189
e79bc535ef9e
ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents:
178
diff
changeset
|
557 bcf win_invert ; Reset invert flag |
0 | 558 |
559 ;---- Is there deco stops ? ------------------------------------------ | |
560 movff char_O_first_deco_depth,WREG | |
561 iorwf WREG | |
562 bnz deco_plan_show_1 | |
563 | |
564 ;---- No Deco -------------------------------------------------------- | |
50 | 565 call TFT_standard_color |
0 | 566 TEXT_SMALL .80, .0, tNoDeco |
567 bsf decoplan_last_ceiling_shown | |
568 return | |
569 | |
570 deco_plan_show_1: | |
571 lfsr FSR0,char_O_deco_depth ; Initialize indexed addressing. | |
572 lfsr FSR1,char_O_deco_time | |
573 | |
574 clrf decoplan_index ; Start with index = 0 | |
575 clrf win_top ; and row = 0 | |
576 | |
577 ; Read stop parameters, indexed by decoplan_index and decoplan_page | |
578 movf decoplan_page,W ; decoplan_gindex = 6*decoplan_page + decoplan_index | |
148 | 579 mullw .8 ; 8 lines/page in decoplan |
0 | 580 movf decoplan_index,W |
581 addwf PRODL,W | |
582 movwf decoplan_gindex ; --> decoplan_gindex | |
583 | |
584 bcf decoplan_last_ceiling_shown ; Not finished yet... | |
585 | |
586 deco_plan_show_2: | |
587 btfsc decoplan_gindex,5 ; Reached table length (32) ? | |
588 bra deco_plan_show_99 ; YES: finished... | |
589 | |
590 ; Read stop parameters, indexed by decoplan_index | |
591 movf decoplan_gindex,W ; index | |
592 movff PLUSW1,up ; char_O_deco_time [gindex] --> up | |
593 movff PLUSW0,lo ; char_O_deco_depth[gindex] | |
594 movf lo,W | |
595 bz deco_plan_show_99 ; depth == 0 : finished. | |
596 | |
597 ; Display the stop line | |
598 rcall deco_plan_show_stop | |
599 | |
600 ; Next | |
601 movlw .24 | |
602 addwf win_top,F ; row: += 24 | |
603 incf decoplan_index,F ; local index += 1 | |
604 incf decoplan_gindex,F ; global index += 1 | |
605 | |
606 ; Max number of lines/page reached ? | |
148 | 607 movlw .8 ; 8 lines/page in decoplan |
0 | 608 cpfseq decoplan_index |
609 bra deco_plan_show_2 ; NO: loop | |
610 | |
611 ; Check if next stop if end-of-list ? | |
612 movf decoplan_gindex,W | |
613 movf PLUSW0,W ; char_O_deco_depth[gindex] | |
614 bz deco_plan_show_99 ; End of list... | |
615 | |
616 ; Display the message "more..." | |
617 rcall deco_plan_show_clear_bottom ; Clear from next line | |
618 | |
50 | 619 call TFT_standard_color |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
620 TEXT_SMALL .88, .220, tMore |
0 | 621 return |
622 | |
623 deco_plan_show_99: | |
624 bsf decoplan_last_ceiling_shown ; Nothing more in table to display. | |
625 rcall deco_plan_show_clear_bottom ; Clear from next line | |
626 return | |
627 | |
628 ;----------------------------------------------------------------------------- | |
629 ; Loop to show all pages of the decoplan (surfacemode) | |
630 | |
631 global deco_show_plan | |
632 deco_show_plan: | |
633 clrf decoplan_page | |
634 call TFT_ClearScreen | |
635 WIN_COLOR color_greenish | |
462
1eeafeeb9287
CHANGE: Indicate "Bailout" for bailout deco plan in internal deco planer
heinrichsweikamp
parents:
432
diff
changeset
|
636 btfsc is_bailout |
1eeafeeb9287
CHANGE: Indicate "Bailout" for bailout deco plan in internal deco planer
heinrichsweikamp
parents:
432
diff
changeset
|
637 bra deco_show_plan_bail_title |
0 | 638 TEXT_SMALL .1,.1, tDivePlan |
462
1eeafeeb9287
CHANGE: Indicate "Bailout" for bailout deco plan in internal deco planer
heinrichsweikamp
parents:
432
diff
changeset
|
639 bra deco_show_plan2 |
1eeafeeb9287
CHANGE: Indicate "Bailout" for bailout deco plan in internal deco planer
heinrichsweikamp
parents:
432
diff
changeset
|
640 deco_show_plan_bail_title: |
1eeafeeb9287
CHANGE: Indicate "Bailout" for bailout deco plan in internal deco planer
heinrichsweikamp
parents:
432
diff
changeset
|
641 TEXT_SMALL .1,.1, tDiveBailout |
1eeafeeb9287
CHANGE: Indicate "Bailout" for bailout deco plan in internal deco planer
heinrichsweikamp
parents:
432
diff
changeset
|
642 deco_show_plan2: |
1eeafeeb9287
CHANGE: Indicate "Bailout" for bailout deco plan in internal deco planer
heinrichsweikamp
parents:
432
diff
changeset
|
643 call TFT_standard_color |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
644 ; Show plan parameters |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
645 WIN_SMALL .0,.25 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
646 STRCPY "Int:" |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
647 movff char_I_dive_interval,lo |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
648 bsf leftbind |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
649 output_8 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
650 STRCAT_PRINT "'" |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
651 WIN_SMALL .0,.50 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
652 STRCPY_TEXT tBtTm_short |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
653 movff char_I_bottom_time,lo |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
654 bsf leftbind |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
655 output_8 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
656 STRCAT_PRINT "'" |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
657 WIN_SMALL .0,.75 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
658 STRCPY_TEXT tDepth |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
659 PUTC ":" |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
660 movff char_I_bottom_depth,lo |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
661 bsf leftbind |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
662 output_8 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
663 STRCAT_PRINT "m" |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
664 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
665 ; Show deco mode |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
666 WIN_TOP .155 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
667 lfsr FSR2,buffer |
480
ad8acade5567
NEW: PSCR mode (Passive semi-closed rebreather)
heinrichsweikamp
parents:
471
diff
changeset
|
668 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
669 call TFT_display_decotype_surface1 |
0 | 670 |
671 ;---- Display model | |
672 movff char_I_deco_model,WREG | |
673 iorwf WREG | |
674 bnz deco_show_plan_m1 | |
675 | |
676 ; Display ZH-L16 sat/desat model. | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
677 TEXT_SMALL .0,.130, tZHL16 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
678 WIN_SMALL .14,.155 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
679 PUTC "," |
0 | 680 movff char_I_desaturation_multiplier,lo |
681 output_8 | |
682 STRCAT "%/" | |
683 movff char_I_saturation_multiplier,lo | |
684 output_8 | |
685 bra deco_show_plan_m2 | |
686 | |
687 ; Display ZH-L16-GF low/high model. | |
688 deco_show_plan_m1: | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
689 TEXT_SMALL .0,.130, tZHL16GF |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
690 WIN_SMALL .14,.155 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
691 PUTC "," |
0 | 692 movff char_I_GF_Low_percentage,lo |
693 output_99x | |
694 STRCAT "%/" | |
695 movff char_I_GF_High_percentage,lo | |
696 output_99x | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
697 deco_show_plan_m2: |
0 | 698 STRCAT_PRINT "%" |
699 | |
700 ;---- Display TTS result | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
701 WIN_SMALL .0,.180 |
0 | 702 STRCPY_TEXT tTTS |
703 STRCAT ": " | |
704 | |
705 movff int_O_ascenttime+0,lo | |
706 movff int_O_ascenttime+1,hi | |
707 bsf leftbind | |
708 output_16 | |
709 STRCAT_PRINT "'" | |
710 | |
711 ;---- Display CNS result | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
712 WIN_TOP .205 |
471
9edb1359ce43
NEW: New Customview 11 in dive mode shows ppO2, EAD/END and CNS
heinrichsweikamp
parents:
462
diff
changeset
|
713 STRCPY_TEXT tCNS2 ; "CNS:" |
0 | 714 movff int_O_CNS_fraction+0,lo |
715 movff int_O_CNS_fraction+1,hi | |
225
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
208
diff
changeset
|
716 output_16_3 ; limit to 999 and display only (0-999) |
0 | 717 STRCAT "%\x92" ; "->" |
718 movff decoplan_CNS+0,lo | |
719 movff decoplan_CNS+1,hi | |
225
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
208
diff
changeset
|
720 output_16_3 ; limit to 999 and display only (0-999) |
0 | 721 STRCAT_PRINT "%" |
722 | |
723 ;---- Loop through pages | |
724 deco_show_plan_1: | |
725 rcall deco_show_plan_page | |
726 incf decoplan_page,F | |
727 | |
728 call logbook_preloop_tasks | |
729 deco_show_plan_2: | |
730 btfsc switch_right | |
731 bra deco_show_plan_3 | |
732 btfsc switch_left | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
733 return ; Return to simulator menu |
0 | 734 call log_screendump_and_onesecond ; Check if we need to make a screenshot and check for new second |
735 btfsc sleepmode ; Timeout? | |
9 | 736 goto restart |
0 | 737 bra deco_show_plan_2 |
738 | |
739 deco_show_plan_3: | |
740 btfss decoplan_last_ceiling_shown | |
741 bra deco_show_plan_1 | |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
742 ; All stops shown |
292 | 743 |
295
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
744 ;---- In CCR mode, compute a BAILOUT decoplan --------------------------------- |
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
745 banksel common |
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
746 btfss FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active |
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
747 bra simulator_show_decoplan5_0 ; NO: normal OC mode: just display |
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
748 |
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
749 btfsc is_bailout ; ALREADY in bailout mode ? |
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
750 bra simulator_show_decoplan5_0 ; YES: alreay BAIL plan: display gas |
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
751 |
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
752 ; Redo 2nd deco-plann, in bailout mode: |
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
753 bsf is_bailout ; Set special bailout mode. |
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
754 rcall deco_planer_redo ; Redo plan computation |
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
755 |
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
756 movff char_I_setpoint_cbar+0,char_I_const_ppO2 |
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
757 bra deco_show_plan ; and display bailout stops |
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
758 |
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
759 ;---- In OC+BAIL modes, show the gas Usage special page ----------------------- |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
760 simulator_show_decoplan5_0: |
295
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
761 bcf is_bailout ; Back to normal |
510
377d958252fb
BUGFIX: Planner in CCR mode used OC gases for volume calculations in some cases
heinrichsweikamp
parents:
480
diff
changeset
|
762 bcf ccr_diluent_setup ; init for OC/Bailout |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
763 |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
764 ; Make sure to pass first gas |
295
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
765 call get_first_gas_to_WREG ; Gets first gas (0-4) into WREG |
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
766 incf WREG,f ; gas 1..5 |
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
767 movff WREG,char_I_first_gas ; Copy for compatibility |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
768 |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
769 ; Compute gas consumption for each tank. |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
770 extern deco_gas_volumes |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
771 call deco_gas_volumes |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
772 movlb .1 |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
773 |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
774 ; Clear the complete stop result column: |
294 | 775 WIN_BOX_BLACK .0, .239, .80, .159 ; top, bottom, left, right |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
776 |
292 | 777 movlw .25 |
778 movwf waitms_temp ; Row for gas list is .25+.25 | |
779 clrf wait_temp ; Gas counter | |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
780 lfsr FSR0,int_O_gas_volumes ; Initialize indexed addressing. |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
781 |
292 | 782 WIN_LEFT .80 ; Set column |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
783 call TFT_standard_color |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
784 |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
785 simulator_show_decoplan5_loop: |
298
2fe34fc0e2ae
new submenu for gas consumption, show actual mix instead of GAS1-GAS5 in deco planner
heinrichsweikamp
parents:
296
diff
changeset
|
786 movff wait_temp,PRODL ; Copy to PRODL first |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
787 incf wait_temp,F ; Increment gas # |
298
2fe34fc0e2ae
new submenu for gas consumption, show actual mix instead of GAS1-GAS5 in deco planner
heinrichsweikamp
parents:
296
diff
changeset
|
788 lfsr FSR2,buffer |
2fe34fc0e2ae
new submenu for gas consumption, show actual mix instead of GAS1-GAS5 in deco planner
heinrichsweikamp
parents:
296
diff
changeset
|
789 bsf short_gas_decriptions |
2fe34fc0e2ae
new submenu for gas consumption, show actual mix instead of GAS1-GAS5 in deco planner
heinrichsweikamp
parents:
296
diff
changeset
|
790 bsf divemode ; Tweak "customview_show_mix:" |
2fe34fc0e2ae
new submenu for gas consumption, show actual mix instead of GAS1-GAS5 in deco planner
heinrichsweikamp
parents:
296
diff
changeset
|
791 call gaslist_strcat_gas ; Input: PRODL : gas number (0..4), Output: "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 |
2fe34fc0e2ae
new submenu for gas consumption, show actual mix instead of GAS1-GAS5 in deco planner
heinrichsweikamp
parents:
296
diff
changeset
|
792 bcf divemode ; Tweak "customview_show_mix:" |
292 | 793 |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
794 movlw .25 |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
795 addwf waitms_temp,F ; Increase row position |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
796 movff waitms_temp,win_top ; Set Row |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
797 |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
798 movff POSTINC0,lo ; Read (16bit) result, low first, |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
799 movff POSTINC0,hi ; then high. |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
800 movf lo,W ; Null ? |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
801 iorwf hi,W |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
802 |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
803 movf lo,W ; == 65535 (saturated ?) |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
804 andwf hi,W |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
805 incf WREG |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
806 bnz simulator_show_decoplan5_2 |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
807 call TFT_attention_color |
298
2fe34fc0e2ae
new submenu for gas consumption, show actual mix instead of GAS1-GAS5 in deco planner
heinrichsweikamp
parents:
296
diff
changeset
|
808 STRCAT_PRINT ":xxxx.x" |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
809 call TFT_standard_color |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
810 bra simulator_show_decoplan5_1 |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
811 |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
812 simulator_show_decoplan5_2: |
298
2fe34fc0e2ae
new submenu for gas consumption, show actual mix instead of GAS1-GAS5 in deco planner
heinrichsweikamp
parents:
296
diff
changeset
|
813 PUTC ":" |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
814 bsf leftbind |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
815 output_16 ; No decimal anymore. |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
816 bcf leftbind |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
817 STRCAT_PRINT "" ; No unit: can be bars or litters. |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
818 |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
819 ; Loop for all 5 gas |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
820 simulator_show_decoplan5_1: |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
821 movlw d'5' ; list all five gases |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
822 cpfseq wait_temp ; All gases shown? |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
823 bra simulator_show_decoplan5_loop ; No |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
824 |
292 | 825 WIN_COLOR color_greenish |
826 WIN_SMALL .80,.25 | |
295
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
827 |
542 | 828 ; btfsc FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active |
829 ; bra simulator_show_decoplan5_4 ; YES: This is bailout mode | |
295
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
830 |
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
831 STRCPY_TEXT tGasUsage ; OC: "Gas Usage" |
542 | 832 ; bra simulator_show_decoplan5_5 |
295
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
833 |
542 | 834 ;simulator_show_decoplan5_4: |
835 ; STRCPY_TEXT tDiveBailout ; CCR: "Bailout" | |
295
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
836 |
542 | 837 ;simulator_show_decoplan5_5: |
292 | 838 STRCAT_PRINT ":" |
839 call TFT_standard_color | |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
840 |
292 | 841 call logbook_preloop_tasks |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
842 simulator_show_decoplan5_3: |
292 | 843 btfsc switch_right |
844 return ; Return to simulator menu | |
845 btfsc switch_left | |
846 return ; Return to simulator menu | |
847 call log_screendump_and_onesecond ; Check if we need to make a screenshot and check for new second | |
848 btfsc sleepmode ; Timeout? | |
849 goto restart | |
850 bra simulator_show_decoplan5_3 | |
0 | 851 |
852 ;============================================================================= | |
853 ; | |
854 global do_demo_divemode | |
855 do_demo_divemode: | |
856 extern option_save_all | |
857 call option_save_all ; Save all settings into EEPROM before starting simulation | |
858 call deco_push_tissues_to_vault | |
859 banksel common ; Bank1 | |
860 | |
861 bsf restore_deco_data ; Restore tissue and CNS after sim | |
862 | |
863 bcf pressure_refresh | |
864 btfss pressure_refresh ; Wait for sensor | |
865 bra $-2 | |
866 | |
867 bsf simulatormode_active ; Set Flag | |
132
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
868 ; Compute dive ambient conditions |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
869 banksel char_I_bottom_depth |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
870 movf char_I_bottom_depth,W |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
871 mullw .100 |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
872 movff PRODL,rel_pressure+0 |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
873 movff PRODH,rel_pressure+1 |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
874 movlw LOW(.1000) |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
875 addwf PRODL,W |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
876 movff WREG,sim_pressure+0 |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
877 movlw HIGH(.1000) |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
878 addwfc PRODH,W |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
879 movff WREG,sim_pressure+1 |
0 | 880 |
136 | 881 banksel common ; Bank1 |
0 | 882 bsf divemode |
883 goto diveloop ; Switch into Divemode! | |
884 | |
885 | |
886 END |