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