Mercurial > public > hwos_code
annotate src/simulator.asm @ 575:bf34a2f784ab
French updates
author | heinrichsweikamp |
---|---|
date | Thu, 15 Feb 2018 10:03:33 +0100 |
parents | b7eb98dbd800 |
children | b455b31ce022 |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
560 | 3 ; File simulator.asm REFACTORED VERSION V2.95a1 |
0 | 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 | |
560 | 12 #include "hwos.inc" ; Mandatory include |
0 | 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" |
298
2fe34fc0e2ae
new submenu for gas consumption, show actual mix instead of GAS1-GAS5 in deco planner
heinrichsweikamp
parents:
296
diff
changeset
|
23 #include "gaslist.inc" |
0 | 24 |
25 gui CODE | |
26 | |
27 extern deco_clear_tissue | |
28 extern deco_push_tissues_to_vault | |
29 extern deco_calc_dive_interval | |
30 extern deco_calc_hauptroutine | |
31 extern deco_pull_tissues_from_vault | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
32 extern TFT_display_decotype_surface1 |
560 | 33 extern get_first_dil_to_WREG |
34 extern get_first_gas_to_WREG | |
35 extern setup_dil_registers | |
36 extern setup_gas_registers | |
37 extern deco_setup_cc_diluents | |
38 extern deco_setup_oc_gases | |
39 | |
0 | 40 |
41 extern log_screendump_and_onesecond, logbook_preloop_tasks | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
42 extern do_planner_menu |
0 | 43 |
44 ;---- Private temp variables ------------------------------------------------- | |
45 | |
560 | 46 CBLOCK tmp+0x12 ; Reserved space for word processor and convert |
47 decoplan_index ; within each page | |
48 decoplan_gindex ; global index | |
49 decoplan_last ; Depth of last stop (CF#29) | |
50 decoplan_flags ; Various private flags. | |
51 decoplan_page ; page number | |
52 decoplan_warnings ; deco engine warnings (ex reserved to tmp+0x18...) | |
53 ENDC | |
54 | |
55 ;---- Defines ---------------------------------------------------------------- | |
56 | |
57 #define decoplan_last_ceiling_shown decoplan_flags,0 | |
58 #define decoplan_abort decoplan_flags,1 | |
59 | |
60 ;---- Demo deco planner ------------------------------------------------------ | |
61 global do_demo_planner | |
0 | 62 |
63 do_demo_planner: | |
560 | 64 btfsc FLAG_gauge_mode ; =1: In Gauge mode |
65 goto do_planner_menu | |
66 btfsc FLAG_apnoe_mode ; =1: In Apnea mode | |
67 goto do_planner_menu | |
68 bcf decoplan_abort ; initialize (clear) abort flag | |
69 bcf is_bailout ; clear bailout condition (may have remained set from last invocation) | |
70 rcall deco_planer | |
71 btfss decoplan_abort ; skip recall deco_show_plan if calculations were aborted | |
72 rcall deco_show_plan | |
73 goto do_planner_menu | |
0 | 74 |
75 | |
560 | 76 global deco_setup |
0 | 77 deco_setup: |
560 | 78 banksel common |
79 btfsc FLAG_ccr_mode | |
80 bra deco_setup_cc | |
81 btfsc FLAG_pscr_mode | |
82 bra deco_setup_cc | |
83 deco_setup_oc: | |
84 call get_first_gas_to_WREG ; gets first gas (1-5) into WREG | |
85 call setup_gas_registers ; with WREG=Gas 1-5 | |
86 call deco_setup_oc_gases ; setup OC/Bailout Gases and configure for OC deco calculation | |
87 bra deco_setup_cont | |
88 deco_setup_cc: | |
89 call get_first_dil_to_WREG ; gets first gas (1-5) into WREG | |
90 call setup_dil_registers ; with WREG=Gas 1-5 | |
91 call deco_setup_cc_diluents ; setup CCR/pSCR diluents and configure for CCR/pSCR deco calculation | |
92 deco_setup_cont: | |
93 ; use ambient conditions for simulation ## V2.94 | |
94 #include "isr.inc" | |
95 SAFE_2BYTE_COPY last_surfpressure_30min, int_I_pres_surface ; copy surface pressure to deco routine | |
548 | 96 |
560 | 97 movlw deco_distance |
98 movff WREG,char_I_deco_distance | |
0 | 99 |
560 | 100 movff opt_last_stop,char_I_depth_last_deco |
101 movff opt_GF_low,char_I_GF_Low_percentage | |
102 movff opt_GF_high,char_I_GF_High_percentage | |
103 | |
104 ; overwrite GF if aGF is wanted | |
105 bsf use_agf | |
106 TSTOSS opt_sim_use_aGF | |
107 bcf use_agf | |
0 | 108 |
560 | 109 btfsc use_agf ; =1: Use aGF |
110 movff opt_aGF_low,char_I_GF_Low_percentage | |
111 btfsc use_agf ; =1: Use aGF | |
112 movff opt_aGF_high,char_I_GF_High_percentage | |
0 | 113 |
560 | 114 bcf is_bailout |
115 | |
116 ; setup char_I_const_ppO2 for CC modes | |
117 clrf WREG | |
118 btfsc FLAG_pscr_mode | |
119 movff WREG,char_I_const_ppO2 ; configure pSCR computations to calculated ppO2 | |
120 btfss FLAG_ccr_mode | |
121 return ; done if not in CCR mode | |
122 movff opt_sim_setpoint_number,WREG ; configure CCR computations to selected setpoint | |
123 decf WREG,W ; 1-5 -> 0-4 | |
124 lfsr FSR1,char_I_setpoint_cbar ; load base address of setpoint list | |
125 movff PLUSW1,char_I_const_ppO2 ; setup setpoint | |
126 return | |
127 | |
0 | 128 ;============================================================================= |
560 | 129 ; Launch deco planning |
0 | 130 ; |
560 | 131 global deco_planer |
0 | 132 deco_planer: |
560 | 133 call speed_fastest ; Quick ! |
134 call deco_push_tissues_to_vault | |
135 rcall deco_setup ; Setup all model parameters. | |
0 | 136 |
137 ;---- Specific settings ------------------------------------------------------ | |
560 | 138 |
139 ; configure the deco engine for normal plan, CNS & gas volume calculation and no delayed ascent | |
140 movff char_O_deco_status,WREG ; bank-safe copy | |
141 bcf WREG,DECO_PLAN_FLAG ; normal plan mode, | |
142 bsf WREG,DECO_CNS_FLAG ; enable CNS calculation (CNS at end of dive), | |
143 bsf WREG,DECO_VOLUME_FLAG ; enable gas volume calculation, and | |
144 bcf WREG,DECO_ASCENT_FLAG ; disable delayed ascent calculation | |
145 movff WREG,char_O_deco_status ; bank-safe copy back | |
146 | |
147 ; configure the deco engine for total-dive gas volume calculation | |
148 movff char_O_main_status,WREG ; bank-safe copy | |
149 bsf WREG,DECO_BOTTOM_FLAG ; set bottom flag | |
150 movff WREG,char_O_main_status ; bank-safe copy back | |
151 | |
295
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
152 deco_planer_redo: |
560 | 153 |
154 ; show deco calculation is in progress | |
155 call TFT_ClearScreen | |
156 WIN_COLOR color_greenish | |
157 TEXT_SMALL .20,.40, tCalculating | |
158 WIN_COLOR color_lightblue | |
159 WIN_SMALL .1,.215 | |
160 STRCPY_TEXT_PRINT tAbort | |
161 | |
162 ; configure the deco engine for restart: | |
163 movff char_O_deco_status,WREG ; bank-safe copy | |
164 bsf WREG,DECO_STATUS_0_FLAG ; configure init ... | |
165 bsf WREG,DECO_STATUS_1_FLAG ; ... state, | |
166 movff WREG,char_O_deco_status ; bank-safe copy back | |
0 | 167 |
168 ;---- Add delay at surface, if needed ---------------------------------------- | |
560 | 169 |
170 banksel char_I_dive_interval | |
0 | 171 tstfsz char_I_dive_interval |
172 call deco_calc_dive_interval | |
173 | |
174 ;---- Dive loop -------------------------------------------------------------- | |
175 | |
560 | 176 ; Compute dive ambient conditions |
0 | 177 banksel char_I_bottom_depth |
178 movf char_I_bottom_depth,W | |
179 mullw .100 | |
180 movlw LOW(.1000) | |
181 addwf PRODL,W | |
182 movwf int_I_pres_respiration+0 | |
183 movlw HIGH(.1000) | |
184 addwfc PRODH,W | |
185 movwf int_I_pres_respiration+1 | |
560 | 186 |
187 banksel common | |
0 | 188 |
560 | 189 movff char_I_bottom_time,char_I_sim_advance_time |
190 | |
191 clrf TMR5L | |
192 clrf TMR5H ; 30,51757813µs/bit in TMR5L:TMR5H | |
0 | 193 |
560 | 194 call deco_calc_hauptroutine ; initialization + complete bottom time part |
195 banksel common | |
196 | |
197 ;---- BAILOUT: Switch to OC gases for ascent cycles -------------------------- | |
0 | 198 |
560 | 199 btfss is_bailout ; Doing a bailout deco plan ? |
200 bra deco_planer_finishing ; NO - keep gases | |
201 ; YES - switch to OC gas | |
111 | 202 |
560 | 203 ; reconfigure the deco engine for delayed ascent mode |
204 movff char_O_deco_status,lo ; bank-safe copy | |
205 bsf lo,DECO_ASCENT_FLAG ; set flag for delayed ascent calculation | |
206 movff lo,char_O_deco_status ; bank-safe copy back | |
207 | |
208 ; configure the deco engine for delayed ascent part gas volume calculation | |
209 movff char_O_main_status,WREG ; bank-safe copy | |
210 bcf WREG,DECO_BOTTOM_FLAG ; set bottom flag | |
211 movff WREG,char_O_main_status ; bank-safe copy back | |
0 | 212 |
560 | 213 ; reconfigure gas settings to OC gases |
214 call get_first_gas_to_WREG ; get first gas (1-5) into WREG | |
215 call setup_gas_registers ; With WREG=Gas 1-5 (or 6, not applicable here) | |
216 call deco_setup_oc_gases ; With WREG=Gas 1-5 (or 6, not applicable here) | |
217 | |
218 ; set the gas change override flag to allow gas changes before deco stops as done in alternative plan | |
219 movff char_O_main_status,lo ; bank-safe copy | |
220 bsf lo,DECO_GASCHANGE_OVRD ; set flag for gas change override | |
221 movff lo,char_O_main_status ; bank-safe copy back | |
222 | |
223 ;---- Wait until status reaches zero ------------------------------------------- | |
0 | 224 |
225 deco_planer_finishing: | |
560 | 226 call deco_calc_hauptroutine ; Simulate more dive time to trigger the deco calculations |
227 banksel common | |
228 | |
229 btfss switch_left ; check if left button was pressed | |
230 bra deco_planer_finishing_1 ; NO - continue calculations | |
231 bsf decoplan_abort ; YES - set abort flag so that deco_show_plan will not be called | |
232 bra deco_planer_finishing_2 ; do some clean-up and return | |
233 deco_planer_finishing_1: | |
234 movff char_O_deco_status,lo ; working copy of char_O_deco_status in bank common | |
235 movlw DECO_STATUS_MASK ; bit mask for deco status bit set | |
236 andwf lo,W ; mask out bits showing state of computation | |
237 tstfsz WREG ; check if a compute cycle is finished (bits 1 and 0 == 0) | |
238 bra deco_planer_finishing ; NO - needs more computation cycles | |
295
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
239 |
296
af13a18a233b
Slight more efficient bail deco, Test with 2 bail tanks.
jDG
parents:
295
diff
changeset
|
240 ;---- Done: add CNS from decoplan, and restore tissues |
560 | 241 |
242 deco_planer_finishing_2: | |
243 | |
244 movff char_O_deco_warnings,decoplan_warnings ; copy warnings | |
245 | |
246 call deco_pull_tissues_from_vault ; restore "real" deco data | |
247 banksel common ; back to bank 1 | |
248 | |
249 movlw b'00111000' ; 1:8 Prescaler -> 65,536ms@16MHz | |
250 movwf T3CON | |
251 goto speed_normal ;(and return) | |
0 | 252 |
253 ;----------------------------------------------------------------------------- | |
254 ; Draw a stop of the deco plan (simulator or dive). | |
255 ; Inputs: lo = depth. Range 3m...93m | |
560 | 256 ; + 0x80 if this is a switch-gas stop. |
0 | 257 ; up = minutes. range 1'..240'. |
258 ; win_top = line to draw on screen. | |
259 ; Trashed: up, lo, win_height, win_leftx2, win_width, win_color*, | |
260 ; WREG, PROD, TBLPTR TABLAT. | |
261 ; | |
262 deco_plan_show_stop: | |
263 | |
560 | 264 ;---- Print depth ---------------------------------------------------- |
265 bcf lo,7 ; clear gas-switch flag (not used any more anyhow) | |
266 lfsr FSR2,char_O_deco_gas | |
267 movf decoplan_gindex,W ; index | |
268 movff PLUSW2,WREG ; get current gas | |
269 rcall simulator_color_gas ; set output color dependent on gas (1-5) | |
0 | 270 |
271 lfsr FSR2,buffer | |
272 | |
560 | 273 TSTOSS opt_units ; 0=Meters, 1=Feets |
0 | 274 bra deco_plan_show_nstd_stop_metric |
275 | |
276 WIN_LEFT .85 | |
277 movf lo,W ; lo = m | |
278 mullw .100 ; PRODL:PRODH = mbar | |
279 movff PRODL,lo | |
280 movff PRODH,hi | |
560 | 281 ; Convert with 334feet/100m to have 10ft, 20ft, 30ft stops... |
0 | 282 movff lo,xA+0 |
283 movff hi,xA+1 | |
284 movlw LOW d'334' ; 334feet/100m | |
285 movwf xB+0 | |
286 movlw HIGH d'334' | |
287 movwf xB+1 | |
288 call mult16x16 ; xA*xB=xC (lo:hi * 328) | |
289 movlw d'50' ; round up | |
290 addwf xC+0,F | |
291 movlw 0 | |
292 addwfc xC+1,F | |
293 addwfc xC+2,F | |
294 addwfc xC+3,F | |
295 movlw d'100' | |
296 movwf xB+0 | |
297 clrf xB+1 | |
298 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
299 movff xC+0,lo | |
300 movff xC+1,hi ; restore lo and hi with updated value | |
301 bsf leftbind | |
302 bsf ignore_digit4 ; Only full feet | |
303 output_16 | |
560 | 304 bcf leftbind |
0 | 305 STRCAT_PRINT "ft " |
306 bra deco_plan_show_nstd_stop_common | |
307 | |
308 deco_plan_show_nstd_stop_metric: | |
309 WIN_LEFT .90 | |
310 bsf leftbind | |
311 output_8 ; outputs into Postinc2! | |
560 | 312 bcf leftbind |
0 | 313 STRCAT_PRINT "m " |
314 deco_plan_show_nstd_stop_common: | |
315 ;---- Print duration ------------------------------------------------- | |
316 WIN_LEFT .135 | |
317 lfsr FSR2,buffer | |
318 | |
319 movf lo,W ; Swap up & lo | |
320 movff up,lo | |
321 movwf up | |
322 | |
323 output_8 ; Allow up to 240' | |
371 | 324 STRCAT "' " ; 1 to 3 chars for depth. |
325 clrf WREG | |
326 movff WREG,buffer+.3 ; limit to 4 chars | |
327 STRCAT_PRINT "" | |
0 | 328 |
329 movf lo,W ; Swap back up & lo | |
330 movff up,lo | |
331 movwf up | |
332 | |
333 ;--------------------------------------------------------------------- | |
560 | 334 ; Draw the bar graph used for deco stops (deco plan in simulator or dive). |
0 | 335 incf win_top,F |
336 movlw .19 | |
337 movwf win_height | |
338 movlw .118 | |
339 movwf win_leftx2 ; column left (0-159) | |
340 movlw .16 | |
432 | 341 movwf win_width+0 ; column max width. |
560 | 342 clrf win_width+1 |
0 | 343 |
344 ; Draw used area (up = minutes): | |
345 movlw .16 ; Limit length (16min) | |
346 cpfslt up | |
347 movwf up | |
348 movff up,win_bargraph ; Active width, the rest is cleared. | |
349 call TFT_box | |
350 | |
351 ; Restore win_top | |
50 | 352 call TFT_standard_color |
0 | 353 decf win_top,F ; Restore win_top |
354 return | |
355 | |
356 ;----------------------------------------------------------------------------- | |
560 | 357 ; Clear unused area below last stop |
0 | 358 ; Inputs: win_top : last used area... |
359 deco_plan_show_clear_bottom: | |
360 movf win_top,W ; Get back from bank0 | |
371 | 361 sublw .239 ; No: bottom row in planning |
0 | 362 movwf win_height |
363 | |
560 | 364 WIN_LEFT .85 ; Full dive menu width |
371 | 365 movlw .159-.85+1 |
432 | 366 movwf win_width+0 |
560 | 367 clrf win_width+1 |
0 | 368 |
369 clrf win_color1 ; Fill with black | |
370 clrf win_color2 | |
371 | |
560 | 372 goto TFT_box ; and return |
0 | 373 |
374 ;----------------------------------------------------------------------------- | |
560 | 375 ; Display the deco plan (simulator). |
0 | 376 ; Inputs: char_O_deco_table (array of stop times, in minutes) |
377 ; decoplan_page = page number. | |
378 ; | |
379 deco_show_plan_page: | |
189
e79bc535ef9e
ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents:
178
diff
changeset
|
380 bcf win_invert ; Reset invert flag |
0 | 381 |
382 ;---- Is there deco stops ? ------------------------------------------ | |
383 movff char_O_first_deco_depth,WREG | |
384 iorwf WREG | |
385 bnz deco_plan_show_1 | |
386 | |
387 ;---- No Deco -------------------------------------------------------- | |
50 | 388 call TFT_standard_color |
0 | 389 TEXT_SMALL .80, .0, tNoDeco |
390 bsf decoplan_last_ceiling_shown | |
391 return | |
392 | |
393 deco_plan_show_1: | |
394 lfsr FSR0,char_O_deco_depth ; Initialize indexed addressing. | |
395 lfsr FSR1,char_O_deco_time | |
396 | |
397 clrf decoplan_index ; Start with index = 0 | |
398 clrf win_top ; and row = 0 | |
399 | |
400 ; Read stop parameters, indexed by decoplan_index and decoplan_page | |
401 movf decoplan_page,W ; decoplan_gindex = 6*decoplan_page + decoplan_index | |
560 | 402 mullw .8 ; 8 lines/page in deco plan |
0 | 403 movf decoplan_index,W |
404 addwf PRODL,W | |
405 movwf decoplan_gindex ; --> decoplan_gindex | |
406 | |
407 bcf decoplan_last_ceiling_shown ; Not finished yet... | |
408 | |
409 deco_plan_show_2: | |
410 btfsc decoplan_gindex,5 ; Reached table length (32) ? | |
411 bra deco_plan_show_99 ; YES: finished... | |
412 | |
413 ; Read stop parameters, indexed by decoplan_index | |
414 movf decoplan_gindex,W ; index | |
415 movff PLUSW1,up ; char_O_deco_time [gindex] --> up | |
416 movff PLUSW0,lo ; char_O_deco_depth[gindex] | |
417 movf lo,W | |
418 bz deco_plan_show_99 ; depth == 0 : finished. | |
419 | |
420 ; Display the stop line | |
421 rcall deco_plan_show_stop | |
422 | |
423 ; Next | |
424 movlw .24 | |
560 | 425 addwf win_top,F ; row: += 24 |
426 incf decoplan_index,F ; local index += 1 | |
427 incf decoplan_gindex,F ; global index += 1 | |
0 | 428 |
429 ; Max number of lines/page reached ? | |
560 | 430 movlw .8 ; 8 lines/page in deco plan |
0 | 431 cpfseq decoplan_index |
560 | 432 bra deco_plan_show_2 ; NO: loop |
0 | 433 |
560 | 434 ; Check if next stop is end-of-list ? |
0 | 435 movf decoplan_gindex,W |
560 | 436 movf PLUSW0,W ; char_O_deco_depth[gindex] |
437 bz deco_plan_show_99 ; End of list... | |
0 | 438 |
439 ; Display the message "more..." | |
440 rcall deco_plan_show_clear_bottom ; Clear from next line | |
441 | |
50 | 442 call TFT_standard_color |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
443 TEXT_SMALL .88, .220, tMore |
0 | 444 return |
445 | |
446 deco_plan_show_99: | |
447 bsf decoplan_last_ceiling_shown ; Nothing more in table to display. | |
448 rcall deco_plan_show_clear_bottom ; Clear from next line | |
449 return | |
450 | |
451 ;----------------------------------------------------------------------------- | |
560 | 452 ; Loop to show all pages of the deco plan (surface mode) |
0 | 453 |
454 global deco_show_plan | |
455 deco_show_plan: | |
456 clrf decoplan_page | |
457 call TFT_ClearScreen | |
458 WIN_COLOR color_greenish | |
560 | 459 btfsc is_bailout |
460 bra deco_show_plan_bail_title | |
0 | 461 TEXT_SMALL .1,.1, tDivePlan |
560 | 462 bra deco_show_plan2 |
462
1eeafeeb9287
CHANGE: Indicate "Bailout" for bailout deco plan in internal deco planer
heinrichsweikamp
parents:
432
diff
changeset
|
463 deco_show_plan_bail_title: |
560 | 464 TEXT_SMALL .1,.1, tDiveBailout |
462
1eeafeeb9287
CHANGE: Indicate "Bailout" for bailout deco plan in internal deco planer
heinrichsweikamp
parents:
432
diff
changeset
|
465 deco_show_plan2: |
560 | 466 call TFT_standard_color |
467 ;---- Display Plan Parameters | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
468 WIN_SMALL .0,.25 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
469 STRCPY "Int:" |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
470 movff char_I_dive_interval,lo |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
471 bsf leftbind |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
472 output_8 |
560 | 473 bcf leftbind |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
474 STRCAT_PRINT "'" |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
475 WIN_SMALL .0,.50 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
476 STRCPY_TEXT tBtTm_short |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
477 movff char_I_bottom_time,lo |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
478 bsf leftbind |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
479 output_8 |
560 | 480 bcf leftbind |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
481 STRCAT_PRINT "'" |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
482 WIN_SMALL .0,.75 |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
483 STRCPY_TEXT tDepth |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
484 PUTC ":" |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
485 movff char_I_bottom_depth,lo |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
486 bsf leftbind |
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
487 output_8 |
560 | 488 bcf leftbind |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
489 STRCAT_PRINT "m" |
560 | 490 |
491 WIN_SMALL .0,.105 ; set position for warnings or sat/dsat factors | |
492 | |
493 ;---- Check for Stop Table Overflow | |
494 btfss decoplan_warnings,stoptable_overflow ; check if we have a overflow warning | |
495 bra deco_show_plan2a ; NO - skip | |
496 ;---- Display Overflow warning | |
497 call TFT_warnings_color ; YES - show overflow warning | |
498 STRCAT_PRINT "incomplete" ; max 10 characters | |
499 bra deco_show_plan_m1 ; skip displaying sat/dsat factors | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
500 |
560 | 501 deco_show_plan2a: |
502 ;---- Check for IBCD Warning | |
503 btfss decoplan_warnings,IBCD_warning_lock ; check if we have a locked IBCD warning | |
504 bra deco_show_plan2b ; NO - skip | |
505 ;---- Display IBCD warning | |
506 call TFT_attention_color ; YES - show IBCD warning | |
507 STRCAT_PRINT "IBCD!" ; max 10 characters | |
508 bra deco_show_plan_m1 ; skip displaying sat/dsat factors | |
509 | |
510 deco_show_plan2b: | |
511 ;---- Display Sat/Desat Factors --> is skipped if there were warnings | |
512 STRCAT_PRINT "SD:" | |
513 WIN_SMALL .25,.105 | |
514 movff char_I_saturation_multiplier,lo | |
515 output_8 | |
516 STRCAT "/" | |
0 | 517 movff char_I_desaturation_multiplier,lo |
518 output_8 | |
560 | 519 STRCAT_PRINT "" |
520 | |
521 deco_show_plan_m1: | |
522 call TFT_standard_color ; clean-up from warnings | |
0 | 523 |
560 | 524 ;---- Get Model |
525 movff char_I_deco_model,WREG | |
526 iorwf WREG | |
527 bz deco_show_plan_m2 | |
528 | |
529 ;---- Display GF low/high values | |
530 WIN_SMALL .0,.130 | |
531 STRCAT_PRINT "GF:" | |
532 WIN_SMALL .25,.130 | |
0 | 533 movff char_I_GF_Low_percentage,lo |
534 output_99x | |
560 | 535 STRCAT "/" |
0 | 536 movff char_I_GF_High_percentage,lo |
537 output_99x | |
560 | 538 STRCAT_PRINT "" |
539 | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
540 deco_show_plan_m2: |
560 | 541 ;---- Display Deco Mode |
542 WIN_SMALL .0,.155 | |
543 lfsr FSR2,buffer | |
544 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR | |
545 call TFT_display_decotype_surface1 | |
546 btfss FLAG_ccr_mode ; current dive mode = CCR ? | |
547 bra deco_show_plan2c ; NO - branch | |
548 WIN_SMALL .25,.155 | |
549 STRCPY "SP:" ; output setpoint used for calculation | |
550 movff opt_sim_setpoint_number,lo | |
551 bsf leftbind | |
552 output_8 | |
553 bcf leftbind | |
554 STRCAT_PRINT "" | |
0 | 555 |
560 | 556 deco_show_plan2c: |
0 | 557 ;---- Display TTS result |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
558 WIN_SMALL .0,.180 |
0 | 559 STRCPY_TEXT tTTS |
560 STRCAT ": " | |
561 movff int_O_ascenttime+0,lo | |
562 movff int_O_ascenttime+1,hi | |
563 bsf leftbind | |
564 output_16 | |
560 | 565 bcf leftbind |
0 | 566 STRCAT_PRINT "'" |
567 | |
568 ;---- Display CNS result | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
569 WIN_TOP .205 |
471
9edb1359ce43
NEW: New Customview 11 in dive mode shows ppO2, EAD/END and CNS
heinrichsweikamp
parents:
462
diff
changeset
|
570 STRCPY_TEXT tCNS2 ; "CNS:" |
0 | 571 movff int_O_CNS_fraction+0,lo |
572 movff int_O_CNS_fraction+1,hi | |
560 | 573 TFT_color_code warn_cns ; Color-code CNS output |
574 bsf leftbind | |
575 output_16_3 ; limit to 999 and display only (0-999) | |
576 bcf leftbind | |
577 STRCAT "%\x92" ; "->" | |
578 movff int_O_normal_CNS_fraction+0,lo | |
579 movff int_O_normal_CNS_fraction+1,hi | |
580 TFT_color_code warn_cns ; Color-code CNS output | |
581 bsf leftbind | |
582 output_16_3 ; limit to 999 and display only (0-999) | |
583 bcf leftbind | |
0 | 584 STRCAT_PRINT "%" |
560 | 585 call TFT_standard_color |
0 | 586 |
587 ;---- Loop through pages | |
588 deco_show_plan_1: | |
560 | 589 ; Clear the complete stop result column: |
590 WIN_BOX_BLACK .0, .239, .80, .159 ; top, bottom, left, right | |
591 | |
0 | 592 rcall deco_show_plan_page |
593 incf decoplan_page,F | |
594 call logbook_preloop_tasks | |
595 deco_show_plan_2: | |
596 btfsc switch_right | |
597 bra deco_show_plan_3 | |
598 btfsc switch_left | |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
599 return ; Return to simulator menu |
560 | 600 call log_screendump_and_onesecond ; Check if we need to make a screen shot and check for new second |
0 | 601 btfsc sleepmode ; Timeout? |
9 | 602 goto restart |
0 | 603 bra deco_show_plan_2 |
604 | |
605 deco_show_plan_3: | |
606 btfss decoplan_last_ceiling_shown | |
607 bra deco_show_plan_1 | |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
608 ; All stops shown |
560 | 609 |
610 ;---- In CCR and pSCR mode, compute a BAILOUT deco plan ----------------------- | |
295
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
611 |
560 | 612 banksel common |
613 movff char_O_deco_status,WREG ; get deco calculation status | |
614 btfss WREG,DECO_MODE_LOOP_FLAG ; check if in CCR or pSCR mode | |
615 bra simulator_show_decoplan5_0 ; NO - normal OC mode: just display | |
616 bsf is_bailout ; YES - redo 2nd deco-plan in bailout mode | |
617 rcall deco_planer_redo ; redo plan computation | |
295
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
618 |
560 | 619 btfss decoplan_abort ; shall we abort? |
620 bra deco_show_plan ; NO - display bailout stops | |
621 return ; YES | |
622 | |
295
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
623 |
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
624 ;---- In OC+BAIL modes, show the gas Usage special page ----------------------- |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
625 simulator_show_decoplan5_0: |
560 | 626 |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
627 movlb .1 |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
628 |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
629 ; Clear the complete stop result column: |
294 | 630 WIN_BOX_BLACK .0, .239, .80, .159 ; top, bottom, left, right |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
631 |
292 | 632 movlw .25 |
633 movwf waitms_temp ; Row for gas list is .25+.25 | |
634 clrf wait_temp ; Gas counter | |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
635 lfsr FSR0,int_O_gas_volumes ; Initialize indexed addressing. |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
636 |
292 | 637 WIN_LEFT .80 ; Set column |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
638 call TFT_standard_color |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
639 |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
640 simulator_show_decoplan5_loop: |
298
2fe34fc0e2ae
new submenu for gas consumption, show actual mix instead of GAS1-GAS5 in deco planner
heinrichsweikamp
parents:
296
diff
changeset
|
641 movff wait_temp,PRODL ; Copy to PRODL first |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
642 incf wait_temp,F ; Increment gas # |
560 | 643 |
644 movff wait_temp,WREG | |
645 rcall simulator_color_gas ; set output color according to gas (number 1-5 in WREG) | |
646 | |
298
2fe34fc0e2ae
new submenu for gas consumption, show actual mix instead of GAS1-GAS5 in deco planner
heinrichsweikamp
parents:
296
diff
changeset
|
647 lfsr FSR2,buffer |
2fe34fc0e2ae
new submenu for gas consumption, show actual mix instead of GAS1-GAS5 in deco planner
heinrichsweikamp
parents:
296
diff
changeset
|
648 bsf short_gas_decriptions |
2fe34fc0e2ae
new submenu for gas consumption, show actual mix instead of GAS1-GAS5 in deco planner
heinrichsweikamp
parents:
296
diff
changeset
|
649 bsf divemode ; Tweak "customview_show_mix:" |
2fe34fc0e2ae
new submenu for gas consumption, show actual mix instead of GAS1-GAS5 in deco planner
heinrichsweikamp
parents:
296
diff
changeset
|
650 call gaslist_strcat_gas ; Input: PRODL : gas number (0..4), Output: "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 |
2fe34fc0e2ae
new submenu for gas consumption, show actual mix instead of GAS1-GAS5 in deco planner
heinrichsweikamp
parents:
296
diff
changeset
|
651 bcf divemode ; Tweak "customview_show_mix:" |
292 | 652 |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
653 movlw .25 |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
654 addwf waitms_temp,F ; Increase row position |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
655 movff waitms_temp,win_top ; Set Row |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
656 |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
657 movff POSTINC0,lo ; Read (16bit) result, low first, |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
658 movff POSTINC0,hi ; then high. |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
659 |
560 | 660 movf lo,W |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
661 andwf hi,W |
560 | 662 incf WREG ; > 65535? |
663 bnz simulator_show_decoplan5_2 ; NO | |
664 STRCAT_PRINT ">65500" ; YES | |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
665 bra simulator_show_decoplan5_1 |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
666 |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
667 simulator_show_decoplan5_2: |
298
2fe34fc0e2ae
new submenu for gas consumption, show actual mix instead of GAS1-GAS5 in deco planner
heinrichsweikamp
parents:
296
diff
changeset
|
668 PUTC ":" |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
669 bsf leftbind |
560 | 670 output_16 ; No decimal anymore. |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
671 bcf leftbind |
560 | 672 STRCAT_PRINT "" ; No unit: can be bars or litters. |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
673 |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
674 ; Loop for all 5 gas |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
675 simulator_show_decoplan5_1: |
560 | 676 movlw d'5' ; list all five gases |
677 cpfseq wait_temp ; All gases shown? | |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
678 bra simulator_show_decoplan5_loop ; No |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
679 |
292 | 680 WIN_COLOR color_greenish |
681 WIN_SMALL .80,.25 | |
560 | 682 STRCPY_TEXT tGasUsage ; OC: "Gas Usage" |
292 | 683 STRCAT_PRINT ":" |
684 call TFT_standard_color | |
560 | 685 call logbook_preloop_tasks |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
686 |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
687 simulator_show_decoplan5_3: |
560 | 688 btfss switch_right |
689 bra simulator_show_decoplan5_3a | |
690 bcf switch_right | |
691 clrf decoplan_page | |
692 bra deco_show_plan_1 ; toggle between stops plan and gas usage | |
693 simulator_show_decoplan5_3a: | |
694 btfss switch_left | |
695 bra simulator_show_decoplan5_4 | |
696 bcf is_bailout ; Back to normal | |
697 bcf ccr_diluent_setup ; init for OC/Bailout | |
292 | 698 return ; Return to simulator menu |
560 | 699 |
700 simulator_show_decoplan5_4: | |
701 call log_screendump_and_onesecond ; Check if we need to make a screen shot and check for new second | |
292 | 702 btfsc sleepmode ; Timeout? |
703 goto restart | |
704 bra simulator_show_decoplan5_3 | |
0 | 705 |
560 | 706 |
707 simulator_color_gas: ; set output color dependent on gas (1-5, in WREG) | |
708 movwf tft_temp1 ; used in TFT_set_color anyway | |
709 dcfsnz tft_temp1,F | |
710 movlw color_white ; color for Gas 1 | |
711 dcfsnz tft_temp1,F | |
712 movlw color_green ; color for Gas 2 | |
713 dcfsnz tft_temp1,F | |
714 movlw color_red ; Color for Gas 3 | |
715 dcfsnz tft_temp1,F | |
716 movlw color_yellow ; color for Gas 4 | |
717 dcfsnz tft_temp1,F | |
718 movlw color_cyan ; color for Gas 5 | |
719 goto TFT_set_color ; set color and return... | |
720 | |
0 | 721 ;============================================================================= |
722 ; | |
723 global do_demo_divemode | |
724 do_demo_divemode: | |
725 extern option_save_all | |
560 | 726 call option_save_all ; Save all settings into EEPROM before starting simulation |
0 | 727 call deco_push_tissues_to_vault |
560 | 728 banksel common ; Bank1 |
0 | 729 |
560 | 730 ; +++ COMMENTED OUT FOR TESTING PURPOSE ONLY !!! +++ |
731 ; +++ DO NOT COMMENT OUT IN OPERATIONAL USE !!! +++ | |
732 bsf restore_deco_data ; Restore tissue and CNS after simulator use | |
0 | 733 |
560 | 734 bcf pressure_refresh |
735 btfss pressure_refresh ; Wait for sensor | |
736 bra $-2 | |
737 | |
738 bsf simulatormode_active ; Set Flag | |
132
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
739 ; Compute dive ambient conditions |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
740 banksel char_I_bottom_depth |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
741 movf char_I_bottom_depth,W |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
742 mullw .100 |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
743 movff PRODL,rel_pressure+0 |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
744 movff PRODH,rel_pressure+1 |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
745 movlw LOW(.1000) |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
746 addwf PRODL,W |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
747 movff WREG,sim_pressure+0 |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
748 movlw HIGH(.1000) |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
749 addwfc PRODH,W |
ec0b1e829399
Bugfix: Start dive mode simulator in correct depth
heinrichsweikamp
parents:
111
diff
changeset
|
750 movff WREG,sim_pressure+1 |
0 | 751 |
560 | 752 banksel common ; Bank1 |
0 | 753 bsf divemode |
560 | 754 goto diveloop ; Switch into Divemode! |
0 | 755 |
756 | |
757 END |