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