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