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