Mercurial > public > hwos_code
annotate src/simulator.asm @ 600:cb59872ad53d
fix typo
author | heinrichsweikamp |
---|---|
date | Sun, 12 Aug 2018 18:18:41 +0200 |
parents | e1f0f5e3d4e4 |
children | ca4556fb60b9 |
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 |
598
e1f0f5e3d4e4
BUGFIX: Internal deco planner did not display results in imperial units
heinrichsweikamp
parents:
582
diff
changeset
|
269 movff hi,up ; backup hi (minutes) |
582 | 270 WIN_LEFT .85 |
271 movf lo,W ; lo = m | |
272 mullw .100 ; PRODL:PRODH = mbar | |
273 movff PRODL,lo | |
274 movff PRODH,hi | |
275 ; Convert with 334feet/100m to have 10ft, 20ft, 30ft stops... | |
276 movff lo,xA+0 | |
277 movff hi,xA+1 | |
278 movlw LOW d'334' ; 334feet/100m | |
279 movwf xB+0 | |
280 movlw HIGH d'334' | |
281 movwf xB+1 | |
282 call mult16x16 ; xA*xB=xC (lo:hi * 328) | |
283 movlw d'50' ; round up | |
284 addwf xC+0,F | |
285 movlw .0 | |
286 addwfc xC+1,F | |
287 addwfc xC+2,F | |
288 addwfc xC+3,F | |
289 movlw d'100' | |
290 movwf xB+0 | |
291 clrf xB+1 | |
292 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
293 movff xC+0,lo | |
294 movff xC+1,hi ; restore lo and hi with updated value | |
295 bsf leftbind | |
296 bsf ignore_digit4 ; Only full feet | |
297 output_16 | |
298 bcf leftbind | |
299 STRCAT_PRINT "ft " | |
598
e1f0f5e3d4e4
BUGFIX: Internal deco planner did not display results in imperial units
heinrichsweikamp
parents:
582
diff
changeset
|
300 movff up,hi ; restore hi (minutes) |
582 | 301 bra deco_plan_show_nstd_stop_common |
0 | 302 |
303 deco_plan_show_nstd_stop_metric: | |
582 | 304 WIN_LEFT .90 |
305 bsf leftbind | |
306 output_8 ; outputs into Postinc2! | |
307 bcf leftbind | |
308 STRCAT_PRINT "m " | |
309 | |
0 | 310 deco_plan_show_nstd_stop_common: |
582 | 311 ;---- Print duration ------------------------------------------------- |
312 WIN_LEFT .135 | |
313 lfsr FSR2,buffer | |
0 | 314 |
582 | 315 movf lo,W ; Swap hi & lo |
316 movff hi,lo | |
317 movwf hi | |
318 | |
319 output_8 ; Allow up to 240' | |
320 clrf WREG | |
321 movff WREG,buffer+.3 ; limit to 2 chars | |
322 STRCAT_PRINT "" | |
0 | 323 |
582 | 324 movf lo,W ; Swap back hi & lo |
325 movff hi,lo | |
326 movwf hi | |
0 | 327 |
582 | 328 ;--------------------------------------------------------------------- |
329 ; Draw the bar graph used for deco stops (deco plan in simulator or dive). | |
330 incf win_top,F | |
331 movlw .19 | |
332 movwf win_height | |
333 movlw .118 | |
334 movwf win_leftx2 ; column left (0-159) | |
335 movlw .16 | |
336 movwf win_width+0 ; column max width. | |
337 clrf win_width+1 | |
0 | 338 |
582 | 339 ; Draw used area (hi = minutes): |
340 movlw .16 ; Limit length (16min) | |
341 cpfslt hi | |
342 movwf hi | |
343 movff hi,win_bargraph ; Active width, the rest is cleared. | |
344 call TFT_box | |
0 | 345 |
582 | 346 ; Restore win_top |
347 call TFT_standard_color | |
348 decf win_top,F ; Restore win_top | |
349 return | |
0 | 350 |
351 ;----------------------------------------------------------------------------- | |
560 | 352 ; Clear unused area below last stop |
0 | 353 ; Inputs: win_top : last used area... |
354 deco_plan_show_clear_bottom: | |
582 | 355 movf win_top,W ; Get back from bank0 |
356 sublw .239 ; No: bottom row in planning | |
357 movwf win_height | |
0 | 358 |
582 | 359 WIN_LEFT .85 ; Full dive menu width |
360 movlw .159-.85+.1 | |
361 movwf win_width+0 | |
362 clrf win_width+1 | |
0 | 363 |
582 | 364 clrf win_color1 ; Fill with black |
365 clrf win_color2 | |
0 | 366 |
582 | 367 goto TFT_box ; and return |
0 | 368 |
369 ;----------------------------------------------------------------------------- | |
560 | 370 ; Display the deco plan (simulator). |
0 | 371 ; Inputs: char_O_deco_table (array of stop times, in minutes) |
372 ; decoplan_page = page number. | |
373 ; | |
374 deco_show_plan_page: | |
582 | 375 bcf win_invert ; Reset invert flag |
0 | 376 |
582 | 377 ;---- Is there deco stops ? ------------------------------------------ |
378 movff char_O_first_deco_depth,WREG | |
379 iorwf WREG | |
380 bnz deco_plan_show_1 | |
0 | 381 |
582 | 382 ;---- No Deco -------------------------------------------------------- |
383 call TFT_standard_color | |
384 TEXT_SMALL .80, .0, tNoDeco | |
385 bsf decoplan_last_ceiling_shown | |
386 return | |
0 | 387 |
388 deco_plan_show_1: | |
582 | 389 lfsr FSR0,char_O_deco_depth ; Initialize indexed addressing. |
390 lfsr FSR1,char_O_deco_time | |
0 | 391 |
582 | 392 clrf decoplan_index ; Start with index = 0 |
393 clrf win_top ; and row = 0 | |
0 | 394 |
582 | 395 ; Read stop parameters, indexed by decoplan_index and decoplan_page |
396 movf decoplan_page,W ; decoplan_gindex = 6*decoplan_page + decoplan_index | |
397 mullw .8 ; 8 lines/page in deco plan | |
398 movf decoplan_index,W | |
399 addwf PRODL,W | |
400 movwf decoplan_gindex ; --> decoplan_gindex | |
0 | 401 |
582 | 402 bcf decoplan_last_ceiling_shown ; Not finished yet... |
0 | 403 |
404 deco_plan_show_2: | |
582 | 405 btfsc decoplan_gindex,5 ; Reached table length (32) ? |
406 bra deco_plan_show_99 ; YES: finished... | |
0 | 407 |
582 | 408 ; Read stop parameters, indexed by decoplan_index |
409 movf decoplan_gindex,W ; index | |
410 movff PLUSW0,lo ; char_O_deco_depth[gindex] | |
411 movff PLUSW1,hi ; char_O_deco_time [gindex] | |
412 movf lo,W | |
413 bz deco_plan_show_99 ; depth == 0 : finished. | |
0 | 414 |
582 | 415 ; Display the stop line |
416 rcall deco_plan_show_stop | |
0 | 417 |
582 | 418 ; Next |
419 movlw .24 | |
420 addwf win_top,F ; row: += 24 | |
421 incf decoplan_index,F ; local index += 1 | |
422 incf decoplan_gindex,F ; global index += 1 | |
0 | 423 |
582 | 424 ; Max number of lines/page reached ? |
425 movlw .8 ; 8 lines/page in deco plan | |
426 cpfseq decoplan_index | |
427 bra deco_plan_show_2 ; NO: loop | |
0 | 428 |
582 | 429 ; Check if next stop is end-of-list ? |
430 movf decoplan_gindex,W | |
431 movf PLUSW0,W ; char_O_deco_depth[gindex] | |
432 bz deco_plan_show_99 ; End of list... | |
0 | 433 |
582 | 434 ; Display the message "more..." |
435 rcall deco_plan_show_clear_bottom ; Clear from next line | |
0 | 436 |
582 | 437 call TFT_standard_color |
438 TEXT_SMALL .88, .220, tMore | |
439 return | |
0 | 440 |
441 deco_plan_show_99: | |
582 | 442 bsf decoplan_last_ceiling_shown ; Nothing more in table to display. |
443 rcall deco_plan_show_clear_bottom ; Clear from next line | |
444 return | |
0 | 445 |
446 ;----------------------------------------------------------------------------- | |
560 | 447 ; Loop to show all pages of the deco plan (surface mode) |
0 | 448 |
582 | 449 global deco_show_plan |
0 | 450 deco_show_plan: |
582 | 451 clrf decoplan_page |
452 call TFT_ClearScreen | |
453 WIN_COLOR color_greenish | |
454 btfsc is_bailout | |
455 bra deco_show_plan_bail_title | |
456 TEXT_SMALL .1,.1, tDivePlan | |
457 bra deco_show_plan2 | |
462
1eeafeeb9287
CHANGE: Indicate "Bailout" for bailout deco plan in internal deco planer
heinrichsweikamp
parents:
432
diff
changeset
|
458 deco_show_plan_bail_title: |
582 | 459 TEXT_SMALL .1,.1, tDiveBailout |
462
1eeafeeb9287
CHANGE: Indicate "Bailout" for bailout deco plan in internal deco planer
heinrichsweikamp
parents:
432
diff
changeset
|
460 deco_show_plan2: |
582 | 461 call TFT_standard_color |
462 ;---- Display Plan Parameters | |
463 WIN_SMALL .0,.25 | |
464 STRCPY "Int:" | |
465 movff char_I_dive_interval,lo | |
466 bsf leftbind | |
467 output_8 | |
468 bcf leftbind | |
469 STRCAT_PRINT "'" | |
470 WIN_SMALL .0,.50 | |
471 STRCPY_TEXT tBtTm_short | |
472 movff char_I_bottom_time,lo | |
473 bsf leftbind | |
474 output_8 | |
475 bcf leftbind | |
476 STRCAT_PRINT "'" | |
477 WIN_SMALL .0,.75 | |
478 STRCPY_TEXT tDepth | |
479 PUTC ":" | |
480 movff char_I_bottom_depth,lo | |
481 bsf leftbind | |
482 output_8 | |
483 bcf leftbind | |
484 STRCAT_PRINT "m" | |
485 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
|
486 |
582 | 487 ;---- Check for Stop Table Overflow |
488 btfss decoplan_warnings,stoptable_overflow ; check if we have a overflow warning | |
489 bra deco_show_plan2a ; NO - skip | |
490 ;---- Display Overflow warning | |
491 call TFT_warnings_color ; YES - show overflow warning | |
492 STRCAT_PRINT "incomplete" ; max 10 characters | |
493 bra deco_show_plan_m1 ; skip displaying sat/dsat factors | |
494 | |
495 deco_show_plan2a: | |
496 ;---- Check for IBCD Warning | |
497 btfss decoplan_warnings,IBCD_warning_lock ; check if we have a locked IBCD warning | |
498 bra deco_show_plan2b ; NO - skip | |
499 ;---- Display IBCD warning | |
500 call TFT_attention_color ; YES - show IBCD warning | |
501 STRCAT_PRINT "IBCD!" ; max 10 characters | |
502 bra deco_show_plan_m1 ; skip displaying sat/dsat factors | |
503 | |
560 | 504 deco_show_plan2b: |
582 | 505 ;---- Display Sat/Desat Factors --> omitted if there were warnings |
506 STRCAT_PRINT "SD:" | |
507 WIN_SMALL .25,.105 | |
508 movff char_I_saturation_multiplier,lo | |
509 output_8 | |
510 STRCAT "/" | |
511 movff char_I_desaturation_multiplier,lo | |
512 output_8 | |
513 STRCAT_PRINT "" | |
560 | 514 |
515 deco_show_plan_m1: | |
582 | 516 call TFT_standard_color ; clean-up from warnings |
0 | 517 |
582 | 518 ;---- Get Model |
519 movff char_I_deco_model,WREG | |
520 iorwf WREG | |
521 bz deco_show_plan_m2 | |
560 | 522 |
582 | 523 ;---- Display GF low/high values |
524 WIN_SMALL .0,.130 | |
525 STRCAT_PRINT "GF:" | |
526 WIN_SMALL .25,.130 | |
527 movff char_I_GF_Low_percentage,lo | |
528 output_99x | |
529 STRCAT "/" | |
530 movff char_I_GF_High_percentage,lo | |
531 output_99x | |
532 STRCAT_PRINT "" | |
560 | 533 |
208
53771bd3d567
NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents:
197
diff
changeset
|
534 deco_show_plan_m2: |
582 | 535 ;---- Display Deco Mode |
536 WIN_SMALL .0,.155 | |
537 lfsr FSR2,buffer | |
538 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR | |
539 call TFT_display_decotype_surface1 | |
540 btfss FLAG_ccr_mode ; current dive mode = CCR ? | |
541 bra deco_show_plan2c ; NO - branch | |
542 WIN_SMALL .25,.155 | |
543 STRCPY "SP:" ; output setpoint used for calculation | |
544 movff opt_sim_setpoint_number,lo | |
545 bsf leftbind | |
546 output_8 | |
547 bcf leftbind | |
548 STRCAT_PRINT "" | |
0 | 549 |
560 | 550 deco_show_plan2c: |
582 | 551 ;---- Display TTS result |
552 WIN_SMALL .0,.180 | |
553 STRCPY_TEXT tTTS | |
554 STRCAT ": " | |
555 movff int_O_ascenttime+0,lo | |
556 movff int_O_ascenttime+1,hi | |
557 bsf leftbind | |
558 output_16 | |
559 bcf leftbind | |
560 STRCAT_PRINT "'" | |
0 | 561 |
582 | 562 ;---- Display CNS result |
563 WIN_TOP .205 | |
564 STRCPY_TEXT tCNS2 ; "CNS:" | |
565 movff int_O_CNS_fraction+0,lo | |
566 movff int_O_CNS_fraction+1,hi | |
567 call TFT_color_code_cns ; Color-code CNS output | |
568 bsf leftbind | |
569 output_16_3 ; limit to 999 and display only (0-999) | |
570 bcf leftbind | |
571 STRCAT "%\x92" ; "->" | |
572 movff int_O_normal_CNS_fraction+0,lo | |
573 movff int_O_normal_CNS_fraction+1,hi | |
574 call TFT_color_code_cns ; Color-code CNS output | |
575 bsf leftbind | |
576 output_16_3 ; limit to 999 and display only (0-999) | |
577 bcf leftbind | |
578 STRCAT_PRINT "%" | |
579 call TFT_standard_color | |
580 | |
581 ;---- Loop through pages | |
0 | 582 deco_show_plan_1: |
582 | 583 ; Clear the complete stop result column: |
584 WIN_BOX_BLACK .0, .239, .80, .159 ; top, bottom, left, right | |
585 | |
586 rcall deco_show_plan_page | |
587 incf decoplan_page,F | |
588 call logbook_preloop_tasks | |
0 | 589 deco_show_plan_2: |
582 | 590 btfsc switch_right |
591 bra deco_show_plan_3 | |
592 btfsc switch_left | |
593 return ; Return to simulator menu | |
594 call log_screendump_and_onesecond ; Check if we need to make a screen shot and check for new second | |
595 btfsc sleepmode ; Timeout? | |
596 goto restart | |
597 bra deco_show_plan_2 | |
0 | 598 |
599 deco_show_plan_3: | |
582 | 600 btfss decoplan_last_ceiling_shown |
601 bra deco_show_plan_1 | |
602 ; All stops shown | |
295
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
603 |
582 | 604 ;---- In CCR and pSCR mode, compute a BAILOUT deco plan ----------------------- |
605 movff char_O_deco_status,WREG ; get deco calculation status | |
606 btfss WREG,DECO_MODE_LOOP_FLAG ; check if in CCR or pSCR mode | |
607 bra simulator_show_decoplan5_0 ; NO - normal OC mode: just display | |
608 bsf is_bailout ; YES - redo 2nd deco-plan in bailout mode | |
609 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
|
610 |
582 | 611 btfss decoplan_abort ; shall we abort? |
612 bra deco_show_plan ; NO - display bailout stops | |
613 return ; YES | |
560 | 614 |
295
7027d735ac62
NEW CCR decoplan: 2nd pass to display bailout stops and gas volumes
jDG
parents:
294
diff
changeset
|
615 |
582 | 616 ;---- In OC+BAIL modes, show the gas usage special page ----------------------- |
617 simulator_show_decoplan5_0: | |
618 ; Clear the complete stop result column: | |
619 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
|
620 |
582 | 621 movlw .25 |
622 movwf row_pos ; Row for gas list is .25+.25 | |
623 clrf gas_counter ; Gas counter | |
624 lfsr FSR0,int_O_gas_volumes ; Initialize indexed addressing. | |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
625 |
582 | 626 WIN_LEFT .80 ; Set column |
627 call TFT_standard_color | |
284
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 simulator_show_decoplan5_loop: |
582 | 630 movff gas_counter,PRODL ; Copy to PRODL first |
631 incf gas_counter,F ; Increment gas # | |
632 | |
633 movff gas_counter,WREG ; copy current gas to WREG for color-coding | |
634 call TFT_color_code_gas ; set output color according to gas (1-5) | |
560 | 635 |
582 | 636 lfsr FSR2,buffer |
637 bsf short_gas_decriptions | |
638 bsf divemode ; Tweak "customview_show_mix:" | |
639 call gaslist_strcat_gas ; Input: PRODL : gas number (0..4), Output: "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 | |
640 bcf divemode ; Tweak "customview_show_mix:" | |
560 | 641 |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
642 movlw .25 |
582 | 643 addwf row_pos,F ; Increase row position |
644 movff row_pos,win_top ; Set Row | |
645 | |
646 movff POSTINC0,lo ; Read (16bit) result, low first, | |
647 movff POSTINC0,hi ; then high. | |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
648 |
582 | 649 movf lo,W |
650 andwf hi,W | |
651 incf WREG ; > 65535? | |
652 bnz simulator_show_decoplan5_1 ; NO | |
653 STRCAT_PRINT ">65500" ; YES | |
654 bra simulator_show_decoplan5_2 | |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
655 |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
656 simulator_show_decoplan5_1: |
582 | 657 PUTC ":" |
658 bsf leftbind | |
659 output_16 ; No decimal anymore. | |
660 bcf leftbind | |
661 STRCAT_PRINT "" | |
662 | |
663 ; Loop for all 5 gas | |
664 simulator_show_decoplan5_2: | |
665 movlw d'5' ; list all five gases | |
666 cpfseq gas_counter ; All gases shown? | |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
667 bra simulator_show_decoplan5_loop ; No |
582 | 668 |
669 WIN_COLOR color_greenish | |
670 | |
671 movlw .30 | |
672 addwf row_pos,F ; Increase row position | |
673 movff row_pos,win_top ; Set Row | |
674 STRCPY_TEXT_PRINT tBarLiter ; "Bar Liter" | |
675 | |
676 WIN_SMALL .80,.25 | |
677 STRCPY_TEXT tGasUsage ; "Gas Usage" | |
678 STRCAT_PRINT ":" | |
679 | |
680 call TFT_standard_color | |
681 call logbook_preloop_tasks | |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
682 |
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
683 simulator_show_decoplan5_3: |
582 | 684 btfss switch_right |
560 | 685 bra simulator_show_decoplan5_3a |
686 bcf switch_right | |
582 | 687 clrf decoplan_page |
560 | 688 bra deco_show_plan_1 ; toggle between stops plan and gas usage |
689 simulator_show_decoplan5_3a: | |
582 | 690 btfss switch_left |
560 | 691 bra simulator_show_decoplan5_4 |
582 | 692 bcf is_bailout ; Back to normal |
693 bcf ccr_diluent_setup ; init for OC/Bailout | |
694 return ; Return to simulator menu | |
560 | 695 |
582 | 696 simulator_show_decoplan5_4: |
697 call log_screendump_and_onesecond ; Check if we need to make a screen shot and check for new second | |
698 btfsc sleepmode ; Timeout? | |
699 goto restart | |
700 bra simulator_show_decoplan5_3 | |
0 | 701 |
582 | 702 END |