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