Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/divemode_menu.asm @ 106:966ebf905514
bugfix in output16_3_call
author | heinrichsweikamp |
---|---|
date | Sun, 19 Dec 2010 20:54:08 +0100 |
parents | 2a2606e9db5f |
children | a2b9eca1f396 |
rev | line source |
---|---|
0 | 1 ; OSTC - diving computer code |
2 ; Copyright (C) 2008 HeinrichsWeikamp GbR | |
3 | |
4 ; This program is free software: you can redistribute it and/or modify | |
5 ; it under the terms of the GNU General Public License as published by | |
6 ; the Free Software Foundation, either version 3 of the License, or | |
7 ; (at your option) any later version. | |
8 | |
9 ; This program is distributed in the hope that it will be useful, | |
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 ; GNU General Public License for more details. | |
13 | |
14 ; You should have received a copy of the GNU General Public License | |
15 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | |
17 | |
18 ; Underwater Menu (Set Gas, Decoplan, etc.) | |
19 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com | |
20 ; written: 11/11/05 | |
21 ; last updated: 090305 | |
22 ; known bugs: | |
23 ; ToDo: | |
24 | |
25 | |
26 test_switches_divemode: | |
27 ; checks switches in divemode | |
28 btfsc switch_left | |
29 bra test_switches_divemode2 | |
30 | |
31 btfss switch_right | |
32 return | |
33 | |
34 bcf switch_left ; Left button pressed! | |
35 bcf switch_right | |
36 | |
37 bcf select_bailoutgas ; Clear Flag for Bailout list | |
38 bsf premenu ; Set Flag for premenu | |
39 bcf menubit | |
40 clrf timeout_counter3 ; timeout_divemenu | |
41 | |
42 btfsc FLAG_apnoe_mode ; In Apnoe mode? | |
43 bra test_switches_divemode1 ; Yes! | |
44 | |
45 test_switches_divemode0: | |
46 WIN_INVERT .1 | |
47 DISPLAYTEXT .4 ;Menu? | |
48 WIN_INVERT .0 | |
49 return | |
50 | |
51 test_switches_divemode1: | |
52 DISPLAYTEXT .141 ;Quit? | |
53 return | |
54 | |
55 test_switches_divemode2: | |
56 bcf switch_left ; Also reactivate left button if there was a right press without prior left press | |
57 bcf switch_right ; enable right button again | |
58 | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
59 btfsc premenu |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
60 bra test_switches_divemode2_2 |
0 | 61 |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
62 bsf toggle_customview ; Toggle customview (Cleared in divemode.asm) |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
63 btfsc standalone_simulator ; Standalone Simualtor active? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
64 bra divemode_menu_simulator ; Yes, Show simulator menu! |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
65 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
66 test_switches_divemode2_2: |
0 | 67 btfss FLAG_apnoe_mode ; In Apnoe mode? |
68 bra test_switches_divemode2a; No! | |
69 | |
70 ; Yes, so quit Apnoe mode at once... | |
71 bcf divemode ; Clear Divemode flag... | |
72 bcf premenu ; clear premenu flag | |
73 return | |
74 | |
75 test_switches_divemode2a: | |
76 bsf menubit ; Enter Divemode-Menu! | |
77 bcf premenu ; clear premenu flag | |
78 call PLED_clear_divemode_menu ; Clear dive mode menu area | |
79 call PLED_divemode_menu_mask_first ; Write Divemode menu1 mask | |
80 bcf display_set_simulator ; Clear Simulator-Menu flag | |
81 movlw d'1' | |
82 movwf menupos ; reset cursor in divemode menu | |
83 call PLED_divemenu_cursor ; show cursor | |
84 bcf switch_right | |
85 bcf switch_left ; Left button pressed! | |
86 return | |
87 | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
88 reset_stopwatch: |
71
6beb680a6130
1.72beta - color-coded gaslist, small fix with stopwatch
heinrichsweikamp
parents:
68
diff
changeset
|
89 btfsc lock_stopwatch_reset ; Reset locked? |
6beb680a6130
1.72beta - color-coded gaslist, small fix with stopwatch
heinrichsweikamp
parents:
68
diff
changeset
|
90 return ; Yes, do not reset (now)... |
0 | 91 ; Maker Set, also reset average Depth.... |
92 clrf average_depth_hold+0 | |
93 clrf average_depth_hold+1 | |
94 clrf average_depth_hold+2 | |
95 clrf average_depth_hold+3 ; Clear average depth register | |
96 movlw d'2' | |
97 movwf average_divesecs+0 | |
98 clrf average_divesecs+1 | |
99 call calc_average_depth | |
100 return | |
101 | |
102 test_switches_divemode_menu: | |
103 btfsc switch_left | |
104 bra test_switches_divemode_menu3 | |
105 btfss switch_right | |
106 return | |
107 | |
108 btfsc display_see_deco ; Is the Decoplan displayed? | |
109 bra divemenu_see_decoplan2 ; Yes, exit menu on left button press | |
110 | |
111 bcf switch_right ; Left button pressed | |
112 clrf timeout_counter3 ; timout_divemenu! | |
113 incf menupos,F | |
114 | |
115 ; Following routine configures the number of menu entries for the different modes | |
116 movlw d'6' ; number of available gases+1, ; number of menu options+1 | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
117 btfsc display_set_gas ; Are we in the "Gaslist" menu? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
118 movlw d'7' ; Yes, Number of entries for this menu+1 = 7 |
0 | 119 btfsc display_set_setpoint ; In SetPoint Menu? |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
120 movlw d'5' ; Number of entries for this menu+1 = 5 |
0 | 121 cpfseq menupos ; =limit? |
122 bra test_switches_divemode_menu1; No! | |
123 movlw d'1' ; Yes, reset to position 1! | |
124 movwf menupos | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
125 |
0 | 126 test_switches_divemode_menu1: |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
127 ; Finally, check if menuposition 3 should be skipped (No customview with function displayed) |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
128 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
129 btfsc display_set_gas ; Are we in the "Gaslist" or "SetPoint" menu? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
130 bra test_switches_divemode_menu1a ; Skip test for sub menus |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
131 btfsc display_set_xgas ; Are we in the "Gaslist" or "SetPoint" menu? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
132 bra test_switches_divemode_menu1a ; Skip test for sub menus |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
133 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
134 movlw d'3' |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
135 cpfseq menupos ; At position 3? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
136 bra test_switches_divemode_menu1a; No |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
137 btfss menu3_active ; Menu position 3 has functionality? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
138 incf menupos,F ; No, +1, skip to menuos=4 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
139 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
140 test_switches_divemode_menu1a: |
0 | 141 call PLED_divemenu_cursor ; update cursor |
142 return | |
143 | |
144 test_switches_divemode_menu3: | |
145 bcf switch_left | |
146 bcf switch_right | |
147 bsf menubit ; Enter Divemode-Menu! | |
148 bcf premenu ; clear premenu flag | |
149 clrf timeout_counter3 | |
150 | |
151 btfsc display_set_gas ; Are we in the "Gaslist" or "SetPoint" menu? | |
152 bra divemenu_set_gas2 ; Yes, so set gas and exit menu | |
153 | |
154 btfsc display_see_deco ; Is the Decoplan displayed? | |
155 bra divemenu_see_decoplan2 ; Yes, exit menu on right button press | |
156 | |
157 btfsc display_set_xgas ; Are we in the "Set Gas" menu? | |
158 bra divemenu_set_xgas2 ; Yes, so configure gas or set menu and exit menu | |
159 | |
160 btfsc display_set_simulator ; Are we in the Divemode Simulator menu? | |
161 goto divemode_menu_simulator2 ; Yes, so adjust depth or set and exit | |
162 | |
163 ; Options for Menu 1 | |
164 dcfsnz menupos,F | |
73
2227459e8ef2
Exchanged Decoplan and Gaslist in dive mode menu
heinrichsweikamp
parents:
71
diff
changeset
|
165 bra divemenu_set_gas ; Set gas sub-menu |
2227459e8ef2
Exchanged Decoplan and Gaslist in dive mode menu
heinrichsweikamp
parents:
71
diff
changeset
|
166 dcfsnz menupos,F |
0 | 167 bra divemenu_see_decoplan ; display the full decoplan |
168 dcfsnz menupos,F | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
169 bra divemode_menu3 ; Customview-function |
0 | 170 dcfsnz menupos,F |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
171 bra divemode_toggle_brightness ; Toggle OLED-Brightness |
0 | 172 dcfsnz menupos,F |
173 bra timeout_divemenu2 ; Quit divemode menu | |
174 return | |
175 | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
176 divemode_menu3: |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
177 movff menupos3,temp1 ; copy |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
178 dcfsnz temp1,F |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
179 bra toggle_stopwatch ; Toggle Stopwatch/Average register |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
180 dcfsnz temp1,F |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
181 bra set_marker ; Set Marker |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
182 dcfsnz temp1,F |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
183 bra divemode_menu3_nothing ; clock... |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
184 dcfsnz temp1,F |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
185 bra divemode_menu3_nothing ; leading tissue... |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
186 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
187 divemode_menu3_nothing: |
0 | 188 bra timeout_divemenu2 ; Quit divemode menu |
189 return | |
190 | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
191 set_marker: |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
192 movlw d'6' ; Type of Alarm (Manual Marker) |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
193 movwf AlarmType ; Copy to Alarm Register |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
194 bsf event_occured ; Set Event Flag |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
195 bra timeout_divemenu2 ; quit menu! |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
196 |
0 | 197 toggle_stopwatch: |
198 btg stopwatch_active ; Toggle Flag | |
199 | |
200 btfss stopwatch_active ; Show Stopwatch? | |
201 bra toggle_stopwatch2 ; No, remove outputs | |
202 | |
203 clrf average_depth_hold+0 | |
204 clrf average_depth_hold+1 | |
205 clrf average_depth_hold+2 | |
206 clrf average_depth_hold+3 ; Clear average depth register | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
207 movlw d'3' |
0 | 208 movwf average_divesecs+0 |
209 clrf average_divesecs+1 | |
210 call calc_average_depth | |
211 bra timeout_divemenu2 ; quit menu! | |
212 | |
213 toggle_stopwatch2: | |
87 | 214 call PLED_clear_customview_divemode ; Remove Stopwatch Outputs |
0 | 215 bra timeout_divemenu2 ; quit menu! |
216 | |
217 divemode_toggle_brightness: | |
218 read_int_eeprom d'90' ; Brightness offset? (Dim>0, Normal = 0) | |
219 tstfsz EEDATA ; Was dimmed? | |
220 bra divemode_toggle_brightness1 ; Yes... | |
221 | |
222 call PLED_brightness_low | |
223 movlw d'1' | |
224 movwf EEDATA ; Copy to EEDATA | |
225 write_int_eeprom d'90' ; Brightness offset? (Dim=1, Normal = 0) | |
226 bra divemode_toggle_brightness3 | |
227 | |
228 divemode_toggle_brightness1: | |
229 call PLED_brightness_full | |
230 movlw d'0' | |
231 movwf EEDATA ; Copy to EEDATA | |
232 write_int_eeprom d'90' ; Brightness offset? (Dim=1, Normal = 0) | |
233 | |
234 divemode_toggle_brightness3: | |
235 ; Now, redraw all outputs (All modes) | |
236 call PLED_active_gas_divemode ; Display gas, if required | |
237 call PLED_temp_divemode ; Displays temperature | |
238 call PLED_depth ; Displays new depth... | |
239 call PLED_max_pressure ; ...and max. depth | |
240 | |
241 btfsc FLAG_apnoe_mode ; Ignore in Apnoe mode | |
242 bra timeout_divemenu2 ; quit menu! | |
243 btfsc gauge_mode ; Ignore in Gauge mode | |
244 bra timeout_divemenu2 ; quit menu! | |
245 | |
246 ; Redraw Outputs in Deco modes | |
247 btfsc dekostop_active | |
248 call PLED_display_deko_mask ; clear nostop time, display decodata | |
249 btfss dekostop_active | |
250 call PLED_display_ndl_mask ; Clear deco data, display nostop time | |
251 bra timeout_divemenu2 ; quit menu! | |
252 | |
253 divemode_set_xgas: ; Set the extra gas... | |
254 bsf display_set_xgas ; Set Flag | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
255 bcf display_set_gas ; Clear Flag |
0 | 256 call PLED_clear_divemode_menu ; Clear Menu |
257 | |
258 movff char_I_O2_ratio, EEDATA ; Reset Gas6 to current gas | |
259 write_int_eeprom d'24' | |
260 movff char_I_He_ratio, EEDATA | |
261 write_int_eeprom d'25' | |
262 | |
263 call PLED_divemode_set_xgas ; Show mask | |
264 | |
265 movlw d'1' | |
266 movwf menupos ; reset cursor | |
267 call PLED_divemenu_cursor ; update cursor | |
268 return | |
269 | |
270 divemode_menu_simulator: | |
271 bsf menubit ; Enter Divemode-Menu! | |
272 bcf premenu ; clear premenu flag | |
273 bcf switch_right | |
274 bcf switch_left ; Left button pressed! | |
104 | 275 bsf display_set_simulator ; Set Flag |
276 bsf menu3_active ; So "+1" is accessible at all times | |
0 | 277 call PLED_clear_divemode_menu ; Clear Menu |
278 call PLED_divemode_simulator_mask; Show mask | |
279 movlw d'1' | |
280 movwf menupos ; reset cursor | |
281 call PLED_divemenu_cursor ; update cursor | |
282 return | |
283 | |
284 divemode_menu_simulator2: | |
285 dcfsnz menupos,F | |
286 bra timeout_divemenu2 ; quit underwater menu! | |
287 dcfsnz menupos,F | |
288 bra divemode_menu_simulator_p1 ; Adjust +1m | |
289 dcfsnz menupos,F | |
290 bra divemode_menu_simulator_m1 ; Adjust -1m | |
291 dcfsnz menupos,F | |
292 bra divemode_menu_simulator_p10 ; Adjust +10m | |
293 dcfsnz menupos,F | |
294 bra divemode_menu_simulator_m10 ; Adjust -10m | |
295 bra timeout_divemenu2 ; quit underwater menu! | |
296 | |
297 divemode_menu_simulator_common: | |
298 call PLED_divemode_simulator_mask ; Redraw Simualtor mask | |
299 | |
300 ; Check limits (140m and 0m) | |
301 movlw LOW d'15000' | |
302 movwf sub_a+0 | |
303 movlw HIGH d'15000' | |
304 movwf sub_a+1 | |
305 movff sim_pressure+0,sub_b+0 | |
306 movff sim_pressure+1,sub_b+1 | |
307 call sub16 ; sub_c = sub_a - sub_b | |
308 btfss neg_flag | |
309 bra divemode_menu_simulator_common2 | |
310 ; Too deep, limit to 140m | |
311 movlw LOW d'15000' | |
312 movwf sim_pressure+0 | |
313 movlw HIGH d'15000' | |
314 movwf sim_pressure+1 | |
315 return | |
316 | |
317 divemode_menu_simulator_common2: | |
318 movlw LOW d'1000' | |
319 movwf sub_a+0 | |
320 movlw HIGH d'1000' | |
321 movwf sub_a+1 | |
322 movff sim_pressure+0,sub_b+0 | |
323 movff sim_pressure+1,sub_b+1 | |
324 call sub16 ; sub_c = sub_a - sub_b | |
325 btfsc neg_flag | |
326 return | |
327 ; Too shallow, limit to 1m | |
328 movlw LOW d'1000' | |
329 movwf sim_pressure+0 | |
330 movlw HIGH d'1000' | |
331 movwf sim_pressure+1 | |
332 return | |
333 | |
334 divemode_menu_simulator_m10: | |
335 movlw LOW d'1000' | |
336 subwf sim_pressure+0,F | |
337 movlw HIGH d'1000' | |
338 subwfb sim_pressure+1,F | |
339 movlw d'5' | |
340 movwf menupos ; reset cursor | |
341 bra divemode_menu_simulator_common | |
342 | |
343 divemode_menu_simulator_p10: | |
344 movlw LOW d'1000' | |
345 addwf sim_pressure+0,F | |
346 movlw HIGH d'1000' | |
347 addwfc sim_pressure+1,F | |
348 movlw d'4' | |
349 movwf menupos ; reset cursor | |
350 bra divemode_menu_simulator_common | |
351 | |
352 divemode_menu_simulator_p1: | |
353 movlw d'100' | |
354 addwf sim_pressure+0,F | |
355 movlw d'0' | |
356 addwfc sim_pressure+1,F | |
357 movlw d'2' | |
358 movwf menupos ; reset cursor | |
359 bra divemode_menu_simulator_common | |
360 | |
361 divemode_menu_simulator_m1: | |
362 movlw d'100' | |
363 subwf sim_pressure+0,F | |
364 movlw d'0' | |
365 subwfb sim_pressure+1,F | |
366 movlw d'3' | |
367 movwf menupos ; reset cursor | |
368 bra divemode_menu_simulator_common | |
369 | |
370 divemenu_see_decoplan: | |
371 bsf display_see_deco ; set flag | |
64 | 372 call PLED_clear_divemode_menu ; Clear Menu |
0 | 373 |
374 read_int_eeprom d'34' | |
375 movlw d'3' | |
376 cpfsgt EEDATA ; in multi-gf mode? Z16 GF OC=4 and Z16 GF CC=5 | |
68 | 377 bra divemenu_see_decoplan1 ; No, standard ZH-L16 |
0 | 378 |
379 bsf multi_gf_display ; Yes, display the multi-gf table screen | |
64 | 380 bcf last_ceiling_gf_shown ; Clear flag |
0 | 381 |
64 | 382 call PLED_decoplan_gf_page1 ; Display the new screen |
0 | 383 return |
384 | |
385 divemenu_see_decoplan1: | |
386 | |
387 movff char_O_deco_status,deco_status ; | |
388 tstfsz deco_status ; deco_status=0 if decompression calculation done | |
389 return ; calculation not yet finished! | |
390 | |
391 call PLED_decoplan ; display the Decoplan | |
392 return | |
393 | |
394 divemenu_see_decoplan2: | |
64 | 395 btfsc multi_gf_display ; Next Page in Multi-GF Screen? |
396 bra divemenu_see_decoplan2_nextgf ; Yes! | |
397 ; No, remove outputs! | |
398 divemenu_see_decoplan2_0: | |
0 | 399 bcf display_see_deco ; clear flag |
400 bra timeout_divemenu2 ; quit menu! | |
401 | |
64 | 402 divemenu_see_decoplan2_nextgf: |
403 incf temp8,F | |
404 btfsc last_ceiling_gf_shown ; last ceiling shown? | |
405 bra divemenu_see_decoplan2_0 ; All done, clear and return | |
406 | |
407 clrf timeout_counter3 ; Clear timeout Divemode menu | |
68 | 408 bra timeout_divemenu3x ; Display next page |
64 | 409 |
0 | 410 divemenu_set_xgas2: |
411 dcfsnz menupos,F | |
412 bra divemenu_set_xgas2_exit ; Use the gas6 configured and exit | |
413 dcfsnz menupos,F | |
414 bra divemenu_set_xgas2_o2plus ; Adjust O2+ | |
415 dcfsnz menupos,F | |
416 bra divemenu_set_xgas2_o2minus ; Adjust O2- | |
417 dcfsnz menupos,F | |
418 bra divemenu_set_xgas2_heplus ; Adjust He+ | |
419 dcfsnz menupos,F | |
420 bra divemenu_set_xgas2_heminus ; Adjust He- | |
421 return | |
422 | |
423 divemenu_set_xgas2_heminus: | |
424 read_int_eeprom d'25' ; He value | |
425 movff EEDATA,lo | |
426 decf lo,F ; decrease He | |
427 movlw d'255' | |
428 cpfseq lo | |
429 bra divemenu_set_xgas2_heminus2 | |
430 incf lo,F ; limit to min=0 | |
431 divemenu_set_xgas2_heminus2: | |
432 movff lo, EEDATA | |
433 write_int_eeprom d'25' ; He Value | |
434 | |
435 call PLED_divemode_set_xgas ; Redraw menu | |
436 movlw d'5' | |
437 movwf menupos ; reset cursor | |
438 return | |
439 | |
440 divemenu_set_xgas2_heplus: | |
441 read_int_eeprom d'25' ; He value | |
442 movff EEDATA,lo | |
443 incf lo,F ; increase He | |
444 movlw d'101' | |
445 cpfseq lo | |
446 bra divemenu_set_xgas2_heplus2 | |
447 movlw d'4' ; O2 Limit | |
448 movwf lo | |
449 divemenu_set_xgas2_heplus2: ; test if O2+He>100... | |
450 read_int_eeprom d'24' ; O2 value | |
451 movf EEDATA,W | |
452 addwf lo,W ; add He value | |
453 movwf hi ; store in temp | |
454 movlw d'101' | |
455 cpfseq hi ; O2 and He > 100? | |
456 bra divemenu_set_xgas2_heplus3 ; No! | |
457 decf lo,F ; reduce He again = unchanged after operation | |
458 divemenu_set_xgas2_heplus3: ; save current value | |
459 movff lo, EEDATA | |
460 write_int_eeprom d'25' ; He Value | |
461 | |
462 call PLED_divemode_set_xgas ; Redraw menu | |
463 movlw d'4' | |
464 movwf menupos ; reset cursor | |
465 return | |
466 | |
467 divemenu_set_xgas2_o2minus: | |
468 read_int_eeprom d'24' ; O2 value | |
469 movff EEDATA,lo | |
470 decf lo,F ; decrease O2 | |
471 movlw d'3' ; Limit-1 | |
472 cpfseq lo | |
473 bra divemenu_set_xgas2_o2minus2 | |
474 incf lo,F ; limit to min=9 | |
475 divemenu_set_xgas2_o2minus2: | |
476 movff lo, EEDATA | |
477 write_int_eeprom d'24' ; O2 Value | |
478 | |
479 call PLED_divemode_set_xgas ; Redraw menu | |
480 movlw d'3' | |
481 movwf menupos ; reset cursor | |
482 return | |
483 | |
484 divemenu_set_xgas2_o2plus: | |
485 read_int_eeprom d'24' ; O2 value | |
486 movff EEDATA,lo | |
487 incf lo,F ; increase O2 | |
488 movlw d'101' | |
489 cpfseq lo | |
490 bra divemenu_set_xgas2_o2plus2 | |
491 movlw d'5' ; O2 limit | |
492 movwf lo | |
493 divemenu_set_xgas2_o2plus2: ; test if O2+He>100... | |
494 read_int_eeprom d'25' ; He value | |
495 movf EEDATA,W | |
496 addwf lo,W ; add O2 value | |
497 movwf hi ; store in temp | |
498 movlw d'101' | |
499 cpfseq hi ; O2 and He > 100? | |
500 bra divemenu_set_xgas2_o2plus3 ; No! | |
501 decf lo,F ; reduce O2 again = unchanged after operation | |
502 divemenu_set_xgas2_o2plus3: ; save current value | |
503 movff lo, EEDATA | |
504 write_int_eeprom d'24' ; O2 Value | |
505 | |
506 call PLED_divemode_set_xgas ; Redraw menu | |
507 movlw d'2' | |
508 movwf menupos ; reset cursor | |
509 return | |
510 | |
511 divemenu_set_xgas2_exit: | |
512 read_int_eeprom d'25' ; Read He ratio | |
513 movff EEDATA,char_I_He_ratio ; And copy into hold register | |
514 | |
515 read_int_eeprom d'24' ; Read O2 ratio | |
516 movff EEDATA, char_I_O2_ratio ; O2 ratio | |
517 movff char_I_He_ratio, wait_temp ; copy into bank1 register | |
518 bsf STATUS,C ; | |
519 movlw d'100' ; 100% | |
520 subfwb wait_temp,W ; minus He | |
521 subfwb EEDATA,F ; minus O2 | |
522 movff EEDATA, char_I_N2_ratio ; = N2! | |
523 bsf manual_gas_changed ; set event flag | |
524 bsf event_occured ; set global event flag | |
99 | 525 bsf is_bailout ;=1: CC mode, but bailout active! |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
526 clrf lo ; clear Setpoint, PLED_const_ppO2_value now displayes "Bail" |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
527 movff lo,char_I_const_ppO2 |
0 | 528 bra timeout_divemenu2 ; quit underwater menu! |
529 | |
530 divemenu_set_gas: | |
531 btfsc FLAG_const_ppO2_mode ; in ppO2 mode? | |
17 | 532 bra divemenu_set_setpoint ; Yes, display SetPoint list |
0 | 533 |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
534 divemenu_set_gas_2: |
0 | 535 bsf display_set_gas ; set flag |
536 call PLED_clear_divemode_menu ; Clear Menu | |
537 call PLED_gas_list ; Display all 5 gases | |
538 movlw d'1' | |
539 movwf menupos ; reset cursor | |
540 call PLED_divemenu_cursor ; update cursor | |
541 return | |
542 | |
543 divemenu_set_setpoint: | |
544 bsf display_set_setpoint ; set flag | |
545 bsf display_set_gas ; set flag | |
546 | |
547 call PLED_clear_divemode_menu ; Clear Menu | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
548 call PLED_splist_start ; Display SetPoints |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
549 DISPLAYTEXT d'137' ; Bailout (as a sub-menu) |
0 | 550 movlw d'1' |
551 movwf menupos ; reset cursor | |
552 call PLED_divemenu_cursor ; update cursor | |
553 return | |
554 | |
555 | |
556 divemenu_set_gas2: | |
557 btfsc select_bailoutgas ; Are we in the Bailout list? | |
558 bra divemenu_set_gas2a ; Yes, choose gas | |
559 | |
560 btfss FLAG_const_ppO2_mode ; are we in ppO2 mode? | |
561 bra divemenu_set_gas2a ; no, choose gas | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
562 ; Yes, so select SP 1-3 |
3 | 563 bcf is_bailout ;=1: CC mode, but bailout active! |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
564 call PLED_show_ppO2_clear ; Clear ppO2 value |
3 | 565 |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
566 divemenu_set_gas1: |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
567 movlw d'4' |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
568 cpfseq menupos ; At the "Bailout" position? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
569 bra divemenu_set_gas1b ; No, select SetPoint 1-3 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
570 bsf select_bailoutgas ; Set Flag |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
571 bcf display_set_setpoint ; Clear Flag |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
572 bra divemenu_set_gas_2 ; Configure the extra gas / Select Bailout |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
573 |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
574 divemenu_set_gas1b: |
0 | 575 movlw d'35' ; offset in memory |
576 addwf menupos,W ; add SP number 0-2 | |
577 movwf EEADR | |
578 call read_eeprom ; Read SetPoint | |
579 movff EEDATA, char_I_const_ppO2 ; Use SetPoint | |
4 | 580 movff EEDATA, ppO2_setpoint_store ; Store also in this byte... |
0 | 581 |
582 divemenu_set_gas1a: | |
583 bcf display_set_setpoint ; Clear Display Flag | |
584 bsf stored_gas_changed ; set event flag | |
585 bsf event_occured ; set global event flag | |
586 bra timeout_divemenu2 ; quit menu! | |
587 | |
588 divemenu_set_gas2a: | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
589 movlw d'6' |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
590 cpfseq menupos ; At the "Gas 6.." position? |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
591 bra divemenu_set_gas2b ; No, select Gas1-5 (Stored in Menupos) |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
592 bra divemode_set_xgas ; Configure the extra gas |
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
593 divemenu_set_gas2b: |
3 | 594 bsf is_bailout ;=1: CC mode, but bailout active! |
0 | 595 clrf lo ; clear Setpoint, PLED_const_ppO2_value now displayes "Bail" |
596 movff lo,char_I_const_ppO2 | |
597 | |
598 bcf display_set_gas ; clear flag | |
599 movff menupos,active_gas ; copy into active gas register | |
600 decf menupos,W ; # of selected gas (0-4) | |
601 mullw d'4' ; times 4... | |
602 movf PRODL,W ; | |
603 addlw d'7' ; +7 = address for He ratio | |
604 movwf EEADR | |
605 call read_eeprom ; Read He ratio | |
606 movff EEDATA,char_I_He_ratio ; And copy into hold register | |
607 | |
608 decf menupos,W ; # of selected gas (0-4) | |
609 mullw d'4' ; times 4... | |
610 movf PRODL,W ; | |
611 addlw d'6' ; +6 = address for O2 ratio | |
612 movwf EEADR | |
613 call read_eeprom ; Read O2 ratio | |
614 movff EEDATA, char_I_O2_ratio ; O2 ratio | |
615 movff char_I_He_ratio, wait_temp ; copy into bank1 register | |
616 bsf STATUS,C ; | |
617 movlw d'100' ; 100% | |
618 subfwb wait_temp,W ; minus He | |
619 subfwb EEDATA,F ; minus O2 | |
620 movff EEDATA, char_I_N2_ratio ; = N2! | |
621 bsf stored_gas_changed ; set event flag | |
622 bsf event_occured ; set global event flag | |
623 bra timeout_divemenu2 ; quit menu! | |
624 | |
625 timeout_divemenu: | |
626 btfss menubit ; is the Dive mode menu displayed? | |
627 return ; No | |
628 | |
629 | |
630 btfsc display_set_simulator ; Is the Simulator Mask active? | |
631 bra timeout_divemenu6 ; Yes, update Simulator mask | |
632 | |
633 btfss display_see_deco ; Is the decoplan active? | |
634 bra timeout_divemenu1 ; No, skip updating the decoplan | |
635 | |
636 btfsc multi_gf_display ; display the multi-gf table screen? | |
637 bra timeout_divemenu3 ; Yes... | |
638 | |
639 movff char_O_deco_status,deco_status ; | |
66 | 640 tstfsz deco_status ; deco_status=0 if decompression calculation done |
641 bra timeout_divemenu1 ; No, skip updating the decoplan | |
0 | 642 |
66 | 643 call PLED_decoplan ; update the Decoplan |
0 | 644 |
645 timeout_divemenu1: | |
646 incf timeout_counter3,F ; increase timeout_counter3 | |
647 GETCUSTOM8 d'10' ; loads timeout_divemenu into WREG | |
648 cpfsgt timeout_counter3 ; ... longer then timeout_divemenu | |
649 return ; No! | |
650 timeout_divemenu2: ; quit divemode menu | |
66 | 651 btfss multi_gf_display ; Was the Multi-GF Table displayed? |
652 bra timeout_divemenu2a ; No, normal OLED rebuild | |
0 | 653 |
654 ; Restore some outputs | |
66 | 655 clrf temp8 ; Page 0-1 of deco list |
0 | 656 btfsc dekostop_active |
66 | 657 call PLED_display_deko_mask ; clear nostop time, display decodata |
0 | 658 btfss dekostop_active |
66 | 659 call PLED_display_ndl_mask ; Clear deco data, display nostop time |
0 | 660 |
661 timeout_divemenu2a: | |
66 | 662 bcf multi_gf_display ; Do not display the multi-gf table screen |
0 | 663 bcf menubit |
664 bcf premenu ; Yes, clear flags and menu, display dive time and mask again | |
66 | 665 call PLED_active_gas_divemode; Display gas, if required |
0 | 666 call PLED_clear_divemode_menu; Clear dive mode menu |
667 call PLED_divemode_mask ; Display mask | |
668 call PLED_divemins ; Display (new) divetime! | |
87 | 669 btfss dekostop_active |
670 call PLED_display_ndl_mask | |
671 btfsc dekostop_active | |
672 call PLED_display_deko_mask | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
87
diff
changeset
|
673 call customview_mask ; Redraw current customview mask |
0 | 674 clrf timeout_counter3 ; Also clear timeout |
675 bcf display_see_deco ; clear all display flags | |
676 bcf display_set_gas | |
677 bcf display_set_xgas | |
678 bcf display_set_setpoint | |
679 bcf display_set_simulator | |
680 bcf switch_left ; and debounce switches | |
681 bcf switch_right | |
71
6beb680a6130
1.72beta - color-coded gaslist, small fix with stopwatch
heinrichsweikamp
parents:
68
diff
changeset
|
682 bsf lock_stopwatch_reset ; Lock the stopwatch reset for at least one second (Cleared in "calc_average_depth:") |
0 | 683 return |
684 | |
685 timeout_divemenu3: | |
64 | 686 movff char_O_deco_status,deco_status ; |
687 tstfsz deco_status ; deco_status=0 if decompression calculation done | |
0 | 688 bra timeout_divemenu1 ; No, skip updating the decoplan |
68 | 689 timeout_divemenu3x: |
64 | 690 call PLED_decoplan_gf_page_current ; Re-Draw Current page of GF Decoplan |
0 | 691 bra timeout_divemenu1 ; Check timeout |
692 | |
693 timeout_divemenu6: | |
694 ; Update Simulator Mask | |
695 call PLED_divemode_simulator_mask; Show mask | |
696 call PLED_divemenu_cursor ; update cursor | |
697 bra timeout_divemenu1 ; Check timeout |