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