Mercurial > public > hwos_code
annotate src/simulator.asm @ 627:bf5fee575701
minor cleanup, reset rx circuity
author | heinrichsweikamp |
---|---|
date | Sun, 30 Jun 2019 23:22:32 +0200 |
parents | c40025d8e750 |
children | cd58f7fc86db |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
623 | 3 ; File simulator.asm combined next generation V3.03.3 |
0 | 4 ; |
623 | 5 ; Deco Calculator |
0 | 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,... | |
0 | 17 #include "start.inc" |
18 #include "divemode.inc" | |
623 | 19 #include "sleepmode.inc" |
0 | 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" |
623 | 24 #include "surfmode.inc" |
25 #include "wait.inc" | |
0 | 26 |
623 | 27 |
582 | 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 | |
623 | 32 extern TFT_decotype_logbook |
582 | 33 extern do_return_demo_planner |
604 | 34 extern dive_boot_oc_bail |
35 extern dive_boot_oc | |
623 | 36 |
37 IFDEF _ccr_pscr | |
604 | 38 extern dive_boot_cc |
623 | 39 ENDIF |
560 | 40 |
0 | 41 |
623 | 42 ;---- Private local Variables ------------------------------------------------- |
0 | 43 |
582 | 44 CBLOCK local1 ; max size is 16 Byte !!! |
45 decoplan_index ; within each page | |
46 decoplan_gindex ; global index | |
623 | 47 decoplan_last ; depth of last stop |
48 decoplan_flags ; private flags | |
582 | 49 decoplan_page ; page number |
50 decoplan_warnings ; deco engine warnings | |
623 | 51 gas_index ; counter for looping through the gases |
52 output_row ; used for positioning of the results output | |
582 | 53 ENDC ; used: 8 byte, remaining: 8 byte |
54 | |
623 | 55 |
56 ;---- Private local Flags ---------------------------------------------------- | |
560 | 57 |
623 | 58 #define decoplan_abort decoplan_flags,0 ; =1: deco calculations were aborted |
59 #define decoplan_last_stop_shown decoplan_flags,1 ; =1: last deco stop is shown | |
60 #define decoplan_pressures_shown decoplan_flags,2 ; =1: show gas volumes in bar as per tank sizes | |
61 #define decoplan_overflow decoplan_flags,3 ; =1: result > 999 | |
62 #define decoplan_toggleflag decoplan_flags,4 ; used to show calculation progress | |
63 ; decoplan_flags,5 ; --- unused | |
64 ; decoplan_flags,6 ; --- unused | |
65 ; decoplan_flags,7 ; --- unused | |
560 | 66 |
604 | 67 |
623 | 68 simulator CODE |
604 | 69 |
623 | 70 ;----------------------------------------------------------------------------- |
604 | 71 |
623 | 72 ;============================================================================= |
73 ; Deco Calculator Main Function | |
74 ; | |
582 | 75 global do_demo_planner |
0 | 76 do_demo_planner: |
604 | 77 btfsc FLAG_gauge_mode ; in gauge mode? |
78 bra do_demo_planner_exit ; YES - abort | |
623 | 79 btfsc FLAG_apnoe_mode ; in apnea mode? |
604 | 80 bra do_demo_planner_exit ; YES - abort |
623 | 81 |
82 clrf decoplan_flags ; clear all local flags | |
83 bsf simulatormode ; activate simulator mode | |
84 bsf reset_timebase ; request ISR to reset the timebase | |
85 ; btfsc reset_timebase ; has the ISR confirmed reset of the timebase? | |
86 ; bra $-2 ; NO - not yet, loop waiting for the ISR | |
87 call deco_push_tissues_to_vault ; back-up the state of the real tissues (C-code) | |
88 banksel common ; back to bank common | |
89 | |
90 rcall deco_calculate ; calculate deco plan | |
91 btfss decoplan_abort ; was the deco plan calculation aborted? | |
92 rcall deco_results ; NO - show results | |
93 | |
94 movff simulator_time,char_I_dive_interval ; get the deco calculator runtime | |
95 call deco_pull_tissues_from_vault ; restore the status of the real tissues (C-code) | |
96 call deco_calc_dive_interval ; catch up with tissue desaturation (C-code) | |
97 call deco_calc_desaturation_time ; calculate desaturation and no-fly/no-altitude time after catch-up (C-code) | |
98 banksel common ; back to bank common | |
99 | |
100 bcf switch_left ; clear left button event (may be left over from abort/exit) | |
101 bcf simulatormode ; terminate simulator mode | |
102 bsf reset_timebase ; request ISR to reset the timebase | |
103 ; btfsc reset_timebase ; has the ISR confirmed reset of timebase? | |
104 ; bra $-2 ; NO - not yet, loop waiting for the ISR | |
105 | |
106 btfsc divemode ; shall go into dive mode? | |
107 goto restart ; YES - goto restart which will dispatch further on to dive mode | |
108 | |
109 btfss trigger_timeout ; timeout on any button press? | |
110 bra do_demo_planner_exit ; NO - take normal exit into surface menu | |
111 bcf trigger_timeout ; YES - clear timeout flag | |
112 bcf restart_fast ; - set next restart to be done slow, i.e. with logos | |
113 goto sleeploop ; - goto sleep mode | |
114 | |
604 | 115 do_demo_planner_exit: |
623 | 116 goto do_return_demo_planner ; return to simulator menu |
0 | 117 |
118 | |
623 | 119 ;============================================================================= |
120 ; Calculate the Deco Plan | |
121 ; | |
122 deco_calculate: | |
123 call request_speed_fastest ; request CPU speed change to fastest speed | |
124 call TFT_ClearScreen ; clear screen to show that calculator is starting up | |
125 | |
126 ; initialization of the deco engine | |
127 btfsc update_surface_pressure ; is there a pending surface pressure update? | |
128 bra $-2 ; YES - loop waiting for the ISR to kick in | |
129 | |
130 ; set mode and gases | |
131 call dive_boot_oc_bail ; basic setup for all modes, also clears bailout_mode | |
132 | |
133 IFDEF _ccr_pscr | |
604 | 134 btfsc FLAG_oc_mode ; in OC mode? |
135 call dive_boot_oc ; YES - set up OC mode | |
136 btfss FLAG_oc_mode ; in OC mode? | |
137 call dive_boot_cc ; NO - set up CCR/pSCR mode | |
623 | 138 ELSE |
139 call dive_boot_oc ; set up OC mode | |
140 ENDIF | |
0 | 141 |
623 | 142 ; set absolute pressure at selected depth |
143 movff char_I_bottom_depth,WREG ; get selected depth in meters | |
144 mullw .100 ; multiply with 100 to get relative pressure in mbar | |
145 movff int_I_pres_surface+0,WREG ; low byte - get surface pressure to WREG | |
146 addwf PRODL,W ; - add relative pressure | |
147 movff WREG,int_I_pres_respiration+0 ; - store as absolute pressure at depth | |
148 movff int_I_pres_surface+1,WREG ; high byte - get surface pressure to WREG | |
149 addwfc PRODH,W ; - add relative pressure | |
150 movff WREG,int_I_pres_respiration+1 ; - store as absolute pressure at depth | |
582 | 151 |
623 | 152 ; set deco stop settings |
153 movlw deco_distance ; get deco distance safety factor | |
154 movff WREG,char_I_deco_distance ; write deco distance safety factor to deco engine | |
155 movff opt_last_stop,char_I_depth_last_deco ; write last stop depth to deco engine | |
0 | 156 |
623 | 157 ; set GF factors |
158 movff opt_GF_low, char_I_GF_Low_percentage ; load normal GF factors by default | |
159 movff opt_GF_high,char_I_GF_High_percentage ; ... | |
160 TSTOSS opt_sim_use_aGF ; shall use alternative GF factors in simulation? | |
161 bra deco_calculate_1 ; NO - keep normal GF factors | |
162 movff opt_aGF_low ,char_I_GF_Low_percentage ; YES - overwrite with alternative GF factors | |
163 movff opt_aGF_high,char_I_GF_High_percentage ; - ... | |
164 | |
165 deco_calculate_1: | |
582 | 166 |
623 | 167 IFDEF _ccr_pscr |
168 ; set char_I_const_ppO2 for pSCR/CCR mode | |
169 clrf WREG ; load coding for pSCR calculated ppO2 | |
170 btfsc FLAG_pscr_mode ; in pSCR mode? | |
171 movff WREG,char_I_const_ppO2 ; YES - configure pSCR computations to calculated ppO2 | |
172 btfss FLAG_ccr_mode ; in CCR mode? | |
173 bra deco_calculate_2 ; NO - skip next | |
174 movff opt_sim_setpoint_number,WREG ; YES - get selected setpoint | |
175 decf WREG,W ; - 1-5 -> 0-4 | |
176 lfsr FSR1,opt_setpoint_cbar ; - load base address of setpoint list | |
177 movff PLUSW1,char_I_const_ppO2 ; - configure setpoint value | |
178 ENDIF | |
0 | 179 |
623 | 180 deco_calculate_2: |
560 | 181 |
623 | 182 ; configure the deco engine - char_O_main_status |
183 movff char_O_main_status,hi ; get the configuration set by dive_boot_oc / dive_boot_cc | |
184 bsf hi,DECO_VOLUME_FLAG ; enable gas volume calculation | |
185 bsf hi,DECO_BOTTOM_FLAG ; include bottom segment into gas needs | |
186 bcf hi,DECO_CAVE_MODE ; cave mode not supported in deco calculator | |
187 bcf hi,DECO_Z_FACTOR_FLAG ; disable Z factors by default | |
188 TSTOSC opt_ZfactorUse ; shall use Z factors? | |
189 bsf hi,DECO_Z_FACTOR_FLAG ; YES - enable Z factors | |
190 bcf hi,DECO_EXTENDED_STOPS ; disable extended stops by default | |
191 TSTOSC opt_extended_stops ; shall make extended stops? | |
192 bsf hi,DECO_EXTENDED_STOPS ; YES - activate extended stops | |
193 bcf hi,DECO_TR_FUNCTIONS ; execution of TR functions is not needed in deco calculator mode | |
194 movff hi,char_O_main_status ; bank-safe copy to deco engine control | |
560 | 195 |
623 | 196 ; configure the deco engine - char_O_deco_status |
197 movff char_O_deco_status,lo ; get the configuration set by dive_boot_oc / dive_boot_cc | |
198 bcf lo,DECO_START_NORM ; clear flag for normal plan mode | |
199 bcf lo,DECO_START_ALT ; clear flag for alternative plan mode | |
200 bsf lo,DECO_INITIALIZE ; set flag for once-per-dive initialization | |
201 bcf lo,DECO_BAILOUT_FLAG ; no gas switches before first deco stop | |
202 bcf lo,DECO_ASCENT_FLAG ; no delayed ascent | |
203 movff lo,char_O_deco_status ; bank-safe copy to deco engine control | |
204 | |
205 deco_calculate_redo: | |
206 | |
207 call request_speed_fastest ; request CPU speed change to fastest speed (again, if in redo) | |
560 | 208 |
623 | 209 ; show that the deco calculation is in progress |
210 call TFT_ClearScreen ; clear screen from last results | |
211 WIN_COLOR color_lightblue ; select color for abort label | |
212 TEXT_SMALL .1,.215, tAbort ; print abort label | |
213 WIN_COLOR color_white ; select color for title and progress outputs | |
214 TEXT_SMALL .0, .40, tCalculating ; print "Calculating..." | |
0 | 215 |
623 | 216 ; calculated the surface interval |
217 TSTOSS opt_surface_interval ; surface interval > 0 ? | |
218 bra deco_calculate_bottom ; NO - continue with bottom segment | |
219 TEXT_SMALL .20,.75, tCalcSurfInter ; YES - print what we are doing | |
220 movff opt_surface_interval,char_I_dive_interval ; - copy surface interval to deco engine | |
221 call deco_calc_dive_interval ; - calculate surface interval (C-code) | |
222 banksel common ; - back to bank common | |
0 | 223 |
623 | 224 ; calculate the bottom segment |
225 deco_calculate_bottom: | |
226 ; advance tissues by selected bottom time, | |
227 ; char_I_sim_advance_time is cleared by deco engine after execution | |
228 movff char_I_bottom_time,char_I_sim_advance_time | |
229 | |
230 TEXT_SMALL .20,.100, tCalcBotSeg ; print what we are doing | |
231 | |
232 ; invoke the deco engine once to condition the real tissues | |
233 ; to their pressure state at the end of the bottom segment | |
234 call deco_calc_hauptroutine ; (C-code) | |
604 | 235 banksel common |
0 | 236 |
623 | 237 IFDEF _ccr_pscr |
238 ; conditional switch to bailout mode | |
239 btfss bailout_mode ; shall calculate a bailout plan? | |
240 bra deco_calculate_ascent ; NO - skip next | |
111 | 241 |
623 | 242 call dive_boot_oc ; YES - switch to OC mode and gases |
243 movff char_O_main_status,hi ; - bank-safe copy from deco engine control (main status) | |
244 bcf hi,DECO_BOTTOM_FLAG ; - exclude bottom segment from gas needs, i.e. calculate ascent needs only | |
245 movff hi,char_O_main_status ; - bank-safe copy back to deco engine control | |
246 movff char_O_deco_status,lo ; - bank-safe copy from deco engine control (deco status) | |
247 bsf lo,DECO_BAILOUT_FLAG ; - allow gas switches before first deco stop | |
248 bsf lo,DECO_ASCENT_FLAG ; - allow delayed ascent | |
249 movff lo,char_O_deco_status ; - bank-safe copy back to deco engine control | |
604 | 250 |
623 | 251 TEXT_SMALL .20,.125, tCalcBailout ; - print what we are doing |
252 ENDIF | |
0 | 253 |
623 | 254 ; calculate ascent |
255 deco_calculate_ascent: | |
256 movff char_O_deco_status,lo ; bank-safe copy from deco engine control | |
257 bsf lo,DECO_START_NORM ; start calculation of a normal plan | |
258 movff lo,char_O_deco_status ; bank-safe copy back to deco engine control | |
259 TEXT_SMALL .20,.150, tCalcAscent ; print what we are doing | |
260 deco_calculate_loop: | |
261 btfsc switch_left ; was the left button pressed? | |
262 bra deco_calculate_abort ; YES - set abort flag, do some clean-up and return | |
263 call deco_calc_hauptroutine ; NO - invoke the deco engine so that it can do the deco calculation (C-code) | |
264 banksel common ; - back to bank common | |
265 movff char_O_depth_sim,lo ; - get the depth reached (in meters) | |
266 WIN_SMALL .70,.150 ; - set output position | |
267 output_8 ; - print depth reached (in meters) | |
268 STRCAT " m" ; - print unit (meters) | |
269 btg decoplan_toggleflag ; - toggle the toggle flag | |
270 btfsc decoplan_toggleflag ; - toggle flag set? | |
271 bra deco_calculate_loop_1 ; YES - print ". " | |
272 STRCAT_PRINT " ." ; NO - print " ." | |
273 bra deco_calculate_loop_2 ; | |
274 deco_calculate_loop_1: ; | |
275 STRCAT_PRINT ". " ; | |
276 deco_calculate_loop_2: ; | |
277 movff char_O_deco_status,lo ; - get deco calculation status | |
278 btfss lo,DECO_COMPLETED_NORM ; - deco calculation completed? | |
279 bra deco_calculate_loop ; NO - loop | |
280 movff char_O_deco_warnings,decoplan_warnings; YES - copy warnings for later display | |
281 bra deco_calculate_finish ; - do some clean-up and return | |
282 deco_calculate_abort: | |
283 bcf switch_left ; clear button event | |
284 bsf decoplan_abort ; set abort flag | |
285 deco_calculate_finish: | |
286 goto request_speed_normal ; request switch back to normal speed and return to deco calculator main function | |
0 | 287 |
288 | |
289 ;----------------------------------------------------------------------------- | |
623 | 290 ; Draw a stop of the deco plan (simulator or dive) |
582 | 291 ; Inputs: lo = depth |
292 ; hi = minutes | |
293 ; win_top = line to draw on screen. | |
294 ; | |
295 ; Trashed: hi, lo, | |
296 ; win_height, win_leftx2, win_width, win_color*, | |
0 | 297 ; WREG, PROD, TBLPTR TABLAT. |
298 ; | |
299 deco_plan_show_stop: | |
623 | 300 ; print depth |
301 lfsr FSR2,char_O_deco_gas ; needed to be initialized here every time because... | |
302 movf decoplan_gindex,W ; ...FSR2 is also used for string operations | |
303 movff PLUSW2,WREG ; get current gas and copy it to WREG for color-coding | |
304 call TFT_color_code_gas ; set output color dependent on gas (1-5) | |
0 | 305 |
623 | 306 lfsr FSR2,buffer ; set up output buffer |
0 | 307 |
623 | 308 TSTOSS opt_units ; 0=Meter, 1=Feet |
309 bra deco_plan_show_nstd_stop_metric ; 0 - do metric | |
310 ; 1 - do imperial | |
311 movff hi,ul ; back-up hi (minutes) | |
604 | 312 WIN_LEFT .80 |
623 | 313 call convert_meter_to_feet ; convert value in lo from meters to feet |
314 output_16_3 ; limit output to 0...999 | |
604 | 315 STRCAT_PRINT "ft" |
623 | 316 movff ul,hi ; restore hi (minutes) |
582 | 317 bra deco_plan_show_nstd_stop_common |
0 | 318 |
319 deco_plan_show_nstd_stop_metric: | |
604 | 320 WIN_LEFT .85 |
623 | 321 output_8 ; outputs into postinc2 |
604 | 322 STRCAT_PRINT "m" |
582 | 323 |
0 | 324 deco_plan_show_nstd_stop_common: |
623 | 325 |
326 ; print duration | |
582 | 327 WIN_LEFT .135 |
328 lfsr FSR2,buffer | |
329 movff hi,lo | |
623 | 330 output_99 ; stop entries are 99 min max. |
604 | 331 STRCAT_PRINT "'" |
0 | 332 |
623 | 333 ; draw the bar graph used for deco stops (lo = minutes) |
582 | 334 incf win_top,F |
335 movlw .19 | |
336 movwf win_height | |
337 movlw .118 | |
623 | 338 movwf win_leftx2 ; column left (0-159) |
339 MOVLI .16,win_width ; column max width | |
340 ; movlw .16 ; limit length to max. column width - not needed, done by TFT_box | |
341 ; cpfslt lo | |
342 ; movwf lo | |
343 incf lo,W ; add 1 for a minimum visible active bargraph area | |
344 movwf win_bargraph ; set width of the active bargraph area | |
345 call TFT_box ; draw bargraph | |
0 | 346 |
623 | 347 ; restore win_top |
582 | 348 call TFT_standard_color |
623 | 349 decf win_top,F ; restore win_top |
582 | 350 return |
0 | 351 |
352 ;----------------------------------------------------------------------------- | |
560 | 353 ; Clear unused area below last stop |
623 | 354 ; Inputs: win_top : last used area |
355 ; | |
0 | 356 deco_plan_show_clear_bottom: |
623 | 357 movf win_top,W ; get back from bank0 |
358 sublw .239 ; bottom row in planning | |
582 | 359 movwf win_height |
0 | 360 |
623 | 361 WIN_LEFT .85 ; full dive menu width |
362 MOVLI .75,win_width ; .159-.85+.1 | |
0 | 363 |
623 | 364 clrf win_color1 ; fill with black |
582 | 365 clrf win_color2 |
0 | 366 |
623 | 367 goto TFT_box ; and return |
0 | 368 |
369 ;----------------------------------------------------------------------------- | |
623 | 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 ; | |
623 | 374 deco_results_page: |
375 bcf win_invert ; reset invert flag | |
376 WIN_COLOR color_greenish | |
377 IFDEF _ccr_pscr | |
378 btfss bailout_mode ; bailout results? | |
379 bra deco_results_page_1 ; NO | |
380 TEXT_SMALL .80,.1, tDiveBailout ; YES | |
381 bra deco_results_page_2 | |
382 ENDIF | |
383 deco_results_page_1: | |
384 TEXT_SMALL .80,.1, tDivePlan | |
385 deco_results_page_2: | |
386 movff char_O_deco_depth,WREG ; get depth of the first deco stop | |
387 iorwf WREG ; is there at least one deco stop? | |
388 bnz deco_plan_show_1 ; YES | |
0 | 389 |
623 | 390 ;---- no deco -------------------------------------------------------- |
582 | 391 call TFT_standard_color |
623 | 392 TEXT_SMALL .80, .25, tNoDeco |
604 | 393 |
394 ; output of remaining NDL time | |
623 | 395 WIN_SMALL .80, .50 ; same line as bottom time |
396 movff char_O_NDL_norm,lo ; get NDL time in normal plan | |
604 | 397 output_8 |
398 PUTC "'" | |
399 PUTC " " | |
623 | 400 STRCAT_TEXT_PRINT tNDLleft ; "left" |
604 | 401 |
623 | 402 bsf decoplan_last_stop_shown |
582 | 403 return |
0 | 404 |
623 | 405 ;---- deco stops --------------------------------------------------------- |
0 | 406 deco_plan_show_1: |
623 | 407 lfsr FSR0,char_O_deco_depth ; initialize indexed addressing |
582 | 408 lfsr FSR1,char_O_deco_time |
0 | 409 |
623 | 410 clrf decoplan_index ; start with index = 0 |
604 | 411 movlw .24 |
623 | 412 movwf win_top ; and row = 0 at position 24 |
0 | 413 |
623 | 414 ; read stop parameters, indexed by decoplan_index and decoplan_page |
415 movf decoplan_page,W ; decoplan_gindex = 6*decoplan_page + decoplan_index | |
416 mullw .8 ; 8 lines/page in deco plan | |
582 | 417 movf decoplan_index,W |
418 addwf PRODL,W | |
623 | 419 movwf decoplan_gindex ; --> decoplan_gindex |
0 | 420 |
623 | 421 bcf decoplan_last_stop_shown ; not done yet... |
0 | 422 |
423 deco_plan_show_2: | |
623 | 424 btfsc decoplan_gindex,5 ; reached table length (32) ? |
425 bra deco_plan_show_99 ; YES - done | |
0 | 426 |
623 | 427 ; read stop parameters, indexed by decoplan_index |
428 movf decoplan_gindex,W ; index | |
429 movff PLUSW0,lo ; char_O_deco_depth[decoplan_gindex] | |
430 movff PLUSW1,hi ; char_O_deco_time [decoplan_gindex] | |
582 | 431 movf lo,W |
623 | 432 bz deco_plan_show_99 ; depth == 0 -> done |
0 | 433 |
623 | 434 ; display the stop line |
582 | 435 rcall deco_plan_show_stop |
0 | 436 |
623 | 437 ; next |
582 | 438 movlw .24 |
623 | 439 addwf win_top,F ; row: += 24 |
440 incf decoplan_index,F ; local index += 1 | |
441 incf decoplan_gindex,F ; global index += 1 | |
0 | 442 |
623 | 443 ; max number of lines/page reached? |
444 movlw .8 ; 8 lines/page in deco plan | |
582 | 445 cpfseq decoplan_index |
623 | 446 bra deco_plan_show_2 ; NO - loop |
0 | 447 |
623 | 448 ; check if next stop is end-of-list? |
582 | 449 movf decoplan_gindex,W |
623 | 450 movf PLUSW0,W ; char_O_deco_depth[decoplan_gindex] |
451 bz deco_plan_show_99 ; end of list | |
0 | 452 |
623 | 453 ; display the message "more..." |
454 rcall deco_plan_show_clear_bottom ; clear from next line | |
0 | 455 |
582 | 456 call TFT_standard_color |
457 TEXT_SMALL .88, .220, tMore | |
458 return | |
0 | 459 |
460 deco_plan_show_99: | |
623 | 461 bsf decoplan_last_stop_shown ; nothing more in table to display |
462 rcall deco_plan_show_clear_bottom ; clear from next line | |
463 call TFT_standard_color | |
582 | 464 return |
0 | 465 |
623 | 466 ;============================================================================= |
467 ; Show Deco Calculation Results | |
468 ; | |
469 deco_results: | |
582 | 470 call TFT_ClearScreen |
471 call TFT_standard_color | |
623 | 472 |
473 ; display plan parameters | |
582 | 474 WIN_SMALL .0,.25 |
623 | 475 STRCPY "Int. :" |
582 | 476 movff char_I_dive_interval,lo |
477 output_8 | |
478 STRCAT_PRINT "'" | |
479 WIN_SMALL .0,.50 | |
480 STRCPY_TEXT tBtTm_short | |
481 movff char_I_bottom_time,lo | |
482 output_8 | |
483 STRCAT_PRINT "'" | |
484 WIN_SMALL .0,.75 | |
485 STRCPY_TEXT tDepth | |
486 PUTC ":" | |
487 movff char_I_bottom_depth,lo | |
488 output_8 | |
489 STRCAT_PRINT "m" | |
490 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
|
491 |
623 | 492 ; check for stop table overflow |
582 | 493 btfss decoplan_warnings,stoptable_overflow ; check if we have a overflow warning |
623 | 494 bra deco_results_0a ; NO - skip |
495 | |
496 ; display overflow warning | |
497 call TFT_warning_color ; YES - show overflow warning | |
582 | 498 STRCAT_PRINT "incomplete" ; max 10 characters |
623 | 499 bra deco_results_m1 ; skip displaying sat/dsat factors |
500 | |
501 deco_results_0a: | |
582 | 502 |
623 | 503 IFDEF _helium |
504 ; check for IBCD warning | |
582 | 505 btfss decoplan_warnings,IBCD_warning_lock ; check if we have a locked IBCD warning |
623 | 506 bra deco_results_2b ; NO - skip |
507 | |
508 ; display IBCD warning | |
582 | 509 call TFT_attention_color ; YES - show IBCD warning |
510 STRCAT_PRINT "IBCD!" ; max 10 characters | |
623 | 511 bra deco_results_m1 ; skip displaying sat/dsat factors |
512 ENDIF | |
582 | 513 |
623 | 514 deco_results_2b: |
515 | |
516 ; display Sat/Desat factors --> omitted if there were warnings | |
582 | 517 STRCAT_PRINT "SD:" |
518 WIN_SMALL .25,.105 | |
519 movff char_I_saturation_multiplier,lo | |
520 output_8 | |
604 | 521 STRCAT "/" |
582 | 522 movff char_I_desaturation_multiplier,lo |
523 output_8 | |
524 STRCAT_PRINT "" | |
560 | 525 |
623 | 526 deco_results_m1: |
527 | |
582 | 528 call TFT_standard_color ; clean-up from warnings |
0 | 529 |
623 | 530 ; get model |
531 movff char_I_deco_model,WREG ; 0: straight Buhlmann, 1: with GF | |
532 iorwf WREG ; GF factors in use? | |
533 bz deco_results_m2 ; NO | |
560 | 534 |
623 | 535 ; display GF low/high factors |
582 | 536 WIN_SMALL .0,.130 |
537 STRCAT_PRINT "GF:" | |
538 WIN_SMALL .25,.130 | |
539 movff char_I_GF_Low_percentage,lo | |
604 | 540 output_8 |
582 | 541 STRCAT "/" |
542 movff char_I_GF_High_percentage,lo | |
604 | 543 output_8 |
582 | 544 STRCAT_PRINT "" |
560 | 545 |
623 | 546 deco_results_m2: |
547 | |
548 ; display deco mode | |
582 | 549 WIN_SMALL .0,.155 |
550 lfsr FSR2,buffer | |
623 | 551 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=pSCR |
552 call TFT_decotype_logbook | |
553 | |
554 IFDEF _ccr_pscr | |
582 | 555 btfss FLAG_ccr_mode ; current dive mode = CCR ? |
623 | 556 bra deco_results_2c ; NO - skip |
582 | 557 WIN_SMALL .25,.155 |
558 STRCPY "SP:" ; output setpoint used for calculation | |
559 movff opt_sim_setpoint_number,lo | |
560 bsf leftbind | |
561 output_8 | |
562 bcf leftbind | |
563 STRCAT_PRINT "" | |
623 | 564 ENDIF |
0 | 565 |
623 | 566 deco_results_2c: |
567 | |
568 btfss FLAG_oc_mode ; current dive mode = OC ? | |
569 bra deco_results_2d ; NO - skip | |
570 TSTOSS opt_extended_stops ; YES - extended stops activated? | |
571 bra deco_results_2d ; NO - skip | |
572 WIN_SMALL .18,.155 ; YES - set position | |
573 STRCAT_PRINT "ext.Stop" ; - print notice | |
574 | |
575 deco_results_2d: | |
576 | |
577 ; display TTS result | |
582 | 578 WIN_SMALL .0,.180 |
579 STRCPY_TEXT tTTS | |
580 STRCAT ": " | |
623 | 581 MOVII int_O_TTS_norm,mpr |
582 | 582 bsf leftbind |
583 output_16 | |
584 bcf leftbind | |
585 STRCAT_PRINT "'" | |
0 | 586 |
623 | 587 ; display CNS result |
582 | 588 WIN_TOP .205 |
589 STRCPY_TEXT tCNS2 ; "CNS:" | |
623 | 590 MOVII int_O_CNS_current,mpr ; get current CNS |
604 | 591 call TFT_color_code_cns ; color-code CNS output |
582 | 592 bsf leftbind |
593 output_16_3 ; limit to 999 and display only (0-999) | |
594 bcf leftbind | |
595 STRCAT "%\x92" ; "->" | |
623 | 596 MOVII int_O_CNS_norm,mpr ; get CNS at end of dive in normal plan |
604 | 597 call TFT_color_code_cns ; color-code CNS output |
582 | 598 bsf leftbind |
599 output_16_3 ; limit to 999 and display only (0-999) | |
600 bcf leftbind | |
601 STRCAT_PRINT "%" | |
602 call TFT_standard_color | |
603 | |
623 | 604 ; loop through deco plan pages |
605 deco_results_1: | |
606 clrf decoplan_page ; start from first page | |
607 bcf decoplan_pressures_shown ; when showing the gas needs, start with volumes (liter) | |
608 deco_results_1a: | |
609 WIN_BOX_BLACK .0, .239, .80, .159 ; clear the complete stop result column (top, bottom, left, right) | |
610 rcall deco_results_page ; show a results page | |
611 incf decoplan_page,F ; increment results page number | |
612 call reset_timeout_surfmode ; reset timeout | |
613 bcf switch_right ; clear left-over right button event | |
614 bcf switch_left ; clear left-over left button event | |
615 deco_results_2: | |
616 btfsc switch_right ; right button pressed? | |
617 bra deco_results_3 ; YES - show further results | |
618 btfsc switch_left ; left button pressed? | |
619 return ; YES - return to deco calculator main function | |
620 call housekeeping ; NO to both - handle screen dump request, timeout and need to enter dive mode | |
621 btfsc divemode ; shall go into dive mode? | |
622 bsf decoplan_abort ; YES - set abort flag | |
623 btfsc trigger_timeout ; timeout on any button press? | |
624 bsf decoplan_abort ; YES - set abort flag | |
625 btfss decoplan_abort ; shall abort? | |
626 bra deco_results_2 ; NO - loop | |
582 | 627 return ; YES |
560 | 628 |
623 | 629 deco_results_3: |
630 btfss decoplan_last_stop_shown ; was the last stop shown already? | |
631 bra deco_results_1a ; NO - loop | |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
632 |
623 | 633 IFDEF _ccr_pscr |
634 movff char_O_deco_status,WREG ; YES - get deco calculation status | |
635 btfss WREG,DECO_MODE_LOOP_FLAG ; - check if calculation was made for loop mode (CCR/pSCR) | |
636 bra deco_results_gas_volumes ; NO - normal OC mode or bailout mode, show gas needs | |
637 bsf bailout_mode ; YES - do a 2nd deco-plan in bailout mode | |
638 rcall deco_calculate_redo ; - redo deco calculation | |
639 btfss decoplan_abort ; - was the calculation aborted? | |
640 bra deco_results ; NO - redo display of deco stops | |
641 return ; YES - return to deco calculator main function | |
642 ENDIF | |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
643 |
623 | 644 ;---- show the gas needs (OC and bailout only) --------------------------- |
645 deco_results_gas_volumes: | |
646 lfsr FSR0,int_O_gas_need_vol ; load base address of gas needs in volume | |
647 | |
648 deco_results_gas_common: | |
649 WIN_BOX_BLACK .0, .239, .80, .159 ; clear the complete stop result column (top, bottom, left, right) | |
650 movlw .25 ; output row is 25 (fixed offset set here) + n*25 (line increment, see below) | |
651 movwf output_row ; set fixed vertical offset for output row | |
604 | 652 WIN_LEFT .80 ; set column |
582 | 653 call TFT_standard_color |
623 | 654 clrf gas_index ; initialize gas counter |
655 bcf is_diluent_menu ; working on OC gases | |
604 | 656 |
623 | 657 deco_results_gas_loop: |
658 movff gas_index,PRODL ; copy gas index to PRODL (interface to gaslist_strcat_gas) | |
659 incf gas_index,F ; increment gas index | |
582 | 660 |
623 | 661 movf gas_index,W ; copy gas index to WREG for color-coding |
582 | 662 call TFT_color_code_gas ; set output color according to gas (1-5) |
560 | 663 |
623 | 664 lfsr FSR2,buffer ; load base address of output buffer |
665 bsf short_gas_descriptions ; configure gaslist_strcat_gas output format | |
666 bsf divemode ; configure gaslist_strcat_gas output format | |
667 call gaslist_strcat_gas ; write "Nxlo", "Txlo/hi", "Air" or "O2" into output buffer | |
668 bcf divemode ; cleanup above | |
560 | 669 |
623 | 670 movlw .25 ; spacing between outputs |
671 addwf output_row,F ; increase row position | |
672 movff output_row,win_top ; set row position | |
582 | 673 |
623 | 674 movff POSTINC0,lo ; read gas volume low byte |
675 movff POSTINC0,hi ; high byte | |
676 | |
677 bcf decoplan_overflow ; no overflow in gas needs by default | |
678 | |
679 btfsc decoplan_pressures_shown ; results in bar? | |
680 bra deco_results_gas_volumes_1 ; YES | |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
681 |
623 | 682 ; output of gas needs in liter |
683 movf lo,W ; check if hi:lo = 65535: copy low byte to WREG | |
684 andwf hi,W ; and do a bitwise AND with the high byte | |
685 incfsz WREG ; add 1, result zero now? | |
686 bra deco_results_gas_volumes_2 ; NO - print volume | |
687 STRCAT_PRINT ">65500" ; YES - print ">65500" | |
688 bra deco_results_gas_volumes_3 ; - continue checking if all gases are shown | |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
689 |
623 | 690 ; output of gas needs in bar |
691 deco_results_gas_volumes_1: | |
692 btfsc hi,int_high_flag ; overflow in result? | |
693 bsf decoplan_overflow ; YES - remember it | |
694 bcf hi,int_high_flag ; clear flag for overflow in result | |
695 btfsc hi,int_warning_flag ; gas needs above available amount? | |
696 bsf win_invert ; YES - print in inverse | |
697 bcf hi,int_warning_flag ; clear flag for gas needs above available amount | |
698 bcf hi,int_attention_flag ; clear flag for gas needs close to available amount | |
699 bcf hi,int_invalid_flag ; clear flag for invalid data | |
700 bcf hi,int_is_zero ; clear flag for zero | |
582 | 701 |
623 | 702 deco_results_gas_volumes_2: |
703 PUTC ":" ; print ":" | |
704 output_16 ; print 16 bit number | |
705 movlw '>' ; load coding of ">" sign into WREG | |
706 btfsc decoplan_overflow ; overflow in result? | |
707 movff WREG,buffer+.7 ; YES - place ">" before number | |
708 STRCAT_PRINT "" ; finalize output | |
709 bcf win_invert ; back to none-inverse printing | |
582 | 710 |
623 | 711 deco_results_gas_volumes_3: |
712 movlw NUM_GAS ; 5 gases to show | |
713 cpfseq gas_index ; all gases shown? | |
714 bra deco_results_gas_loop ; NO - loop | |
715 | |
716 WIN_COLOR color_greenish ; set color | |
717 TEXT_SMALL .80,.01,tGasUsage ; "Gas Usage" | |
582 | 718 |
623 | 719 btfsc decoplan_pressures_shown ; results shown in bar? |
720 bra deco_results_gas_volumes_4 ; YES | |
721 TEXT_SMALL .120,.25,tLiterLong ; NO - in Liter then | |
722 bra deco_results_gas_volumes_5 ; - continue with initialization of housekeeping | |
604 | 723 |
623 | 724 deco_results_gas_volumes_4: |
725 TEXT_SMALL .120,.25,tbar ; " bar" (with leading space) | |
284
d1117b99fd99
preperations to compute gas consumtion in simulator
heinrichsweikamp
parents:
275
diff
changeset
|
726 |
623 | 727 deco_results_gas_volumes_5: |
728 call TFT_standard_color ; revert to standard color | |
729 call reset_timeout_surfmode ; reset timeout | |
730 bcf switch_right ; clear left-over right button event | |
731 bcf switch_left ; clear left-over left button event | |
732 deco_results_gas_volumes_6: | |
733 btfsc switch_right ; right button pressed? | |
734 bra deco_results_gas_volumes_7 ; YES - show results in bar or restart with deco stops again | |
735 btfsc switch_left ; left button pressed? | |
736 return ; YES - return to deco calculator main function | |
737 call housekeeping ; NO to both - handle screen dump request, timeout and need to enter dive mode | |
738 btfsc divemode ; shall go into dive mode? | |
739 bsf decoplan_abort ; YES - set abort flag | |
740 btfsc trigger_timeout ; timeout on any button press? | |
741 bsf decoplan_abort ; YES - set abort flag | |
742 btfss decoplan_abort ; shall abort? | |
743 bra deco_results_gas_volumes_6 ; NO - loop | |
744 return ; YES | |
560 | 745 |
623 | 746 deco_results_gas_volumes_7: |
747 btfsc decoplan_pressures_shown ; results shown in bar? | |
748 bra deco_results_1 ; YES - show deco stops again | |
749 bsf decoplan_pressures_shown ; NO - but now | |
750 lfsr FSR0,int_O_gas_need_pres ; - load base address of gas needs in bar | |
751 bra deco_results_gas_common ; - re-run gas needs output in pressure mode | |
752 | |
0 | 753 |
582 | 754 END |