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
|
|
12 #include "ostc3.inc" ; Mandatory include.
|
|
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"
|
|
22
|
|
23 gui CODE
|
|
24
|
|
25 extern deco_clear_tissue
|
|
26 extern deco_push_tissues_to_vault
|
|
27 extern deco_calc_dive_interval
|
|
28 extern deco_calc_hauptroutine
|
|
29 extern deco_calc_tissue
|
|
30 extern deco_calc_CNS_fraction
|
|
31 extern deco_calc_CNS_planning
|
|
32 extern deco_pull_tissues_from_vault
|
|
33
|
|
34 extern log_screendump_and_onesecond, logbook_preloop_tasks
|
|
35
|
|
36 ;---- Private temp variables -------------------------------------------------
|
|
37 CBLOCK tmp+0x10 ; Reserved space for wordprocessor and convert
|
|
38 decoplan_index ; within each page
|
|
39 decoplan_gindex ; global index
|
|
40 decoplan_last ; Depth of last stop (CF#29)
|
|
41 decoplan_max ; Number of lines per page.
|
|
42 decoplan_flags ; Various private flags.
|
|
43 decoplan_CNS:2 ; Backup CNS before vault restore
|
|
44 ; Reserved to tmp+0x1F...
|
|
45 ENDC
|
|
46 #define decoplan_last_ceiling_shown decoplan_flags,0
|
|
47
|
|
48 ;---- Demo decoplanner -------------------------------------------------------
|
|
49 global do_demo_planner
|
|
50 extern do_planner_menu
|
|
51
|
|
52 do_demo_planner:
|
|
53 call speed_fastest
|
|
54 ; call deco_reset ; TODO: remove reset all Decodata
|
|
55 call deco_planer
|
|
56 call deco_show_plan
|
|
57 bcf switch_right
|
|
58 bcf switch_left
|
|
59 goto do_planner_menu
|
|
60
|
|
61 ;=============================================================================
|
|
62 ; Pass all parameters to the C code
|
|
63 ;
|
|
64
|
|
65 global get_first_dil_to_WREG
|
|
66 get_first_dil_to_WREG: ; Gets first dil (0-4) into WREG
|
|
67 lfsr FSR1,opt_dil_type ; Point to dil types
|
|
68 clrf lo ; start with Gas0
|
|
69 bra get_first_gas_to_WREG2 ; Start
|
|
70
|
|
71 global get_first_gas_to_WREG
|
|
72 get_first_gas_to_WREG: ; Gets first gas (0-4) into WREG
|
|
73 lfsr FSR1,opt_gas_type ; Point to gas types
|
|
74 clrf lo ; start with Gas0
|
|
75 get_first_gas_to_WREG2:
|
|
76 movf lo,W ;
|
|
77 movf PLUSW1,W ; Get Type of Gas #lo
|
|
78 sublw .1 ; it is = 1 (First Gas)
|
|
79 bz get_first_gas_to_WREG3 ; Found the first gas!
|
|
80 incf lo,F ; ++
|
|
81 movlw NUM_GAS+1
|
|
82 cpfseq lo ; All done?
|
|
83 bra get_first_gas_to_WREG2 ; Not yet
|
|
84 retlw .1 ; No first gas found, use #1
|
|
85 get_first_gas_to_WREG3:
|
|
86 movf lo,W ; Put into Wreg
|
|
87 return ; Done
|
|
88
|
|
89 deco_setup:
|
|
90 banksel char_I_step_is_1min ; Select the right bank...
|
|
91 clrf char_I_step_is_1min ; Default to 2sec steps.
|
46
|
92 clrf char_I_const_ppO2 ; Clear for OC, will be set for CC later
|
0
|
93
|
|
94 ; Fixed ambient surface pressure to 1bar.
|
|
95 movlw LOW(.1000)
|
|
96 movwf int_I_pres_surface+0
|
|
97 movwf int_I_pres_respiration+0
|
|
98 movlw HIGH(.1000)
|
|
99 movwf int_I_pres_surface+1
|
|
100 movwf int_I_pres_respiration+1
|
|
101
|
46
|
102 clrf int_I_divemins+0 ; Dive start
|
0
|
103 clrf int_I_divemins+1
|
46
|
104 banksel common ; Bank1
|
|
105 bcf use_agf ; =1: Use aGF
|
|
106
|
40
|
107 rcall deco_setup_dive
|
0
|
108
|
46
|
109 ; Setup char_I_const_ppO2 for CC modes
|
|
110 btfsc FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active
|
40
|
111 movff char_I_setpoint_cbar+0,char_I_const_ppO2 ; Setup fixed Setpoint (Always start with SP1)
|
|
112
|
|
113 rcall get_first_gas_to_WREG ; Gets first gas (0-4) into WREG
|
0
|
114 movff WREG,char_I_first_gas ; Copy for compatibility
|
|
115 extern setup_gas_registers
|
|
116 call setup_gas_registers ; With WREG=Gas 0-4, set current N2/He/O2 ratios.
|
|
117 extern set_actual_ppo2
|
|
118 call set_actual_ppo2 ; Then configure char_I_actual_ppO2 (For CNS)
|
40
|
119 return
|
0
|
120
|
|
121 global deco_setup_dive
|
|
122 deco_setup_dive: ; Called from divemode
|
|
123 banksel common ; Bank1
|
|
124
|
|
125 btfss FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active
|
|
126 rcall deco_setup_oc_gases ; Setup OC Gases
|
|
127 btfsc FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active
|
|
128 rcall deco_setup_cc_diluents ; Setup CC Diluents
|
|
129 btfsc is_bailout ; =1: Bailout
|
|
130 rcall deco_setup_oc_gases ; Setup OC/Bailout Gases
|
|
131
|
|
132 movlw deco_distance
|
|
133 movff WREG,char_I_deco_distance
|
|
134 movff opt_last_stop,char_I_depth_last_deco
|
|
135 movff opt_GF_low,char_I_GF_Low_percentage
|
|
136 movff opt_GF_high,char_I_GF_High_percentage
|
|
137 ;Overwrite GF if aGF is wanted
|
|
138 btfsc use_agf ; =1: Use aGF
|
|
139 movff opt_aGF_low,char_I_GF_Low_percentage
|
|
140 btfsc use_agf ; =1: Use aGF
|
|
141 movff opt_aGF_high,char_I_GF_High_percentage
|
|
142 return
|
|
143
|
|
144 deco_setup_cc_diluents:
|
|
145 movff opt_dil_He_ratio+0,char_I_deco_He_ratio+0
|
|
146 movff char_I_deco_He_ratio+0,lo
|
|
147 movff opt_dil_O2_ratio+0,WREG
|
|
148 addwf lo,W ; O2 + He -> WREG
|
|
149 sublw .100 ; 100 - (O2 + He) -> WREG
|
|
150 movff WREG,char_I_deco_N2_ratio+0
|
|
151 movff opt_dil_type+0,WREG ; 0=Disabled, 1=First, 2=Normal
|
|
152 tstfsz WREG ; Disabled?
|
|
153 bra $+4 ; No
|
|
154 movff WREG,char_I_deco_gas_change+0 ; Yes, clear char_I_deco_gas_change
|
|
155
|
|
156 movff opt_dil_He_ratio+1,char_I_deco_He_ratio+1
|
|
157 movff char_I_deco_He_ratio+1,lo
|
|
158 movff opt_dil_O2_ratio+1,WREG
|
|
159 addwf lo,W ; O2 + He -> WREG
|
|
160 sublw .100 ; 100 - (O2 + He) -> WREG
|
|
161 movff WREG,char_I_deco_N2_ratio+1
|
|
162 movff opt_dil_type+1,WREG ; 0=Disabled, 1=First, 2=Normal
|
|
163 tstfsz WREG ; Disabled?
|
|
164 bra $+4 ; No
|
|
165 movff WREG,char_I_deco_gas_change+1 ; Yes, clear char_I_deco_gas_change
|
|
166
|
|
167 movff opt_dil_He_ratio+2,char_I_deco_He_ratio+2
|
|
168 movff char_I_deco_He_ratio+2,lo
|
|
169 movff opt_dil_O2_ratio+2,WREG
|
|
170 addwf lo,W ; O2 + He -> WREG
|
|
171 sublw .100 ; 100 - (O2 + He) -> WREG
|
|
172 movff WREG,char_I_deco_N2_ratio+2
|
|
173 movff opt_dil_type+2,WREG ; 0=Disabled, 1=First, 2=Normal
|
|
174 tstfsz WREG ; Disabled?
|
|
175 bra $+4 ; No
|
|
176 movff WREG,char_I_deco_gas_change+2 ; Yes, clear char_I_deco_gas_change
|
|
177
|
|
178 movff opt_dil_He_ratio+3,char_I_deco_He_ratio+3
|
|
179 movff char_I_deco_He_ratio+3,lo
|
|
180 movff opt_dil_O2_ratio+3,WREG
|
|
181 addwf lo,W ; O2 + He -> WREG
|
|
182 sublw .100 ; 100 - (O2 + He) -> WREG
|
|
183 movff WREG,char_I_deco_N2_ratio+3
|
|
184 movff opt_dil_type+3,WREG ; 0=Disabled, 1=First, 2=Normal
|
|
185 tstfsz WREG ; Disabled?
|
|
186 bra $+4 ; No
|
|
187 movff WREG,char_I_deco_gas_change+3 ; Yes, clear char_I_deco_gas_change
|
|
188
|
|
189 movff opt_dil_He_ratio+4,char_I_deco_He_ratio+4
|
|
190 movff char_I_deco_He_ratio+4,lo
|
|
191 movff opt_dil_O2_ratio+4,WREG
|
|
192 addwf lo,W ; O2 + He -> WREG
|
|
193 sublw .100 ; 100 - (O2 + He) -> WREG
|
|
194 movff WREG,char_I_deco_N2_ratio+4
|
|
195 movff opt_dil_type+4,WREG ; 0=Disabled, 1=First, 2=Normal
|
|
196 tstfsz WREG ; Disabled?
|
|
197 bra $+4 ; No
|
|
198 movff WREG,char_I_deco_gas_change+4 ; Yes, clear char_I_deco_gas_change
|
|
199 return
|
|
200
|
|
201 deco_setup_oc_gases:
|
|
202 movff opt_gas_He_ratio+0,char_I_deco_He_ratio+0
|
|
203 movff char_I_deco_He_ratio+0,lo
|
|
204 movff opt_gas_O2_ratio+0,WREG
|
|
205 addwf lo,W ; O2 + He -> WREG
|
|
206 sublw .100 ; 100 - (O2 + He) -> WREG
|
|
207 movff WREG,char_I_deco_N2_ratio+0
|
|
208 movff opt_gas_type+0,WREG ; 0=Disabled, 1=First, 2=Travel, 3=Deco
|
|
209 tstfsz WREG ; Disabled?
|
|
210 bra $+4 ; No
|
|
211 movff WREG,char_I_deco_gas_change+0 ; Yes, clear char_I_deco_gas_change
|
|
212
|
|
213 movff opt_gas_He_ratio+1,char_I_deco_He_ratio+1
|
|
214 movff char_I_deco_He_ratio+1,lo
|
|
215 movff opt_gas_O2_ratio+1,WREG
|
|
216 addwf lo,W ; O2 + He -> WREG
|
|
217 sublw .100 ; 100 - (O2 + He) -> WREG
|
|
218 movff WREG,char_I_deco_N2_ratio+1
|
|
219 movff opt_gas_type+1,WREG ; 0=Disabled, 1=First, 2=Travel, 3=Deco
|
|
220 tstfsz WREG ; Disabled?
|
|
221 bra $+4 ; No
|
|
222 movff WREG,char_I_deco_gas_change+1 ; Yes, clear char_I_deco_gas_change
|
|
223
|
|
224 movff opt_gas_He_ratio+2,char_I_deco_He_ratio+2
|
|
225 movff char_I_deco_He_ratio+2,lo
|
|
226 movff opt_gas_O2_ratio+2,WREG
|
|
227 addwf lo,W ; O2 + He -> WREG
|
|
228 sublw .100 ; 100 - (O2 + He) -> WREG
|
|
229 movff WREG,char_I_deco_N2_ratio+2
|
|
230 movff opt_gas_type+2,WREG ; 0=Disabled, 1=First, 2=Travel, 3=Deco
|
|
231 tstfsz WREG ; Disabled?
|
|
232 bra $+4 ; No
|
|
233 movff WREG,char_I_deco_gas_change+2 ; Yes, clear char_I_deco_gas_change
|
|
234
|
|
235 movff opt_gas_He_ratio+3,char_I_deco_He_ratio+3
|
|
236 movff char_I_deco_He_ratio+3,lo
|
|
237 movff opt_gas_O2_ratio+3,WREG
|
|
238 addwf lo,W ; O2 + He -> WREG
|
|
239 sublw .100 ; 100 - (O2 + He) -> WREG
|
|
240 movff WREG,char_I_deco_N2_ratio+3
|
|
241 movff opt_gas_type+3,WREG ; 0=Disabled, 1=First, 2=Travel, 3=Deco
|
|
242 tstfsz WREG ; Disabled?
|
|
243 bra $+4 ; No
|
|
244 movff WREG,char_I_deco_gas_change+3 ; Yes, clear char_I_deco_gas_change
|
|
245
|
|
246 movff opt_gas_He_ratio+4,char_I_deco_He_ratio+4
|
|
247 movff char_I_deco_He_ratio+4,lo
|
|
248 movff opt_gas_O2_ratio+4,WREG
|
|
249 addwf lo,W ; O2 + He -> WREG
|
|
250 sublw .100 ; 100 - (O2 + He) -> WREG
|
|
251 movff WREG,char_I_deco_N2_ratio+4
|
|
252 movff opt_gas_type+4,WREG ; 0=Disabled, 1=First, 2=Travel, 3=Deco
|
|
253 tstfsz WREG ; Disabled?
|
|
254 bra $+4 ; No
|
|
255 movff WREG,char_I_deco_gas_change+4 ; Yes, clear char_I_deco_gas_change
|
|
256 return
|
|
257
|
|
258 ;=============================================================================
|
|
259 ; Reset decompression tissues
|
|
260 ;
|
|
261 global deco_reset
|
|
262 deco_reset:
|
|
263 rcall deco_setup ; Setup all model parameters.
|
|
264 call deco_clear_tissue ; Set all tissues to Pamb * N2_ratio
|
|
265 call deco_clear_CNS_fraction ; Reset CNS value.
|
|
266 banksel common ; Bank1
|
|
267 return
|
|
268
|
|
269 ;=============================================================================
|
|
270 ; Launch decoplanning
|
|
271 ;
|
|
272 global deco_planer
|
|
273 deco_planer:
|
|
274 call speed_fastest ; Quick !
|
|
275 rcall deco_setup ; Setup all model parameters.
|
|
276 call deco_push_tissues_to_vault
|
|
277 banksel common ; Bank1
|
|
278
|
|
279 ;---- Specific settings ------------------------------------------------------
|
|
280
|
|
281 banksel char_O_deco_status ; Bank 2
|
|
282 movlw .3 ; Start in surface state.
|
|
283 movwf char_O_deco_status
|
|
284
|
|
285 banksel char_I_step_is_1min ; Bank 3
|
|
286 movlw 1
|
|
287 movwf char_I_step_is_1min ; Set 1min steps
|
|
288
|
|
289 ;---- Add delay at surface, if needed ----------------------------------------
|
|
290 tstfsz char_I_dive_interval
|
|
291 call deco_calc_dive_interval
|
|
292
|
|
293 ;---- Dive loop --------------------------------------------------------------
|
|
294
|
|
295 ; Compute dive ambiant conditions
|
|
296 banksel char_I_bottom_depth
|
|
297 movf char_I_bottom_depth,W
|
|
298 mullw .100
|
|
299 movlw LOW(.1000)
|
|
300 addwf PRODL,W
|
|
301 movwf int_I_pres_respiration+0
|
|
302 movlw HIGH(.1000)
|
|
303 addwfc PRODH,W
|
|
304 movwf int_I_pres_respiration+1
|
|
305
|
|
306 banksel int_I_divemins ; Bank 4
|
|
307 clrf int_I_divemins+0 ; Clear dive time
|
|
308 clrf int_I_divemins+1
|
|
309
|
|
310 clrf TMR5L
|
|
311 clrf TMR5H ; 30,51757813µs/bit in TMR5L:TMR5H
|
|
312 call deco_calc_hauptroutine ; Reset + simulate first min.
|
|
313
|
|
314 deco_planer_loop:
|
|
315 banksel int_I_divemins ; Bank 3
|
|
316 incf int_I_divemins,F ; Done 1 min.
|
|
317 btg LEDg
|
|
318
|
|
319 movf char_I_bottom_time,W ; Finished ?
|
|
320 xorwf int_I_divemins,W
|
|
321 bz deco_planer_endloop ; YES
|
|
322
|
|
323 call deco_calc_tissue ; JUST calc tissue (faster).
|
|
324 call deco_calc_CNS_fraction ; Also calculate CNS (in 1min loop)
|
|
325 bra deco_planer_loop
|
|
326
|
|
327 deco_planer_endloop:
|
|
328 banksel char_I_step_is_1min
|
|
329 clrf char_I_step_is_1min ; Back to 2sec loops
|
|
330
|
|
331 ;---- Wait until status reach zero -------------------------------------------
|
|
332 deco_planer_finishing:
|
|
333 btg LEDg
|
|
334 clrf TMR5L
|
|
335 clrf TMR5H ; 30,51757813µs/bit in TMR5L:TMR5H
|
|
336 call deco_calc_hauptroutine ; Simulate 2sec more
|
|
337
|
|
338 banksel char_O_deco_status ; Bank 2
|
|
339 movf char_O_deco_status,W
|
|
340 bz deco_planer_finished
|
|
341
|
|
342 bra deco_planer_finishing
|
|
343
|
|
344 deco_planer_finished:
|
|
345 call deco_calc_CNS_planning
|
|
346 movff int_O_CNS_fraction+0,decoplan_CNS+0
|
|
347 movff int_O_CNS_fraction+1,decoplan_CNS+1
|
|
348 call deco_pull_tissues_from_vault
|
|
349 bcf LEDg
|
|
350 banksel common ; Bank1
|
|
351 movlw b'00111000' ; 1:8 Prescaler -> 65,536ms@16MHz
|
|
352 movwf T3CON
|
|
353 call speed_normal
|
|
354 return
|
|
355
|
|
356 ;-----------------------------------------------------------------------------
|
|
357 ; Draw a stop of the deco plan (simulator or dive).
|
|
358 ; Inputs: lo = depth. Range 3m...93m
|
|
359 ; + 80 if this is a switch-gas stop.
|
|
360 ; up = minutes. range 1'..240'.
|
|
361 ; win_top = line to draw on screen.
|
|
362 ; Trashed: up, lo, win_height, win_leftx2, win_width, win_color*,
|
|
363 ; WREG, PROD, TBLPTR TABLAT.
|
|
364 ;
|
|
365 deco_plan_show_stop:
|
|
366 ;---- Print depth ----------------------------------------------------
|
|
367 btfss lo,7 ; Bit set ?
|
|
368 bra deco_plan_show_std_stop ; No : Just an usual stop.
|
|
369
|
|
370 TFT_ATTENTION_COLOR
|
|
371 bcf lo,7 ; and cleanup depth.
|
|
372 bra deco_plan_show_nstd_stop
|
|
373
|
|
374 deco_plan_show_std_stop:
|
|
375 TFT_STD_COLOR
|
|
376
|
|
377 deco_plan_show_nstd_stop:
|
|
378 lfsr FSR2,buffer
|
|
379
|
|
380 TSTOSS opt_units ; 0=Meters, 1=Feets
|
|
381 bra deco_plan_show_nstd_stop_metric
|
|
382
|
|
383 WIN_LEFT .85
|
|
384 movf lo,W ; lo = m
|
|
385 mullw .100 ; PRODL:PRODH = mbar
|
|
386 movff PRODL,lo
|
|
387 movff PRODH,hi
|
|
388 ; Convert with 334feet/100m to have 10ft, 20ft, 30ft stops...
|
|
389 movff lo,xA+0
|
|
390 movff hi,xA+1
|
|
391 movlw LOW d'334' ; 334feet/100m
|
|
392 movwf xB+0
|
|
393 movlw HIGH d'334'
|
|
394 movwf xB+1
|
|
395 call mult16x16 ; xA*xB=xC (lo:hi * 328)
|
|
396 movlw d'50' ; round up
|
|
397 addwf xC+0,F
|
|
398 movlw 0
|
|
399 addwfc xC+1,F
|
|
400 addwfc xC+2,F
|
|
401 addwfc xC+3,F
|
|
402 movlw d'100'
|
|
403 movwf xB+0
|
|
404 clrf xB+1
|
|
405 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
|
|
406 movff xC+0,lo
|
|
407 movff xC+1,hi ; restore lo and hi with updated value
|
|
408 bsf leftbind
|
|
409 bsf ignore_digit4 ; Only full feet
|
|
410 output_16
|
|
411 STRCAT_PRINT "ft "
|
|
412 bra deco_plan_show_nstd_stop_common
|
|
413
|
|
414 deco_plan_show_nstd_stop_metric:
|
|
415 WIN_LEFT .90
|
|
416 bsf leftbind
|
|
417 output_8 ; outputs into Postinc2!
|
|
418 STRCAT_PRINT "m "
|
|
419 deco_plan_show_nstd_stop_common:
|
|
420 ;---- Print duration -------------------------------------------------
|
|
421 WIN_LEFT .135
|
|
422 lfsr FSR2,buffer
|
|
423
|
|
424 movf lo,W ; Swap up & lo
|
|
425 movff up,lo
|
|
426 movwf up
|
|
427
|
|
428 output_8 ; Allow up to 240'
|
|
429 STRCAT_PRINT "' " ; 1 to 3 chars for depth.
|
|
430
|
|
431 movf lo,W ; Swap back up & lo
|
|
432 movff up,lo
|
|
433 movwf up
|
|
434
|
|
435 ;---------------------------------------------------------------------
|
|
436 ; Draw the bar graph used for deco stops (decoplan in simulator or dive).
|
|
437 incf win_top,F
|
|
438 movlw .19
|
|
439 movwf win_height
|
|
440 movlw .118
|
|
441 movwf win_leftx2 ; column left (0-159)
|
|
442 movlw .16
|
|
443 movwf win_width ; column max width.
|
|
444
|
|
445 ; Draw used area (up = minutes):
|
|
446 movlw .16 ; Limit length (16min)
|
|
447 cpfslt up
|
|
448 movwf up
|
|
449 movff up,win_bargraph ; Active width, the rest is cleared.
|
|
450 call TFT_box
|
|
451
|
|
452 ; Restore win_top
|
|
453 TFT_STD_COLOR
|
|
454 decf win_top,F ; Restore win_top
|
|
455 return
|
|
456
|
|
457 ;-----------------------------------------------------------------------------
|
|
458 ; Clear unused area belw last stop
|
|
459 ; Inputs: win_top : last used area...
|
|
460 deco_plan_show_clear_bottom:
|
|
461 movf win_top,W ; Get back from bank0
|
|
462 btfsc divemode ; In dive mode ?
|
|
463 sublw .168 ; Yes: bottom row in divemode
|
|
464 btfss divemode ; In dive mode ?
|
|
465 sublw .240 ; No: bottom row in planning
|
|
466 movwf win_height
|
|
467
|
|
468 WIN_LEFT .85 ; Full divemenu width
|
|
469 movlw .160-.85+1
|
|
470 movwf win_width
|
|
471
|
|
472 clrf win_color1 ; Fill with black
|
|
473 clrf win_color2
|
|
474
|
|
475 goto TFT_box
|
|
476
|
|
477 ;-----------------------------------------------------------------------------
|
|
478 ; Display the decoplan (simulator or divemode).
|
|
479 ; Inputs: char_O_deco_table (array of stop times, in minutes)
|
|
480 ; decoplan_page = page number.
|
|
481 ;
|
|
482 deco_show_plan_page:
|
|
483 WIN_INVERT 0
|
|
484
|
|
485 ;---- Is there deco stops ? ------------------------------------------
|
|
486 movff char_O_first_deco_depth,WREG
|
|
487 iorwf WREG
|
|
488 bnz deco_plan_show_1
|
|
489
|
|
490 ;---- No Deco --------------------------------------------------------
|
|
491 TFT_STD_COLOR
|
|
492 TEXT_SMALL .80, .0, tNoDeco
|
|
493 bsf decoplan_last_ceiling_shown
|
|
494 return
|
|
495
|
|
496 deco_plan_show_1:
|
|
497 lfsr FSR0,char_O_deco_depth ; Initialize indexed addressing.
|
|
498 lfsr FSR1,char_O_deco_time
|
|
499
|
|
500 movlw .8 ; 8 lines/page in decoplan
|
|
501 btfsc divemode
|
|
502 movlw .6 ; 6 lines/page in divemode.
|
|
503 movwf decoplan_max
|
|
504
|
|
505 clrf decoplan_index ; Start with index = 0
|
|
506 clrf win_top ; and row = 0
|
|
507
|
|
508 ; Read stop parameters, indexed by decoplan_index and decoplan_page
|
|
509 movf decoplan_page,W ; decoplan_gindex = 6*decoplan_page + decoplan_index
|
|
510 mulwf decoplan_max
|
|
511 movf decoplan_index,W
|
|
512 addwf PRODL,W
|
|
513 movwf decoplan_gindex ; --> decoplan_gindex
|
|
514
|
|
515 bcf decoplan_last_ceiling_shown ; Not finished yet...
|
|
516
|
|
517 deco_plan_show_2:
|
|
518 btfsc decoplan_gindex,5 ; Reached table length (32) ?
|
|
519 bra deco_plan_show_99 ; YES: finished...
|
|
520
|
|
521 ; Read stop parameters, indexed by decoplan_index
|
|
522 movf decoplan_gindex,W ; index
|
|
523 movff PLUSW1,up ; char_O_deco_time [gindex] --> up
|
|
524 movff PLUSW0,lo ; char_O_deco_depth[gindex]
|
|
525 movf lo,W
|
|
526 bz deco_plan_show_99 ; depth == 0 : finished.
|
|
527
|
|
528 ; Display the stop line
|
|
529 rcall deco_plan_show_stop
|
|
530
|
|
531 ; Next
|
|
532 movlw .24
|
|
533 addwf win_top,F ; row: += 24
|
|
534 incf decoplan_index,F ; local index += 1
|
|
535 incf decoplan_gindex,F ; global index += 1
|
|
536
|
|
537 ; Max number of lines/page reached ?
|
|
538 movf decoplan_max,W ; index+1 == max ?
|
|
539 cpfseq decoplan_index
|
|
540 bra deco_plan_show_2 ; NO: loop
|
|
541
|
|
542 ; Check if next stop if end-of-list ?
|
|
543 movf decoplan_gindex,W
|
|
544 movf PLUSW0,W ; char_O_deco_depth[gindex]
|
|
545 bz deco_plan_show_99 ; End of list...
|
|
546
|
|
547 ; Display the message "more..."
|
|
548 rcall deco_plan_show_clear_bottom ; Clear from next line
|
|
549
|
|
550 TFT_STD_COLOR
|
|
551 TEXT_SMALL .85, .240-.25, tMore
|
|
552 return
|
|
553
|
|
554 deco_plan_show_99:
|
|
555 bsf decoplan_last_ceiling_shown ; Nothing more in table to display.
|
|
556 rcall deco_plan_show_clear_bottom ; Clear from next line
|
|
557 return
|
|
558
|
|
559 ;-----------------------------------------------------------------------------
|
|
560 ; Loop to show all pages of the decoplan (surfacemode)
|
|
561
|
|
562 global deco_show_plan
|
|
563 deco_show_plan:
|
|
564 clrf decoplan_page
|
|
565 call TFT_ClearScreen
|
|
566 WIN_COLOR color_greenish
|
|
567 TEXT_SMALL .1,.1, tDivePlan
|
|
568 TFT_STD_COLOR
|
|
569 WIN_LEFT .0
|
|
570
|
|
571 ;---- Display model
|
|
572 movff char_I_deco_model,WREG
|
|
573 iorwf WREG
|
|
574 bnz deco_show_plan_m1
|
|
575
|
|
576 ; Display ZH-L16 sat/desat model.
|
|
577 TEXT_SMALL .0,.40, tZHL16
|
|
578 WIN_TOP .65
|
|
579 lfsr FSR2,buffer
|
|
580 movff char_I_desaturation_multiplier,lo
|
|
581 bsf leftbind
|
|
582 output_8
|
|
583 STRCAT "%/"
|
|
584 movff char_I_saturation_multiplier,lo
|
|
585 output_8
|
|
586 STRCAT_PRINT "%"
|
|
587 bra deco_show_plan_m2
|
|
588
|
|
589 ; Display ZH-L16-GF low/high model.
|
|
590 deco_show_plan_m1:
|
|
591 TEXT_SMALL .0,.40, tZHL16GF
|
|
592 WIN_TOP .65
|
|
593 lfsr FSR2,buffer
|
|
594 movff char_I_GF_Low_percentage,lo
|
|
595 output_99x
|
|
596 STRCAT "%/"
|
|
597 movff char_I_GF_High_percentage,lo
|
|
598 output_99x
|
|
599 STRCAT_PRINT "%"
|
|
600 ;bra deco_show_plan_m2
|
|
601
|
40
|
602 deco_show_plan_m2:
|
|
603 ; Show deco mode
|
|
604 extern TFT_display_decotype_surface1
|
|
605 WIN_TOP .90
|
|
606 lfsr FSR2,buffer
|
|
607 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea
|
|
608 call TFT_display_decotype_surface1
|
0
|
609
|
|
610 ;---- Display TTS result
|
|
611 WIN_TOP .165
|
|
612 STRCPY_TEXT tTTS
|
|
613 STRCAT ": "
|
|
614
|
|
615 movff int_O_ascenttime+0,lo
|
|
616 movff int_O_ascenttime+1,hi
|
|
617 bsf leftbind
|
|
618 output_16
|
|
619 STRCAT_PRINT "'"
|
|
620
|
|
621 ;---- Display CNS result
|
|
622 WIN_TOP .190
|
|
623 STRCPY_TEXT tCNS
|
|
624 STRCAT ": "
|
|
625 movff int_O_CNS_fraction+0,lo
|
|
626 movff int_O_CNS_fraction+1,hi
|
|
627 output_16_3
|
|
628 STRCAT "%\x92" ; "->"
|
|
629 movff decoplan_CNS+0,lo
|
|
630 movff decoplan_CNS+1,hi
|
|
631 output_16_3
|
|
632 STRCAT_PRINT "%"
|
|
633
|
|
634 ;---- Loop through pages
|
|
635 deco_show_plan_1:
|
|
636 call speed_normal
|
|
637 rcall deco_show_plan_page
|
|
638 incf decoplan_page,F
|
|
639
|
|
640 call logbook_preloop_tasks
|
|
641 deco_show_plan_2:
|
|
642 btfsc switch_right
|
|
643 bra deco_show_plan_3
|
|
644 btfsc switch_left
|
|
645 bra deco_show_plan_4
|
|
646 call log_screendump_and_onesecond ; Check if we need to make a screenshot and check for new second
|
|
647 btfsc sleepmode ; Timeout?
|
9
|
648 goto restart
|
0
|
649 bra deco_show_plan_2
|
|
650
|
|
651 deco_show_plan_3:
|
|
652 btfss decoplan_last_ceiling_shown
|
|
653 bra deco_show_plan_1
|
|
654
|
|
655 deco_show_plan_4:
|
|
656 call speed_normal ; Display in fast mode.
|
|
657 return
|
|
658
|
|
659 ;=============================================================================
|
|
660 ;
|
|
661 global do_demo_divemode
|
|
662 do_demo_divemode:
|
|
663 extern option_save_all
|
|
664 call option_save_all ; Save all settings into EEPROM before starting simulation
|
|
665 call deco_push_tissues_to_vault
|
|
666 banksel common ; Bank1
|
|
667
|
|
668 bsf restore_deco_data ; Restore tissue and CNS after sim
|
|
669
|
|
670 bcf pressure_refresh
|
|
671 btfss pressure_refresh ; Wait for sensor
|
|
672 bra $-2
|
|
673
|
|
674 bsf simulatormode_active ; Set Flag
|
|
675 movlw LOW simulator_start_depth
|
|
676 movff WREG,rel_pressure+0
|
|
677 movlw HIGH simulator_start_depth
|
|
678 movff WREG,rel_pressure+1 ; Set Depth
|
|
679
|
|
680 movlw LOW (simulator_start_depth+.1000)
|
|
681 movff WREG,sim_pressure+0
|
|
682 movlw HIGH (simulator_start_depth+.1000)
|
|
683 movff WREG,sim_pressure+1 ; Set Depth
|
|
684
|
|
685 bsf divemode
|
|
686 goto diveloop ; Switch into Divemode!
|
|
687
|
|
688
|
|
689 END |