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