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