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