0
|
1
|
|
2 ; OSTC - diving computer code
|
|
3 ; Copyright (C) 2008 HeinrichsWeikamp GbR
|
|
4
|
|
5 ; This program is free software: you can redistribute it and/or modify
|
|
6 ; it under the terms of the GNU General Public License as published by
|
|
7 ; the Free Software Foundation, either version 3 of the License, or
|
|
8 ; (at your option) any later version.
|
|
9
|
|
10 ; This program is distributed in the hope that it will be useful,
|
|
11 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 ; GNU General Public License for more details.
|
|
14
|
|
15 ; You should have received a copy of the GNU General Public License
|
|
16 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
|
18
|
|
19 ; menu "Simulator"
|
|
20 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com
|
|
21 ; written: 081210
|
|
22 ; last updated: 081210
|
|
23 ; known bugs:
|
|
24 ; ToDo:
|
|
25
|
|
26 menu_simulator:
|
|
27 movlw d'1'
|
|
28 movwf logbook_temp1 ; Bottom time
|
|
29 movlw d'15'
|
|
30 movwf logbook_temp2 ; Max. Depth
|
|
31 movlw d'1'
|
|
32 movwf menupos
|
|
33
|
|
34 menu_simulator1:
|
|
35 clrf timeout_counter2
|
|
36 bsf menubit
|
|
37 bsf cursor
|
|
38 call PLED_ClearScreen
|
|
39 call PLED_simulator_mask
|
|
40
|
|
41 menu_simulator2:
|
|
42 bcf switch_left
|
|
43 bcf switch_right
|
|
44 bcf menubit2
|
|
45 bcf menubit3
|
|
46 call PLED_simulator_data
|
|
47 call PLED_menu_cursor
|
|
48
|
|
49 menu_simulator_loop:
|
|
50 call check_switches_menu
|
|
51 menu_simulator_loop2:
|
|
52 btfss onesecupdate
|
|
53 bra menu_simulator_loop3
|
|
54
|
|
55 call timeout_surfmode
|
|
56 call set_dive_modes
|
|
57 call test_charger ; check if charger IC is active
|
|
58 call get_battery_voltage ; get battery voltage
|
|
59
|
|
60 bcf onesecupdate ; End of one second tasks
|
|
61
|
|
62 menu_simulator_loop3:
|
|
63 btfsc menubit2
|
|
64 goto menu_simulator_do ; call submenu
|
|
65
|
|
66 btfss menubit
|
|
67 goto menu ; exit setup menu and return to main menu
|
|
68
|
|
69 btfsc sleepmode
|
|
70 goto more_menu
|
|
71
|
|
72 btfsc divemode
|
|
73 goto restart ; exit menu, restart and enter divemode
|
|
74
|
|
75 bra menu_simulator_loop
|
|
76
|
|
77 menu_simulator_do: ; calls submenu
|
|
78 dcfsnz menupos,F
|
|
79 bra simulator_startdive
|
|
80 dcfsnz menupos,F
|
|
81 bra simulator_inc_bottomtime
|
|
82 dcfsnz menupos,F
|
|
83 bra simulator_inc_maxdepth
|
|
84 dcfsnz menupos,F
|
|
85 bra simulator_calc_deco
|
|
86 dcfsnz menupos,F
|
|
87 bra simulator_show_decoplan
|
|
88 movlw d'4'
|
|
89 movwf menupos
|
|
90 goto more_menu2 ; exit...
|
|
91
|
|
92 simulator_inc_bottomtime:
|
|
93 movlw d'2'
|
|
94 addwf logbook_temp1,F ; Here: Bottomtime in m
|
|
95 movlw d'199'
|
|
96 cpfslt logbook_temp1
|
|
97 movwf logbook_temp1
|
|
98 movlw d'2'
|
|
99 movwf menupos
|
|
100 bra menu_simulator2
|
|
101
|
|
102 simulator_inc_maxdepth:
|
|
103 movlw d'3'
|
|
104 addwf logbook_temp2,F ; Here: Maxdepth in m
|
|
105 movlw d'99'
|
|
106 cpfslt logbook_temp2
|
|
107 movwf logbook_temp2
|
|
108 movlw d'3'
|
|
109 movwf menupos
|
|
110 bra menu_simulator2
|
|
111
|
|
112 simulator_startdive:
|
|
113 ; Descent to -3m depth
|
|
114 ; Set standalone_simulator flag (Displays Simulator menu during simulation by pressing ENTER button)
|
|
115 ; Clear standalone_simulator after (any) dive
|
|
116 bsf simulatormode_active ; normal simulator mode
|
|
117 bsf standalone_simulator ; Standalone Simulator active
|
|
118
|
|
119 movff logbook_temp2,xA+0
|
|
120 clrf xA+1
|
|
121 movlw d'100'
|
|
122 movwf xB+0
|
|
123 clrf xB+1
|
|
124 call mult16x16 ;xA*xB=xC ; Depth in m*100
|
|
125
|
|
126 movlw LOW d'1000'
|
|
127 addwf xC+0,F
|
|
128 movlw HIGH d'1000'
|
|
129 addwfc xC+1,F ; Add 1000mBar
|
|
130
|
|
131 movff xC+0,sim_pressure+0
|
|
132 movff xC+1,sim_pressure+1
|
|
133
|
|
134 movff sim_pressure+0,amb_pressure+0 ; override readings with simulator values
|
|
135 movff sim_pressure+1,amb_pressure+1
|
|
136
|
|
137 bcf menubit2
|
|
138 bcf menubit3
|
|
139 bcf menubit
|
|
140 bcf switch_left
|
|
141 bcf switch_right
|
|
142
|
|
143 call simulator_save_tissue_data ; Stores 32 floats "pre_tissue" into bank3
|
|
144
|
|
145 bsf divemode ; Set divemode flag
|
|
146 ostc_debug 'P' ; Sends debug-information to screen if debugmode active
|
|
147 goto diveloop ; Start Divemode
|
|
148
|
|
149 simulator_save_tissue_data:
|
|
150 bsf restore_deco_data ; Set restore flag
|
|
151 ostc_debug 'S' ; Sends debug-information to screen if debugmode active
|
|
152 call main_push_tissues_to_vault
|
|
153 movlb 0x01 ; Back to RAM Bank1
|
|
154 ostc_debug 'T' ; Sends debug-information to screen if debugmode active
|
|
155 return
|
|
156
|
|
157 simulator_restore_tissue_data:
|
|
158 bcf restore_deco_data ; clear restore flag
|
|
159 ostc_debug 'S' ; Sends debug-information to screen if debugmode active
|
|
160 call main_pull_tissues_from_vault
|
|
161 movlb 0x01 ; Back to RAM Bank1
|
|
162 ostc_debug 'T' ; Sends debug-information to screen if debugmode active
|
|
163
|
|
164 ostc_debug 'G' ; Sends debug-information to screen if debugmode active
|
|
165 call deco_main_calc_desaturation_time ; calculate desaturation time
|
|
166 movlb b'00000001' ; select ram bank 1
|
|
167 call calculate_noflytime ; Calc NoFly time
|
|
168 ostc_debug 'H' ; Sends debug-information to screen if debugmode active
|
|
169 return
|
|
170
|
|
171 simulator_show_decoplan:
|
|
172 call PLED_ClearScreen
|
|
173 call divemenu_see_decoplan
|
|
174
|
|
175 bcf switch_left
|
|
176 bcf switch_right
|
|
177
|
|
178 simulator_show_decoplan2:
|
|
179 btfss onesecupdate
|
|
180 bra simulator_show_decoplan3
|
|
181
|
|
182 call timeout_surfmode
|
|
183 call set_dive_modes
|
|
184 call test_charger ; check if charger IC is active
|
|
185 call get_battery_voltage ; get battery voltage
|
|
186
|
|
187 bcf onesecupdate ; End of one second tasks
|
|
188
|
|
189 simulator_show_decoplan3:
|
|
190 btfsc switch_left
|
|
191 bra simulator_show_decoplan4 ; Quit display
|
|
192
|
|
193 btfsc switch_right
|
|
194 bra simulator_show_decoplan4 ; Quit display
|
|
195
|
|
196 btfsc sleepmode
|
|
197 goto more_menu
|
|
198
|
|
199 btfsc divemode
|
|
200 goto restart ; exit menu, restart and enter divemode
|
|
201
|
|
202 bra simulator_show_decoplan2
|
|
203
|
|
204 simulator_show_decoplan4:
|
|
205 movlw d'5'
|
|
206 movwf menupos
|
|
207 bra menu_simulator1
|
|
208
|
|
209
|
|
210 simulator_calc_deco:
|
|
211 call diveloop_boot ; configure gases, etc.
|
|
212
|
|
213 bsf simulatormode_active ; normal simulator mode
|
|
214 bsf standalone_simulator ; Standalone Simulator active
|
|
215
|
|
216
|
|
217 movff logbook_temp2,xA+0
|
|
218 clrf xA+1
|
|
219 movlw d'100'
|
|
220 movwf xB+0
|
|
221 clrf xB+1
|
|
222 call mult16x16 ;xA*xB=xC ; Depth in m*100
|
|
223
|
|
224 movlw LOW d'1000'
|
|
225 addwf xC+0,F
|
|
226 movlw HIGH d'1000'
|
|
227 addwfc xC+1,F ; Add 1000mBar
|
|
228
|
|
229 movff xC+0,sim_pressure+0
|
|
230 movff xC+1,sim_pressure+1
|
|
231
|
|
232 movff sim_pressure+0,amb_pressure+0 ; override readings with simulator values
|
|
233 movff sim_pressure+1,amb_pressure+1
|
|
234
|
|
235 call simulator_save_tissue_data ; Stores 32 floats "pre_tissue" into bank3
|
|
236
|
|
237 WIN_INVERT .1
|
|
238 DISPLAYTEXT .12 ;" Wait.."
|
|
239 WIN_INVERT .0
|
|
240
|
|
241 simulator_calc_deco_loop1:
|
|
242 call PLED_simulator_data
|
|
243
|
|
244 ; movlw .011
|
|
245 ; call PLED_SetColumn
|
|
246 ; movlw .009
|
|
247 ; call PLED_SetRow
|
|
248 ; lfsr FSR2,letter
|
|
249 ; movff char_O_array_decodepth+0,lo ; Get Depth
|
|
250 ; bsf leftbind
|
|
251 ; output_8
|
|
252 ; bcf leftbind
|
|
253 ; movlw ' '
|
|
254 ; movwf POSTINC2
|
|
255 ;call word_processor
|
|
256
|
|
257
|
|
258 simulator_calc_deco_loop2:
|
21
|
259 btg LED_red
|
0
|
260
|
31
|
261 movlw d'1'
|
|
262 movff WREG,char_I_step_is_1min ; 1 minute mode
|
|
263
|
0
|
264 call divemode_check_decogases ; Checks for decogases and sets the gases
|
|
265 call divemode_prepare_flags_for_deco
|
|
266
|
|
267 call deco_main_calc_hauptroutine ; calc_tissue
|
|
268 movlb b'00000001' ; rambank 1 selected
|
|
269 ostc_debug 'C' ; Sends debug-information to screen if debugmode active
|
|
270
|
|
271 decfsz logbook_temp1,F
|
|
272 bra simulator_calc_deco_loop1
|
|
273
|
|
274 movff char_O_deco_status,deco_status ;
|
|
275 tstfsz deco_status ; deco_status=0 if decompression calculation done
|
|
276 bra simulator_calc_deco2 ; Not finished
|
|
277
|
|
278 simulator_calc_deco3:
|
21
|
279 bsf LED_red
|
0
|
280
|
|
281 call simulator_restore_tissue_data ; Restore 32 floats "pre_tissue" from bank3
|
|
282
|
|
283 bcf simulatormode_active ; normal simulator mode
|
|
284 bcf standalone_simulator ; Standalone Simulator active
|
|
285
|
|
286 WAITMS d'250'
|
|
287 WAITMS d'250'
|
|
288 WAITMS d'250' ; Wait for Pressure Sensor to get real pressure again...
|
|
289
|
21
|
290 bcf LED_red
|
0
|
291
|
|
292 movlw d'1'
|
|
293 movwf logbook_temp1 ; Bottom time>0!
|
|
294
|
|
295 movlw d'5' ; Pre-Set Cursor to "Show Decoplan"
|
|
296 movwf menupos
|
31
|
297
|
|
298 movlw d'0'
|
|
299 movff WREG,char_I_step_is_1min ; 2 second deco mode
|
|
300
|
0
|
301 bra menu_simulator1 ; Done.
|
|
302
|
|
303 simulator_calc_deco2:
|
31
|
304 movlw d'0'
|
|
305 movff WREG,char_I_step_is_1min ; 2 second deco mode
|
|
306
|
0
|
307 call divemode_check_decogases ; Checks for decogases and sets the gases
|
|
308 call divemode_prepare_flags_for_deco
|
|
309
|
|
310 call deco_main_calc_hauptroutine ; calc_tissue
|
|
311 movlb b'00000001' ; rambank 1 selected
|
|
312
|
|
313 movff char_O_deco_status,deco_status ;
|
|
314 tstfsz deco_status ; deco_status=0 if decompression calculation done
|
|
315 bra simulator_calc_deco2 ; Not finished
|
|
316 bra simulator_calc_deco3 ; finished! |