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