annotate src/simulator.asm @ 95:3dfc2b7ced6d

BUGFIX: Show "*" always in front of the initial Setpoint 1
author heinrichsweikamp
date Mon, 28 Apr 2014 10:17:18 +0200
parents f2201aa374db
children 53a99a2dc6a1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
heinrichsweikamp
parents:
diff changeset
3 ; File simulator.asm
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Decoplan interface to C model code.
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2011-07-09 : [jDG] Creation...
heinrichsweikamp
parents:
diff changeset
11
heinrichsweikamp
parents:
diff changeset
12 #include "ostc3.inc" ; Mandatory include.
heinrichsweikamp
parents:
diff changeset
13 #include "convert.inc" ; output_*
heinrichsweikamp
parents:
diff changeset
14 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c
heinrichsweikamp
parents:
diff changeset
15 #include "strings.inc" ; STRCPY,...
heinrichsweikamp
parents:
diff changeset
16 #include "tft.inc" ; WIN_LEFT,...
heinrichsweikamp
parents:
diff changeset
17 #include "wait.inc" ; speed_*
heinrichsweikamp
parents:
diff changeset
18 #include "start.inc"
heinrichsweikamp
parents:
diff changeset
19 #include "divemode.inc"
heinrichsweikamp
parents:
diff changeset
20 #include "math.inc"
heinrichsweikamp
parents:
diff changeset
21 #include "eeprom_rs232.inc"
50
ec4d8503ec45 NEW: user-selectable color schemes
heinrichsweikamp
parents: 46
diff changeset
22 #include "tft_outputs.inc"
0
heinrichsweikamp
parents:
diff changeset
23
heinrichsweikamp
parents:
diff changeset
24 gui CODE
heinrichsweikamp
parents:
diff changeset
25
heinrichsweikamp
parents:
diff changeset
26 extern deco_clear_tissue
heinrichsweikamp
parents:
diff changeset
27 extern deco_push_tissues_to_vault
heinrichsweikamp
parents:
diff changeset
28 extern deco_calc_dive_interval
heinrichsweikamp
parents:
diff changeset
29 extern deco_calc_hauptroutine
heinrichsweikamp
parents:
diff changeset
30 extern deco_calc_tissue
heinrichsweikamp
parents:
diff changeset
31 extern deco_calc_CNS_fraction
heinrichsweikamp
parents:
diff changeset
32 extern deco_calc_CNS_planning
heinrichsweikamp
parents:
diff changeset
33 extern deco_pull_tissues_from_vault
heinrichsweikamp
parents:
diff changeset
34
heinrichsweikamp
parents:
diff changeset
35 extern log_screendump_and_onesecond, logbook_preloop_tasks
heinrichsweikamp
parents:
diff changeset
36
heinrichsweikamp
parents:
diff changeset
37 ;---- Private temp variables -------------------------------------------------
heinrichsweikamp
parents:
diff changeset
38 CBLOCK tmp+0x10 ; Reserved space for wordprocessor and convert
heinrichsweikamp
parents:
diff changeset
39 decoplan_index ; within each page
heinrichsweikamp
parents:
diff changeset
40 decoplan_gindex ; global index
heinrichsweikamp
parents:
diff changeset
41 decoplan_last ; Depth of last stop (CF#29)
heinrichsweikamp
parents:
diff changeset
42 decoplan_max ; Number of lines per page.
heinrichsweikamp
parents:
diff changeset
43 decoplan_flags ; Various private flags.
heinrichsweikamp
parents:
diff changeset
44 decoplan_CNS:2 ; Backup CNS before vault restore
heinrichsweikamp
parents:
diff changeset
45 ; Reserved to tmp+0x1F...
heinrichsweikamp
parents:
diff changeset
46 ENDC
heinrichsweikamp
parents:
diff changeset
47 #define decoplan_last_ceiling_shown decoplan_flags,0
heinrichsweikamp
parents:
diff changeset
48
heinrichsweikamp
parents:
diff changeset
49 ;---- Demo decoplanner -------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
50 global do_demo_planner
heinrichsweikamp
parents:
diff changeset
51 extern do_planner_menu
heinrichsweikamp
parents:
diff changeset
52
heinrichsweikamp
parents:
diff changeset
53 do_demo_planner:
heinrichsweikamp
parents:
diff changeset
54 call speed_fastest
heinrichsweikamp
parents:
diff changeset
55 ; call deco_reset ; TODO: remove reset all Decodata
heinrichsweikamp
parents:
diff changeset
56 call deco_planer
heinrichsweikamp
parents:
diff changeset
57 call deco_show_plan
heinrichsweikamp
parents:
diff changeset
58 bcf switch_right
heinrichsweikamp
parents:
diff changeset
59 bcf switch_left
heinrichsweikamp
parents:
diff changeset
60 goto do_planner_menu
heinrichsweikamp
parents:
diff changeset
61
heinrichsweikamp
parents:
diff changeset
62 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
63 ; Pass all parameters to the C code
heinrichsweikamp
parents:
diff changeset
64 ;
heinrichsweikamp
parents:
diff changeset
65
heinrichsweikamp
parents:
diff changeset
66 global get_first_dil_to_WREG
heinrichsweikamp
parents:
diff changeset
67 get_first_dil_to_WREG: ; Gets first dil (0-4) into WREG
heinrichsweikamp
parents:
diff changeset
68 lfsr FSR1,opt_dil_type ; Point to dil types
heinrichsweikamp
parents:
diff changeset
69 clrf lo ; start with Gas0
81
8e13866b5496 add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents: 50
diff changeset
70 get_first_dil_to_WREG2:
8e13866b5496 add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents: 50
diff changeset
71 movf lo,W ;
8e13866b5496 add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents: 50
diff changeset
72 movf PLUSW1,W ; Get Type of Dil #lo
8e13866b5496 add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents: 50
diff changeset
73 sublw .1 ; it is = 1 (First Dil)
8e13866b5496 add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents: 50
diff changeset
74 bz get_first_dil_to_WREG3 ; Found the first dil!
8e13866b5496 add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents: 50
diff changeset
75 incf lo,F ; ++
8e13866b5496 add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents: 50
diff changeset
76 movlw NUM_GAS+1
8e13866b5496 add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents: 50
diff changeset
77 cpfseq lo ; All done?
8e13866b5496 add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents: 50
diff changeset
78 bra get_first_dil_to_WREG2 ; Not yet
8e13866b5496 add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents: 50
diff changeset
79 ; No first dil found, use #1
8e13866b5496 add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents: 50
diff changeset
80 movlw .1
8e13866b5496 add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents: 50
diff changeset
81 movff WREG,opt_dil_type+0 ; Set Dil1 to First
8e13866b5496 add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents: 50
diff changeset
82 return
8e13866b5496 add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents: 50
diff changeset
83 get_first_dil_to_WREG3:
8e13866b5496 add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents: 50
diff changeset
84 movf lo,W ; Put into Wreg
8e13866b5496 add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents: 50
diff changeset
85 return ; Done
0
heinrichsweikamp
parents:
diff changeset
86
heinrichsweikamp
parents:
diff changeset
87 global get_first_gas_to_WREG
heinrichsweikamp
parents:
diff changeset
88 get_first_gas_to_WREG: ; Gets first gas (0-4) into WREG
heinrichsweikamp
parents:
diff changeset
89 lfsr FSR1,opt_gas_type ; Point to gas types
heinrichsweikamp
parents:
diff changeset
90 clrf lo ; start with Gas0
heinrichsweikamp
parents:
diff changeset
91 get_first_gas_to_WREG2:
heinrichsweikamp
parents:
diff changeset
92 movf lo,W ;
heinrichsweikamp
parents:
diff changeset
93 movf PLUSW1,W ; Get Type of Gas #lo
heinrichsweikamp
parents:
diff changeset
94 sublw .1 ; it is = 1 (First Gas)
heinrichsweikamp
parents:
diff changeset
95 bz get_first_gas_to_WREG3 ; Found the first gas!
heinrichsweikamp
parents:
diff changeset
96 incf lo,F ; ++
heinrichsweikamp
parents:
diff changeset
97 movlw NUM_GAS+1
heinrichsweikamp
parents:
diff changeset
98 cpfseq lo ; All done?
heinrichsweikamp
parents:
diff changeset
99 bra get_first_gas_to_WREG2 ; Not yet
81
8e13866b5496 add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents: 50
diff changeset
100 ; No first gas found, use #1
8e13866b5496 add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents: 50
diff changeset
101 movlw .1
8e13866b5496 add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents: 50
diff changeset
102 movff WREG,opt_gas_type+0 ; Set Gas1 to First
8e13866b5496 add some extra safety checks when settings were altered from the PC software
mh@mh-THINK.localdomain
parents: 50
diff changeset
103 return
0
heinrichsweikamp
parents:
diff changeset
104 get_first_gas_to_WREG3:
heinrichsweikamp
parents:
diff changeset
105 movf lo,W ; Put into Wreg
heinrichsweikamp
parents:
diff changeset
106 return ; Done
heinrichsweikamp
parents:
diff changeset
107
heinrichsweikamp
parents:
diff changeset
108 deco_setup:
heinrichsweikamp
parents:
diff changeset
109 banksel char_I_step_is_1min ; Select the right bank...
heinrichsweikamp
parents:
diff changeset
110 clrf char_I_step_is_1min ; Default to 2sec steps.
46
05227510cae0 Bugfix: deco gas init in OC planner
heinrichsweikamp
parents: 40
diff changeset
111 clrf char_I_const_ppO2 ; Clear for OC, will be set for CC later
0
heinrichsweikamp
parents:
diff changeset
112
heinrichsweikamp
parents:
diff changeset
113 ; Fixed ambient surface pressure to 1bar.
heinrichsweikamp
parents:
diff changeset
114 movlw LOW(.1000)
heinrichsweikamp
parents:
diff changeset
115 movwf int_I_pres_surface+0
heinrichsweikamp
parents:
diff changeset
116 movwf int_I_pres_respiration+0
heinrichsweikamp
parents:
diff changeset
117 movlw HIGH(.1000)
heinrichsweikamp
parents:
diff changeset
118 movwf int_I_pres_surface+1
heinrichsweikamp
parents:
diff changeset
119 movwf int_I_pres_respiration+1
heinrichsweikamp
parents:
diff changeset
120
46
05227510cae0 Bugfix: deco gas init in OC planner
heinrichsweikamp
parents: 40
diff changeset
121 clrf int_I_divemins+0 ; Dive start
0
heinrichsweikamp
parents:
diff changeset
122 clrf int_I_divemins+1
46
05227510cae0 Bugfix: deco gas init in OC planner
heinrichsweikamp
parents: 40
diff changeset
123 banksel common ; Bank1
05227510cae0 Bugfix: deco gas init in OC planner
heinrichsweikamp
parents: 40
diff changeset
124 bcf use_agf ; =1: Use aGF
05227510cae0 Bugfix: deco gas init in OC planner
heinrichsweikamp
parents: 40
diff changeset
125
40
1e2d2b0bca5b Bugfix: Simulator in CC mode
mh@mh-THINK.fritz.box
parents: 9
diff changeset
126 rcall deco_setup_dive
0
heinrichsweikamp
parents:
diff changeset
127
46
05227510cae0 Bugfix: deco gas init in OC planner
heinrichsweikamp
parents: 40
diff changeset
128 ; Setup char_I_const_ppO2 for CC modes
05227510cae0 Bugfix: deco gas init in OC planner
heinrichsweikamp
parents: 40
diff changeset
129 btfsc FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active
40
1e2d2b0bca5b Bugfix: Simulator in CC mode
mh@mh-THINK.fritz.box
parents: 9
diff changeset
130 movff char_I_setpoint_cbar+0,char_I_const_ppO2 ; Setup fixed Setpoint (Always start with SP1)
1e2d2b0bca5b Bugfix: Simulator in CC mode
mh@mh-THINK.fritz.box
parents: 9
diff changeset
131
1e2d2b0bca5b Bugfix: Simulator in CC mode
mh@mh-THINK.fritz.box
parents: 9
diff changeset
132 rcall get_first_gas_to_WREG ; Gets first gas (0-4) into WREG
0
heinrichsweikamp
parents:
diff changeset
133 movff WREG,char_I_first_gas ; Copy for compatibility
heinrichsweikamp
parents:
diff changeset
134 extern setup_gas_registers
heinrichsweikamp
parents:
diff changeset
135 call setup_gas_registers ; With WREG=Gas 0-4, set current N2/He/O2 ratios.
heinrichsweikamp
parents:
diff changeset
136 extern set_actual_ppo2
heinrichsweikamp
parents:
diff changeset
137 call set_actual_ppo2 ; Then configure char_I_actual_ppO2 (For CNS)
40
1e2d2b0bca5b Bugfix: Simulator in CC mode
mh@mh-THINK.fritz.box
parents: 9
diff changeset
138 return
0
heinrichsweikamp
parents:
diff changeset
139
heinrichsweikamp
parents:
diff changeset
140 global deco_setup_dive
heinrichsweikamp
parents:
diff changeset
141 deco_setup_dive: ; Called from divemode
heinrichsweikamp
parents:
diff changeset
142 banksel common ; Bank1
heinrichsweikamp
parents:
diff changeset
143
heinrichsweikamp
parents:
diff changeset
144 btfss FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active
heinrichsweikamp
parents:
diff changeset
145 rcall deco_setup_oc_gases ; Setup OC Gases
heinrichsweikamp
parents:
diff changeset
146 btfsc FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active
heinrichsweikamp
parents:
diff changeset
147 rcall deco_setup_cc_diluents ; Setup CC Diluents
heinrichsweikamp
parents:
diff changeset
148 btfsc is_bailout ; =1: Bailout
heinrichsweikamp
parents:
diff changeset
149 rcall deco_setup_oc_gases ; Setup OC/Bailout Gases
heinrichsweikamp
parents:
diff changeset
150
heinrichsweikamp
parents:
diff changeset
151 movlw deco_distance
heinrichsweikamp
parents:
diff changeset
152 movff WREG,char_I_deco_distance
heinrichsweikamp
parents:
diff changeset
153 movff opt_last_stop,char_I_depth_last_deco
heinrichsweikamp
parents:
diff changeset
154 movff opt_GF_low,char_I_GF_Low_percentage
heinrichsweikamp
parents:
diff changeset
155 movff opt_GF_high,char_I_GF_High_percentage
heinrichsweikamp
parents:
diff changeset
156 ;Overwrite GF if aGF is wanted
heinrichsweikamp
parents:
diff changeset
157 btfsc use_agf ; =1: Use aGF
heinrichsweikamp
parents:
diff changeset
158 movff opt_aGF_low,char_I_GF_Low_percentage
heinrichsweikamp
parents:
diff changeset
159 btfsc use_agf ; =1: Use aGF
heinrichsweikamp
parents:
diff changeset
160 movff opt_aGF_high,char_I_GF_High_percentage
heinrichsweikamp
parents:
diff changeset
161 return
heinrichsweikamp
parents:
diff changeset
162
heinrichsweikamp
parents:
diff changeset
163 deco_setup_cc_diluents:
heinrichsweikamp
parents:
diff changeset
164 movff opt_dil_He_ratio+0,char_I_deco_He_ratio+0
heinrichsweikamp
parents:
diff changeset
165 movff char_I_deco_He_ratio+0,lo
heinrichsweikamp
parents:
diff changeset
166 movff opt_dil_O2_ratio+0,WREG
heinrichsweikamp
parents:
diff changeset
167 addwf lo,W ; O2 + He -> WREG
heinrichsweikamp
parents:
diff changeset
168 sublw .100 ; 100 - (O2 + He) -> WREG
heinrichsweikamp
parents:
diff changeset
169 movff WREG,char_I_deco_N2_ratio+0
heinrichsweikamp
parents:
diff changeset
170 movff opt_dil_type+0,WREG ; 0=Disabled, 1=First, 2=Normal
heinrichsweikamp
parents:
diff changeset
171 tstfsz WREG ; Disabled?
heinrichsweikamp
parents:
diff changeset
172 bra $+4 ; No
heinrichsweikamp
parents:
diff changeset
173 movff WREG,char_I_deco_gas_change+0 ; Yes, clear char_I_deco_gas_change
heinrichsweikamp
parents:
diff changeset
174
heinrichsweikamp
parents:
diff changeset
175 movff opt_dil_He_ratio+1,char_I_deco_He_ratio+1
heinrichsweikamp
parents:
diff changeset
176 movff char_I_deco_He_ratio+1,lo
heinrichsweikamp
parents:
diff changeset
177 movff opt_dil_O2_ratio+1,WREG
heinrichsweikamp
parents:
diff changeset
178 addwf lo,W ; O2 + He -> WREG
heinrichsweikamp
parents:
diff changeset
179 sublw .100 ; 100 - (O2 + He) -> WREG
heinrichsweikamp
parents:
diff changeset
180 movff WREG,char_I_deco_N2_ratio+1
heinrichsweikamp
parents:
diff changeset
181 movff opt_dil_type+1,WREG ; 0=Disabled, 1=First, 2=Normal
heinrichsweikamp
parents:
diff changeset
182 tstfsz WREG ; Disabled?
heinrichsweikamp
parents:
diff changeset
183 bra $+4 ; No
heinrichsweikamp
parents:
diff changeset
184 movff WREG,char_I_deco_gas_change+1 ; Yes, clear char_I_deco_gas_change
heinrichsweikamp
parents:
diff changeset
185
heinrichsweikamp
parents:
diff changeset
186 movff opt_dil_He_ratio+2,char_I_deco_He_ratio+2
heinrichsweikamp
parents:
diff changeset
187 movff char_I_deco_He_ratio+2,lo
heinrichsweikamp
parents:
diff changeset
188 movff opt_dil_O2_ratio+2,WREG
heinrichsweikamp
parents:
diff changeset
189 addwf lo,W ; O2 + He -> WREG
heinrichsweikamp
parents:
diff changeset
190 sublw .100 ; 100 - (O2 + He) -> WREG
heinrichsweikamp
parents:
diff changeset
191 movff WREG,char_I_deco_N2_ratio+2
heinrichsweikamp
parents:
diff changeset
192 movff opt_dil_type+2,WREG ; 0=Disabled, 1=First, 2=Normal
heinrichsweikamp
parents:
diff changeset
193 tstfsz WREG ; Disabled?
heinrichsweikamp
parents:
diff changeset
194 bra $+4 ; No
heinrichsweikamp
parents:
diff changeset
195 movff WREG,char_I_deco_gas_change+2 ; Yes, clear char_I_deco_gas_change
heinrichsweikamp
parents:
diff changeset
196
heinrichsweikamp
parents:
diff changeset
197 movff opt_dil_He_ratio+3,char_I_deco_He_ratio+3
heinrichsweikamp
parents:
diff changeset
198 movff char_I_deco_He_ratio+3,lo
heinrichsweikamp
parents:
diff changeset
199 movff opt_dil_O2_ratio+3,WREG
heinrichsweikamp
parents:
diff changeset
200 addwf lo,W ; O2 + He -> WREG
heinrichsweikamp
parents:
diff changeset
201 sublw .100 ; 100 - (O2 + He) -> WREG
heinrichsweikamp
parents:
diff changeset
202 movff WREG,char_I_deco_N2_ratio+3
heinrichsweikamp
parents:
diff changeset
203 movff opt_dil_type+3,WREG ; 0=Disabled, 1=First, 2=Normal
heinrichsweikamp
parents:
diff changeset
204 tstfsz WREG ; Disabled?
heinrichsweikamp
parents:
diff changeset
205 bra $+4 ; No
heinrichsweikamp
parents:
diff changeset
206 movff WREG,char_I_deco_gas_change+3 ; Yes, clear char_I_deco_gas_change
heinrichsweikamp
parents:
diff changeset
207
heinrichsweikamp
parents:
diff changeset
208 movff opt_dil_He_ratio+4,char_I_deco_He_ratio+4
heinrichsweikamp
parents:
diff changeset
209 movff char_I_deco_He_ratio+4,lo
heinrichsweikamp
parents:
diff changeset
210 movff opt_dil_O2_ratio+4,WREG
heinrichsweikamp
parents:
diff changeset
211 addwf lo,W ; O2 + He -> WREG
heinrichsweikamp
parents:
diff changeset
212 sublw .100 ; 100 - (O2 + He) -> WREG
heinrichsweikamp
parents:
diff changeset
213 movff WREG,char_I_deco_N2_ratio+4
heinrichsweikamp
parents:
diff changeset
214 movff opt_dil_type+4,WREG ; 0=Disabled, 1=First, 2=Normal
heinrichsweikamp
parents:
diff changeset
215 tstfsz WREG ; Disabled?
heinrichsweikamp
parents:
diff changeset
216 bra $+4 ; No
heinrichsweikamp
parents:
diff changeset
217 movff WREG,char_I_deco_gas_change+4 ; Yes, clear char_I_deco_gas_change
heinrichsweikamp
parents:
diff changeset
218 return
heinrichsweikamp
parents:
diff changeset
219
heinrichsweikamp
parents:
diff changeset
220 deco_setup_oc_gases:
heinrichsweikamp
parents:
diff changeset
221 movff opt_gas_He_ratio+0,char_I_deco_He_ratio+0
heinrichsweikamp
parents:
diff changeset
222 movff char_I_deco_He_ratio+0,lo
heinrichsweikamp
parents:
diff changeset
223 movff opt_gas_O2_ratio+0,WREG
heinrichsweikamp
parents:
diff changeset
224 addwf lo,W ; O2 + He -> WREG
heinrichsweikamp
parents:
diff changeset
225 sublw .100 ; 100 - (O2 + He) -> WREG
heinrichsweikamp
parents:
diff changeset
226 movff WREG,char_I_deco_N2_ratio+0
heinrichsweikamp
parents:
diff changeset
227 movff opt_gas_type+0,WREG ; 0=Disabled, 1=First, 2=Travel, 3=Deco
heinrichsweikamp
parents:
diff changeset
228 tstfsz WREG ; Disabled?
heinrichsweikamp
parents:
diff changeset
229 bra $+4 ; No
heinrichsweikamp
parents:
diff changeset
230 movff WREG,char_I_deco_gas_change+0 ; Yes, clear char_I_deco_gas_change
heinrichsweikamp
parents:
diff changeset
231
heinrichsweikamp
parents:
diff changeset
232 movff opt_gas_He_ratio+1,char_I_deco_He_ratio+1
heinrichsweikamp
parents:
diff changeset
233 movff char_I_deco_He_ratio+1,lo
heinrichsweikamp
parents:
diff changeset
234 movff opt_gas_O2_ratio+1,WREG
heinrichsweikamp
parents:
diff changeset
235 addwf lo,W ; O2 + He -> WREG
heinrichsweikamp
parents:
diff changeset
236 sublw .100 ; 100 - (O2 + He) -> WREG
heinrichsweikamp
parents:
diff changeset
237 movff WREG,char_I_deco_N2_ratio+1
heinrichsweikamp
parents:
diff changeset
238 movff opt_gas_type+1,WREG ; 0=Disabled, 1=First, 2=Travel, 3=Deco
heinrichsweikamp
parents:
diff changeset
239 tstfsz WREG ; Disabled?
heinrichsweikamp
parents:
diff changeset
240 bra $+4 ; No
heinrichsweikamp
parents:
diff changeset
241 movff WREG,char_I_deco_gas_change+1 ; Yes, clear char_I_deco_gas_change
heinrichsweikamp
parents:
diff changeset
242
heinrichsweikamp
parents:
diff changeset
243 movff opt_gas_He_ratio+2,char_I_deco_He_ratio+2
heinrichsweikamp
parents:
diff changeset
244 movff char_I_deco_He_ratio+2,lo
heinrichsweikamp
parents:
diff changeset
245 movff opt_gas_O2_ratio+2,WREG
heinrichsweikamp
parents:
diff changeset
246 addwf lo,W ; O2 + He -> WREG
heinrichsweikamp
parents:
diff changeset
247 sublw .100 ; 100 - (O2 + He) -> WREG
heinrichsweikamp
parents:
diff changeset
248 movff WREG,char_I_deco_N2_ratio+2
heinrichsweikamp
parents:
diff changeset
249 movff opt_gas_type+2,WREG ; 0=Disabled, 1=First, 2=Travel, 3=Deco
heinrichsweikamp
parents:
diff changeset
250 tstfsz WREG ; Disabled?
heinrichsweikamp
parents:
diff changeset
251 bra $+4 ; No
heinrichsweikamp
parents:
diff changeset
252 movff WREG,char_I_deco_gas_change+2 ; Yes, clear char_I_deco_gas_change
heinrichsweikamp
parents:
diff changeset
253
heinrichsweikamp
parents:
diff changeset
254 movff opt_gas_He_ratio+3,char_I_deco_He_ratio+3
heinrichsweikamp
parents:
diff changeset
255 movff char_I_deco_He_ratio+3,lo
heinrichsweikamp
parents:
diff changeset
256 movff opt_gas_O2_ratio+3,WREG
heinrichsweikamp
parents:
diff changeset
257 addwf lo,W ; O2 + He -> WREG
heinrichsweikamp
parents:
diff changeset
258 sublw .100 ; 100 - (O2 + He) -> WREG
heinrichsweikamp
parents:
diff changeset
259 movff WREG,char_I_deco_N2_ratio+3
heinrichsweikamp
parents:
diff changeset
260 movff opt_gas_type+3,WREG ; 0=Disabled, 1=First, 2=Travel, 3=Deco
heinrichsweikamp
parents:
diff changeset
261 tstfsz WREG ; Disabled?
heinrichsweikamp
parents:
diff changeset
262 bra $+4 ; No
heinrichsweikamp
parents:
diff changeset
263 movff WREG,char_I_deco_gas_change+3 ; Yes, clear char_I_deco_gas_change
heinrichsweikamp
parents:
diff changeset
264
heinrichsweikamp
parents:
diff changeset
265 movff opt_gas_He_ratio+4,char_I_deco_He_ratio+4
heinrichsweikamp
parents:
diff changeset
266 movff char_I_deco_He_ratio+4,lo
heinrichsweikamp
parents:
diff changeset
267 movff opt_gas_O2_ratio+4,WREG
heinrichsweikamp
parents:
diff changeset
268 addwf lo,W ; O2 + He -> WREG
heinrichsweikamp
parents:
diff changeset
269 sublw .100 ; 100 - (O2 + He) -> WREG
heinrichsweikamp
parents:
diff changeset
270 movff WREG,char_I_deco_N2_ratio+4
heinrichsweikamp
parents:
diff changeset
271 movff opt_gas_type+4,WREG ; 0=Disabled, 1=First, 2=Travel, 3=Deco
heinrichsweikamp
parents:
diff changeset
272 tstfsz WREG ; Disabled?
heinrichsweikamp
parents:
diff changeset
273 bra $+4 ; No
heinrichsweikamp
parents:
diff changeset
274 movff WREG,char_I_deco_gas_change+4 ; Yes, clear char_I_deco_gas_change
94
f2201aa374db BUGFIX: compass calibration does now timeout automatically after 60s
heinrichsweikamp
parents: 81
diff changeset
275 nop
f2201aa374db BUGFIX: compass calibration does now timeout automatically after 60s
heinrichsweikamp
parents: 81
diff changeset
276
f2201aa374db BUGFIX: compass calibration does now timeout automatically after 60s
heinrichsweikamp
parents: 81
diff changeset
277 movlw .0
f2201aa374db BUGFIX: compass calibration does now timeout automatically after 60s
heinrichsweikamp
parents: 81
diff changeset
278 movff WREG,char_I_const_ppO2 ; Clear constant ppO2 for OC/bailout
0
heinrichsweikamp
parents:
diff changeset
279 return
heinrichsweikamp
parents:
diff changeset
280
heinrichsweikamp
parents:
diff changeset
281 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
282 ; Reset decompression tissues
heinrichsweikamp
parents:
diff changeset
283 ;
heinrichsweikamp
parents:
diff changeset
284 global deco_reset
heinrichsweikamp
parents:
diff changeset
285 deco_reset:
heinrichsweikamp
parents:
diff changeset
286 rcall deco_setup ; Setup all model parameters.
heinrichsweikamp
parents:
diff changeset
287 call deco_clear_tissue ; Set all tissues to Pamb * N2_ratio
heinrichsweikamp
parents:
diff changeset
288 call deco_clear_CNS_fraction ; Reset CNS value.
heinrichsweikamp
parents:
diff changeset
289 banksel common ; Bank1
heinrichsweikamp
parents:
diff changeset
290 return
heinrichsweikamp
parents:
diff changeset
291
heinrichsweikamp
parents:
diff changeset
292 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
293 ; Launch decoplanning
heinrichsweikamp
parents:
diff changeset
294 ;
heinrichsweikamp
parents:
diff changeset
295 global deco_planer
heinrichsweikamp
parents:
diff changeset
296 deco_planer:
heinrichsweikamp
parents:
diff changeset
297 call speed_fastest ; Quick !
heinrichsweikamp
parents:
diff changeset
298 rcall deco_setup ; Setup all model parameters.
heinrichsweikamp
parents:
diff changeset
299 call deco_push_tissues_to_vault
heinrichsweikamp
parents:
diff changeset
300 banksel common ; Bank1
heinrichsweikamp
parents:
diff changeset
301
heinrichsweikamp
parents:
diff changeset
302 ;---- Specific settings ------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
303
heinrichsweikamp
parents:
diff changeset
304 banksel char_O_deco_status ; Bank 2
heinrichsweikamp
parents:
diff changeset
305 movlw .3 ; Start in surface state.
heinrichsweikamp
parents:
diff changeset
306 movwf char_O_deco_status
heinrichsweikamp
parents:
diff changeset
307
heinrichsweikamp
parents:
diff changeset
308 banksel char_I_step_is_1min ; Bank 3
heinrichsweikamp
parents:
diff changeset
309 movlw 1
heinrichsweikamp
parents:
diff changeset
310 movwf char_I_step_is_1min ; Set 1min steps
heinrichsweikamp
parents:
diff changeset
311
heinrichsweikamp
parents:
diff changeset
312 ;---- Add delay at surface, if needed ----------------------------------------
heinrichsweikamp
parents:
diff changeset
313 tstfsz char_I_dive_interval
heinrichsweikamp
parents:
diff changeset
314 call deco_calc_dive_interval
heinrichsweikamp
parents:
diff changeset
315
heinrichsweikamp
parents:
diff changeset
316 ;---- Dive loop --------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
317
heinrichsweikamp
parents:
diff changeset
318 ; Compute dive ambiant conditions
heinrichsweikamp
parents:
diff changeset
319 banksel char_I_bottom_depth
heinrichsweikamp
parents:
diff changeset
320 movf char_I_bottom_depth,W
heinrichsweikamp
parents:
diff changeset
321 mullw .100
heinrichsweikamp
parents:
diff changeset
322 movlw LOW(.1000)
heinrichsweikamp
parents:
diff changeset
323 addwf PRODL,W
heinrichsweikamp
parents:
diff changeset
324 movwf int_I_pres_respiration+0
heinrichsweikamp
parents:
diff changeset
325 movlw HIGH(.1000)
heinrichsweikamp
parents:
diff changeset
326 addwfc PRODH,W
heinrichsweikamp
parents:
diff changeset
327 movwf int_I_pres_respiration+1
heinrichsweikamp
parents:
diff changeset
328
heinrichsweikamp
parents:
diff changeset
329 banksel int_I_divemins ; Bank 4
heinrichsweikamp
parents:
diff changeset
330 clrf int_I_divemins+0 ; Clear dive time
heinrichsweikamp
parents:
diff changeset
331 clrf int_I_divemins+1
heinrichsweikamp
parents:
diff changeset
332
heinrichsweikamp
parents:
diff changeset
333 clrf TMR5L
heinrichsweikamp
parents:
diff changeset
334 clrf TMR5H ; 30,51757813µs/bit in TMR5L:TMR5H
heinrichsweikamp
parents:
diff changeset
335 call deco_calc_hauptroutine ; Reset + simulate first min.
heinrichsweikamp
parents:
diff changeset
336
heinrichsweikamp
parents:
diff changeset
337 deco_planer_loop:
heinrichsweikamp
parents:
diff changeset
338 banksel int_I_divemins ; Bank 3
heinrichsweikamp
parents:
diff changeset
339 incf int_I_divemins,F ; Done 1 min.
heinrichsweikamp
parents:
diff changeset
340 btg LEDg
heinrichsweikamp
parents:
diff changeset
341
heinrichsweikamp
parents:
diff changeset
342 movf char_I_bottom_time,W ; Finished ?
heinrichsweikamp
parents:
diff changeset
343 xorwf int_I_divemins,W
heinrichsweikamp
parents:
diff changeset
344 bz deco_planer_endloop ; YES
heinrichsweikamp
parents:
diff changeset
345
heinrichsweikamp
parents:
diff changeset
346 call deco_calc_tissue ; JUST calc tissue (faster).
heinrichsweikamp
parents:
diff changeset
347 call deco_calc_CNS_fraction ; Also calculate CNS (in 1min loop)
heinrichsweikamp
parents:
diff changeset
348 bra deco_planer_loop
heinrichsweikamp
parents:
diff changeset
349
heinrichsweikamp
parents:
diff changeset
350 deco_planer_endloop:
heinrichsweikamp
parents:
diff changeset
351 banksel char_I_step_is_1min
heinrichsweikamp
parents:
diff changeset
352 clrf char_I_step_is_1min ; Back to 2sec loops
heinrichsweikamp
parents:
diff changeset
353
heinrichsweikamp
parents:
diff changeset
354 ;---- Wait until status reach zero -------------------------------------------
heinrichsweikamp
parents:
diff changeset
355 deco_planer_finishing:
heinrichsweikamp
parents:
diff changeset
356 btg LEDg
heinrichsweikamp
parents:
diff changeset
357 clrf TMR5L
heinrichsweikamp
parents:
diff changeset
358 clrf TMR5H ; 30,51757813µs/bit in TMR5L:TMR5H
heinrichsweikamp
parents:
diff changeset
359 call deco_calc_hauptroutine ; Simulate 2sec more
heinrichsweikamp
parents:
diff changeset
360
heinrichsweikamp
parents:
diff changeset
361 banksel char_O_deco_status ; Bank 2
heinrichsweikamp
parents:
diff changeset
362 movf char_O_deco_status,W
heinrichsweikamp
parents:
diff changeset
363 bz deco_planer_finished
heinrichsweikamp
parents:
diff changeset
364
heinrichsweikamp
parents:
diff changeset
365 bra deco_planer_finishing
heinrichsweikamp
parents:
diff changeset
366
heinrichsweikamp
parents:
diff changeset
367 deco_planer_finished:
heinrichsweikamp
parents:
diff changeset
368 call deco_calc_CNS_planning
heinrichsweikamp
parents:
diff changeset
369 movff int_O_CNS_fraction+0,decoplan_CNS+0
heinrichsweikamp
parents:
diff changeset
370 movff int_O_CNS_fraction+1,decoplan_CNS+1
heinrichsweikamp
parents:
diff changeset
371 call deco_pull_tissues_from_vault
heinrichsweikamp
parents:
diff changeset
372 bcf LEDg
heinrichsweikamp
parents:
diff changeset
373 banksel common ; Bank1
heinrichsweikamp
parents:
diff changeset
374 movlw b'00111000' ; 1:8 Prescaler -> 65,536ms@16MHz
heinrichsweikamp
parents:
diff changeset
375 movwf T3CON
heinrichsweikamp
parents:
diff changeset
376 call speed_normal
heinrichsweikamp
parents:
diff changeset
377 return
heinrichsweikamp
parents:
diff changeset
378
heinrichsweikamp
parents:
diff changeset
379 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
380 ; Draw a stop of the deco plan (simulator or dive).
heinrichsweikamp
parents:
diff changeset
381 ; Inputs: lo = depth. Range 3m...93m
heinrichsweikamp
parents:
diff changeset
382 ; + 80 if this is a switch-gas stop.
heinrichsweikamp
parents:
diff changeset
383 ; up = minutes. range 1'..240'.
heinrichsweikamp
parents:
diff changeset
384 ; win_top = line to draw on screen.
heinrichsweikamp
parents:
diff changeset
385 ; Trashed: up, lo, win_height, win_leftx2, win_width, win_color*,
heinrichsweikamp
parents:
diff changeset
386 ; WREG, PROD, TBLPTR TABLAT.
heinrichsweikamp
parents:
diff changeset
387 ;
heinrichsweikamp
parents:
diff changeset
388 deco_plan_show_stop:
heinrichsweikamp
parents:
diff changeset
389 ;---- Print depth ----------------------------------------------------
heinrichsweikamp
parents:
diff changeset
390 btfss lo,7 ; Bit set ?
heinrichsweikamp
parents:
diff changeset
391 bra deco_plan_show_std_stop ; No : Just an usual stop.
heinrichsweikamp
parents:
diff changeset
392
50
ec4d8503ec45 NEW: user-selectable color schemes
heinrichsweikamp
parents: 46
diff changeset
393 call TFT_attention_color
0
heinrichsweikamp
parents:
diff changeset
394 bcf lo,7 ; and cleanup depth.
heinrichsweikamp
parents:
diff changeset
395 bra deco_plan_show_nstd_stop
heinrichsweikamp
parents:
diff changeset
396
heinrichsweikamp
parents:
diff changeset
397 deco_plan_show_std_stop:
50
ec4d8503ec45 NEW: user-selectable color schemes
heinrichsweikamp
parents: 46
diff changeset
398 call TFT_standard_color
0
heinrichsweikamp
parents:
diff changeset
399
heinrichsweikamp
parents:
diff changeset
400 deco_plan_show_nstd_stop:
heinrichsweikamp
parents:
diff changeset
401 lfsr FSR2,buffer
heinrichsweikamp
parents:
diff changeset
402
heinrichsweikamp
parents:
diff changeset
403 TSTOSS opt_units ; 0=Meters, 1=Feets
heinrichsweikamp
parents:
diff changeset
404 bra deco_plan_show_nstd_stop_metric
heinrichsweikamp
parents:
diff changeset
405
heinrichsweikamp
parents:
diff changeset
406 WIN_LEFT .85
heinrichsweikamp
parents:
diff changeset
407 movf lo,W ; lo = m
heinrichsweikamp
parents:
diff changeset
408 mullw .100 ; PRODL:PRODH = mbar
heinrichsweikamp
parents:
diff changeset
409 movff PRODL,lo
heinrichsweikamp
parents:
diff changeset
410 movff PRODH,hi
heinrichsweikamp
parents:
diff changeset
411 ; Convert with 334feet/100m to have 10ft, 20ft, 30ft stops...
heinrichsweikamp
parents:
diff changeset
412 movff lo,xA+0
heinrichsweikamp
parents:
diff changeset
413 movff hi,xA+1
heinrichsweikamp
parents:
diff changeset
414 movlw LOW d'334' ; 334feet/100m
heinrichsweikamp
parents:
diff changeset
415 movwf xB+0
heinrichsweikamp
parents:
diff changeset
416 movlw HIGH d'334'
heinrichsweikamp
parents:
diff changeset
417 movwf xB+1
heinrichsweikamp
parents:
diff changeset
418 call mult16x16 ; xA*xB=xC (lo:hi * 328)
heinrichsweikamp
parents:
diff changeset
419 movlw d'50' ; round up
heinrichsweikamp
parents:
diff changeset
420 addwf xC+0,F
heinrichsweikamp
parents:
diff changeset
421 movlw 0
heinrichsweikamp
parents:
diff changeset
422 addwfc xC+1,F
heinrichsweikamp
parents:
diff changeset
423 addwfc xC+2,F
heinrichsweikamp
parents:
diff changeset
424 addwfc xC+3,F
heinrichsweikamp
parents:
diff changeset
425 movlw d'100'
heinrichsweikamp
parents:
diff changeset
426 movwf xB+0
heinrichsweikamp
parents:
diff changeset
427 clrf xB+1
heinrichsweikamp
parents:
diff changeset
428 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
heinrichsweikamp
parents:
diff changeset
429 movff xC+0,lo
heinrichsweikamp
parents:
diff changeset
430 movff xC+1,hi ; restore lo and hi with updated value
heinrichsweikamp
parents:
diff changeset
431 bsf leftbind
heinrichsweikamp
parents:
diff changeset
432 bsf ignore_digit4 ; Only full feet
heinrichsweikamp
parents:
diff changeset
433 output_16
heinrichsweikamp
parents:
diff changeset
434 STRCAT_PRINT "ft "
heinrichsweikamp
parents:
diff changeset
435 bra deco_plan_show_nstd_stop_common
heinrichsweikamp
parents:
diff changeset
436
heinrichsweikamp
parents:
diff changeset
437 deco_plan_show_nstd_stop_metric:
heinrichsweikamp
parents:
diff changeset
438 WIN_LEFT .90
heinrichsweikamp
parents:
diff changeset
439 bsf leftbind
heinrichsweikamp
parents:
diff changeset
440 output_8 ; outputs into Postinc2!
heinrichsweikamp
parents:
diff changeset
441 STRCAT_PRINT "m "
heinrichsweikamp
parents:
diff changeset
442 deco_plan_show_nstd_stop_common:
heinrichsweikamp
parents:
diff changeset
443 ;---- Print duration -------------------------------------------------
heinrichsweikamp
parents:
diff changeset
444 WIN_LEFT .135
heinrichsweikamp
parents:
diff changeset
445 lfsr FSR2,buffer
heinrichsweikamp
parents:
diff changeset
446
heinrichsweikamp
parents:
diff changeset
447 movf lo,W ; Swap up & lo
heinrichsweikamp
parents:
diff changeset
448 movff up,lo
heinrichsweikamp
parents:
diff changeset
449 movwf up
heinrichsweikamp
parents:
diff changeset
450
heinrichsweikamp
parents:
diff changeset
451 output_8 ; Allow up to 240'
heinrichsweikamp
parents:
diff changeset
452 STRCAT_PRINT "' " ; 1 to 3 chars for depth.
heinrichsweikamp
parents:
diff changeset
453
heinrichsweikamp
parents:
diff changeset
454 movf lo,W ; Swap back up & lo
heinrichsweikamp
parents:
diff changeset
455 movff up,lo
heinrichsweikamp
parents:
diff changeset
456 movwf up
heinrichsweikamp
parents:
diff changeset
457
heinrichsweikamp
parents:
diff changeset
458 ;---------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
459 ; Draw the bar graph used for deco stops (decoplan in simulator or dive).
heinrichsweikamp
parents:
diff changeset
460 incf win_top,F
heinrichsweikamp
parents:
diff changeset
461 movlw .19
heinrichsweikamp
parents:
diff changeset
462 movwf win_height
heinrichsweikamp
parents:
diff changeset
463 movlw .118
heinrichsweikamp
parents:
diff changeset
464 movwf win_leftx2 ; column left (0-159)
heinrichsweikamp
parents:
diff changeset
465 movlw .16
heinrichsweikamp
parents:
diff changeset
466 movwf win_width ; column max width.
heinrichsweikamp
parents:
diff changeset
467
heinrichsweikamp
parents:
diff changeset
468 ; Draw used area (up = minutes):
heinrichsweikamp
parents:
diff changeset
469 movlw .16 ; Limit length (16min)
heinrichsweikamp
parents:
diff changeset
470 cpfslt up
heinrichsweikamp
parents:
diff changeset
471 movwf up
heinrichsweikamp
parents:
diff changeset
472 movff up,win_bargraph ; Active width, the rest is cleared.
heinrichsweikamp
parents:
diff changeset
473 call TFT_box
heinrichsweikamp
parents:
diff changeset
474
heinrichsweikamp
parents:
diff changeset
475 ; Restore win_top
50
ec4d8503ec45 NEW: user-selectable color schemes
heinrichsweikamp
parents: 46
diff changeset
476 call TFT_standard_color
0
heinrichsweikamp
parents:
diff changeset
477 decf win_top,F ; Restore win_top
heinrichsweikamp
parents:
diff changeset
478 return
heinrichsweikamp
parents:
diff changeset
479
heinrichsweikamp
parents:
diff changeset
480 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
481 ; Clear unused area belw last stop
heinrichsweikamp
parents:
diff changeset
482 ; Inputs: win_top : last used area...
heinrichsweikamp
parents:
diff changeset
483 deco_plan_show_clear_bottom:
heinrichsweikamp
parents:
diff changeset
484 movf win_top,W ; Get back from bank0
heinrichsweikamp
parents:
diff changeset
485 btfsc divemode ; In dive mode ?
heinrichsweikamp
parents:
diff changeset
486 sublw .168 ; Yes: bottom row in divemode
heinrichsweikamp
parents:
diff changeset
487 btfss divemode ; In dive mode ?
heinrichsweikamp
parents:
diff changeset
488 sublw .240 ; No: bottom row in planning
heinrichsweikamp
parents:
diff changeset
489 movwf win_height
heinrichsweikamp
parents:
diff changeset
490
heinrichsweikamp
parents:
diff changeset
491 WIN_LEFT .85 ; Full divemenu width
heinrichsweikamp
parents:
diff changeset
492 movlw .160-.85+1
heinrichsweikamp
parents:
diff changeset
493 movwf win_width
heinrichsweikamp
parents:
diff changeset
494
heinrichsweikamp
parents:
diff changeset
495 clrf win_color1 ; Fill with black
heinrichsweikamp
parents:
diff changeset
496 clrf win_color2
heinrichsweikamp
parents:
diff changeset
497
heinrichsweikamp
parents:
diff changeset
498 goto TFT_box
heinrichsweikamp
parents:
diff changeset
499
heinrichsweikamp
parents:
diff changeset
500 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
501 ; Display the decoplan (simulator or divemode).
heinrichsweikamp
parents:
diff changeset
502 ; Inputs: char_O_deco_table (array of stop times, in minutes)
heinrichsweikamp
parents:
diff changeset
503 ; decoplan_page = page number.
heinrichsweikamp
parents:
diff changeset
504 ;
heinrichsweikamp
parents:
diff changeset
505 deco_show_plan_page:
heinrichsweikamp
parents:
diff changeset
506 WIN_INVERT 0
heinrichsweikamp
parents:
diff changeset
507
heinrichsweikamp
parents:
diff changeset
508 ;---- Is there deco stops ? ------------------------------------------
heinrichsweikamp
parents:
diff changeset
509 movff char_O_first_deco_depth,WREG
heinrichsweikamp
parents:
diff changeset
510 iorwf WREG
heinrichsweikamp
parents:
diff changeset
511 bnz deco_plan_show_1
heinrichsweikamp
parents:
diff changeset
512
heinrichsweikamp
parents:
diff changeset
513 ;---- No Deco --------------------------------------------------------
50
ec4d8503ec45 NEW: user-selectable color schemes
heinrichsweikamp
parents: 46
diff changeset
514 call TFT_standard_color
0
heinrichsweikamp
parents:
diff changeset
515 TEXT_SMALL .80, .0, tNoDeco
heinrichsweikamp
parents:
diff changeset
516 bsf decoplan_last_ceiling_shown
heinrichsweikamp
parents:
diff changeset
517 return
heinrichsweikamp
parents:
diff changeset
518
heinrichsweikamp
parents:
diff changeset
519 deco_plan_show_1:
heinrichsweikamp
parents:
diff changeset
520 lfsr FSR0,char_O_deco_depth ; Initialize indexed addressing.
heinrichsweikamp
parents:
diff changeset
521 lfsr FSR1,char_O_deco_time
heinrichsweikamp
parents:
diff changeset
522
heinrichsweikamp
parents:
diff changeset
523 movlw .8 ; 8 lines/page in decoplan
heinrichsweikamp
parents:
diff changeset
524 btfsc divemode
heinrichsweikamp
parents:
diff changeset
525 movlw .6 ; 6 lines/page in divemode.
heinrichsweikamp
parents:
diff changeset
526 movwf decoplan_max
heinrichsweikamp
parents:
diff changeset
527
heinrichsweikamp
parents:
diff changeset
528 clrf decoplan_index ; Start with index = 0
heinrichsweikamp
parents:
diff changeset
529 clrf win_top ; and row = 0
heinrichsweikamp
parents:
diff changeset
530
heinrichsweikamp
parents:
diff changeset
531 ; Read stop parameters, indexed by decoplan_index and decoplan_page
heinrichsweikamp
parents:
diff changeset
532 movf decoplan_page,W ; decoplan_gindex = 6*decoplan_page + decoplan_index
heinrichsweikamp
parents:
diff changeset
533 mulwf decoplan_max
heinrichsweikamp
parents:
diff changeset
534 movf decoplan_index,W
heinrichsweikamp
parents:
diff changeset
535 addwf PRODL,W
heinrichsweikamp
parents:
diff changeset
536 movwf decoplan_gindex ; --> decoplan_gindex
heinrichsweikamp
parents:
diff changeset
537
heinrichsweikamp
parents:
diff changeset
538 bcf decoplan_last_ceiling_shown ; Not finished yet...
heinrichsweikamp
parents:
diff changeset
539
heinrichsweikamp
parents:
diff changeset
540 deco_plan_show_2:
heinrichsweikamp
parents:
diff changeset
541 btfsc decoplan_gindex,5 ; Reached table length (32) ?
heinrichsweikamp
parents:
diff changeset
542 bra deco_plan_show_99 ; YES: finished...
heinrichsweikamp
parents:
diff changeset
543
heinrichsweikamp
parents:
diff changeset
544 ; Read stop parameters, indexed by decoplan_index
heinrichsweikamp
parents:
diff changeset
545 movf decoplan_gindex,W ; index
heinrichsweikamp
parents:
diff changeset
546 movff PLUSW1,up ; char_O_deco_time [gindex] --> up
heinrichsweikamp
parents:
diff changeset
547 movff PLUSW0,lo ; char_O_deco_depth[gindex]
heinrichsweikamp
parents:
diff changeset
548 movf lo,W
heinrichsweikamp
parents:
diff changeset
549 bz deco_plan_show_99 ; depth == 0 : finished.
heinrichsweikamp
parents:
diff changeset
550
heinrichsweikamp
parents:
diff changeset
551 ; Display the stop line
heinrichsweikamp
parents:
diff changeset
552 rcall deco_plan_show_stop
heinrichsweikamp
parents:
diff changeset
553
heinrichsweikamp
parents:
diff changeset
554 ; Next
heinrichsweikamp
parents:
diff changeset
555 movlw .24
heinrichsweikamp
parents:
diff changeset
556 addwf win_top,F ; row: += 24
heinrichsweikamp
parents:
diff changeset
557 incf decoplan_index,F ; local index += 1
heinrichsweikamp
parents:
diff changeset
558 incf decoplan_gindex,F ; global index += 1
heinrichsweikamp
parents:
diff changeset
559
heinrichsweikamp
parents:
diff changeset
560 ; Max number of lines/page reached ?
heinrichsweikamp
parents:
diff changeset
561 movf decoplan_max,W ; index+1 == max ?
heinrichsweikamp
parents:
diff changeset
562 cpfseq decoplan_index
heinrichsweikamp
parents:
diff changeset
563 bra deco_plan_show_2 ; NO: loop
heinrichsweikamp
parents:
diff changeset
564
heinrichsweikamp
parents:
diff changeset
565 ; Check if next stop if end-of-list ?
heinrichsweikamp
parents:
diff changeset
566 movf decoplan_gindex,W
heinrichsweikamp
parents:
diff changeset
567 movf PLUSW0,W ; char_O_deco_depth[gindex]
heinrichsweikamp
parents:
diff changeset
568 bz deco_plan_show_99 ; End of list...
heinrichsweikamp
parents:
diff changeset
569
heinrichsweikamp
parents:
diff changeset
570 ; Display the message "more..."
heinrichsweikamp
parents:
diff changeset
571 rcall deco_plan_show_clear_bottom ; Clear from next line
heinrichsweikamp
parents:
diff changeset
572
50
ec4d8503ec45 NEW: user-selectable color schemes
heinrichsweikamp
parents: 46
diff changeset
573 call TFT_standard_color
0
heinrichsweikamp
parents:
diff changeset
574 TEXT_SMALL .85, .240-.25, tMore
heinrichsweikamp
parents:
diff changeset
575 return
heinrichsweikamp
parents:
diff changeset
576
heinrichsweikamp
parents:
diff changeset
577 deco_plan_show_99:
heinrichsweikamp
parents:
diff changeset
578 bsf decoplan_last_ceiling_shown ; Nothing more in table to display.
heinrichsweikamp
parents:
diff changeset
579 rcall deco_plan_show_clear_bottom ; Clear from next line
heinrichsweikamp
parents:
diff changeset
580 return
heinrichsweikamp
parents:
diff changeset
581
heinrichsweikamp
parents:
diff changeset
582 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
583 ; Loop to show all pages of the decoplan (surfacemode)
heinrichsweikamp
parents:
diff changeset
584
heinrichsweikamp
parents:
diff changeset
585 global deco_show_plan
heinrichsweikamp
parents:
diff changeset
586 deco_show_plan:
heinrichsweikamp
parents:
diff changeset
587 clrf decoplan_page
heinrichsweikamp
parents:
diff changeset
588 call TFT_ClearScreen
heinrichsweikamp
parents:
diff changeset
589 WIN_COLOR color_greenish
heinrichsweikamp
parents:
diff changeset
590 TEXT_SMALL .1,.1, tDivePlan
50
ec4d8503ec45 NEW: user-selectable color schemes
heinrichsweikamp
parents: 46
diff changeset
591 call TFT_standard_color
0
heinrichsweikamp
parents:
diff changeset
592 WIN_LEFT .0
heinrichsweikamp
parents:
diff changeset
593
heinrichsweikamp
parents:
diff changeset
594 ;---- Display model
heinrichsweikamp
parents:
diff changeset
595 movff char_I_deco_model,WREG
heinrichsweikamp
parents:
diff changeset
596 iorwf WREG
heinrichsweikamp
parents:
diff changeset
597 bnz deco_show_plan_m1
heinrichsweikamp
parents:
diff changeset
598
heinrichsweikamp
parents:
diff changeset
599 ; Display ZH-L16 sat/desat model.
heinrichsweikamp
parents:
diff changeset
600 TEXT_SMALL .0,.40, tZHL16
heinrichsweikamp
parents:
diff changeset
601 WIN_TOP .65
heinrichsweikamp
parents:
diff changeset
602 lfsr FSR2,buffer
heinrichsweikamp
parents:
diff changeset
603 movff char_I_desaturation_multiplier,lo
heinrichsweikamp
parents:
diff changeset
604 bsf leftbind
heinrichsweikamp
parents:
diff changeset
605 output_8
heinrichsweikamp
parents:
diff changeset
606 STRCAT "%/"
heinrichsweikamp
parents:
diff changeset
607 movff char_I_saturation_multiplier,lo
heinrichsweikamp
parents:
diff changeset
608 output_8
heinrichsweikamp
parents:
diff changeset
609 STRCAT_PRINT "%"
heinrichsweikamp
parents:
diff changeset
610 bra deco_show_plan_m2
heinrichsweikamp
parents:
diff changeset
611
heinrichsweikamp
parents:
diff changeset
612 ; Display ZH-L16-GF low/high model.
heinrichsweikamp
parents:
diff changeset
613 deco_show_plan_m1:
heinrichsweikamp
parents:
diff changeset
614 TEXT_SMALL .0,.40, tZHL16GF
heinrichsweikamp
parents:
diff changeset
615 WIN_TOP .65
heinrichsweikamp
parents:
diff changeset
616 lfsr FSR2,buffer
heinrichsweikamp
parents:
diff changeset
617 movff char_I_GF_Low_percentage,lo
heinrichsweikamp
parents:
diff changeset
618 output_99x
heinrichsweikamp
parents:
diff changeset
619 STRCAT "%/"
heinrichsweikamp
parents:
diff changeset
620 movff char_I_GF_High_percentage,lo
heinrichsweikamp
parents:
diff changeset
621 output_99x
heinrichsweikamp
parents:
diff changeset
622 STRCAT_PRINT "%"
heinrichsweikamp
parents:
diff changeset
623 ;bra deco_show_plan_m2
heinrichsweikamp
parents:
diff changeset
624
40
1e2d2b0bca5b Bugfix: Simulator in CC mode
mh@mh-THINK.fritz.box
parents: 9
diff changeset
625 deco_show_plan_m2:
1e2d2b0bca5b Bugfix: Simulator in CC mode
mh@mh-THINK.fritz.box
parents: 9
diff changeset
626 ; Show deco mode
1e2d2b0bca5b Bugfix: Simulator in CC mode
mh@mh-THINK.fritz.box
parents: 9
diff changeset
627 extern TFT_display_decotype_surface1
1e2d2b0bca5b Bugfix: Simulator in CC mode
mh@mh-THINK.fritz.box
parents: 9
diff changeset
628 WIN_TOP .90
1e2d2b0bca5b Bugfix: Simulator in CC mode
mh@mh-THINK.fritz.box
parents: 9
diff changeset
629 lfsr FSR2,buffer
1e2d2b0bca5b Bugfix: Simulator in CC mode
mh@mh-THINK.fritz.box
parents: 9
diff changeset
630 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea
1e2d2b0bca5b Bugfix: Simulator in CC mode
mh@mh-THINK.fritz.box
parents: 9
diff changeset
631 call TFT_display_decotype_surface1
0
heinrichsweikamp
parents:
diff changeset
632
heinrichsweikamp
parents:
diff changeset
633 ;---- Display TTS result
heinrichsweikamp
parents:
diff changeset
634 WIN_TOP .165
heinrichsweikamp
parents:
diff changeset
635 STRCPY_TEXT tTTS
heinrichsweikamp
parents:
diff changeset
636 STRCAT ": "
heinrichsweikamp
parents:
diff changeset
637
heinrichsweikamp
parents:
diff changeset
638 movff int_O_ascenttime+0,lo
heinrichsweikamp
parents:
diff changeset
639 movff int_O_ascenttime+1,hi
heinrichsweikamp
parents:
diff changeset
640 bsf leftbind
heinrichsweikamp
parents:
diff changeset
641 output_16
heinrichsweikamp
parents:
diff changeset
642 STRCAT_PRINT "'"
heinrichsweikamp
parents:
diff changeset
643
heinrichsweikamp
parents:
diff changeset
644 ;---- Display CNS result
heinrichsweikamp
parents:
diff changeset
645 WIN_TOP .190
heinrichsweikamp
parents:
diff changeset
646 STRCPY_TEXT tCNS
heinrichsweikamp
parents:
diff changeset
647 STRCAT ": "
heinrichsweikamp
parents:
diff changeset
648 movff int_O_CNS_fraction+0,lo
heinrichsweikamp
parents:
diff changeset
649 movff int_O_CNS_fraction+1,hi
heinrichsweikamp
parents:
diff changeset
650 output_16_3
heinrichsweikamp
parents:
diff changeset
651 STRCAT "%\x92" ; "->"
heinrichsweikamp
parents:
diff changeset
652 movff decoplan_CNS+0,lo
heinrichsweikamp
parents:
diff changeset
653 movff decoplan_CNS+1,hi
heinrichsweikamp
parents:
diff changeset
654 output_16_3
heinrichsweikamp
parents:
diff changeset
655 STRCAT_PRINT "%"
heinrichsweikamp
parents:
diff changeset
656
heinrichsweikamp
parents:
diff changeset
657 ;---- Loop through pages
heinrichsweikamp
parents:
diff changeset
658 deco_show_plan_1:
heinrichsweikamp
parents:
diff changeset
659 call speed_normal
heinrichsweikamp
parents:
diff changeset
660 rcall deco_show_plan_page
heinrichsweikamp
parents:
diff changeset
661 incf decoplan_page,F
heinrichsweikamp
parents:
diff changeset
662
heinrichsweikamp
parents:
diff changeset
663 call logbook_preloop_tasks
heinrichsweikamp
parents:
diff changeset
664 deco_show_plan_2:
heinrichsweikamp
parents:
diff changeset
665 btfsc switch_right
heinrichsweikamp
parents:
diff changeset
666 bra deco_show_plan_3
heinrichsweikamp
parents:
diff changeset
667 btfsc switch_left
heinrichsweikamp
parents:
diff changeset
668 bra deco_show_plan_4
heinrichsweikamp
parents:
diff changeset
669 call log_screendump_and_onesecond ; Check if we need to make a screenshot and check for new second
heinrichsweikamp
parents:
diff changeset
670 btfsc sleepmode ; Timeout?
9
150d07db6048 Timeout in decoplanner result page
heinrichsweikamp
parents: 0
diff changeset
671 goto restart
0
heinrichsweikamp
parents:
diff changeset
672 bra deco_show_plan_2
heinrichsweikamp
parents:
diff changeset
673
heinrichsweikamp
parents:
diff changeset
674 deco_show_plan_3:
heinrichsweikamp
parents:
diff changeset
675 btfss decoplan_last_ceiling_shown
heinrichsweikamp
parents:
diff changeset
676 bra deco_show_plan_1
heinrichsweikamp
parents:
diff changeset
677
heinrichsweikamp
parents:
diff changeset
678 deco_show_plan_4:
heinrichsweikamp
parents:
diff changeset
679 call speed_normal ; Display in fast mode.
heinrichsweikamp
parents:
diff changeset
680 return
heinrichsweikamp
parents:
diff changeset
681
heinrichsweikamp
parents:
diff changeset
682 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
683 ;
heinrichsweikamp
parents:
diff changeset
684 global do_demo_divemode
heinrichsweikamp
parents:
diff changeset
685 do_demo_divemode:
heinrichsweikamp
parents:
diff changeset
686 extern option_save_all
heinrichsweikamp
parents:
diff changeset
687 call option_save_all ; Save all settings into EEPROM before starting simulation
heinrichsweikamp
parents:
diff changeset
688 call deco_push_tissues_to_vault
heinrichsweikamp
parents:
diff changeset
689 banksel common ; Bank1
heinrichsweikamp
parents:
diff changeset
690
heinrichsweikamp
parents:
diff changeset
691 bsf restore_deco_data ; Restore tissue and CNS after sim
heinrichsweikamp
parents:
diff changeset
692
heinrichsweikamp
parents:
diff changeset
693 bcf pressure_refresh
heinrichsweikamp
parents:
diff changeset
694 btfss pressure_refresh ; Wait for sensor
heinrichsweikamp
parents:
diff changeset
695 bra $-2
heinrichsweikamp
parents:
diff changeset
696
heinrichsweikamp
parents:
diff changeset
697 bsf simulatormode_active ; Set Flag
heinrichsweikamp
parents:
diff changeset
698 movlw LOW simulator_start_depth
heinrichsweikamp
parents:
diff changeset
699 movff WREG,rel_pressure+0
heinrichsweikamp
parents:
diff changeset
700 movlw HIGH simulator_start_depth
heinrichsweikamp
parents:
diff changeset
701 movff WREG,rel_pressure+1 ; Set Depth
heinrichsweikamp
parents:
diff changeset
702
heinrichsweikamp
parents:
diff changeset
703 movlw LOW (simulator_start_depth+.1000)
heinrichsweikamp
parents:
diff changeset
704 movff WREG,sim_pressure+0
heinrichsweikamp
parents:
diff changeset
705 movlw HIGH (simulator_start_depth+.1000)
heinrichsweikamp
parents:
diff changeset
706 movff WREG,sim_pressure+1 ; Set Depth
heinrichsweikamp
parents:
diff changeset
707
heinrichsweikamp
parents:
diff changeset
708 bsf divemode
heinrichsweikamp
parents:
diff changeset
709 goto diveloop ; Switch into Divemode!
heinrichsweikamp
parents:
diff changeset
710
heinrichsweikamp
parents:
diff changeset
711
heinrichsweikamp
parents:
diff changeset
712 END